/* ============================================================
   Team Maverick · Appointments — Wholesale Payments
   Google-Calendar-style layout · brand hues as subtle tints
   ============================================================ */

:root {
  /* Wholesale Payments brand */
  --wp-navy:    #16204F;
  --wp-blue:    #1E8FE8;
  --wp-sky:     #18A0E8;
  --wp-green:   #2EB875;
  --wp-green-2: #3EC97D;
  --wp-mint:    #71DC8B;
  --wp-gray:    #A7ABB3;

  /* Light theme */
  --bg:        #ffffff;
  --canvas:    #ffffff;
  --surface:   #ffffff;
  --surface-2: #f6f8fb;
  --rail:      #f5f7fb;
  --text:      #17204a;
  --text-2:    #566079;
  --text-3:    #8992a8;
  --line:      #e6e9f2;
  --line-soft: #eef1f7;
  --hairline:  #eaedf4;
  --shadow-sm: 0 1px 2px rgba(22, 32, 79, 0.06);
  --shadow-md: 0 2px 6px rgba(22, 32, 79, 0.08), 0 8px 24px rgba(22, 32, 79, 0.08);
  --shadow-lg: 0 20px 55px rgba(22, 32, 79, 0.20);
  --wash-a: rgba(30, 143, 232, 0.045);
  --wash-b: rgba(46, 184, 117, 0.04);
  --appbar-bg: #ffffff;
  --brand-word: var(--wp-navy);
  --today-wash: rgba(30, 143, 232, 0.055);
  --hover: rgba(22, 32, 79, 0.045);
  --tint: 12%;
  --pill-text-dark: #17204a;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
          "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Dark: near-black neutral base (Apple-style) — the saturated navy lives in
   accents and brand hues, not in the backgrounds, so event colors stay clean */
:root[data-theme="dark"] {
  --bg:        #0a0c12;
  --canvas:    #0e1017;
  --surface:   #171a22;
  --surface-2: #12141b;
  --rail:      #0c0e14;
  --text:      #f2f4f9;
  --text-2:    #a9afbe;
  --text-3:    #6d7383;
  --line:      rgba(255, 255, 255, 0.09);
  --line-soft: rgba(255, 255, 255, 0.055);
  --hairline:  rgba(255, 255, 255, 0.065);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 2px 6px rgba(0, 0, 0, 0.32), 0 12px 30px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.6);
  --wash-a: rgba(30, 143, 232, 0.045);
  --wash-b: rgba(46, 184, 117, 0.035);
  --appbar-bg: #0e1017;
  --brand-word: #ffffff;
  --today-wash: rgba(30, 143, 232, 0.09);
  --hover: rgba(255, 255, 255, 0.06);
  --tint: 17%;
  --pill-text-dark: #f2f4f9;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); height: 100%; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Installed app (PWA): there is no collapsing browser chrome, and iOS
   standalone under-reports 100dvh by the status-bar inset — which strands
   the bottom nav above a dead strip. The large viewport is the full screen
   there, so size the app by it. */
@media (display-mode: standalone) {
  body { height: 100vh; height: 100lvh; }
}

button { font-family: inherit; font-size: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input { font-family: inherit; }

/* ---------------- App bar ---------------- */

.appbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 60px;
  padding: 0 12px 0 8px;
  background: var(--appbar-bg);
  border-bottom: 1px solid var(--line);
  z-index: 40;
}

/* ---------------- Live ticker ---------------- */
/* Topmost element, so it (not the appbar) absorbs the notch inset. */
.ticker {
  flex: none;
  display: flex;
  align-items: stretch;
  padding-top: env(safe-area-inset-top);
  background: var(--appbar-bg);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
  z-index: 41;
}
.ticker-viewport { position: relative; flex: 1; min-width: 0; overflow: hidden; }
.ticker-viewport::before, .ticker-viewport::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 26px; z-index: 1; pointer-events: none;
}
.ticker-viewport::before { left: 0; background: linear-gradient(to right, var(--appbar-bg), transparent); }
.ticker-viewport::after { right: 0; background: linear-gradient(to left, var(--appbar-bg), transparent); }
.ticker-track {
  display: inline-flex; align-items: center;
  height: 34px; white-space: nowrap; will-change: transform;
  animation: tick-scroll var(--tick-dur, 40s) linear infinite;
}
@keyframes tick-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(var(--tick-shift, -50%)); }
}
.ticker:hover .ticker-track { animation-play-state: paused; }
.tick-seq { display: inline-flex; align-items: center; }
.tick-item {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 600; color: var(--text-2);
  padding: 4px 0; cursor: pointer;
}
.tick-item:hover .tick-title { color: var(--text); }
.tick-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--agent-c, var(--wp-blue)); }
.tick-time { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.tick-agent { color: color-mix(in srgb, var(--agent-c, var(--wp-blue)) 74%, var(--text)); }
.tick-item.is-payout .tick-time { color: #d4a017; }
.tick-item.is-payout .tick-dot { background: #d4a017; }
.tick-sep { margin: 0 15px; font-size: 7px; color: var(--text-3); opacity: 0.7; flex: none; }
.tick-msg { font-size: 12px; font-weight: 600; color: var(--text-3); padding-right: 40px; }
@media (max-width: 640px) {
  .ticker-track { height: 31px; }
  .tick-item, .tick-msg { font-size: 11.5px; }
}
@media (prefers-reduced-motion: reduce) {
  .ticker-track { animation: none; }
  .ticker-viewport { overflow-x: auto; }
}

.brand { display: flex; align-items: center; text-decoration: none; color: inherit; flex: none; }
.brand-logo-img { height: 30px; width: auto; display: block; }
/* Dark mode swaps in assets/logo-dark.png (white wordmark) via applyTheme() —
   no white chip needed behind the logo. */
.brand-divider { width: 1px; height: 26px; background: var(--line); margin: 0 4px 0 10px; flex: none; }
.team-tag { font-weight: 650; font-size: 15px; letter-spacing: -0.02em; color: var(--text-2); white-space: nowrap; flex: none; }

/* text fallback until logo loads */
.brand-row.no-logo .brand, .brand.no-logo, .no-logo .brand-divider { display: none; }

.ghost-btn {
  margin-left: 14px;
  padding: 7px 15px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  white-space: nowrap;
  flex: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.ghost-btn:hover { background: var(--hover); }

.datenav { display: inline-flex; align-items: center; gap: 2px; margin-left: 4px; flex: none; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 50%;
  color: var(--text-2);
  transition: background 0.15s ease, color 0.15s ease, transform 0.08s ease;
  flex: none;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn.small { width: 34px; height: 34px; }
.icon-btn:focus-visible, .ghost-btn:focus-visible, .vs-btn:focus-visible,
.chip:focus-visible, .link-btn:focus-visible, .agent-toggle:focus-visible {
  outline: 2.5px solid color-mix(in srgb, var(--wp-blue) 62%, transparent);
  outline-offset: 2px;
}
.ic { width: 20px; height: 20px; display: block; }
.icon-btn.spinning .ic { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.ic-moon { display: none; }
:root[data-theme="dark"] .ic-sun { display: none; }
:root[data-theme="dark"] .ic-moon { display: block; }

.current-label {
  margin: 0 0 0 8px;
  font-size: clamp(16px, 2vw, 21px);
  font-weight: 650;
  letter-spacing: -0.022em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 40px;
}

.appbar-right { display: flex; align-items: center; gap: 4px; flex: none; }

/* Search */
.search-wrap {
  display: flex; align-items: center; gap: 6px;
  height: 40px; padding: 0 8px 0 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid transparent;
  width: 210px;
  transition: background 0.15s ease, border-color 0.15s ease, width 0.2s ease;
}
.search-wrap:focus-within { background: var(--surface); border-color: var(--line); width: 250px; }
.search-ic { width: 18px; height: 18px; color: var(--text-3); flex: none; }
.search-input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: none;
  font-size: 13.5px; color: var(--text);
}
.search-input::placeholder { color: var(--text-3); }
.search-clear { width: 28px; height: 28px; }

/* View switcher */
.viewswitch {
  display: inline-flex;
  margin-left: 6px;
  padding: 3px;
  border-radius: 10px;
  background: var(--surface-2);
  gap: 2px;
}
.vs-btn {
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-2);
  white-space: nowrap;
  transition: background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}
.vs-btn.is-active { background: var(--surface); color: var(--wp-blue); box-shadow: var(--shadow-sm); }

/* ---------------- Shell (sidebar + content) ---------------- */

.shell { flex: 1; display: flex; min-height: 0; }

.sidebar {
  flex: none;
  width: 256px;
  background: var(--rail);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 12px 24px;
  scrollbar-width: thin;
}

.sidebar-scrim {
  position: fixed; inset: 0; z-index: 44;
  background: rgba(9, 12, 30, 0.4);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}

/* Mini month */
.mini { padding: 6px 6px 12px; }
.mini-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.mini-label { font-size: 13.5px; font-weight: 650; letter-spacing: -0.01em; padding-left: 6px; }
.mini-nav { display: flex; gap: 2px; }
.mini-nav .icon-btn.small { width: 30px; height: 30px; }
.mini-nav .ic { width: 16px; height: 16px; }

.mini-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; }
.mini-dow {
  text-align: center; font-size: 10px; font-weight: 600; color: var(--text-3);
  height: 22px; line-height: 22px;
}
.mini-day {
  position: relative;
  aspect-ratio: 1; min-height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11.5px; font-weight: 550;
  color: var(--text-2);
  border-radius: 50%;
  transition: background 0.12s ease, color 0.12s ease;
}
.mini-day:hover { background: var(--hover); }
.mini-day.is-out { color: var(--text-3); opacity: 0.5; }
.mini-day.has-ev::after {
  content: ""; position: absolute; bottom: 3px; left: 50%; transform: translateX(-50%);
  width: 3.5px; height: 3.5px; border-radius: 50%; background: var(--wp-green);
}
.mini-day.is-today { background: color-mix(in srgb, var(--wp-blue) 14%, transparent); color: var(--wp-blue); font-weight: 700; }
.mini-day.is-sel { box-shadow: inset 0 0 0 1.6px color-mix(in srgb, var(--wp-blue) 60%, transparent); color: var(--text); }
.mini-day.is-today.is-sel { background: var(--wp-blue); color: #fff; box-shadow: none; }

/* Sidebar sections */
.side-section { margin-top: 18px; padding: 0 4px; }
.side-title {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-3); margin-bottom: 8px; padding: 0 4px;
}
.link-btn { color: var(--wp-blue); font-weight: 600; }
.link-btn:hover { text-decoration: underline; }
.link-btn.tiny { font-size: 11px; text-transform: none; letter-spacing: 0; }

.agent-list {
  display: flex; flex-direction: column; gap: 3px;
  max-height: 218px; overflow-y: auto;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--text) 22%, transparent) transparent;
}
.agent-list::-webkit-scrollbar { width: 8px; }
.agent-list::-webkit-scrollbar-track { background: transparent; }
.agent-list::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--text) 20%, transparent);
  border-radius: 4px; border: 2px solid transparent; background-clip: padding-box;
}
.agent-list::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--text) 32%, transparent); background-clip: padding-box; }
.agent-toggle {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 9px; border-radius: 9px;
  text-align: left; width: 100%;
  background: color-mix(in srgb, var(--agent-c, var(--wp-gray)) 8%, transparent);
  transition: background 0.12s ease;
}
.agent-toggle:hover { background: color-mix(in srgb, var(--agent-c, var(--wp-gray)) 15%, transparent); }
/* Checkbox in a light hue of the agent's logo-family color */
.agent-check {
  width: 18px; height: 18px; border-radius: 5px; flex: none;
  border: 1.5px solid color-mix(in srgb, var(--agent-c, var(--wp-gray)) 50%, transparent);
  background: transparent;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.agent-check svg { width: 12px; height: 12px; color: color-mix(in srgb, var(--agent-c, var(--wp-gray)) 78%, var(--text)); }
.agent-toggle[aria-pressed="true"] .agent-check {
  background: color-mix(in srgb, var(--agent-c, var(--wp-gray)) 24%, var(--surface));
  border-color: color-mix(in srgb, var(--agent-c, var(--wp-gray)) 68%, transparent);
}
.agent-toggle[aria-pressed="false"] { background: transparent; }
.agent-toggle[aria-pressed="false"]:hover { background: color-mix(in srgb, var(--agent-c, var(--wp-gray)) 8%, transparent); }
.agent-toggle[aria-pressed="false"] .agent-check { background: transparent; }
.agent-toggle[aria-pressed="false"] .agent-check svg { display: none; }
.agent-toggle[aria-pressed="false"] .agent-name { color: var(--text-3); }
.agent-name { font-size: 13.5px; font-weight: 550; letter-spacing: -0.01em; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-cnt { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; flex: none; }

.side-stats { display: flex; flex-direction: column; gap: 7px; }
.side-stat {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: 11px;
  background: var(--surface); border: 1px solid var(--line-soft);
}
.side-stat .ss-num { font-size: 19px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; color: var(--ss-c, var(--wp-blue)); flex: none; min-width: 30px; }
.side-stat .ss-label { font-size: 12px; color: var(--text-2); font-weight: 500; }

/* Glance tiles are clickable — they open a breakdown panel */
button.side-stat { cursor: pointer; width: 100%; text-align: left; transition: background 0.12s ease, border-color 0.12s ease, transform 0.08s ease; }
button.side-stat:hover { background: var(--hover); border-color: color-mix(in srgb, var(--ss-c, var(--wp-blue)) 30%, transparent); }
button.side-stat:active { transform: scale(0.985); }
.ss-chev { margin-left: auto; color: var(--text-3); font-size: 15px; font-weight: 600; line-height: 1; }
button.side-stat:hover .ss-chev { color: var(--ss-c, var(--wp-blue)); }

/* Breakdown panel */
.glance-sub { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }
.glance-list { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.glance-empty { padding: 28px 8px; text-align: center; color: var(--text-3); font-size: 13px; }
.gl-agent-head { display: flex; align-items: center; gap: 8px; margin: 12px 2px 3px; font-size: 13px; }
.gl-agent-head:first-child { margin-top: 2px; }
.gl-agent-head b { font-weight: 650; letter-spacing: -0.01em; }
.gl-cnt { margin-left: auto; font-size: 11.5px; color: var(--text-3); }

/* ---------------- Content / views ---------------- */

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--canvas); position: relative; }
.content::before {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(46rem 26rem at 8% -6%, var(--wash-a), transparent 60%),
    radial-gradient(46rem 26rem at 96% -8%, var(--wash-b), transparent 60%);
}
.banner, .view-host { position: relative; z-index: 1; }

.banner {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 12px 16px 0; padding: 11px 15px; border-radius: 13px;
  font-size: 13px;
  border: 1px solid color-mix(in srgb, var(--wp-blue) 22%, transparent);
  background: color-mix(in srgb, var(--wp-blue) 6%, var(--surface));
  color: var(--text); flex: none;
}
.banner.warn { border-color: color-mix(in srgb, #e0932f 34%, transparent); background: color-mix(in srgb, #e0932f 8%, var(--surface)); }
.banner .link-btn { font-weight: 700; }

.view-host { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; padding: 14px 16px 16px; }

.view { flex: 1; min-height: 0; display: flex; flex-direction: column; animation: fade 0.2s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .view { animation: none; } }

/* ===== Shared event colors ===== */
.ev-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--agent-c, var(--wp-blue)); flex: none; }

.status-pill {
  font-size: 10px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 999px;
  background: color-mix(in srgb, var(--st-c, var(--wp-gray)) 16%, transparent);
  color: color-mix(in srgb, var(--st-c, var(--wp-gray)) 82%, var(--text));
  flex: none; white-space: nowrap;
}

/* ============================================================
   MONTH VIEW
   ============================================================ */
.month { flex: 1; min-height: 0; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--surface); box-shadow: var(--shadow-sm); }
.month-dow { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-bottom: 1px solid var(--line-soft); flex: none; }
.month-dow span { text-align: center; padding: 9px 0 7px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-3); }
.month-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-auto-rows: 1fr; }

.mday {
  border-right: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft);
  padding: 4px 5px 5px; min-width: 0; display: flex; flex-direction: column; gap: 2px;
  overflow: hidden; text-align: left; transition: background 0.12s ease; position: relative;
}
.mday:nth-child(7n) { border-right: 0; }
.mday:hover { background: var(--hover); }
.mday.is-out { background: color-mix(in srgb, var(--text) 2.5%, transparent); }
.mday.is-out .mnum { color: var(--text-3); opacity: 0.55; }
.mday.is-today { background: var(--today-wash); }
.mnum {
  align-self: center; margin-top: 1px;
  font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text-2);
  width: 23px; height: 23px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%;
}
.mday.is-today .mnum { background: var(--wp-blue); color: #fff; font-weight: 700; }
.mday-events { display: flex; flex-direction: column; gap: 2px; overflow: hidden; }

.mev {
  display: flex; align-items: center; gap: 5px;
  font-size: 11.5px; line-height: 1.3; font-weight: 550;
  padding: 2px 6px; border-radius: 6px;
  background: color-mix(in srgb, var(--agent-c, var(--wp-blue)) var(--tint), transparent);
  color: var(--pill-text-dark);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
  width: 100%; text-align: left;
}
.mev .mev-t { font-weight: 700; font-size: 10.5px; font-variant-numeric: tabular-nums; color: color-mix(in srgb, var(--agent-c, var(--wp-blue)) 70%, var(--text)); flex: none; }
.mev .mev-title { overflow: hidden; text-overflow: ellipsis; }
.mev.is-cancelled { text-decoration: line-through; opacity: 0.55; }
.mmore { font-size: 11px; font-weight: 650; color: var(--text-2); padding: 1px 6px; text-align: left; border-radius: 6px; }
.mmore:hover { background: var(--hover); }

.mday-dots { display: none; gap: 3px; justify-content: center; flex-wrap: wrap; margin-top: 2px; }
.mday-dots i { width: 5.5px; height: 5.5px; border-radius: 50%; background: var(--agent-c, var(--wp-blue)); }

/* ============================================================
   DAY & WEEK (time grid)
   ============================================================ */
.timegrid { flex: 1; min-height: 0; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--surface); box-shadow: var(--shadow-sm); }
.tg-allday {
  display: grid; border-bottom: 1px solid var(--line); flex: none; max-height: 92px; overflow-y: auto;
}
.tg-head { display: grid; border-bottom: 1px solid var(--line); flex: none; }
.tg-head .tg-corner { border-right: 1px solid var(--line-soft); }
.tg-daycol-head {
  padding: 7px 6px; text-align: center; border-right: 1px solid var(--line-soft); min-width: 0;
}
.tg-daycol-head:last-child { border-right: 0; }
.tg-dow { font-size: 11px; font-weight: 650; letter-spacing: 0.03em; text-transform: uppercase; color: var(--text-3); }
.tg-dnum {
  font-size: 20px; font-weight: 650; letter-spacing: -0.02em; margin-top: 2px;
  width: 34px; height: 34px; line-height: 34px; border-radius: 50%; display: inline-block;
  font-variant-numeric: tabular-nums;
}
.tg-daycol-head.is-today .tg-dnum { background: var(--wp-blue); color: #fff; }
.tg-daycol-head.is-today .tg-dow { color: var(--wp-blue); }

.tg-scroll { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.tg-body { display: grid; position: relative; }
.tg-axis { grid-column: 1; }
.tg-hour { height: 52px; position: relative; }
.tg-hour-label {
  position: absolute; top: -7px; right: 8px; font-size: 10.5px; color: var(--text-3);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.tg-col { position: relative; border-right: 1px solid var(--line-soft); }
.tg-col:last-child { border-right: 0; }
.tg-col.is-today { background: var(--today-wash); }
.tg-line { position: absolute; left: 0; right: 0; height: 0; border-top: 1px solid var(--line-soft); }
.tg-line.faint { border-top-style: dotted; opacity: 0.6; }

.tg-now { position: absolute; left: 0; right: 0; height: 0; border-top: 2px solid #e0483d; z-index: 6; pointer-events: none; }
.tg-now::before { content: ""; position: absolute; left: -1px; top: -5px; width: 9px; height: 9px; border-radius: 50%; background: #e0483d; }

.tev {
  position: absolute; left: 3px; right: 3px;
  border-radius: 7px; padding: 4px 7px; overflow: hidden;
  background: color-mix(in srgb, var(--agent-c, var(--wp-blue)) var(--tint), var(--surface));
  border-left: 3px solid var(--agent-c, var(--wp-blue));
  box-shadow: var(--shadow-sm); cursor: pointer; min-height: 22px;
  transition: filter 0.12s ease, transform 0.08s ease; z-index: 5;
}
.tev:hover { filter: brightness(1.03); z-index: 7; }
.tev:active { transform: scale(0.995); }
.tev .tev-title { font-size: 12px; font-weight: 650; letter-spacing: -0.01em; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tev .tev-time { font-size: 10.5px; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tev .tev-agent { font-size: 10.5px; color: color-mix(in srgb, var(--agent-c, var(--wp-blue)) 74%, var(--text)); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tev .tev-agent-inline { color: color-mix(in srgb, var(--agent-c, var(--wp-blue)) 74%, var(--text)); font-weight: 600; }
.tev.is-cancelled .tev-title { text-decoration: line-through; opacity: 0.6; }
.tev.compact { padding: 2px 7px; }
.tev.compact .tev-title { font-size: 11px; }

.tg-allday-row { display: contents; }
.tg-allday .tg-corner {
  padding: 6px 8px; font-size: 9.5px; font-weight: 650; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.05em; line-height: 1.25; text-align: right;
  border-right: 1px solid var(--line-soft); display: flex; align-items: center; justify-content: flex-end;
}
.tg-allday-cell { padding: 5px 5px; border-right: 1px solid var(--line-soft); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tg-allday-cell:last-child { border-right: 0; }
.allday-chip {
  display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600;
  padding: 3px 8px; border-radius: 7px; min-width: 0;
  background: color-mix(in srgb, var(--agent-c, var(--wp-blue)) var(--tint), transparent);
  color: var(--pill-text-dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: filter 0.12s ease;
}
.allday-chip:hover { filter: brightness(1.05); }

/* Day view: all-day events become roomy cards in a responsive grid */
.tg-allday.is-day { max-height: 184px; }
.tg-allday.is-day .tg-allday-cell {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 8px;
  padding: 10px 12px;
  align-content: start;
}
.tg-allday.is-day .allday-chip {
  align-items: flex-start; text-align: left;
  padding: 9px 12px; border-radius: 11px; white-space: normal;
  background: color-mix(in srgb, var(--agent-c, var(--wp-blue)) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--agent-c, var(--wp-blue)) 24%, transparent);
  box-shadow: var(--shadow-sm);
}
.adc-main { min-width: 0; display: flex; flex-direction: column; flex: 1; }
.adc-title {
  font-size: 13px; font-weight: 650; letter-spacing: -0.01em; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.adc-sub {
  font-size: 11.5px; font-weight: 500; color: var(--text-2); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
@media (max-width: 640px) {
  .tg-allday.is-day .tg-allday-cell { grid-template-columns: 1fr; padding: 8px; }
}

/* ============================================================
   SCHEDULE VIEW (agenda list)
   ============================================================ */
.schedule { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; padding-right: 2px; }
.sch-day { display: flex; gap: 16px; padding: 14px 6px; border-bottom: 1px solid var(--line-soft); }
.sch-day:last-child { border-bottom: 0; }
.sch-date { flex: none; width: 92px; text-align: right; padding-top: 2px; position: sticky; top: 0; }
.sch-date .sd-dow { font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-3); }
.sch-date .sd-num { font-size: 26px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.05; }
.sch-date .sd-mon { font-size: 11.5px; color: var(--text-3); }
.sch-date.is-today .sd-num { color: var(--wp-blue); }
.sch-items { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 7px; }

.sch-ev {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 10px 13px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line-soft);
  border-left: 3px solid var(--agent-c, var(--wp-blue));
  box-shadow: var(--shadow-sm); text-align: left; width: 100%; cursor: pointer;
  transition: background 0.12s ease, transform 0.08s ease;
}
.sch-ev:hover { background: var(--hover); }
.sch-ev:active { transform: scale(0.997); }
.sch-time { flex: none; width: 88px; padding-top: 1px; }
.sch-time .st1 { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.sch-time .st2 { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.sch-main { flex: 1; min-width: 0; }
.sch-title { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sch-meta { margin-top: 2px; font-size: 12px; color: var(--text-2); display: flex; gap: 6px; flex-wrap: wrap; align-items: baseline; }
.sch-meta .sep { color: var(--text-3); }
.sch-meta .ag { font-weight: 600; color: color-mix(in srgb, var(--agent-c, var(--wp-blue)) 76%, var(--text)); }
.sch-notes { margin-top: 3px; font-size: 12px; color: var(--text-3); }
.sch-ev.is-cancelled .sch-title, .sch-ev.is-cancelled .st1 { text-decoration: line-through; opacity: 0.6; }

/* ---------------- Empty / skeleton ---------------- */
.empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: var(--text-3); padding: 40px 20px; }
.empty-emoji { font-size: 34px; margin-bottom: 8px; }
.empty-title { font-size: 15px; font-weight: 650; color: var(--text-2); }
.empty p { margin: 4px 0 0; font-size: 13px; max-width: 320px; }

.skeleton-wrap { flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 4px; }
.skeleton { border-radius: 12px; background: var(--surface); border: 1px solid var(--line-soft); position: relative; overflow: hidden; }
.skeleton::after { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 30%, var(--hover) 50%, transparent 70%); background-size: 220% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { from { background-position: 150% 0; } to { background-position: -80% 0; } }

/* ============================================================
   EVENT POPOVER
   ============================================================ */
#popover-layer { position: fixed; inset: 0; z-index: 70; pointer-events: none; }
.pop-scrim {
  position: absolute; inset: 0; pointer-events: auto;
  background: rgba(9, 12, 30, 0.32);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  animation: fadeScrim 0.16s ease both;
}
@keyframes fadeScrim { from { opacity: 0; } to { opacity: 1; } }

/* Appointment detail — right-side panel */
.detail-panel {
  position: absolute; top: 0; right: 0; bottom: 0; pointer-events: auto;
  width: min(400px, 100vw);
  background: var(--bg); border-left: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  padding: 20px 22px calc(24px + env(safe-area-inset-bottom));
  padding-top: calc(20px + env(safe-area-inset-top));
  overflow-y: auto;
  animation: slideIn 0.22s cubic-bezier(0.3, 0.9, 0.35, 1) both;
}
@keyframes slideIn { from { transform: translateX(40px); opacity: 0.4; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .detail-panel, .pop-scrim { animation: none; } }

.detail-panel .pop-accent { border-radius: 0; height: 4px; }
/* The ✕ is absolutely positioned, so it needs the safe-area offset itself —
   otherwise it lands under the iPhone status bar in the installed app. */
.detail-panel .pop-close { top: calc(10px + env(safe-area-inset-top, 0px)); }
.detail-panel .pop-title { font-size: 19px; margin-top: 8px; line-height: 1.3; }
.detail-panel .pop-row { font-size: 13.5px; margin-top: 12px; }
.detail-body { margin-top: 4px; }

/* Thumb-reachable Close bar pinned to the bottom of detail panels on phones —
   the top-right ✕ is out of one-handed reach there. */
.dp-close-bar { display: none; }
.settings-close-mobile { display: none; }
@media (max-width: 640px) { .settings-close-mobile { display: inline-block; } }
@media (max-width: 640px) {
  .detail-panel { padding-bottom: calc(92px + env(safe-area-inset-bottom)); }
  .detail-panel .pop-close { width: 38px; height: 38px; background: var(--surface-2); }
  .dp-close-bar {
    display: block; position: fixed; left: 14px; right: 14px;
    bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 5;
  }
  .dp-close-bar button {
    width: 100%; padding: 14px; border-radius: 999px;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--line); box-shadow: var(--shadow-lg);
    font-size: 15px; font-weight: 650; letter-spacing: -0.01em;
  }
  .dp-close-bar button:active { transform: scale(0.98); }
}

.pop-title.is-payout-title {
  background: linear-gradient(90deg, #D4A017, var(--wp-green));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}

.detail-link { color: var(--wp-blue); font-weight: 600; text-decoration: none; word-break: break-word; }
.detail-link:hover { text-decoration: underline; }

.detail-sec {
  margin-top: 20px; padding-top: 14px;
  border-top: 1px solid var(--line-soft);
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-3);
}
.detail-extra { margin: 6px 0 0; }
.detail-extra > div {
  display: flex; gap: 12px; align-items: baseline;
  padding: 7px 0; border-bottom: 1px solid var(--line-soft);
}
.detail-extra > div:last-child { border-bottom: 0; }
.detail-extra dt {
  flex: none; width: 118px;
  font-size: 12px; font-weight: 650; color: var(--text-3);
}
.detail-extra dd { margin: 0; font-size: 13px; color: var(--text); min-width: 0; word-break: break-word; }

/* Legacy anchored popover base (kept for shared row/close styles) */
@keyframes popIn { from { opacity: 0; transform: scale(0.97) translateY(4px); } to { opacity: 1; transform: none; } }
.pop-accent { position: absolute; top: 0; left: 0; right: 0; height: 4px; background: var(--agent-c, var(--wp-blue)); }
.pop-close { position: absolute; top: 10px; right: 10px; }
.pop-title { font-size: 16px; font-weight: 700; letter-spacing: -0.02em; margin: 4px 44px 8px 0; }
.pop-row { display: flex; gap: 10px; align-items: flex-start; margin-top: 9px; font-size: 13px; color: var(--text-2); }
.pop-row .pic { width: 17px; height: 17px; flex: none; color: var(--text-3); margin-top: 1px; }
.pop-row b { color: var(--text); font-weight: 600; }

/* ============================================================
   Modals
   ============================================================ */
.backdrop {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(9, 12, 30, 0.46);
  -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn 0.16s ease both;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@media (min-width: 641px) { .backdrop { align-items: center; padding: 24px; } }

.modal {
  width: 100%; max-width: 470px; background: var(--bg);
  border: 1px solid var(--line); border-radius: 22px 22px 0 0;
  box-shadow: var(--shadow-lg); padding: 20px 22px calc(22px + env(safe-area-inset-bottom));
  animation: sheetUp 0.22s cubic-bezier(0.32, 0.9, 0.35, 1) both;
  max-height: 90dvh; overflow-y: auto;
}
@media (min-width: 641px) { .modal { border-radius: 22px; padding-bottom: 22px; } }
@keyframes sheetUp { from { transform: translateY(22px); opacity: 0.5; } to { transform: none; opacity: 1; } }

.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h2 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -0.02em; }

.field-label { display: block; font-size: 12.5px; font-weight: 650; color: var(--text-2); margin-bottom: 6px; }
.field {
  width: 100%; padding: 11px 13px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font-size: 13.5px; outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field:focus { border-color: color-mix(in srgb, var(--wp-blue) 55%, transparent); box-shadow: 0 0 0 3.5px color-mix(in srgb, var(--wp-blue) 14%, transparent); }
.field-hint { font-size: 12px; color: var(--text-3); margin: 8px 0 4px; line-height: 1.5; }
.field-hint code { font-size: 11px; background: var(--hover); padding: 1px 5px; border-radius: 5px; }

.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 0; border-top: 1px solid var(--line-soft); margin-top: 12px; }
.settings-row-title { font-size: 14px; font-weight: 650; letter-spacing: -0.01em; }
.settings-row-sub { font-size: 12px; color: var(--text-3); margin-top: 1px; }

.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--surface-2); gap: 2px; }
.seg-btn { padding: 5px 11px; border-radius: 7px; font-size: 12.5px; font-weight: 600; color: var(--text-2); transition: background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease; }
.seg-btn.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.switch { width: 46px; height: 28px; border-radius: 999px; background: color-mix(in srgb, var(--text) 16%, transparent); position: relative; transition: background 0.18s ease; flex: none; }
.switch .knob { position: absolute; top: 2.5px; left: 2.5px; width: 23px; height: 23px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.25); transition: transform 0.18s cubic-bezier(0.3,0.9,0.4,1.2); }
.switch[aria-checked="true"] { background: var(--wp-green); }
.switch[aria-checked="true"] .knob { transform: translateX(18px); }

.modal-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 18px; }
.settings-status { font-size: 12.5px; color: var(--text-3); flex: 1; }
/* 💰 payout milestone events — golden, celebratory but subtle */
.mev.is-payout,
.allday-chip.is-payout,
.sch-ev.is-payout {
  background: linear-gradient(90deg,
    color-mix(in srgb, #D4A017 16%, transparent),
    color-mix(in srgb, #2EB875 10%, transparent));
  border: 1px solid color-mix(in srgb, #D4A017 38%, transparent);
}
.mev.is-payout .mev-title,
.sch-ev.is-payout .sch-title { font-weight: 700; }

.conn-status {
  margin: 12px 0 0; padding-top: 10px;
  border-top: 1px solid var(--line-soft);
  font-size: 11.5px; color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.settings-status.ok { color: var(--wp-green); font-weight: 650; }
.settings-status.err { color: #d9544f; font-weight: 650; }

.primary-btn {
  padding: 10px 20px; border-radius: 12px; font-size: 14px; font-weight: 700; letter-spacing: -0.01em;
  color: #fff; background: linear-gradient(135deg, var(--wp-blue), var(--wp-green));
  box-shadow: 0 4px 14px color-mix(in srgb, var(--wp-blue) 30%, transparent);
  transition: filter 0.15s ease, transform 0.1s ease;
}
.primary-btn:hover { filter: brightness(1.06); }
.primary-btn:active { transform: scale(0.97); }
.primary-btn:disabled { opacity: 0.55; cursor: default; }

.sc-list { margin: 0; display: grid; grid-template-columns: 1fr; gap: 2px; }
.sc-list > div { display: flex; align-items: center; gap: 14px; padding: 7px 4px; border-bottom: 1px solid var(--line-soft); }
.sc-list > div:last-child { border-bottom: 0; }
.sc-list dt { margin: 0; flex: none; width: 92px; display: flex; gap: 5px; }
.sc-list dd { margin: 0; font-size: 13px; color: var(--text-2); }
kbd { display: inline-block; min-width: 20px; text-align: center; padding: 2px 6px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface-2); font-family: var(--font); font-size: 11.5px; font-weight: 650; color: var(--text); box-shadow: 0 1px 0 var(--line); }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1000px) {
  .search-wrap { width: 180px; }
  .search-wrap:focus-within { width: 200px; }
}

@media (max-width: 860px) {
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 46;
    width: 280px; padding-top: calc(12px + env(safe-area-inset-top));
    transform: translateX(-100%); transition: transform 0.24s cubic-bezier(0.32,0.9,0.35,1);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .team-tag, .brand-divider { display: none; }
  .search-wrap { display: none; }
  .viewswitch { display: none; }
}

@media (min-width: 861px) {
  #btn-menu { display: none; }
  .sidebar-scrim { display: none !important; }
}

@media (max-width: 560px) {
  /* Compact month: dots instead of chips */
  .mev, .mmore { display: none; }
  .mday { align-items: center; padding: 4px 2px; }
  .mday-dots { display: flex; }
  .mday-events { display: none; }
  .sch-date { width: 62px; }
  .sch-time { width: 72px; }
}

/* Bottom view switcher on phones */
.bottom-nav { display: none; }
@media (max-width: 860px) {
  .bottom-nav {
    display: flex; flex: none;
    border-top: 1px solid var(--line); background: var(--appbar-bg);
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 30;
  }
  .bn-btn {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 8px 0 7px; font-size: 10.5px; font-weight: 600; color: var(--text-3);
  }
  .bn-btn .ic { width: 20px; height: 20px; }
  .bn-btn.is-active { color: var(--wp-blue); }
}


/* ============================================================
   Mobile polish
   ============================================================ */
@media (max-width: 640px) {
  /* One clean appbar row on phones: the wordmark moves into the drawer,
     the theme switch lives in Settings, and the date label gets the room.
     (The ticker above absorbs the notch inset.) */
  .appbar {
    height: 54px;
    gap: 2px;
    padding: 0 6px 0 4px;
  }
  .brand, .brand-divider { display: none; }
  #btn-theme { display: none; }
  .icon-btn { width: 38px; height: 38px; }
  .icon-btn.small { width: 32px; height: 32px; }
  .ghost-btn { margin-left: 2px; padding: 6px 12px; font-size: 12.5px; }
  .datenav { margin-left: 0; }
  .appbar-right { gap: 0; }
  .current-label { font-size: 17px; margin-left: 6px; }
  .tg-dnum { font-size: 17px; width: 30px; height: 30px; line-height: 30px; }
}

/* Branding header inside the drawer (phones/tablets — the appbar drops it) */
.sidebar-brand { display: none; }
@media (max-width: 860px) {
  .sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 2px 6px 14px; margin-bottom: 6px;
    border-bottom: 1px solid var(--line);
  }
  .sidebar-brand .brand-logo-img { height: 26px; }
  .sidebar-brand-team {
    font-size: 13px; font-weight: 650; letter-spacing: -0.01em;
    color: var(--text-2); white-space: nowrap;
  }
}
