:root {
  --bg: #f4f9f8;
  --card: #ffffff;
  --ink: #17302e;
  --muted: #5d7673;
  --line: #dfebe9;
  --teal: #2a9d8f;
  --teal-deep: #1d7a6f;
  --teal-soft: #e3f3f0;
  --amber: #b7791f;
  --amber-soft: #fcf1dc;
  --rose: #b54a4a;
  --rose-soft: #fbe9e7;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(23, 48, 46, .05), 0 6px 20px rgba(23, 48, 46, .05);
  font-size: 18px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.4; -webkit-font-smoothing: antialiased;
}
h2 { font-size: 1.2rem; margin: 0; font-weight: 650; letter-spacing: -.01em; }

.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 1.5rem;
  padding: .8rem 1.6rem; background: rgba(244, 249, 248, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .8rem; }
.brand-mark {
  width: 2.5rem; height: 2.5rem; border-radius: 12px; background: var(--teal); color: #fff;
  display: grid; place-items: center; font-size: 1.7rem; font-weight: 700; line-height: 1;
}
.brand-name { font-weight: 700; font-size: 1.1rem; }
.brand-sub { color: var(--muted); font-size: .9rem; }
.jump { display: flex; gap: .4rem; margin-left: auto; }
.jump a {
  color: var(--teal-deep); text-decoration: none; padding: .45rem .9rem; border-radius: 999px;
  font-size: .9rem; font-weight: 600;
}
.jump a:hover { background: var(--teal-soft); }
.live {
  display: flex; align-items: center; gap: .5rem; padding: .45rem .9rem; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line); font-size: .85rem; color: var(--muted); white-space: nowrap;
}
.live-dot { width: .6rem; height: .6rem; border-radius: 50%; background: #c2cfcd; }
.live[data-state="live"] .live-dot { background: var(--teal); box-shadow: 0 0 0 0 rgba(42,157,143,.5); animation: pulse 2.4s infinite; }
.live[data-state="down"] .live-dot { background: var(--amber); }
.live.flash { border-color: var(--teal); background: var(--teal-soft); }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px rgba(42,157,143,0); } 100% { box-shadow: 0 0 0 0 rgba(42,157,143,0); } }

main { max-width: 1680px; margin: 0 auto; padding: 1.4rem 1.6rem 3rem; display: grid; gap: 1.4rem; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.stats > div { display: contents; }
.stat { background: var(--card); border-radius: var(--radius); padding: 1rem 1.3rem; box-shadow: var(--shadow); border: 1px solid var(--line); }
.stat-label { color: var(--muted); font-size: .85rem; font-weight: 600; }
.stat-value { font-size: 2.3rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; color: var(--teal-deep); font-variant-numeric: tabular-nums; }
.stat-note { color: var(--muted); font-size: .88rem; }
.stat.warn .stat-value { color: var(--rose); }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); min-width: 0; scroll-margin-top: 5.5rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.1rem 1.4rem .6rem; }
.card-head .sub { color: var(--muted); font-size: .85rem; }
.card-body { padding: .4rem 1.4rem 1.3rem; }
.card-body.scroll { max-height: 34rem; overflow-y: auto; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.4rem; align-items: start; }

.seg { display: inline-flex; background: var(--teal-soft); border-radius: 999px; padding: .25rem; }
.seg-btn { border: 0; background: transparent; font: inherit; font-size: .9rem; font-weight: 600; color: var(--teal-deep); padding: .45rem 1.1rem; border-radius: 999px; cursor: pointer; min-height: 2.4rem; }
.seg-btn.active { background: var(--teal); color: #fff; }

/* timeline */
.tl { --gutter: 3.6rem; overflow-x: auto; padding-bottom: .4rem; }
.tl-head, .tl-body { display: grid; grid-template-columns: var(--gutter) 1fr; min-width: calc(var(--gutter) + var(--lanes) * 11rem); }
.tl-head { position: sticky; top: 0; }
.tl-corner { }
.tl-head .tl-lane-title:first-of-type { }
.tl-head { grid-template-columns: var(--gutter) repeat(var(--lanes), 1fr); }
.tl-lane-title { padding: .3rem .5rem .6rem; border-bottom: 2px solid var(--teal-soft); display: flex; flex-direction: column; }
.lane-name { font-weight: 650; }
.lane-count { color: var(--muted); font-size: .8rem; }
.tl-body { position: relative; height: var(--h); }
.tl-hours { position: relative; }
.tl-hour { position: absolute; left: 0; transform: translateY(-.6em); font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.tl-lanes { position: relative; display: grid; grid-template-columns: repeat(var(--lanes), 1fr); height: var(--h);
  background-image: repeating-linear-gradient(to bottom, var(--line) 0, var(--line) 1px, transparent 1px, transparent var(--pph)); }
.tl-col { position: relative; border-left: 1px dashed var(--line); }
.tl-now { position: absolute; left: 0; right: 0; height: 0; border-top: 2px solid var(--rose); z-index: 5; pointer-events: none; }
.tl-now-label { position: absolute; left: -3.6rem; top: -.7rem; background: var(--rose); color: #fff; font-size: .72rem; font-weight: 700; padding: .05rem .4rem; border-radius: 6px; }

.appt {
  position: absolute; padding: .45rem .7rem; border-radius: 14px; background: var(--teal-soft);
  border-left: 5px solid var(--teal); overflow: hidden; display: flex; flex-direction: column; gap: .05rem;
  box-shadow: 0 1px 2px rgba(23,48,46,.08);
}
.appt-time { font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 600; }
.appt-pet { font-weight: 700; font-size: 1.02rem; line-height: 1.2; }
.appt-species { font-weight: 500; color: var(--muted); font-size: .8rem; margin-left: .4rem; }
.appt-owner { font-size: .88rem; }
.appt-foot { display: flex; justify-content: space-between; align-items: center; gap: .4rem; margin-top: .15rem; }
.appt-reason { font-size: .84rem; color: var(--teal-deep); font-weight: 650; }
.appt-where { font-size: .78rem; color: var(--muted); }
.chip { display: inline-block; font-size: .74rem; font-weight: 700; padding: .12rem .6rem; border-radius: 999px; background: #fff; color: var(--teal-deep); border: 1px solid var(--line); white-space: nowrap; }
.st-checkedin, .st-arrived, .st-waiting { background: #eaf5ff; border-left-color: #3b82c4; }
.st-checkedin .chip, .st-arrived .chip, .st-waiting .chip { color: #2a6396; }
.st-inprogress, .st-ongoing { background: #dff3ef; border-left-color: var(--teal-deep); }
.st-completed { background: #f1f4f4; border-left-color: #9db5b1; color: #4c615f; }
.st-completed .appt-reason, .st-completed .chip { color: #4c615f; }
.st-cancelled { background: #f6f6f6; border-left-color: #c3c9c8; color: #8a9695; }
.st-cancelled .appt-pet { text-decoration: line-through; }
.st-noshow { background: var(--amber-soft); border-left-color: var(--amber); }
.st-noshow .chip { color: var(--amber); }

/* lists */
.rows { list-style: none; margin: 0; padding: 0; }
.row { display: flex; justify-content: space-between; gap: 1rem; padding: .8rem .2rem; border-top: 1px solid var(--line); align-items: center; }
.row:first-child { border-top: 0; }
.row-main { min-width: 0; }
.row-title { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { color: var(--muted); font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.muted { color: var(--muted); font-weight: 500; }
.row-side { text-align: right; flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; gap: .2rem; }
.row-strong { font-weight: 700; font-variant-numeric: tabular-nums; }
.chip-calm { background: var(--teal-soft); border-color: transparent; }
.chip-soon { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.chip-late { background: var(--rose-soft); color: var(--rose); border-color: transparent; }
.row-overdue { background: linear-gradient(90deg, var(--rose-soft), transparent 70%); border-radius: 12px; }
.row-overdue .row-strong { color: var(--rose); }

.chart-wrap { position: relative; height: 18rem; }
.chart-total { color: var(--muted); font-size: .9rem; margin-top: .6rem; text-align: center; }

.empty { text-align: center; padding: 2.2rem 1rem; }
.empty-title { font-weight: 650; color: var(--teal-deep); }
.empty-hint { color: var(--muted); font-size: .9rem; }
.note { margin: .2rem 0 .8rem; padding: .6rem .9rem; border-radius: 12px; font-size: .9rem; }
.note-error { background: var(--amber-soft); color: var(--amber); }

#toasts { position: fixed; right: 1.2rem; bottom: 1.2rem; display: flex; flex-direction: column; gap: .6rem; z-index: 50; max-width: min(24rem, calc(100vw - 2rem)); }
.toast { background: var(--ink); color: #fff; padding: .8rem 1.1rem; border-radius: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.2); animation: toast-in .25s ease; font-size: .92rem; }
.toast b { color: #8fe0d3; display: block; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.toast.out { opacity: 0; transform: translateY(6px); transition: .3s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.swap { animation: soft-in .35s ease; }
@keyframes soft-in { from { opacity: .55; } }

@media (max-width: 1200px) {
  .grid3 { grid-template-columns: 1fr 1fr; }
  #week { grid-column: 1 / -1; }
  .jump { display: none; }
  .live { margin-left: auto; }
}
@media (max-width: 800px) {
  :root { font-size: 17px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .grid3 { grid-template-columns: 1fr; }
  main { padding: 1rem; }
  .topbar { padding: .7rem 1rem; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
