:root {
  --blue: #1a73e8; --brand: #001fd2; --text: #3c4043; --text-strong: #202124; --muted: #70757a;
  --line: #dadce0; --line-soft: #e8eaed; --hover: #f1f3f4; --today: #1a73e8; --red: #ea4335;
  --hour: 48px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: Roboto, "Google Sans", -apple-system, "Segoe UI", Arial, sans-serif; color: var(--text); background: #fff; font-size: 14px; }
button { font-family: inherit; color: inherit; }
[hidden] { display: none !important; }

/* Login */
.login { min-height: 100%; display: flex; align-items: center; justify-content: center; background: #f1f3f4; padding: 16px; }
.login-card { background: #fff; border-radius: 12px; padding: 32px; width: 100%; max-width: 360px; box-shadow: 0 1px 3px rgba(60,64,67,.3), 0 4px 8px rgba(60,64,67,.15); display: flex; flex-direction: column; gap: 10px; }
.login-card h1 { font-size: 22px; font-weight: 400; color: var(--text-strong); margin: 10px 0 8px; }
.login-card label { font-size: 13px; color: var(--muted); }
.login-card input { padding: 12px; border: 1px solid var(--line); border-radius: 6px; font-size: 15px; }
.login-card input:focus { outline: 2px solid var(--blue); border-color: transparent; }
.err { color: #d93025; font-size: 13px; }

/* Buttons */
.btn { border: none; border-radius: 6px; padding: 9px 16px; font-size: 14px; font-weight: 500; cursor: pointer; background: none; }
.btn.primary { background: var(--blue); color: #fff; }
.btn.primary:hover { background: #1765cc; box-shadow: 0 1px 2px rgba(60,64,67,.3); }
.btn.outline { border: 1px solid var(--line); border-radius: 18px; padding: 8px 16px; }
.btn.outline:hover, .btn.text:hover { background: var(--hover); }
.btn.text { color: var(--blue); }
.btn.danger { color: #d93025; }
.btn.danger:hover { background: #fce8e6; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; border: none; background: none; cursor: pointer; font-size: 22px; color: var(--text); display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: var(--hover); }

/* Layout */
.app { display: flex; flex-direction: column; height: 100vh; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 8px 16px; border-bottom: 1px solid var(--line); min-height: 64px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; font-size: 22px; color: var(--text); width: 232px; }
.brand-ico { width: 38px; height: 38px; }
.navs { display: flex; }
.range-title { font-size: 22px; font-weight: 400; color: var(--text-strong); white-space: nowrap; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.toggle { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; cursor: pointer; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 18px; overflow: hidden; }
.seg button { border: none; background: none; padding: 8px 14px; cursor: pointer; font-size: 14px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: #e8f0fe; color: #1967d2; font-weight: 500; }
.body { flex: 1; display: flex; min-height: 0; }
.side { width: 256px; flex-shrink: 0; padding: 8px 12px 16px 12px; overflow-y: auto; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; border-left: 1px solid var(--line-soft); }

.create { display: inline-flex; align-items: center; gap: 12px; border: none; background: #fff; border-radius: 16px; padding: 14px 22px 14px 16px; font-size: 14px; font-weight: 500; cursor: pointer; box-shadow: 0 1px 2px rgba(60,64,67,.3), 0 1px 3px 1px rgba(60,64,67,.15); margin: 8px 0 18px; }
.create span { font-size: 26px; color: var(--blue); line-height: 20px; }
.create:hover { box-shadow: 0 1px 3px rgba(60,64,67,.3), 0 4px 8px 3px rgba(60,64,67,.15); background: #f6fafe; }

/* Mini-Kalender */
.mini-head { display: flex; align-items: center; justify-content: space-between; padding: 0 4px 6px 8px; font-weight: 500; color: var(--text-strong); }
.mini-head .icon-btn { width: 28px; height: 28px; font-size: 18px; }
.mini-grid { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 11px; }
.mini-grid .dow { color: var(--muted); padding: 4px 0; }
.mini-grid button { border: none; background: none; width: 26px; height: 26px; border-radius: 50%; margin: 1px auto; cursor: pointer; font-size: 11px; }
.mini-grid button:hover { background: var(--hover); }
.mini-grid button.other { color: #9aa0a6; }
.mini-grid button.sel { background: #d2e3fc; color: #185abc; }
.mini-grid button.today { background: var(--today); color: #fff; }
.mini-grid button.has { font-weight: 700; }

.side-block { margin-top: 22px; }
.side-block h3 { font-size: 14px; font-weight: 500; color: var(--text-strong); padding: 0 8px 6px; }
.legend li, .upcoming li { list-style: none; display: flex; align-items: center; gap: 10px; padding: 5px 8px; font-size: 13px; border-radius: 6px; }
.legend .sw { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }
.upcoming li { cursor: pointer; align-items: flex-start; }
.upcoming li:hover { background: var(--hover); }
.upcoming .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.upcoming small { display: block; color: var(--muted); }
.upcoming .empty { color: var(--muted); cursor: default; }

/* Zeitraster (Tag/Woche) */
.grid-head { display: flex; border-bottom: 1px solid var(--line); padding-right: var(--sbw, 0px); }
.gutter { width: 64px; flex-shrink: 0; }
.col-head { flex: 1; text-align: center; padding: 10px 0 8px; border-left: 1px solid var(--line-soft); min-width: 0; cursor: pointer; }
.col-head .dow { font-size: 11px; font-weight: 500; color: var(--muted); letter-spacing: .8px; text-transform: uppercase; }
.col-head .num { font-size: 24px; width: 44px; height: 44px; line-height: 44px; border-radius: 50%; margin: 2px auto 0; color: var(--text-strong); }
.col-head:hover .num { background: var(--hover); }
.col-head.today .dow { color: var(--today); }
.col-head.today .num { background: var(--today); color: #fff; }
.col-head .closed { font-size: 11px; color: var(--muted); }
.grid-scroll { flex: 1; overflow-y: auto; position: relative; }
.grid { display: flex; position: relative; }
.hours { width: 64px; flex-shrink: 0; }
.hours div { height: var(--hour); position: relative; }
.hours span { position: absolute; top: -7px; right: 8px; font-size: 10px; color: var(--muted); }
.day-col { flex: 1; position: relative; border-left: 1px solid var(--line-soft); min-width: 0; }
.day-col .slot { height: var(--hour); border-bottom: 1px solid var(--line-soft); }
.day-col .closed-bg { position: absolute; left: 0; right: 0; background: repeating-linear-gradient(-45deg, #f8f9fa 0 6px, #f1f3f4 6px 12px); pointer-events: none; }
.now-line { position: absolute; left: -1px; right: 0; height: 2px; background: var(--red); z-index: 4; pointer-events: none; }
.now-line::before { content: ""; position: absolute; left: -6px; top: -5px; width: 12px; height: 12px; border-radius: 50%; background: var(--red); }

.ev { position: absolute; border-radius: 5px; padding: 3px 6px; color: #fff; font-size: 12px; line-height: 1.3; overflow: hidden; cursor: pointer; z-index: 2; border: 1px solid #fff; }
.ev:hover { box-shadow: 0 2px 6px rgba(0,0,0,.25); z-index: 3; }
.ev b { font-weight: 500; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev span { opacity: .92; white-space: nowrap; }
.ev.cancelled { opacity: .55; text-decoration: line-through; background-image: repeating-linear-gradient(-45deg, rgba(255,255,255,.25) 0 4px, transparent 4px 8px); }
.ev.block { background: #616161 !important; background-image: repeating-linear-gradient(-45deg, rgba(255,255,255,.12) 0 6px, transparent 6px 12px) !important; }
.ev.manual::after { content: "☎"; position: absolute; right: 5px; top: 3px; font-size: 10px; }
.ghost { position: absolute; left: 2px; right: 6px; background: rgba(26,115,232,.18); border: 1px dashed var(--blue); border-radius: 5px; pointer-events: none; z-index: 1; font-size: 11px; color: #185abc; padding: 2px 6px; }

/* Monat */
.month { flex: 1; display: grid; grid-template-columns: repeat(7, 1fr); grid-auto-rows: 1fr; min-height: 0; }
.month .mh { text-align: center; font-size: 11px; font-weight: 500; color: var(--muted); padding: 8px 0 4px; text-transform: uppercase; border-left: 1px solid var(--line-soft); }
.mcell { border-left: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); padding: 4px; min-height: 90px; overflow: hidden; cursor: pointer; }
.mcell .n { text-align: center; font-size: 12px; font-weight: 500; margin-bottom: 2px; }
.mcell .n span { display: inline-block; width: 24px; height: 24px; line-height: 24px; border-radius: 50%; }
.mcell.other .n { color: #9aa0a6; }
.mcell.today .n span { background: var(--today); color: #fff; }
.mev { display: flex; align-items: center; gap: 6px; font-size: 12px; padding: 1px 6px; border-radius: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.mev:hover { background: var(--hover); }
.mev i { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.mev.cancelled { text-decoration: line-through; color: var(--muted); }
.more { font-size: 12px; color: var(--text-strong); font-weight: 500; padding: 1px 6px; }

/* Popover */
.popover { position: fixed; z-index: 50; width: 400px; max-width: calc(100vw - 24px); background: #fff; border-radius: 8px; box-shadow: 0 24px 38px 3px rgba(0,0,0,.14), 0 9px 46px 8px rgba(0,0,0,.12), 0 11px 15px -7px rgba(0,0,0,.2); padding: 8px 8px 16px; }
.pop-tools { display: flex; justify-content: flex-end; gap: 2px; }
.pop-tools .icon-btn { width: 36px; height: 36px; font-size: 17px; color: #5f6368; }
.pop-row { display: flex; gap: 16px; padding: 6px 16px 6px 12px; align-items: flex-start; }
.pop-row .ic { width: 24px; text-align: center; color: #5f6368; flex-shrink: 0; font-size: 15px; }
.pop-row .sq { width: 14px; height: 14px; border-radius: 4px; margin: 6px 5px 0; }
.pop-title { font-size: 22px; color: var(--text-strong); line-height: 1.3; }
.pop-sub { color: var(--text); font-size: 14px; margin-top: 2px; }
.pop-row a { color: var(--blue); text-decoration: none; }
.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 10px; background: #e6f4ea; color: #137333; margin-left: 6px; vertical-align: middle; font-weight: 500; }
.badge.red { background: #fce8e6; color: #c5221f; }
.badge.grey { background: #f1f3f4; color: #5f6368; }
.pop-actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px 0 50px; }

/* Dialog */
.dialog-wrap { position: fixed; inset: 0; background: rgba(32,33,36,.45); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px; }
.dialog { background: #fff; border-radius: 10px; width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow-y: auto; box-shadow: 0 24px 38px 3px rgba(0,0,0,.14); }
.dialog.wide { max-width: 720px; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px 24px; }
.dlg-head h3 { font-size: 20px; font-weight: 400; color: var(--text-strong); }
.dlg-body { padding: 8px 24px 8px; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 18px; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tabs button { border: none; background: none; padding: 7px 14px; border-radius: 6px; cursor: pointer; font-weight: 500; color: var(--muted); }
.tabs button.on { background: #e8f0fe; color: #1967d2; }
.f { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.f label { font-size: 12px; color: var(--muted); }
.f input, .f select, .f textarea { padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px; font-size: 14px; font-family: inherit; background: #fff; }
.f input:focus, .f select:focus, .f textarea:focus { outline: 2px solid var(--blue); border-color: transparent; }
.f2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.f3 { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 12px; }
.chk { display: flex; gap: 8px; align-items: center; font-size: 13px; margin: 4px 0 8px; }
.mail-meta { font-size: 13px; color: var(--muted); margin-bottom: 10px; line-height: 1.6; }
.mail-frame { width: 100%; height: 560px; border: 1px solid var(--line); border-radius: 8px; }
.mail-list button { display: block; width: 100%; text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 8px 12px; margin-bottom: 6px; cursor: pointer; }
.mail-list button.on { border-color: var(--blue); background: #f6fafe; }

.toast { position: fixed; left: 24px; bottom: 24px; background: #323232; color: #fff; padding: 12px 20px; border-radius: 6px; z-index: 80; font-size: 14px; box-shadow: 0 3px 5px rgba(0,0,0,.2); }

@media (max-width: 900px) {
  .side { display: none; }
  .brand { width: auto; }
  .brand span, .toggle { display: none; }
  .range-title { font-size: 17px; }
  .topbar { gap: 6px; padding: 8px; }
  .gutter, .hours { width: 44px; }
  .f2, .f3 { grid-template-columns: 1fr; gap: 0; }
}
