:root {
  --bg: #f5f4ef;
  --card: #ffffff;
  --ink: #14201d;
  --muted: #66706c;
  --line: #e2e0d8;
  --brand: #0f3d34;
  --brand-2: #1d5c4f;
  --accent: #c8f169;
  --accent-ink: #253b05;
  --taken: #e9e7e1;
  --danger: #b4321f;
  --danger-bg: #fbe9e5;
  --warn-bg: #fff6d6;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 32, 29, .06), 0 4px 14px rgba(20, 32, 29, .05);
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1513; --card: #17211e; --ink: #e9efe9; --muted: #9aa7a2; --line: #26332f;
    --brand: #c8f169; --brand-2: #b2dc56; --accent: #c8f169; --accent-ink: #1b2a04;
    --taken: #222d29; --danger: #ff8a75; --danger-bg: #3a1d18; --warn-bg: #3a3215;
    --shadow: none; color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.45 degular, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh; overflow-x: hidden;
  padding-bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
}
body.has-actionbar { padding-bottom: calc(var(--nav-h) + var(--safe-b) + 96px); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
h1, h2, .brand, .big, .dnum, .cost-hero b, .login h1 { font-family: degular-display, degular, sans-serif; }
h1 { font-size: 1.75rem; margin: 4px 0 12px; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 20px 0 10px; }
h3 { font-size: 1rem; margin: 0 0 6px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.right { text-align: right; }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; font-size: 1.05rem; }
.brand b { font-weight: 700; }
.logo {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: #0f3d34; color: #c8f169; font-weight: 700;
}
.topcost {
  margin-left: auto; background: var(--card); border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 12px; font-size: .85rem; white-space: nowrap; text-decoration: none;
}
.topcost b { font-variant-numeric: tabular-nums; }

main { max-width: 760px; margin: 0 auto; padding: 14px 16px; }
.loading { padding: 40px 0; text-align: center; color: var(--muted); }

/* bottom nav */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: flex; background: var(--card); border-top: 1px solid var(--line);
}
.nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--muted); font-size: .72rem; font-weight: 600;
}
.nav a svg { width: 24px; height: 24px; }
.nav a.active { color: var(--brand); }
@media (min-width: 900px) {
  /* nav sits in the top bar's right end; the bar reserves that space */
  .topbar { min-height: 56px; padding-top: 0; padding-bottom: 0; padding-right: calc(var(--nav-w, 440px) + 16px); }
  .nav { top: 0; bottom: auto; left: auto; right: 16px; height: 56px; padding: 0; border: 0; background: transparent; width: auto; gap: 4px; }
  .nav a { flex: none; flex-direction: row; gap: 6px; padding: 0 12px; font-size: .95rem; }
  .nav a svg { width: 18px; height: 18px; }
  body, body.has-actionbar { padding-bottom: 110px; }
}

/* cards & forms */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.card + .card { margin-top: 12px; }
.stack > * + * { margin-top: 12px; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=month], select, textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); font-size: 16px;
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 40%, transparent); outline-offset: 2px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.check input { width: 22px; height: 22px; accent-color: var(--brand-2); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); font-weight: 600; cursor: pointer; text-decoration: none; touch-action: manipulation;
}
.btn.primary { background: #0f3d34; color: #fff; border-color: #0f3d34; }
.btn.accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: .9rem; border-radius: 10px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.iconbtn { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); cursor: pointer; display: grid; place-items: center; }

.banner { border-radius: 12px; padding: 10px 12px; font-size: .9rem; margin-bottom: 12px; }
.banner.warn { background: var(--warn-bg); }
.banner.danger { background: var(--danger-bg); color: var(--danger); }
.error { color: var(--danger); font-size: .9rem; min-height: 1.2em; margin: 6px 0; }

/* segmented */
.seg { display: flex; background: var(--taken); border-radius: 12px; padding: 4px; gap: 4px; margin: 12px 0; }
.seg button {
  flex: 1; min-height: 40px; border: 0; background: transparent; border-radius: 9px; font-weight: 600; font-size: .9rem;
  cursor: pointer; color: var(--muted); padding: 0 6px;
}
.seg button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

/* date strip */
.datestrip {
  display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x proximity; padding: 4px 16px 10px; margin: 0 -16px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.datestrip::-webkit-scrollbar { display: none; }
.day {
  flex: 0 0 64px; scroll-snap-align: start; border: 1px solid var(--line); background: var(--card); border-radius: 14px;
  padding: 8px 4px; text-align: center; cursor: pointer; position: relative;
}
.day .dow { font-size: .72rem; text-transform: uppercase; color: var(--muted); font-weight: 600; letter-spacing: .03em; }
.day .dnum { font-size: 1.35rem; font-weight: 700; line-height: 1.2; }
.day .free { font-size: .7rem; color: var(--muted); }
.day.weekend .dnum { color: var(--muted); }
.day.on { background: #0f3d34; border-color: #0f3d34; color: #fff; }
.day.on .dow, .day.on .free, .day.on.weekend .dnum { color: #cfe0d9; }
.day .mine-dot { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--card); }
.day.full .free { color: var(--danger); }
.monthlabel { white-space: nowrap; font-weight: 700; font-size: .95rem; margin: 2px 0 6px; display: flex; align-items: center; gap: 8px; }

/* office map */
.office { display: grid; gap: 12px; }
@media (min-width: 640px) { .office { grid-template-columns: 1fr 1fr; } }
.room {
  background: var(--card); border: 2px solid var(--ink); border-radius: 6px; padding: 12px; position: relative;
}
.room::after { /* door gap */
  content: ""; position: absolute; bottom: -2px; left: 22px; width: 38px; height: 2px; background: var(--card);
}
.room-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.room-head h3 { margin: 0; }
.desks { display: grid; gap: 10px; }
.desk {
  min-height: 74px; border-radius: 10px; border: 2px solid var(--brand-2); background: var(--card);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  cursor: pointer; position: relative; padding: 6px; touch-action: manipulation; transition: transform .08s;
}
.desk:active { transform: scale(.97); }
.desk .lbl { font-weight: 700; font-size: 1.05rem; }
.desk .st { font-size: .72rem; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.desk .chair { position: absolute; bottom: -9px; width: 22px; height: 10px; border-radius: 0 0 10px 10px; border: 2px solid var(--brand-2); border-top: 0; background: var(--bg); }
.desk.sel { background: #0f3d34; border-color: #0f3d34; color: #fff; }
.desk.sel .st { color: #cfe0d9; }
.desk.mine { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.desk.mine .st { color: var(--accent-ink); }
.desk.taken, .desk.blocked { background: var(--taken); border-color: var(--line); cursor: not-allowed; color: var(--muted); }
.desk.blocked { background: repeating-linear-gradient(-45deg, var(--taken), var(--taken) 6px, var(--danger-bg) 6px, var(--danger-bg) 12px); }
.desk.taken .chair, .desk.blocked .chair { border-color: var(--line); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .78rem; color: var(--muted); margin: 10px 0 0; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 5px; border: 2px solid var(--brand-2); }
.legend i.l-sel { background: #0f3d34; border-color: #0f3d34; }
.legend i.l-mine { background: var(--accent); border-color: var(--accent); }
.legend i.l-taken { background: var(--taken); border-color: var(--line); }
.legend i.l-blocked { background: var(--danger-bg); border-color: var(--danger-bg); }

/* hourly grid */
.hours { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
@media (min-width: 560px) { .hours { grid-template-columns: repeat(6, 1fr); } }
.hour {
  min-height: 52px; border-radius: 10px; border: 2px solid var(--brand-2); background: var(--card);
  font-weight: 700; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2px; touch-action: manipulation;
}
.hour small { font-weight: 500; font-size: .66rem; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hour.sel { background: #0f3d34; border-color: #0f3d34; color: #fff; }
.hour.sel small { color: #cfe0d9; }
.hour.mine { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.hour.taken, .hour.past, .hour.blocked { background: var(--taken); border-color: var(--line); color: var(--muted); cursor: not-allowed; }

/* action bar */
.actionbar {
  position: fixed; left: 0; right: 0; z-index: 25; bottom: calc(var(--nav-h) + var(--safe-b));
  padding: 10px 16px; background: var(--card); border-top: 1px solid var(--line);
  box-shadow: 0 -6px 20px rgba(0, 0, 0, .06); display: flex; align-items: center; gap: 12px;
}
.actionbar .sum { flex: 1; min-width: 0; }
.actionbar .sum b { display: block; font-size: 1.05rem; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.actionbar .sum div { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (min-width: 900px) { .actionbar { bottom: 0; } .actionbar > * { max-width: 760px; } .actionbar { justify-content: center; } }

/* costs */
.cost-hero { background: #0f3d34; color: #fff; border: 0; }
.cost-hero .muted { color: #b9cfc7; }
.cost-hero .big { font-size: 2.1rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.cost-hero .iconbtn { background: transparent; border-color: #2f5d52; color: #fff; }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 12px; }
.kpi { background: rgba(255, 255, 255, .08); border-radius: 10px; padding: 8px 10px; }
.kpi b { display: block; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.kpi span { font-size: .75rem; color: #b9cfc7; }

/* lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 600; overflow-wrap: anywhere; }
.list .sub { font-size: .82rem; color: var(--muted); overflow-wrap: anywhere; }
.list .amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.daygroup { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; margin: 16px 0 4px; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .72rem; font-weight: 700; background: var(--taken); color: var(--muted); }
.pill.ok { background: color-mix(in srgb, var(--accent) 60%, transparent); color: var(--accent-ink); }
.pill.err { background: var(--danger-bg); color: var(--danger); }
.pill.role-admin { background: #0f3d34; color: #fff; }
.pill.role-staff { background: color-mix(in srgb, var(--accent) 60%, transparent); color: var(--accent-ink); }

.door { display: flex; gap: 12px; align-items: center; }
.door .ic { width: 42px; height: 42px; border-radius: 12px; background: var(--taken); display: grid; place-items: center; flex: none; }
.door.on .ic { background: var(--accent); color: var(--accent-ink); }

/* admin */
.subtabs { display: flex; gap: 6px; overflow-x: auto; margin: 0 -16px 12px; padding: 0 16px 4px; scrollbar-width: none; }
.subtabs::-webkit-scrollbar { display: none; }
.subtabs a { flex: none; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); text-decoration: none; font-weight: 600; font-size: .9rem; }
.subtabs a.on { background: #0f3d34; color: #fff; border-color: #0f3d34; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table td, .table th { padding: 8px 4px; border-bottom: 1px solid var(--line); text-align: left; }
.table th { font-size: .75rem; color: var(--muted); text-transform: uppercase; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
details.card summary { cursor: pointer; font-weight: 700; min-height: 30px; }

/* toast & dialog */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 50;
  bottom: calc(var(--nav-h) + var(--safe-b) + 90px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600;
  max-width: calc(100vw - 32px); box-shadow: 0 8px 30px rgba(0, 0, 0, .2);
}
.toast.err { background: var(--danger); color: #fff; }
dialog { border: 0; border-radius: 18px; padding: 18px; width: min(440px, calc(100vw - 32px)); background: var(--card); color: var(--ink); }
dialog::backdrop { background: rgba(10, 20, 17, .45); }

/* login */
.login { max-width: 400px; margin: 8vh auto 0; }
.login .logo { width: 52px; height: 52px; border-radius: 15px; font-size: 1.6rem; margin-bottom: 14px; }
.empty { text-align: center; padding: 30px 10px; color: var(--muted); }
[hidden] { display: none !important; }
.grid2 > * { min-width: 0; }
input[type=date], input[type=month] { min-width: 0; max-width: 100%; -webkit-appearance: none; appearance: none; display: block; }
.variants { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.variant {
  text-align: left; border: 2px solid var(--line); background: var(--card); border-radius: 12px; padding: 10px 12px;
  cursor: pointer; display: flex; flex-direction: column; gap: 2px; min-width: 0;
}
.variant b { font-size: .95rem; }
.variant span { font-size: .78rem; color: var(--muted); line-height: 1.25; }
.variant em { font-style: normal; font-weight: 700; font-size: .85rem; margin-top: 4px; font-variant-numeric: tabular-nums; }
.variant.on { border-color: #0f3d34; box-shadow: inset 0 0 0 1px #0f3d34; }
.actionbar .btn.accent { padding: 0 16px; }
.google-btn { display: flex; justify-content: center; min-height: 44px; }
.divider { display: flex; align-items: center; gap: 10px; margin: 16px 0; color: var(--muted); font-size: .8rem; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.desk[data-manage], .hour[data-manage] { cursor: pointer; }
.days-btn { position: relative; }
.days-btn svg { width: 20px; height: 20px; }
.days-btn .badge {
  position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px;
  background: #0f3d34; color: #fff; font-size: .7rem; font-weight: 700; display: grid; place-items: center;
}
.day-list { max-height: 50vh; overflow: auto; border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; }
.day-pick { border-bottom: 1px solid var(--line); }
.day-pick:last-child { border-bottom: 0; }
.day-pick.off { opacity: .5; }
.actionbar { gap: 8px; }
.day-pick .grow { flex: 1; }
.seg-dark { background: rgba(255, 255, 255, .1); }
.seg-dark button { color: #b9cfc7; }
.seg-dark button.on { background: #fff; color: #0f3d34; }
