/* =========================================================================
   Stays — private short-term rental dashboard
   Mobile first. Layout switches at 768px.
   ========================================================================= */

:root {
  --bg:            #f7f7f5;
  --surface:       #ffffff;
  --surface-2:     #fbfbf9;
  --surface-sunk:  #f1f1ee;
  --line:          #e6e5e0;
  --line-strong:   #d7d6d0;
  --text:          #1d2025;
  --text-2:        #4a4f57;
  --muted:         #767b84;

  --accent:        #3f6fa8;
  --accent-ink:    #2f5580;
  --accent-soft:   #ecf2f9;

  --danger:        #b0453d;
  --danger-soft:   #fbeeec;
  --warn-ink:      #7c5a12;
  --warn-bg:       #fdf6e4;
  --warn-line:     #ecdcaf;
  --ok:            #3f8a72;

  --src-airbnb:    #c2565c;
  --src-booking:   #3d6bb3;
  --src-direct:    #3f8a72;
  --src-other:     #7b6ea6;

  --radius:        12px;
  --radius-lg:     16px;
  --shadow-1:      0 1px 2px rgba(20, 22, 26, .05);
  --shadow-2:      0 8px 30px rgba(20, 22, 26, .12);

  --rowhead:       144px;
  --day-w:         32px;
  --lane-h:        30px;

  --topbar-h:      56px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
          Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:           #16181c;
    --surface:      #1e2126;
    --surface-2:    #23262c;
    --surface-sunk: #191c20;
    --line:         #2e3238;
    --line-strong:  #3c4148;
    --text:         #e8e9eb;
    --text-2:       #c2c5ca;
    --muted:        #949aa3;

    --accent:       #7aa7d9;
    --accent-ink:   #a3c4e6;
    --accent-soft:  #23303e;

    --danger:       #e0837b;
    --danger-soft:  #33211f;
    --warn-ink:     #e6c980;
    --warn-bg:      #2b2517;
    --warn-line:    #4a3f21;
    --ok:           #6cb79c;

    --src-airbnb:   #d4757a;
    --src-booking:  #6d97d8;
    --src-direct:   #5aab92;
    --src-other:    #9b8fc7;

    --shadow-1:     0 1px 2px rgba(0, 0, 0, .4);
    --shadow-2:     0 8px 30px rgba(0, 0, 0, .55);
  }
}

/* ---------------------------------------------------------------- reset */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body.locked { overflow: hidden; }

[hidden] { display: none !important; }

h1, h2, h3, p, dl, dd, figure { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--surface); padding: 10px 14px; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

/* --------------------------------------------------------------- topbar */

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 12px;
  min-height: var(--topbar-h);
  padding: 8px 14px;
  padding-top: max(8px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(150%) blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 650; letter-spacing: -.01em; color: var(--text);
}
.brand-mark { width: 26px; height: 26px; color: var(--accent); flex: none; }
.brand span { display: none; }

.viewtabs {
  display: flex; gap: 2px; margin-left: auto;
  background: var(--surface-sunk);
  border: 1px solid var(--line);
  border-radius: 10px; padding: 2px;
}
.tab {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  padding: 7px 12px; border-radius: 8px; font-size: 13.5px; font-weight: 550;
  color: var(--muted); white-space: nowrap;
}
.tab[aria-pressed="true"] {
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-1);
}

.topbar-actions { display: none; gap: 8px; }

/* --------------------------------------------------------------- buttons */

.btn {
  appearance: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 16px;
  border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text);
  font-size: 14.5px; font-weight: 550; text-decoration: none;
  transition: background .12s ease, border-color .12s ease;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(.5px); }
.btn[disabled] { opacity: .5; cursor: default; }

.btn-primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.btn-primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
@media (prefers-color-scheme: dark) { .btn-primary { color: #10151b; } }

.btn-quiet { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-quiet:hover { background: var(--surface-sunk); }

.btn-danger-quiet { background: transparent; border-color: transparent; color: var(--danger); }
.btn-danger-quiet:hover { background: var(--danger-soft); }
.btn-danger-quiet.confirming {
  background: var(--danger); border-color: var(--danger); color: #fff;
}

.btn-sm { min-height: 32px; padding: 0 10px; font-size: 13px; border-radius: 8px; }

.iconbtn {
  appearance: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; flex: none;
  border: 1px solid transparent; border-radius: 10px;
  background: transparent; color: var(--text-2);
}
.iconbtn:hover { background: var(--surface-sunk); }
.iconbtn svg { width: 20px; height: 20px; }

/* ------------------------------------------------------------ period bar */

/* Only the month row sticks. The summary strip scrolls away with the content
   so it never eats a quarter of a phone screen. --stick-y is measured from
   the real topbar in app.js. */
.periodbar {
  position: sticky; top: var(--stick-y, 57px);
  z-index: 30;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(150%) blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 9px 14px;
}

.periodbar-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}

.monthnav { display: flex; align-items: center; gap: 2px; }
.monthlabel {
  font-size: 17px; font-weight: 650; letter-spacing: -.015em;
  min-width: 9.5ch; text-align: center;
}
.monthnav .btn-sm { margin-left: 6px; }

.staying {
  font-size: 13.5px; color: var(--muted);
  display: flex; align-items: center; gap: 7px;
  width: 100%;
}
.staying .dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: none;
}
.staying strong { color: var(--text-2); font-weight: 600; }

/* ---------------------------------------------------------- summary strip */

.summary-wrap { padding: 12px 14px 0; }

.summary {
  display: flex; gap: 8px;
  overflow-x: auto; scrollbar-width: thin;
  padding: 0 14px 4px;
  margin: 0 -14px;
  -webkit-overflow-scrolling: touch;
}
.summary::-webkit-scrollbar { height: 0; }

.stat {
  flex: none; min-width: 132px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 9px 12px 10px;
  box-shadow: var(--shadow-1);
}
.stat dt {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 600; white-space: nowrap;
}
.stat dd {
  font-size: 17px; font-weight: 650; letter-spacing: -.02em;
  margin-top: 2px; font-variant-numeric: tabular-nums;
}
.stat dd.money-out { color: var(--danger); }
.stat .sub { font-size: 11.5px; color: var(--muted); font-weight: 500; letter-spacing: 0; }

.stat-occ dd { display: flex; align-items: baseline; gap: 6px; }
.occbar {
  height: 4px; border-radius: 2px; background: var(--surface-sunk);
  margin-top: 7px; overflow: hidden;
}
.occbar > i { display: block; height: 100%; background: var(--accent); border-radius: 2px; }

/* ----------------------------------------------------------------- main */

.main { padding: 14px; padding-bottom: 96px; }
.main:focus { outline: none; }

.loading, .errorbox {
  padding: 40px 16px; text-align: center; color: var(--muted);
}
.errorbox { color: var(--danger); }

/* --------------------------------------------------------- empty states */

.empty {
  max-width: 460px; margin: 8vh auto 0; text-align: center;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 32px 24px 28px;
  box-shadow: var(--shadow-1);
}
.empty-icon {
  width: 48px; height: 48px; margin: 0 auto 14px; color: var(--accent); opacity: .9;
}
.empty h2 { font-size: 19px; letter-spacing: -.02em; margin-bottom: 8px; }
.empty p { color: var(--muted); font-size: 14.5px; margin-bottom: 20px; }
.empty .btn { min-height: 44px; }

.empty-inline {
  margin: 24px auto; padding: 28px 22px; max-width: 420px;
  background: var(--surface-2); border: 1px dashed var(--line-strong);
  box-shadow: none;
}

/* -------------------------------------------------------------- agenda */

.agenda-section + .agenda-section { margin-top: 22px; }
.agenda-heading {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); font-weight: 650; margin-bottom: 8px; padding: 0 2px;
}

.cards { display: flex; flex-direction: column; gap: 8px; }

.card {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px;
  width: 100%; text-align: left; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line);
  border-left: 3px solid var(--src, var(--line-strong));
  border-radius: var(--radius); padding: 12px 14px; min-height: 76px;
  box-shadow: var(--shadow-1);
  transition: border-color .12s ease, background .12s ease;
}
.card:hover { background: var(--surface-2); }
.card.is-past { opacity: .62; }

.card-top {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--muted);
}
.card-prop { font-weight: 600; color: var(--text-2); }
.card-name {
  grid-column: 1; font-size: 17px; font-weight: 650; letter-spacing: -.015em;
  line-height: 1.25;
}
.card-name .given { font-weight: 450; color: var(--muted); font-size: 14.5px; }
.card-dates {
  grid-column: 1; font-size: 13.5px; color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.card-dates .nights { color: var(--muted); }
.card-money {
  grid-column: 2; grid-row: 2 / span 2; text-align: right; align-self: center;
  font-variant-numeric: tabular-nums;
}
.card-total { font-size: 16px; font-weight: 650; letter-spacing: -.015em; white-space: nowrap; }
.card-ngn { font-size: 12px; color: var(--muted); white-space: nowrap; }
.card-bal {
  grid-column: 1 / -1; margin-top: 4px;
  font-size: 12.5px; font-weight: 600; color: var(--danger);
}

.badge {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 650; letter-spacing: .02em;
  padding: 2px 7px; border-radius: 999px;
  color: #fff; background: var(--src, var(--muted)); white-space: nowrap;
}
@media (prefers-color-scheme: dark) { .badge { color: #14171b; } }

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 650; padding: 2px 7px; border-radius: 999px;
  border: 1px solid currentColor;
}
.pill-unpaid    { color: var(--danger); }
.pill-part      { color: var(--warn-ink); }
.pill-paid      { color: var(--ok); }
.pill-inactive  { color: var(--muted); }
.pill-today     { color: var(--accent); background: var(--accent-soft); border-color: transparent; }

.pastbar { display: flex; justify-content: center; margin-top: 18px; }

/* ------------------------------------------------------------- timeline */

.tl-wrap {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-1);
}

.tl {
  overflow: auto;
  max-height: calc(100vh - 260px);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.tl-inner {
  width: max-content; min-width: 100%;
  --cols: var(--rowhead) repeat(var(--days), var(--day-w));
}

.tl-head {
  display: grid; grid-template-columns: var(--cols);
  position: sticky; top: 0; z-index: 3;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line-strong);
}
.tl-corner {
  position: sticky; left: 0; z-index: 4;
  background: var(--surface-2);
  border-right: 1px solid var(--line-strong);
  display: flex; align-items: center; padding: 0 12px;
  font-size: 11px; font-weight: 650; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted);
}
.tl-day {
  padding: 6px 0 7px; text-align: center; line-height: 1.15;
  border-left: 1px solid var(--line);
}
.tl-day .dow {
  display: block; font-size: 9.5px; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted); font-weight: 600;
}
.tl-day .dnum { display: block; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tl-day.is-we { background: var(--surface-sunk); }
.tl-day.is-today { background: var(--accent-soft); }
.tl-day.is-today .dnum { color: var(--accent-ink); font-weight: 750; }
.tl-day.is-today .dow  { color: var(--accent-ink); }

.tl-row {
  display: grid; grid-template-columns: var(--cols);
  border-bottom: 1px solid var(--line);
}
.tl-row:last-child { border-bottom: 0; }

.tl-rowhead {
  position: sticky; left: 0; z-index: 2;
  background: var(--surface);
  border-right: 1px solid var(--line-strong);
  padding: 8px 12px;
  display: flex; flex-direction: column; justify-content: center;
  min-width: 0;
}
.tl-rowhead .pname {
  font-size: 13.5px; font-weight: 600; letter-spacing: -.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tl-rowhead .ploc {
  font-size: 11.5px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.tl-track {
  grid-column: 2 / -1;
  display: grid;
  grid-template-columns: repeat(var(--days), var(--day-w));
  grid-template-rows: repeat(var(--lanes, 1), var(--lane-h));
  padding: 4px 0;
  row-gap: 3px;
}

.tl-cell {
  grid-row: 1 / -1;
  /* it is a <button>, so the UA border has to go before the column rule shows */
  border: 0; border-left: 1px solid var(--line);
  background: transparent; padding: 0; margin: -4px 0;
  cursor: pointer; appearance: none;
}
.tl-cell.is-we { background: color-mix(in srgb, var(--surface-sunk) 60%, transparent); }
.tl-cell.is-today { background: color-mix(in srgb, var(--accent-soft) 70%, transparent); }
.tl-cell:hover { background: var(--accent-soft); }

.bar {
  position: relative; z-index: 1;
  appearance: none; border: 0; cursor: pointer;
  margin: 0 2px; padding: 0 8px; min-width: 0;
  border-radius: 7px;
  background: var(--src, var(--muted));
  color: #fff;
  font-size: 12px; font-weight: 600; letter-spacing: -.005em;
  text-align: left; line-height: var(--lane-h);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06);
}
@media (prefers-color-scheme: dark) { .bar { color: #14171b; } }
.bar:hover { filter: brightness(1.06); }
.bar .amt { opacity: .8; font-weight: 500; }

/* payment not complete -> striped, lower-contrast fill */
.bar.is-owing {
  background-image: repeating-linear-gradient(
    -45deg,
    rgba(255, 255, 255, .32) 0 6px,
    rgba(255, 255, 255, 0)   6px 12px
  );
  box-shadow: inset 0 0 0 1.5px var(--src, var(--muted));
}
.bar.is-unpaid {
  background-color: color-mix(in srgb, var(--src, var(--muted)) 22%, var(--surface));
  color: var(--text);
  box-shadow: inset 0 0 0 1.5px var(--src, var(--muted));
}
.bar.is-unpaid .amt { opacity: .7; }

.bar.cut-left  { border-top-left-radius: 2px;  border-bottom-left-radius: 2px;  margin-left: 0; }
.bar.cut-right { border-top-right-radius: 2px; border-bottom-right-radius: 2px; margin-right: 0; }

.tl-legend {
  display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center;
  padding: 10px 14px; border-top: 1px solid var(--line);
  background: var(--surface-2); font-size: 12px; color: var(--muted);
}
.tl-legend .key { display: inline-flex; align-items: center; gap: 6px; }
.tl-legend .swatch {
  width: 20px; height: 10px; border-radius: 3px; background: var(--src, var(--muted));
}
.tl-legend .swatch.striped {
  background-image: repeating-linear-gradient(
    -45deg, rgba(255,255,255,.4) 0 4px, rgba(255,255,255,0) 4px 8px);
  --src: var(--muted);
}

.tl-note {
  margin-top: 10px; font-size: 12.5px; color: var(--muted); text-align: center;
}

/* ------------------------------------------------------------- settings */

.settings { max-width: 880px; margin: 0 auto; display: grid; gap: 22px; }

.sect {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-1); overflow: hidden;
}
.sect-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.sect-head h2 { font-size: 15.5px; letter-spacing: -.01em; }
.sect-head p { font-size: 12.5px; color: var(--muted); width: 100%; }
.sect-head .btn { margin-left: auto; }
.sect-body { padding: 6px 16px 14px; }

.plist > li {
  display: grid; gap: 4px 12px;
  grid-template-columns: 1fr auto;
  padding: 14px 0; border-bottom: 1px solid var(--line);
}
.plist > li:last-child { border-bottom: 0; }
.plist .pl-name { font-weight: 650; font-size: 15px; letter-spacing: -.01em; }
.plist .pl-meta { font-size: 12.5px; color: var(--muted); grid-column: 1; }
.plist .pl-meta span + span::before { content: "·"; margin: 0 6px; opacity: .6; }
.plist .pl-actions {
  grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px;
}
.plist .pl-tags { grid-column: 2; grid-row: 1; display: flex; gap: 6px; align-items: center; }

.rates { width: 100%; border-collapse: collapse; }
.rates th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 650; padding: 10px 8px 8px; border-bottom: 1px solid var(--line);
}
.rates th:last-child, .rates td:last-child { text-align: right; }
.rates td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.rates tr:last-child td { border-bottom: 0; }
.rates .code { font-weight: 650; font-variant-numeric: tabular-nums; }
.rates .upd { font-size: 12px; color: var(--muted); }
.rates input[type="number"], .rates input[type="text"] {
  width: 100%; max-width: 160px;
}
.rates .newcode { max-width: 90px; text-transform: uppercase; }
.rates-foot { font-size: 12.5px; color: var(--muted); padding: 12px 8px 2px; }

/* ---------------------------------------------------------------- forms */

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }

/* Vertical rhythm is owned by the form itself, so fields sitting side by side
   inside a .field-row are never pushed out of alignment with each other. */
.panel-body > * + * { margin-top: 14px; }
.panel-body > .toggle { margin-top: 20px; }

/* Keep controls on one baseline even when a neighbouring label wraps. */
.field-row > .field > input,
.field-row > .field > select,
.field-row > .field > textarea { margin-top: auto; }
.field > label {
  font-size: 12.5px; font-weight: 600; color: var(--text-2);
  display: flex; align-items: baseline; gap: 6px;
}
.req { font-size: 10.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }

input[type="text"], input[type="number"], input[type="date"], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: 10px;
  appearance: none; -webkit-appearance: none;
}
textarea { min-height: 72px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%23767b84' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 12px 8px;
  padding-right: 34px;
}
input[type="date"] { min-height: 44px; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row-3 { grid-template-columns: repeat(3, 1fr); }

.hint { font-size: 11.5px; color: var(--muted); }

.formerror {
  background: var(--danger-soft); color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  border-radius: 10px; padding: 10px 12px; font-size: 13.5px;
}

.warn {
  background: var(--warn-bg); color: var(--warn-ink);
  border: 1px solid var(--warn-line);
  border-radius: 10px; padding: 10px 12px; font-size: 13px;
}
.warn strong { font-weight: 700; }

.suggest {
  appearance: none; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px; min-height: 38px;
  border: 1px dashed var(--line-strong); border-radius: 10px;
  background: var(--surface-2); color: var(--accent);
  font-size: 13px; font-weight: 600; text-align: left;
}
.suggest:hover { background: var(--accent-soft); border-color: var(--accent); }

.calc {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  padding: 12px; border-radius: 12px;
  background: var(--surface-sunk); border: 1px solid var(--line);
}
.calc dt {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 650;
}
.calc dd {
  font-size: 15px; font-weight: 650; letter-spacing: -.015em; margin-top: 2px;
  font-variant-numeric: tabular-nums; overflow-wrap: anywhere;
}
.calc dd.money-out { color: var(--danger); }

.toggle {
  display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: start;
  padding: 14px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px;
}
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
  width: 44px; height: 26px; border-radius: 999px; background: var(--line-strong);
  padding: 3px; transition: background .15s ease; flex: none; display: block;
}
.toggle-thumb {
  display: block; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow-1); transition: transform .15s ease;
}
.toggle input:checked + .toggle-track { background: var(--accent); }
.toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(18px); }
.toggle input:focus-visible + .toggle-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.toggle-text strong { display: block; font-size: 14px; }
.toggle-text small { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }

/* --------------------------------------------------------------- panels */

.scrim {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(20, 22, 26, .38);
  opacity: 0; transition: opacity .2s ease;
}
.scrim.open { opacity: 1; }

.panel {
  position: fixed; z-index: 60;
  display: flex; flex-direction: column;
  background: var(--surface);
  box-shadow: var(--shadow-2);

  /* mobile: full-screen sheet */
  inset: 0;
  transform: translateY(100%);
  transition: transform .24s cubic-bezier(.32, .72, 0, 1);
}
.panel.open { transform: none; }
.panel-stacked { z-index: 70; }

.panel-head {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 12px 12px 18px;
  padding-top: max(12px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line); flex: none;
}
.panel-head h2 { font-size: 17px; letter-spacing: -.02em; margin-right: auto; }

.panel-body { flex: 1 1 auto; overflow-y: auto; padding: 18px; -webkit-overflow-scrolling: touch; }

.panel-foot {
  flex: none; display: flex; align-items: center; gap: 8px;
  padding: 12px 18px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); background: var(--surface-2);
}
.panel-foot-left { margin-right: auto; }
.panel-foot-right { display: flex; gap: 8px; }
.panel-foot .btn { min-height: 44px; }

/* ------------------------------------------------------------------ fab */

.fab {
  position: fixed; z-index: 45;
  right: 18px; bottom: max(18px, calc(env(safe-area-inset-bottom) + 12px));
  width: 56px; height: 56px; border-radius: 50%;
  border: 0; cursor: pointer;
  background: var(--accent); color: #fff;
  box-shadow: 0 6px 20px color-mix(in srgb, var(--accent) 40%, transparent);
  display: flex; align-items: center; justify-content: center;
}
.fab svg { width: 26px; height: 26px; }
.fab:active { transform: scale(.96); }
@media (prefers-color-scheme: dark) { .fab { color: #10151b; } }

/* ---------------------------------------------------------------- toast */

.toast {
  position: fixed; z-index: 90; left: 50%; transform: translateX(-50%) translateY(20px);
  bottom: max(20px, calc(env(safe-area-inset-bottom) + 16px));
  max-width: min(92vw, 460px);
  background: var(--text); color: var(--bg);
  padding: 11px 16px; border-radius: 10px; font-size: 13.5px; font-weight: 550;
  box-shadow: var(--shadow-2); opacity: 0;
  transition: opacity .18s ease, transform .18s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.err { background: var(--danger); color: #fff; }

/* ========================================================================
   DESKTOP  (>= 768px)
   ======================================================================== */

@media (min-width: 768px) {
  :root { --rowhead: 200px; --day-w: 40px; --lane-h: 32px; }

  body { font-size: 15px; }

  .brand span { display: inline; font-size: 16px; }
  .viewtabs { margin-left: 24px; }
  .topbar-actions { display: flex; margin-left: auto; }
  .topbar { padding-inline: 22px; gap: 8px; }

  .periodbar { padding: 11px 22px; }
  .periodbar-row { flex-wrap: nowrap; }
  .staying { width: auto; margin-left: auto; justify-content: flex-end; }
  .summary-wrap { padding: 14px 22px 0; }
  /* One scrolling row rather than a wrapping wall: with a dozen properties a
     wrapped strip pushes the calendar off screen. */
  .summary { margin: 0 -22px; padding: 0 22px 6px; }
  .stat { min-width: 160px; }

  .main { padding: 18px 22px 40px; }

  .fab { display: none; }

  .cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 10px; }

  .tl { max-height: calc(100vh - 300px); }

  /* slide-over from the right */
  .panel {
    inset: 0 0 0 auto;
    width: min(480px, 100vw);
    transform: translateX(100%);
    border-left: 1px solid var(--line);
  }
  .panel-stacked { width: min(440px, 100vw); }
  .panel-head { padding-top: 14px; }

  .plist > li { grid-template-columns: 1fr auto auto; align-items: center; }
  .plist .pl-actions { grid-column: 3; grid-row: 1 / span 2; margin-top: 0; }
  .plist .pl-tags { grid-column: 2; grid-row: 1 / span 2; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
