:root {
  --bg: #f4f4f7;
  --surface: #ffffff;
  --surface-2: #f0f0f4;
  --text: #15171c;
  --muted: #6b6f7a;
  --line: #e4e4ea;
  --accent: #4f46e5;
  --accent-soft: #eceafd;
  --accent-text: #ffffff;
  --here: #12a150;
  --here-soft: #e3f6eb;
  --warn: #c2410c;
  --warn-soft: #fdeee4;
  --danger: #dc2626;
  --shadow: 0 1px 2px rgba(16, 18, 27, 0.06), 0 4px 16px rgba(16, 18, 27, 0.06);
  --radius: 18px;
  --tabbar-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115;
    --surface: #181b21;
    --surface-2: #20242c;
    --text: #eef0f4;
    --muted: #979cab;
    --line: #2a2e37;
    --accent: #8b85ff;
    --accent-soft: #26244a;
    --accent-text: #0f1115;
    --here: #34d17a;
    --here-soft: #15301f;
    --warn: #fb923c;
    --warn-soft: #3a2415;
    --danger: #f87171;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button,
input,
select {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
  border: 0;
  background: none;
  padding: 0;
}
[hidden] {
  display: none !important;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
}

/* top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
}
.topbar h1 {
  margin: 0;
  font-size: 30px;
  letter-spacing: -0.02em;
}
.topbar-me {
  width: 36px;
  height: 36px;
}

main {
  padding: 4px 16px 0;
}

/* tab bar */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 6px 8px calc(env(safe-area-inset-bottom) + 6px);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--line);
}
.tabbar button {
  flex: 1;
  max-width: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 0;
  border-radius: 12px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}
.tabbar svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tabbar button[aria-current="page"] {
  color: var(--accent);
}

/* generic */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 22px 4px 8px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.section-title .count {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 600;
}
.muted {
  color: var(--muted);
}
.small {
  font-size: 13px;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 14px;
  font-weight: 650;
  background: var(--surface-2);
}
.btn.primary {
  background: var(--accent);
  color: var(--accent-text);
}
.btn.ghost {
  background: transparent;
  color: var(--accent);
}
.btn.danger {
  color: var(--danger);
}
.btn.block {
  width: 100%;
}
.btn:active {
  transform: scale(0.98);
}
.btn[disabled] {
  opacity: 0.5;
  pointer-events: none;
}
.row-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}
.row-actions .btn {
  flex: 1;
}
.input,
select.input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}
label.field {
  display: block;
  margin-bottom: 12px;
}
label.field > span {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 4px;
}

/* avatars */
.avatar {
  --size: 36px;
  position: relative;
  flex: none;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  font-size: calc(var(--size) * 0.38);
  font-weight: 700;
  color: #fff;
  overflow: hidden;
  background: hsl(var(--hue, 240) 55% 52%);
}
.avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.avatar.lg {
  --size: 72px;
}
.avatar.sm {
  --size: 26px;
}
.avatar.guest {
  background: var(--surface-2);
  color: var(--muted);
  border: 1.5px dashed var(--muted);
}
.stack {
  display: flex;
}
.stack .avatar {
  --size: 28px;
  border: 2px solid var(--surface);
  margin-left: -8px;
}
.stack .avatar:first-child {
  margin-left: 0;
}
.stack .more {
  margin-left: 6px;
  font-size: 13px;
  color: var(--muted);
  align-self: center;
}

/* today hero */
.hero {
  text-align: center;
  padding: 22px 16px 20px;
}
.hero .greet {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.hero .date {
  color: var(--muted);
  margin-top: 2px;
}
.checkin {
  position: relative;
  width: 184px;
  height: 184px;
  margin: 26px auto 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 25%, color-mix(in srgb, var(--accent) 70%, #fff), var(--accent));
  color: var(--accent-text);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.01em;
  box-shadow: 0 12px 30px color-mix(in srgb, var(--accent) 40%, transparent);
  display: grid;
  place-items: center;
  transition: transform 0.15s ease;
}
.checkin small {
  display: block;
  font-size: 13px;
  font-weight: 600;
  opacity: 0.85;
  margin-top: 2px;
}
.checkin::after {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--accent) 35%, transparent);
  animation: pulse 2.4s ease-out infinite;
}
.checkin:active {
  transform: scale(0.96);
}
@keyframes pulse {
  0% {
    transform: scale(0.95);
    opacity: 1;
  }
  100% {
    transform: scale(1.15);
    opacity: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .checkin::after {
    animation: none;
  }
}
.hero .hint {
  color: var(--muted);
  font-size: 15px;
}
.hero .hint b {
  color: var(--text);
}
.seat-big {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 22px auto 6px;
}
.seat-big .badge-check {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--here-soft);
  color: var(--here);
  display: grid;
  place-items: center;
}
.seat-big .badge-check svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.seat-big .where {
  text-align: left;
}
.seat-big .where .seat-office {
  color: var(--muted);
  font-size: 15px;
}
.seat-big .where .table {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.pop {
  animation: pop 0.45s cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes pop {
  from {
    transform: scale(0.6);
    opacity: 0;
  }
}

/* stats */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 4px;
}
.stat {
  background: var(--surface);
  border-radius: 14px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
}
.stat b {
  display: block;
  font-size: 22px;
  letter-spacing: -0.01em;
}
.stat span {
  font-size: 12px;
  color: var(--muted);
}

/* people list */
.people {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.person {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  min-height: 56px;
}
.person + .person {
  border-top: 1px solid var(--line);
}
.person .who {
  flex: 1;
  min-width: 0;
}
.person .name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.person .sub {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.person.faded {
  opacity: 0.55;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}
.chip.here {
  background: var(--here-soft);
  color: var(--here);
}
.chip.here::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.chip.wait {
  background: var(--warn-soft);
  color: var(--warn);
}
.chip.me {
  background: var(--accent-soft);
  color: var(--accent);
}
.tag {
  flex: none;
  min-width: 44px;
  text-align: center;
  padding: 5px 8px;
  border-radius: 10px;
  background: var(--surface-2);
  font-weight: 750;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.empty {
  text-align: center;
  padding: 26px 16px;
  color: var(--muted);
}

/* floor map */
.offices {
  display: grid;
  gap: 12px;
}
.office {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
}
.office-h {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 0 4px 10px;
  font-weight: 700;
}
.office-h span {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}
.tables {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(var(--cols, 3), 1fr);
}
.tbl {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 92px;
  padding: 8px 4px;
  border-radius: 14px;
  background: var(--surface-2);
  text-align: center;
  font-size: 12px;
  line-height: 1.2;
}
.tbl .num {
  position: absolute;
  top: 6px;
  left: 9px;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
}
.tbl .occ {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  padding: 0 4px;
}
.tbl.free {
  background: transparent;
  border: 1.5px dashed var(--line);
  color: var(--muted);
}
.tbl.free .plus {
  font-size: 22px;
  line-height: 1;
}
.tbl.held {
  background: repeating-linear-gradient(-45deg, var(--surface-2), var(--surface-2) 6px, transparent 6px, transparent 12px);
}
.tbl.here {
  background: var(--here-soft);
}
.tbl.mine {
  outline: 2.5px solid var(--accent);
  outline-offset: -2.5px;
}
.tbl.expected .avatar {
  opacity: 0.6;
}
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 10px 4px 0;
  font-size: 12px;
  color: var(--muted);
}
.legend i {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 4px;
  vertical-align: -2px;
  margin-right: 4px;
  background: var(--surface-2);
}
.legend i.here {
  background: var(--here-soft);
  border: 1px solid var(--here);
}
.legend i.mine {
  border: 2px solid var(--accent);
}
.legend i.free {
  background: transparent;
  border: 1.5px dashed var(--muted);
}

/* week */
.weeknav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 4px 0 14px;
}
.weeknav .label {
  text-align: center;
  font-weight: 700;
}
.weeknav .label small {
  display: block;
  font-weight: 500;
  color: var(--muted);
  font-size: 13px;
}
.iconbtn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  font-size: 22px;
}
.day {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 10px;
  overflow: hidden;
}
.day.past {
  opacity: 0.6;
}
.day.today {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.day-h {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  width: 100%;
  text-align: left;
}
.day-date {
  width: 46px;
  flex: none;
  text-align: center;
}
.day-date small {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
}
.day-date b {
  font-size: 22px;
}
.day-mid {
  flex: 1;
  min-width: 0;
}
.day-mid .meter {
  height: 6px;
  border-radius: 6px;
  background: var(--surface-2);
  margin-top: 8px;
  overflow: hidden;
}
.day-mid .meter span {
  display: block;
  height: 100%;
  border-radius: 6px;
  background: var(--accent);
}
.day-mid .meter span.full {
  background: var(--warn);
}
.day-mid .cnt {
  font-size: 13px;
  color: var(--muted);
}
.toggle {
  flex: none;
  min-width: 96px;
  height: 38px;
  padding: 0 12px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 14px;
  background: var(--surface-2);
}
.toggle.on {
  background: var(--accent);
  color: var(--accent-text);
}
.toggle.here {
  background: var(--here);
  color: #fff;
}
.day-body {
  padding: 0 14px 14px;
  border-top: 1px solid var(--line);
}
.day-body .people {
  box-shadow: none;
  background: var(--surface-2);
  margin-top: 12px;
}
.day-body .person + .person {
  border-top-color: var(--bg);
}

/* date chips for the Tables tab */
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 12px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar {
  display: none;
}
.datechip {
  flex: none;
  width: 54px;
  padding: 8px 0;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}
.datechip small {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
}
.datechip b {
  font-size: 18px;
}
.datechip[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-text);
}
.datechip[aria-pressed="true"] small {
  color: inherit;
  opacity: 0.85;
}

/* me */
.profile {
  display: flex;
  align-items: center;
  gap: 14px;
}
.profile .who {
  flex: 1;
  min-width: 0;
}
.regulars-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}
.regulars-row + .regulars-row {
  border-top: 1px solid var(--line);
}
.regulars-row .wd {
  width: 92px;
  font-weight: 600;
}
.regulars-row select {
  flex: 1;
}
.grid-wrap {
  overflow-x: auto;
}
table.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.grid th,
table.grid td {
  padding: 6px 4px;
  text-align: center;
  border-bottom: 1px solid var(--line);
}
table.grid th {
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
}
table.grid td:first-child,
table.grid th:first-child {
  text-align: left;
  font-weight: 700;
  white-space: nowrap;
}
table.grid .avatar {
  --size: 26px;
}
.note {
  font-size: 13px;
  color: var(--muted);
  margin: 8px 2px 0;
}

/* sheet */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
}
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  animation: fade 0.2s ease;
}
.sheet-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-width: 560px;
  margin: 0 auto;
  max-height: 88dvh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  padding: 8px 18px calc(env(safe-area-inset-bottom) + 18px);
  animation: up 0.25s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.sheet-grip {
  width: 40px;
  height: 5px;
  border-radius: 5px;
  background: var(--line);
  margin: 0 auto 14px;
}
.sheet h2 {
  margin: 0 0 6px;
  font-size: 20px;
}
@keyframes up {
  from {
    transform: translateY(100%);
  }
}
@keyframes fade {
  from {
    opacity: 0;
  }
}

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 18px);
  transform: translateX(-50%);
  z-index: 60;
  max-width: calc(100% - 32px);
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  animation: up-toast 0.25s ease;
}
.toast.error {
  background: var(--danger);
  color: #fff;
}
@keyframes up-toast {
  from {
    transform: translate(-50%, 20px);
    opacity: 0;
  }
}

.loading {
  display: grid;
  place-items: center;
  min-height: 50dvh;
}
.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.error-box {
  text-align: center;
  padding: 40px 16px;
}
.day-body .chip:not(.here):not(.wait):not(.me),
.day-body .tag {
  background: var(--surface);
}
