/* Layout: sticky top bar, short hero with the island scene, then two panels (table, timeline). */
:root {
  --bg: #f3f7f7;
  --surface: #ffffff;
  --ink: #10292b;
  --muted: #5b7174;
  --line: #d8e3e3;
  --line-soft: #e8efef;
  --accent: #0b7a75;
  --accent-ink: #ffffff;
  --accent-soft: #ddf0ee;
  --sun: #f0a032;
  --sun-ink: #a8610a;
  --sun-soft: #fff0d6;
  --ok: #23804a;
  --ok-soft: #e1f3e7;
  --err: #b3372b;
  --err-soft: #fbe8e5;
  --g1: #79b13f;
  --g2: #1a9fd1;

  /* illustration */
  --sky: #cfeeee;
  --sea: #3aa9b4;
  --wave: #b9ecef;
  --sand: #f1d9a6;
  --trunk: #9a6a3c;
  --leaf: #2f9a5a;
  --drink: #f3743c;
  --glass: #ffffff;

  --font-display: "Unbounded", "Golos Text", system-ui, sans-serif;
  --font-body: "Golos Text", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;

  --radius: 14px;
  --shadow: 0 1px 2px rgb(16 41 43 / .06), 0 6px 20px rgb(16 41 43 / .05);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c1a1c; --surface: #12262a; --ink: #e3eeed; --muted: #93a9ab; --line: #24393d; --line-soft: #1a2f33;
    --accent: #3cc2b8; --accent-ink: #052321; --accent-soft: #133c3a; --sun: #f2b155; --sun-ink: #f2b155; --sun-soft: #3a2d17;
    --ok: #5cc27d; --ok-soft: #173826; --err: #f07d70; --err-soft: #3b1f1c; --g1: #8fc75a; --g2: #4cbbe6;
    --sky: #1b3d4a; --sea: #1f6f7b; --wave: #5fb7c1; --sand: #b99a63; --trunk: #7b5532; --leaf: #2f8a55;
    --drink: #f08a52; --glass: #dfeeee;
    --shadow: 0 1px 2px rgb(0 0 0 / .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c1a1c; --surface: #12262a; --ink: #e3eeed; --muted: #93a9ab; --line: #24393d; --line-soft: #1a2f33;
  --accent: #3cc2b8; --accent-ink: #052321; --accent-soft: #133c3a; --sun: #f2b155; --sun-ink: #f2b155; --sun-soft: #3a2d17;
  --ok: #5cc27d; --ok-soft: #173826; --err: #f07d70; --err-soft: #3b1f1c; --g1: #8fc75a; --g2: #4cbbe6;
  --sky: #1b3d4a; --sea: #1f6f7b; --wave: #5fb7c1; --sand: #b99a63; --trunk: #7b5532; --leaf: #2f8a55;
  --drink: #f08a52; --glass: #dfeeee;
  --shadow: 0 1px 2px rgb(0 0 0 / .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font-body);
}
.wrap {
  max-width: 1300px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
main.wrap { padding-block: 24px 48px; display: grid; gap: 20px; }
main > section { display: grid; gap: 20px; min-width: 0; }
a { color: var(--accent); }
h1, h2 { text-wrap: balance; margin: 0; }
h1 { font: 600 clamp(22px, 3.2vw, 32px)/1.15 var(--font-display); letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 600; }
.muted { color: var(--muted); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- top bar ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 5;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.top-in { display: flex; align-items: center; gap: 28px; min-height: 58px; flex-wrap: wrap; }
.brand {
  font: 600 17px/1 var(--font-display);
  color: var(--ink);
  text-decoration: none;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.brand span { color: var(--sun-ink); }
.brand small { font: 500 14px/1 var(--font-body); color: var(--muted); margin-left: 6px; }
nav { display: flex; gap: 4px; }
nav a {
  text-decoration: none;
  color: var(--muted);
  padding: 7px 12px;
  border-radius: 999px;
  font-weight: 500;
}
nav a:hover { color: var(--ink); background: var(--line-soft); }
nav a.on { color: var(--accent); background: var(--accent-soft); }
.who { margin-left: auto; display: flex; align-items: center; gap: 10px; font-weight: 500; }

.avatar {
  width: 30px; height: 30px; flex: none;
  border-radius: 50%;
  display: inline-grid; place-items: center;
  font-size: 12px; font-weight: 600; letter-spacing: .02em;
  color: var(--accent-ink); background: var(--accent);
}

/* ---------- theme switcher ---------- */
.theme-btn { margin-left: auto; padding: 7px; border-radius: 999px; }
.who:not([hidden]) + .theme-btn { margin-left: 0; }
.theme-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
/* show the icon of the theme you would switch to */
.theme-btn .ic-sun { display: none; }
:root[data-theme="dark"] .theme-btn .ic-sun { display: block; }
:root[data-theme="dark"] .theme-btn .ic-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .theme-btn .ic-sun { display: block; }
  :root:not([data-theme]) .theme-btn .ic-moon { display: none; }
}

/* ---------- controls ---------- */
button, .ghost {
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background-color .15s, border-color .15s;
}
button:hover, .ghost:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover { filter: brightness(1.06); }
button.danger { color: var(--err); }
button.danger.armed { background: var(--err); border-color: var(--err); color: var(--surface); }
button.link { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 500; }
button.link:hover { text-decoration: underline; }
input[type=number], select {
  font: inherit; font-size: 14px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}
input[type=number]:focus, select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- island scene ---------- */
.scene { display: block; width: 100%; height: auto; aspect-ratio: 320 / 190; max-width: 100%; }
.i-sky { fill: var(--sky); }
.i-sun { fill: var(--sun); }
.i-sun-glow { fill: var(--sun); opacity: .18; }
.i-sea { fill: var(--sea); }
.i-wave { fill: none; stroke: var(--wave); stroke-width: 2.5; stroke-linecap: round; }
.i-sand { fill: var(--sand); }
.i-trunk { fill: none; stroke: var(--trunk); stroke-width: 7; stroke-linecap: round; }
.i-leaf { fill: var(--leaf); stroke: var(--leaf); stroke-width: 3; stroke-linejoin: round; }
.i-nut { fill: var(--trunk); }
.i-glass { fill: var(--glass); opacity: .85; }
.i-drink { fill: var(--drink); }
.i-stem { fill: none; stroke: var(--glass); stroke-width: 3; stroke-linecap: round; }
.i-straw { fill: none; stroke: var(--err); stroke-width: 3; stroke-linecap: round; }
.i-lime { fill: var(--g1); }
.i-lime-in { fill: var(--wave); opacity: .7; }
.i-umbrella { fill: var(--accent); }
.i-stick { fill: none; stroke: var(--trunk); stroke-width: 2; stroke-linecap: round; }
@media (prefers-reduced-motion: no-preference) {
  .i-sun-glow { animation: glow 5s ease-in-out infinite; transform-origin: 232px 66px; }
  @keyframes glow { 50% { transform: scale(1.12); opacity: .1; } }
}

/* ---------- hero ---------- */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 28px;
  align-items: center;
}
.hero-text { display: grid; gap: 12px; min-width: 0; }
.hero-text h1 span { color: var(--sun-ink); }
.hero-scene { border-radius: 18px; }
.stats { display: flex; flex-wrap: wrap; gap: 8px; }
.stat {
  display: inline-flex; align-items: baseline; gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 14px;
  color: var(--muted);
}
.stat b { color: var(--ink); font-variant-numeric: tabular-nums; font-size: 15px; }
.stat.warn b { color: var(--err); }
.stat.good b { color: var(--ok); }
.rule { margin: 0; color: var(--muted); font-size: 14px; max-width: 62ch; }

.msg {
  margin: 0;
  background: var(--err-soft);
  color: var(--err);
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 500;
}

/* ---------- panels ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  min-width: 0;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.table-scroll { overflow-x: auto; }

/* ---------- table ---------- */
.grid { border-collapse: collapse; width: 100%; }
#grid { table-layout: fixed; min-width: 1000px; }
#grid col.c-name { width: 210px; }
#grid col.c-num { width: 76px; }
#grid col.c-mark { width: 108px; }
#grid td.slot, #grid thead th.slot-h { border-left: 1px solid var(--line-soft); padding-inline: 10px; }
.grid th, .grid td { padding: 10px 14px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line-soft); }
.grid thead th {
  font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted);
  white-space: nowrap;
  background: var(--bg);
}
.grid tbody tr:last-child td { border-bottom: 0; }
.grid td.num, .grid th.num { text-align: right; width: 70px; font-variant-numeric: tabular-nums; }
.grid tr.group td {
  padding: 14px 14px 6px;
  font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted);
}
.grid tr.group .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; vertical-align: 1px; }
.grid tr.group.g0 .dot { background: var(--g1); }
.grid tr.group.g1 .dot { background: var(--g2); }
.grid tr.mine td { background: var(--sun-soft); }
.grid tr.group.mine-group .dot { background: var(--sun); }
.grid tr.group.mine-group td { color: var(--sun-ink); }

/* collapsible groups by position */
.head-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.head-actions button { padding: 5px 12px; font-size: 13px; }
.grp-toggle {
  border: 0; background: none; padding: 2px 0; border-radius: 6px;
  font: inherit; color: inherit; letter-spacing: inherit; text-transform: inherit;
  display: inline-flex; align-items: center; gap: 0; cursor: pointer; max-width: 100%;
}
.grp-toggle:hover { color: var(--ink); }
.chev {
  width: 7px; height: 7px; margin: 0 10px 0 2px; flex: none;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translate(-2px, -2px); transition: transform .15s;
}
.collapsed .chev { transform: rotate(-45deg); }
.grp-count { margin-left: 12px; font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--muted); font-size: 12px; }
.grid tr.group.collapsed td { padding-bottom: 14px; border-bottom: 1px solid var(--line-soft); }

.tl-group { min-height: 30px; }
.tl-group .tl-name { width: auto; flex: 1; padding-top: 10px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.tl-group .tl-track { display: none; }
.tl-group .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; }
.tl-group.g0 .dot { background: var(--g1); }
.tl-group.g1 .dot { background: var(--g2); }
.tl-group.mine-group .tl-name { color: var(--sun-ink); }
.grid td.name { font-weight: 500; }
.grid td.name .you { font-size: 12px; color: var(--sun-ink); font-weight: 600; margin-left: 6px; }
.grid td.name .pos { display: block; font-size: 12px; font-weight: 400; color: var(--muted); }
.grid td.left span { display: block; font-weight: 600; }
.grid td.left span.zero { color: var(--muted); }
.grid td.left small { display: block; font-size: 11px; color: var(--muted); white-space: nowrap; }
.grid td.slot { white-space: nowrap; overflow: hidden; }

.chip {
  display: inline-flex; flex-direction: column; align-items: flex-start; gap: 0;
  padding: 4px 10px;
  line-height: 1.3;
  text-align: left;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  border: 0;
  font-weight: 400;
}
.chip small { color: var(--muted); font-size: 12px; }
.chip.active, button.add.active { box-shadow: 0 0 0 2px var(--sun); }
.chip.long.active { box-shadow: inset 0 0 0 1px var(--accent), 0 0 0 2px var(--sun); }
.chip.long { box-shadow: inset 0 0 0 1px var(--accent); }
button.chip:hover { background: var(--accent); color: var(--accent-ink); }
button.chip:hover small { color: inherit; }
button.add {
  border: 1px dashed var(--accent);
  color: var(--accent);
  background: transparent;
  padding: 4px 10px;
  border-radius: 8px;
}
button.add:hover { background: var(--accent-soft); }

.grid th.mark, .grid td.mark { text-align: center; width: 90px; white-space: nowrap; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.no { background: var(--err-soft); color: var(--err); }

.grid tr.edit-row td { background: var(--sun-soft); padding: 4px 14px 14px; }
.edit {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.edit-title { font-weight: 600; }
.edit label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; }
.edit .preview { font-size: 14px; color: var(--muted); }
.edit .preview b { color: var(--ink); font-weight: 600; }
.edit .preview .over { color: var(--err); font-weight: 600; }
.edit .actions { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }
input.day { width: 58px; flex: none; }
input.days-in { width: 72px; }

.log td { font-size: 14px; }
.log td.when { white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; }
.log .act { font-weight: 500; }
.log .act.add { color: var(--ok); }
.log .act.delete { color: var(--err); }
.log .act.login { color: var(--muted); font-weight: 400; }

/* ---------- timeline ---------- */
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 14px; height: 8px; border-radius: 3px; display: inline-block; }
.sw-mine { background: var(--sun); }
.sw-other { background: var(--accent); }
.sw-holiday { background: var(--sun-soft); box-shadow: inset 0 0 0 1px var(--sun); }

.timeline { font-size: 13px; min-width: 720px; padding: 6px 0 10px; }
.tl-row { display: flex; min-height: 34px; align-items: stretch; }
.tl-name {
  width: 190px; flex: none;
  padding: 7px 18px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-weight: 500;
}
.tl-row.mine .tl-name { color: var(--sun-ink); }
.tl-track { position: relative; flex: 1; margin-right: 18px; }
.tl-head .tl-track { display: flex; }
.tl-month { flex: 1; text-align: center; padding: 6px 0; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.tl-grid { position: absolute; inset: 0; display: flex; pointer-events: none; }
.tl-grid span { flex: 1; border-left: 1px solid var(--line-soft); }
.tl-grid span:last-child { border-right: 1px solid var(--line-soft); }
.tl-holiday { position: absolute; top: 0; bottom: 0; background: var(--sun-soft); }
.tl-bar {
  position: absolute; top: 8px; bottom: 8px;
  background: var(--accent);
  min-width: 4px;
  border-radius: 5px;
}
.tl-bar.mine { background: var(--sun); }

/* ---------- login ---------- */
.login { justify-items: center; padding-top: 3vh; }
.login-card {
  width: 100%; max-width: 460px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.login-body { padding: 22px 24px 26px; display: grid; gap: 10px; }
.login-body p { margin: 0; font-size: 14px; }
#login-pick, #login-adfs { display: grid; gap: 10px; }
.steps { margin: 4px 0 0; padding-left: 22px; display: grid; gap: 6px; font-size: 14px; }
.steps b { color: var(--ink); }
.who .logout-btn { padding: 5px 12px; font-size: 13px; }
.primary-link {
  justify-self: start; margin-top: 8px;
  padding: 10px 18px; border-radius: 9px;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 600; text-decoration: none;
}
.primary-link:hover { filter: brightness(1.06); }
.login-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; margin-top: 8px; }
.login-actions .primary-link { margin-top: 0; }
.switch-link { font-size: 14px; }
.notice {
  margin: 0; padding: 10px 14px; border-radius: 10px;
  background: var(--sun-soft); color: var(--ink);
  box-shadow: inset 3px 0 0 var(--sun);
}

/* ---------- employees (admins) ---------- */
.person-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; padding: 16px 18px; }
.person-form label, .people-table label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.person-form input, .people-table input {
  font: inherit; font-size: 14px; padding: 6px 8px; min-width: 0;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink);
}
.person-form input:focus, .people-table input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.person-form input[name=name] { width: 260px; }
.person-form input[name=position] { width: 220px; }
.person-form input[name=login] { width: 200px; }
input.bal { width: 90px; }
.people-table { min-width: 1000px; table-layout: fixed; }
.people-table col.pc-name { width: 30%; }
.people-table col.pc-pos { width: 25%; }
.people-table col.pc-login { width: 22%; }
.people-table col.pc-bal { width: 96px; }
.people-table col.pc-vac { width: 110px; }
.people-table col.pc-acts { width: 120px; }
.people-table input[name=login]::placeholder { color: var(--err); opacity: .7; }
.people-table td { padding: 6px 10px; }
.people-table input { width: 100%; }
.people-table td.acts { white-space: nowrap; text-align: right; width: 1%; }
.people-table td.acts button { padding: 5px 10px; font-size: 13px; }
.people-table tr.dirty td { background: var(--sun-soft); }
.people-table td.vac { color: var(--muted); font-size: 13px; white-space: nowrap; }
.login-list { display: grid; gap: 6px; margin-top: 8px; }
.login-list .grp {
  font-size: 12px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em;
  margin-top: 10px;
  display: flex; align-items: center; gap: 8px;
}
.login-list .grp i { width: 8px; height: 8px; border-radius: 50%; }
.login-list .grp.g0 i { background: var(--g1); }
.login-list .grp.g1 i { background: var(--g2); }
.login-list button { width: 100%; justify-content: flex-start; padding: 8px 10px; gap: 12px; font-size: 15px; }
.login-list button:hover { background: var(--accent-soft); }

/* ---------- small screens ---------- */
@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; }
  .hero-scene { display: none; }
  .top-in { gap: 12px; padding-block: 8px; }
  .who { margin-left: 0; }
  .theme-btn { margin-left: auto !important; }
}
@media (max-width: 640px) {
  #grid, #grid tbody, #grid tr { display: block; }
  #grid thead { display: none; }
  #grid td { display: block; border: 0; padding: 4px 16px; }
  #grid tr { border-bottom: 1px solid var(--line-soft); padding-block: 8px; }
  #grid tr.group { border: 0; padding-block: 8px 0; }
  #grid td.slot { width: auto; }
  #grid td.slot:empty { display: none; }
  #grid td.name { min-width: 0; }
  #grid td.num, #grid td.mark { text-align: left; width: auto; display: inline-block; }
  #grid td.planned::before { content: "План: "; color: var(--muted); }
  #grid td.left span, #grid td.left small { display: inline; margin-left: 4px; }
  #grid td.left:not(:empty)::before { content: "Остаток: "; color: var(--muted); }
  #grid td.m-min::before { content: "28+ дней: "; color: var(--muted); font-size: 12px; }
  #grid td.m-long::before { content: "14 подряд: "; color: var(--muted); font-size: 12px; }
  #grid { min-width: 0; }
  #grid colgroup { display: none; }
  #grid td.slot { border-left: 0; overflow: visible; display: inline-block; padding-right: 0; }
  #grid tr.edit-row td { display: block; }
  .edit .actions { margin-left: 0; }
}
