:root {
  --bg: #f4f5f7; --panel: #ffffff; --text: #1d2330; --muted: #6b7385; --line: #e5e7ec;
  --accent: #2f6fed; --accent-weak: #e8efff; --ok: #1f9d55; --ok-weak: #e3f6ea;
  --warn: #c98a00; --warn-weak: #fff4d6; --bad: #d64545; --bad-weak: #fde8e8;
  --mine: #7b4ce0; --mine-weak: #efe8fd; --side: #151a24; --side-text: #c4cad6;
  --radius: 12px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f131a; --panel: #171c25; --text: #e6e9ef; --muted: #8b93a5; --line: #262d3a;
    --accent: #5b8cff; --accent-weak: #1c2742; --ok: #3ccf7a; --ok-weak: #15301f;
    --warn: #f0b429; --warn-weak: #33290f; --bad: #ff6b6b; --bad-weak: #3a1a1a;
    --mine: #a681ff; --mine-weak: #2a2140; --side: #0b0e14; --side-text: #aab2c2;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 12px; }
code { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }

/* shell */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { background: var(--side); color: var(--side-text); padding: 18px 12px;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 16px; color: #fff; padding: 4px 10px 18px; }
.brand.big { font-size: 22px; color: var(--text); padding: 0; }
.logo { color: var(--accent); }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; opacity: .55;
  padding: 14px 10px 6px; }
.sidebar nav a { color: var(--side-text); padding: 8px 10px; border-radius: 8px; display: flex; gap: 10px; }
.sidebar nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.sidebar nav a.active { background: rgba(91,140,255,.18); color: #fff; }
.ico { width: 16px; text-align: center; opacity: .8; }
.logout { padding: 0 10px; }
.content { padding: 24px 28px 48px; max-width: 1280px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px;
  margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }

/* cards & grid */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.grid { display: grid; gap: 16px; }
.grid .card { margin-bottom: 0; }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); margin-bottom: 16px; }
.grid.two { grid-template-columns: 1.4fr 1fr; margin-bottom: 16px; }
.kpi-label { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.kpi-value { font-size: 18px; font-weight: 650; margin-bottom: 4px; }
.ok { color: var(--ok); } .warn { color: var(--warn); } .bad { color: var(--bad); }

/* controls */
.btn { font: inherit; border: 1px solid var(--line); background: var(--panel); color: var(--text);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-weight: 550; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.wide { width: 100%; }
input, select { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; }
input:focus, select:focus { outline: 2px solid var(--accent-weak); border-color: var(--accent); }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
label input, label select { font-size: 14px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 10px 0; }
.row .grow { flex: 1; min-width: 200px; }
form { margin: 0; }

/* tables */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 8px; border-bottom: 1px solid var(--line); }
td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
table.dense td { padding: 6px 8px; }
tr.off td { opacity: .55; }
tr.row-bad td { background: var(--bad-weak); }
td.actions { display: flex; gap: 6px; justify-content: flex-end; }
.table-wrap { overflow-x: auto; }

/* badges */
.badge { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px;
  background: var(--line); color: var(--muted); white-space: nowrap; }
.badge.ok, .badge.free { background: var(--ok-weak); color: var(--ok); }
.badge.error, .badge.busy { background: var(--bad-weak); color: var(--bad); }
.badge.skipped { background: var(--warn-weak); color: var(--warn); }
.badge.mine { background: var(--mine-weak); color: var(--mine); }
.chip { display: inline-block; font-size: 12px; padding: 1px 7px; margin-right: 3px; border-radius: 6px;
  background: var(--accent-weak); color: var(--accent); }
.bar { display: inline-block; width: 80px; height: 6px; background: var(--line); border-radius: 3px;
  vertical-align: middle; margin-right: 6px; overflow: hidden; }
.bar i { display: block; height: 100%; }
.bar i.ok { background: var(--ok); } .bar i.warn { background: var(--warn); } .bar i.bad { background: var(--bad); }

/* flash */
.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; background: var(--ok-weak); color: var(--ok); }
.flash.error { background: var(--bad-weak); color: var(--bad); }

/* tabs & day picker */
.tabs { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--line); padding: 4px; border-radius: 10px; }
.tabs a { padding: 6px 12px; border-radius: 7px; color: var(--muted); }
.tabs a.active { background: var(--accent-weak); color: var(--accent); }
.days { display: flex; gap: 8px; margin-bottom: 16px; overflow-x: auto; }
.day { display: flex; flex-direction: column; align-items: center; min-width: 74px; padding: 8px 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; color: var(--text); }
.day span { font-size: 12px; color: var(--muted); }
.day i { font-style: normal; font-size: 10px; color: var(--accent); }
.day.active { border-color: var(--accent); background: var(--accent-weak); }
.day:hover { text-decoration: none; border-color: var(--accent); }

/* workspace */
.workspace { display: grid; grid-template-columns: 1fr 300px; gap: 16px; align-items: start; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-bottom: 12px; flex-wrap: wrap; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: -2px; }
.dot.free { background: var(--ok); } .dot.busy { background: #9aa1ae; } .dot.mine { background: var(--mine); }
.dot.star { background: var(--warn); color: #fff; font-size: 9px; text-align: center; line-height: 12px; font-weight: 700; }
.zone-map { position: relative; width: 100%; overflow: hidden; border-radius: 10px; background: #d9dbe0; }
.zone-bg { position: absolute; max-width: none; pointer-events: none; user-select: none; }
.desk { position: absolute; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 11px; font-weight: 700; border: 3px solid rgba(255,255,255,.9);
  box-shadow: 0 2px 6px rgba(0,0,0,.35); transition: transform .12s; text-decoration: none; }
.desk:hover { transform: scale(1.15); z-index: 2; text-decoration: none; }
.desk.free { background: var(--ok); }
.desk.busy { background: #8d94a1; }
.desk.mine { background: var(--mine); }
.desk.unknown { background: #b5bac4; }
.desk.selected { outline: 3px solid var(--accent); outline-offset: 2px; z-index: 3; }
.desk-name { text-shadow: 0 1px 2px rgba(0,0,0,.4); white-space: nowrap; }
.desk-prio { position: absolute; top: -8px; right: -8px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--warn); color: #fff; font-size: 10px; display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff; }
.side .card { margin-bottom: 16px; }
.desk-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.desk-head h2 { margin: 0; }
.booking { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.booking:last-child { border-bottom: 0; }
.prio-list { margin: 0; padding-left: 22px; }
.prio-list li { padding: 3px 0; font-weight: 600; }
.empty { text-align: center; padding: 40px 0; }

/* rule form */
.rule-form { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-top: 16px;
  padding-top: 16px; border-top: 1px solid var(--line); }
.weekdays { border: 0; padding: 0; margin: 0; display: flex; gap: 4px; align-items: flex-end; }
.weekdays legend { font-size: 12px; color: var(--muted); padding: 0; margin-bottom: 4px; }
.chk { flex-direction: row; }
.chk input { position: absolute; opacity: 0; width: 0; height: 0; }
.chk span { display: inline-block; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  color: var(--text); font-size: 13px; cursor: pointer; background: var(--panel); }
.chk input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.chk input:focus-visible + span { outline: 2px solid var(--accent); }

/* login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.card.login { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; padding: 28px; }
.card.login p { margin: -6px 0 6px; }

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 8px; padding: 10px; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .nav-group, .brand { display: none; }
  .workspace, .grid.two { grid-template-columns: 1fr; }
  .content { padding: 16px; }
}

/* team */
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.people .card { margin-bottom: 0; }
.person.off { opacity: .6; }
.person.add { border-style: dashed; }
.person-head { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.person-head h2 { margin: 0; }
.person-head .grow { flex: 1; min-width: 0; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--accent-weak); color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; flex: none; }
.facts { display: grid; grid-template-columns: 90px 1fr; gap: 6px 10px; margin: 0 0 6px; font-size: 13px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
details { margin-top: 8px; }
summary { cursor: pointer; }
.invite-box { border-color: var(--accent); background: var(--accent-weak); }
.copy { width: 100%; font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; }
.card.invite { max-width: 560px; width: 100%; margin: 40px auto; display: flex; flex-direction: column; gap: 10px; }
.steps { padding-left: 20px; margin: 4px 0 8px; }
.steps li { margin: 6px 0; }
kbd { font: 12px ui-monospace, monospace; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; }
.stack { display: flex; flex-direction: column; gap: 10px; }

/* person switcher & teammates on the map */
.who { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.who a { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text); }
.who a.active { border-color: var(--accent); background: var(--accent-weak); color: var(--accent); }
.who a:hover { text-decoration: none; border-color: var(--accent); }
.who .mini { width: 20px; height: 20px; font-size: 11px; }
.desk.team { background: #2f9bd6; }
.dot.team { background: #2f9bd6; }
.badge.team { background: #dff1fb; color: #1f7fb3; }
.desk-who { position: absolute; bottom: -18px; left: 50%; transform: translateX(-50%); font-size: 10px;
  background: rgba(0,0,0,.65); color: #fff; padding: 0 5px; border-radius: 4px; white-space: nowrap; }
