/* Court Desk — dashboard Toei Tennis
   Tông: sân cứng xanh đậm + vàng bóng tennis. Sáng / tối theo hệ thống, đổi tay được. */

:root {
  --safe-top: env(safe-area-inset-top, 0px);  /* chat.js đọc để không kéo nút chat vào tai thỏ / thanh Home */
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --bg: #f5f6f2;
  --surface: #ffffff;
  --surface-2: #f0f2ec;
  --surface-3: #e7eae2;
  --border: #e2e5dc;
  --border-strong: #cfd4c7;
  --text: #121614;
  --text-2: #3b433d;
  --muted: #6c756e;
  --ball: #c6f432;
  --ball-ink: #1b2400;
  --green: #17895a;
  --green-soft: #dff3e8;
  --lime: #7fb800;
  --lime-soft: #eef7d4;
  --amber: #d48a12;
  --amber-soft: #fbefd6;
  --red: #d24b4b;
  --red-soft: #fbe3e1;
  --violet: #6d5ce8;
  --violet-soft: #ebe8fd;
  --blue: #2f6fdf;
  --green-ink: #0b6b44;
  --amber-ink: #8a5300;
  --red-ink: #b42323;
  --violet-ink: #4b39c7;
  /* chấm sân (khách quen): 亀戸 · 猿江 · 大島 · 文花 · khác — đã kiểm CVD / độ sáng cho nền sáng */
  --park-1: #17895a; --park-2: #2f6fdf; --park-3: #b87708; --park-4: #6d5ce8; --park-0: #9aa39c;
  --shadow: 0 1px 2px rgba(16, 24, 18, .05), 0 4px 16px rgba(16, 24, 18, .05);
  --shadow-lg: 0 12px 48px rgba(10, 16, 12, .18);
  --radius: 14px;
  --radius-sm: 9px;
  --font: 'Inter', 'Hiragino Sans', 'Noto Sans JP', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0c100e;
  --surface: #131917;
  --surface-2: #19211d;
  --surface-3: #212b26;
  --border: #232d28;
  --border-strong: #33403a;
  --text: #e8eee9;
  --text-2: #c2cbc4;
  --muted: #8a958d;
  --green: #3ccf8e;
  --green-soft: rgba(60, 207, 142, .14);
  --lime: #b5e33a;
  --lime-soft: rgba(181, 227, 58, .13);
  --amber: #f0b34a;
  --amber-soft: rgba(240, 179, 74, .14);
  --red: #f07070;
  --red-soft: rgba(240, 112, 112, .14);
  --violet: #9d90ff;
  --violet-soft: rgba(157, 144, 255, .15);
  --blue: #6ea0ff;
  --green-ink: #3ccf8e;
  --amber-ink: #f0b34a;
  --red-ink: #f07070;
  --violet-ink: #a99dff;
  --park-1: #1fa56c; --park-2: #4f86ec; --park-3: #c08414; --park-4: #8572f2; --park-0: #5d6862;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 18px rgba(0, 0, 0, .25);
  --shadow-lg: 0 16px 56px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font: 14px/1.5 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 1, "cv11" 1;
}
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
svg { width: 18px; height: 18px; fill: currentColor; flex: none; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 14.5px; font-weight: 600; }
h3 { font-size: 16px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
.pos { color: var(--green-ink); }
.neg { color: var(--red-ink); }
p { margin: 0; }

/* ─── Brand ─── */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; letter-spacing: -.02em; }
.brand--lg { font-size: 24px; justify-content: center; }
.brand__ball {
  width: 22px; height: 22px; border-radius: 50%; background: var(--ball); position: relative; flex: none;
  box-shadow: inset -3px -3px 0 rgba(0, 0, 0, .08);
}
.brand--lg .brand__ball { width: 30px; height: 30px; }
.brand__ball::before, .brand__ball::after {
  content: ""; position: absolute; top: 18%; bottom: 18%; width: 40%; border: 1.6px solid var(--ball-ink); border-radius: 50%;
}
.brand__ball::before { left: -18%; border-left-color: transparent; border-top-color: transparent; border-bottom-color: transparent; }
.brand__ball::after { right: -18%; border-right-color: transparent; border-top-color: transparent; border-bottom-color: transparent; }

/* ─── Buttons ─── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 600; font-size: 13.5px; cursor: pointer; transition: background .15s, border-color .15s, transform .05s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn svg { width: 16px; height: 16px; }
.btn--sm { height: 32px; padding: 0 11px; font-size: 13px; }
.btn--block { width: 100%; height: 42px; }
.btn--primary { background: var(--text); color: var(--bg); }
.btn--primary:hover { opacity: .9; }
.btn--ball { background: var(--ball); color: var(--ball-ink); }
.btn--ghost { background: var(--surface); border-color: var(--border); color: var(--text-2); }
.btn--ghost:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn--danger { background: var(--red); color: #fff; }
.btn--danger:hover { opacity: .9; }
.btn--danger-ghost { background: transparent; border-color: var(--border); color: var(--red-ink); }
.btn--danger-ghost:hover { background: var(--red-soft); border-color: transparent; }
.btn.is-busy { pointer-events: none; opacity: .65; }
.iconbtn {
  width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer;
}
.iconbtn:hover { background: var(--surface-2); color: var(--text); }
.iconbtn svg path[d^="M15 6"], .iconbtn svg path[d^="M9 6"], .iconbtn svg path[d^="M6 6"] { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.link { color: var(--muted); font-size: 13px; font-weight: 500; }
.link:hover { color: var(--text); }

/* ─── Login ─── */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background:
  radial-gradient(1000px 500px at 50% -10%, rgba(198, 244, 50, .18), transparent 60%), var(--bg); }
.login__card {
  width: min(380px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  padding: 32px 28px; box-shadow: var(--shadow-lg); display: grid; gap: 18px; text-align: center;
}
.login__card form, .login__card #login-step1 { display: grid; gap: 10px; }
.login__card input { text-align: center; font-family: var(--mono); font-size: 24px; letter-spacing: .4em; height: 52px; }
.login__err { color: var(--red-ink); font-size: 13px; }
.hint { font-size: 12.5px; color: var(--muted); }

.field { display: grid; gap: 6px; text-align: left; }
.field > span { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.field input {
  height: 38px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s;
}
.field input:focus { border-color: var(--text-2); box-shadow: 0 0 0 3px var(--surface-3); }
/* iPhone Safari vẽ ô ngày theo kiểu riêng (chữ canh giữa, cao / rộng tối thiểu riêng) → lệch với ô bên cạnh
   (khung sửa lô bóng). Bỏ kiểu riêng: cao, rộng, canh chữ như ô nhập thường. */
input[type="date"] { -webkit-appearance: none; appearance: none; box-sizing: border-box; min-width: 0; max-width: 100%; }
input[type="date"]::-webkit-date-and-time-value { text-align: left; margin: 0; line-height: 20px; }
/* Chiều cao cố định thì Safari để chữ ngày dính mép trên (30/10, ảnh iPhone) → cao tự nhiên = dòng 20px + đệm trên dưới
   bằng nhau, chữ luôn giữa ô (ô ngày WebKit tự thêm ~4px quanh chữ → đệm 6 / 3px = cao 38 / 32px như ô bên cạnh). */
.field input[type="date"], .balledit .field input[type="date"] { height: auto; padding-top: 6px; padding-bottom: 6px; line-height: 20px; }
.ballform input[type="date"] { height: auto; padding-top: 3px; padding-bottom: 3px; line-height: 20px; }
input[type="date"]::-webkit-calendar-picker-indicator { margin: 0 0 0 4px; }
.field--inline { grid-template-columns: auto; }
.field--inline input { width: 150px; height: 32px; }

/* ─── Layout ─── */
.app {
  display: grid; grid-template-columns: 232px 1fr; min-height: 100vh;
  background: linear-gradient(90deg, var(--surface) 0 231px, var(--border) 231px 232px, transparent 232px);
}
.side {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 28px;
  padding: 22px 14px 18px; border-right: 1px solid var(--border); background: var(--surface);
}
.side .brand { padding: 0 8px; }
.nav { display: grid; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--muted); font-weight: 500; transition: background .12s, color .12s;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.on { background: var(--surface-2); color: var(--text); font-weight: 600; }
.nav a.on svg { color: var(--green); }
.nav .badge { margin-left: auto; }
.side__foot { margin-top: auto; display: flex; gap: 4px; padding: 0 4px; }

/* đáy chừa chỗ nút chat (52px + cách đáy 24px): cuộn hết trang thì nút không che số tiền ở cột phải */
.main { min-width: 0; padding: 26px clamp(16px, 3vw, 36px) 100px; display: flex; flex-direction: column; gap: 18px; }
.top { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.top .muted { margin-top: 2px; font-size: 13px; }
.top__right { display: flex; align-items: center; gap: 12px; }
.sync { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); }
.sync i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.sync.is-loading i { background: var(--amber); animation: pulse 1s infinite; }
.sync.is-error i { background: var(--red); }
@keyframes pulse { 50% { opacity: .3; } }

.page { display: flex; flex-direction: column; gap: 18px; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }

.grid { display: grid; gap: 18px; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); min-width: 0;
}
.card--flush { padding: 0; overflow: hidden; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card__head--pad { padding: 18px 18px 0; }

.banner {
  padding: 12px 16px; border-radius: var(--radius-sm); background: var(--amber-soft); color: var(--text);
  border: 1px solid color-mix(in srgb, var(--amber) 35%, transparent); font-size: 13.5px;
}
.banner--error { background: var(--red-soft); border-color: color-mix(in srgb, var(--red) 35%, transparent); }
.banner--live, .banner--ok, .banner--flash { display: flex; gap: 12px; align-items: center; }
.banner--live { background: var(--lime-soft); border-color: color-mix(in srgb, var(--lime) 40%, transparent); }
.banner--ok { background: var(--green-soft); border-color: color-mix(in srgb, var(--green) 40%, transparent); }
.livebar__main { display: grid; gap: 3px; min-width: 0; }
.livebar__step { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.livebar__step .lv-ic { width: 18px; height: 18px; }
.livebar__pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--lime); flex: none; animation: live-pulse 1.4s ease-out infinite; }
@keyframes live-pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--lime) 55%, transparent); } 100% { box-shadow: 0 0 0 10px transparent; } }

/* ─── Live Log (log trực tiếp) ─── */
.lv-ic { width: 26px; height: 26px; border-radius: 8px; display: inline-grid; place-items: center; flex: none; background: var(--surface-2); color: var(--muted); }
.lv-ic svg { width: 62%; height: 62%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.lv-ic--ok { background: var(--green-soft); color: var(--green); }
.lv-ic--err { background: var(--red-soft); color: var(--red); }
.lv-ic--warn { background: var(--amber-soft); color: var(--amber); }
.lv-ic--accent { background: var(--lime-soft); color: var(--lime); }
.live__tick { display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; font-size: 13.5px; padding: 11px 14px; border-radius: var(--radius-sm); background: var(--surface-2); margin-bottom: 6px; }
.live__tick-main { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.live__tick .status-dot { margin-right: 0; }
.live__free { display: flex; gap: 14px; font-size: 13px; color: var(--muted); }
.live__free .num { color: var(--text); margin-left: 4px; }
.live__list { max-height: 460px; overflow-y: auto; overscroll-behavior: contain; }
.live__day { position: sticky; top: 0; z-index: 1; background: var(--surface); padding: 12px 0 6px; font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--border); }
.live__time { font-family: var(--mono); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.live__row { display: grid; grid-template-columns: 4.6em 26px 1fr; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--border); font-size: 13.5px; }
.live__day + .live__row { border-top: 0; }
.live__body { min-width: 0; display: grid; gap: 1px; }
.live__title { font-weight: 500; display: flex; align-items: center; gap: 6px; }
.live__row.is-imp .live__title { font-weight: 650; }
.live__count { font-size: 11px; font-weight: 600; color: var(--muted); background: var(--surface-2); border-radius: 99px; padding: 1px 7px; }
.live__detail { font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.live__list--raw .live__day { font-family: var(--font); }
.live__raw { display: grid; grid-template-columns: 4.6em 2.6em 4.5em 1fr; gap: 8px; padding: 3px 0; font-family: var(--mono); font-size: 11.5px; line-height: 1.5; align-items: baseline; }
.live__src { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live__msg { overflow-wrap: anywhere; min-width: 0; }
.lv-badge { font-size: 10px; font-weight: 700; text-align: center; border-radius: 4px; padding: 1px 0; background: var(--surface-2); color: var(--muted); }
.lv-badge--info { color: var(--text); }
.lv-badge--warning { background: var(--amber-soft); color: var(--amber); }
.lv-badge--error, .lv-badge--critical { background: var(--red-soft); color: var(--red); }
.live__raw:has(.lv-badge--debug) .live__msg { color: var(--muted); }
@media (max-width: 480px) { .live__raw { grid-template-columns: 4.6em 2.6em 1fr; } .live__src { display: none; } }

.pill, .badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 99px;
  font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--text-2); white-space: nowrap;
}
.badge { height: 19px; padding: 0 7px; font-size: 11px; background: var(--red); color: #fff; }
.pill--green { background: var(--green-soft); color: var(--green-ink); }
.pill--amber { background: var(--amber-soft); color: var(--amber-ink); }
.pill--red { background: var(--red-soft); color: var(--red-ink); }
.pill--violet { background: var(--violet-soft); color: var(--violet-ink); }
.pill--ball { background: var(--ball); color: var(--ball-ink); }

/* ─── KPI ─── */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.kpi { position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 6px; }
.kpi__label { font-size: 12.5px; color: var(--muted); font-weight: 500; display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 32px; }
.kpi__icon { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; flex: none; }
.kpi__icon svg { width: 18px; height: 18px; fill: none; }
.kpi__icon--green { background: var(--green-soft); color: var(--green-ink); }
.kpi__icon--violet { background: var(--violet-soft); color: var(--violet-ink); }
.kpi__icon--amber { background: var(--lime-soft); color: var(--lime); }
.kpi__icon--ball { background: rgba(198, 244, 50, .16); color: var(--ball); }
.kpi__value { font-size: 27px; font-weight: 700; letter-spacing: -.03em; line-height: 1.15; }
.kpi__value small { font-size: 15px; font-weight: 600; color: var(--muted); margin-left: 2px; }
.kpi__foot { font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.kpi--hero {
  background: linear-gradient(135deg, #142a1f 0%, #0d1813 100%);
  color: #f1f6f2; border-color: #1f3328;
}
.kpi--hero > * { position: relative; z-index: 1; }
.kpi--hero::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(120% 90% at 100% 0%, rgba(198, 244, 50, .20), transparent 55%);
}
.kpi--hero .kpi__label, .kpi--hero .kpi__foot { color: #a9bcb0; }
.kpi--hero .kpi__value small { color: #a9bcb0; }
.kpi--hero .kpi__foot b { color: #f1f6f2; }
.kpi--hero .delta.up { color: #86ebb9; }
.kpi--hero .delta.down { color: #ffa3a3; }
.kpi--hero .kpi__share { margin-top: 4px; display: inline-flex; align-self: flex-start; }
.kpi--link { color: inherit; text-decoration: none; cursor: pointer; transition: transform .15s ease; }
.kpi--link:hover { transform: translateY(-2px); }
/* 来月: ô ngày 土日祝 / 休み — xanh có sân · viền đứt đang tìm · xám 予定あり */
.card--month #month { display: flex; flex-direction: column; gap: 12px; }
.mdays { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 6px; }
.mday { display: grid; justify-items: center; gap: 3px; padding: 6px 2px 7px; border-radius: 10px; border: 1.5px solid transparent;
  background: var(--surface-2); color: var(--text); font: inherit; cursor: pointer; line-height: 1.1; }
.mday__d { font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; display: flex; align-items: baseline; gap: 2px; }
.mday__d i { font-style: normal; font-size: 10px; font-weight: 600; color: var(--muted); }
.mday__d i.sat { color: var(--blue); } .mday__d i.sun { color: var(--red-ink); }
.mday__p { font-size: 12px; font-weight: 700; min-height: 15px; }
.mday__p sup { font-size: 9px; margin-left: 1px; }
.mday--has { background: var(--green-soft); border-color: color-mix(in srgb, var(--green) 45%, transparent); }
.mday--has .mday__p { color: var(--green-ink); }
.mday--open { background: transparent; border: 1.5px dashed var(--border-strong); }
.mday--open .mday__p { color: var(--muted); }
.mday--busy { background: var(--surface-3); }
.mday--busy .mday__p { color: var(--muted); }
.mday.is-past { opacity: .45; }
.mday.is-today { box-shadow: 0 0 0 2px var(--accent); }
.mday:hover { border-color: var(--border-strong); }
.mkey { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); }
.mkey span { display: inline-flex; align-items: center; gap: 5px; }
.mkey i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.mkey--has { background: var(--green-soft); border: 1.5px solid color-mix(in srgb, var(--green) 45%, transparent); }
.mkey--open { border: 1.5px dashed var(--border-strong); }
.mkey--busy { background: var(--surface-3); }
.mlot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); display: grid; gap: 8px; }
.mlot__head { display: flex; justify-content: space-between; align-items: baseline; font-size: 13.5px; }
.mlot__steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 6px; }
.mlot__steps li { display: grid; gap: 2px; padding: 7px 8px; border-radius: 9px; background: var(--surface-2); font-size: 12px; min-width: 0; }
.mlot__steps b { display: flex; align-items: center; gap: 3px; font-size: 12.5px; }
.mlot__steps b svg { width: 13px; height: 13px; fill: currentColor; }
.mlot__steps span { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.mlot__steps .is-done { opacity: .55; }
.mlot__steps .is-now, .mlot__steps .is-next { background: var(--green-soft); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--green) 45%, transparent); }
.mlot__steps .is-now b, .mlot__steps .is-next b { color: var(--green-ink); }
.health__svcs { display: flex; gap: 14px; flex-wrap: wrap; }
.empty--sm { padding: 18px 0; }
.meter { height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; margin-top: 4px; }
.meter > i { display: block; height: 100%; border-radius: inherit; background: var(--green); }
.delta { font-weight: 600; }

/* ─── Lists ─── */
.list { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--border);
}
.row:first-child { border-top: 0; padding-top: 2px; }
.row__main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.row__title { font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row__sub { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__aside { text-align: right; display: grid; gap: 4px; justify-items: end; }
.row__actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.datebox {
  width: 52px; flex: none; text-align: center; border-radius: 10px; background: var(--surface-2); padding: 5px 0 6px;
  line-height: 1.1;
}
.datebox b { display: block; font-size: 17px; letter-spacing: -.02em; }
.datebox span { font-size: 11px; color: var(--muted); font-weight: 600; }
.datebox.is-today { background: var(--ball); color: var(--ball-ink); }
.datebox.is-today span { color: var(--ball-ink); opacity: .7; }
.empty { padding: 26px 8px; text-align: center; color: var(--muted); font-size: 13.5px; display: grid; gap: 6px; justify-items: center; }
.empty svg { width: 28px; height: 28px; opacity: .45; }

.fillbar { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; }
.fillbar__track { width: 56px; height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.fillbar__track i { display: block; height: 100%; border-radius: inherit; }

.health { display: grid; gap: 12px; }
.health__row { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 13.5px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 8px; background: var(--muted); }
.status-dot.ok { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.status-dot.bad { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.status-dot.idle { background: var(--border-strong); }

/* ─── Calendar ─── */
.cal__bar { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 14px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.cal__nav { display: flex; align-items: center; gap: 6px; }
.cal__nav h2 { font-size: 17px; min-width: 128px; text-align: center; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.dot--full { background: var(--green); }
.dot--mid { background: var(--lime); }
.dot--low { background: var(--amber); }
.dot--nocourt { background: transparent; border: 1.5px dashed var(--muted); }
.dot--join { background: var(--violet); }
.dot--off { background: var(--muted); }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal__wd { padding: 9px 10px; font-size: 12px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--border); background: var(--surface-2); }
.cal__wd.sat { color: var(--blue); }
.cal__wd.sun { color: var(--red-ink); }
.cal__day {
  min-height: 112px; padding: 7px 7px 9px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 4px; cursor: pointer; transition: background .12s; min-width: 0;
}
.cal__day:nth-child(7n) { border-right: 0; }
.cal__day:hover { background: var(--surface-2); }
.cal__day.out { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.cal__day.out .cal__num { opacity: .4; }
.cal__day.past .chip { opacity: .62; }
.cal__num { font-size: 12.5px; font-weight: 600; color: var(--text-2); width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; }
.cal__day.sun .cal__num, .cal__day.hol .cal__num { color: var(--red-ink); }
.cal__day.sat .cal__num { color: var(--blue); }
.cal__day.today .cal__num { background: var(--ball); color: var(--ball-ink); }
.chip {
  display: flex; align-items: center; gap: 5px; padding: 3px 6px; border-radius: 6px; font-size: 11.5px; font-weight: 600;
  line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-left: 3px solid; min-width: 0;
}
.chip span { overflow: hidden; text-overflow: ellipsis; }
.chip b { margin-left: auto; font-weight: 700; padding-left: 4px; }
.chip--full { background: var(--green-soft); border-color: var(--green); }
.chip--mid { background: var(--lime-soft); border-color: var(--lime); }
.chip--low { background: var(--amber-soft); border-color: var(--amber); }
.chip--zero { background: var(--red-soft); border-color: var(--red); }
.chip--nocourt { background: transparent; border: 1.5px dashed var(--border-strong); color: var(--muted); }
/* Event 中止: khối xám đặc (khác viền gạch 「event 未作成」), chữ gạch ngang, bên phải ghi 中止. */
.chip--off { background: var(--surface-2); border-color: var(--muted); color: var(--muted); }
.chip--off span { text-decoration: line-through; }
.chip--off b { font-weight: 600; }
.chip--join { background: var(--violet-soft); border-color: var(--violet); }
.chip--hidden::after { content: "ẩn"; font-size: 10px; padding: 0 4px; border-radius: 4px; background: var(--text); color: var(--bg); margin-left: 4px; }
.cal__more { font-size: 11px; color: var(--muted); padding-left: 4px; }
.cal-sum { display: flex; gap: 28px; flex-wrap: wrap; }
.cal-sum div { display: grid; gap: 2px; }
.cal-sum b { font-size: 19px; letter-spacing: -.02em; }
.cal-sum span { font-size: 12.5px; color: var(--muted); }

/* ─── Drawer / modal ─── */
.drawer { position: fixed; inset: 0; z-index: 40; }
.drawer__scrim, .modal { background: rgba(8, 12, 10, .42); backdrop-filter: blur(2px); }
.drawer__scrim { position: absolute; inset: 0; animation: fadein .15s; }
.drawer__panel {
  position: absolute; right: 0; top: 0; bottom: 0; width: min(440px, 100%); background: var(--surface);
  border-left: 1px solid var(--border); box-shadow: var(--shadow-lg); padding: 20px; overflow-y: auto;
  animation: slidein .2s ease; padding-bottom: calc(20px + env(safe-area-inset-bottom));
}
.drawer__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } }
@keyframes slidedown { from { transform: translateY(-12px); opacity: 0; } }
@keyframes fadein { from { opacity: 0; } }
.item { border: 1px solid var(--border); border-radius: 12px; padding: 14px; display: grid; gap: 10px; margin-bottom: 12px; }
.item__head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.item__title { font-weight: 600; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-weight: 500; }
.kv .kv__wide { grid-column: 1 / -1; text-align: left; }
.guests { display: flex; flex-wrap: wrap; gap: 6px; margin-top: -2px; }
/* Khách: trả tiền = chỉ tên (mờ) · 招待 = màu chủ đạo của theme + nhãn (tím trùng nhãn 「参加」 event đi chơi) */
.guest {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 8px;
  border: 1px solid var(--border); background: transparent; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
@media (hover: hover) { .guest:hover { background: var(--surface-2); } }  /* iPhone: hover dính lại sau khi chạm */
.guest b { font-size: 11px; font-weight: 600; padding: 2px 6px; border-radius: 6px; background: var(--accent); color: var(--on-accent, #fff); }
.guest.is-free { border-color: var(--accent); background: var(--accent-soft); color: var(--text); padding-right: 4px; }

.guest:disabled { opacity: .6; cursor: default; }
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px; animation: fadein .12s; }
.modal__card { width: min(400px, 100%); background: var(--surface); border-radius: 16px; padding: 22px; box-shadow: var(--shadow-lg); display: grid; gap: 12px; }
.modal__card p { color: var(--text-2); }
.modal__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 80; display: grid; gap: 8px; width: min(380px, calc(100% - 40px)); }
.toast {
  background: var(--text); color: var(--bg); padding: 12px 14px; border-radius: 12px; box-shadow: var(--shadow-lg);
  font-size: 13.5px; white-space: pre-line; animation: slidein .2s ease;
}
.toast--error { background: var(--red-ink); color: #fff; }
/* Tối: khối trắng chói giữa nền tối → thẻ tối có viền như các thẻ khác */
:root[data-theme="dark"] .toast:not(.toast--error) { background: var(--surface-2); color: var(--text); border: 1px solid var(--border-strong); }

/* ─── Charts / tables ─── */
.chart { position: relative; height: 300px; }
.chart--sm { height: 220px; }
/* Thu chi theo tháng: 3 số chính · chú thích HTML (gọn 1 dòng trên điện thoại) · khung tháng đang xem */
.mkpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.mkpi { display: grid; gap: 2px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); min-width: 0; }
.mkpi__label { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mkpi__value { font-size: 21px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; white-space: nowrap; }
.mkpi__sub { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mlegend { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; margin-top: 10px; font-size: 12px; color: var(--text-2); }
.mlegend span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.mlegend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.mlegend i.ln { width: 14px; height: 2px; border-radius: 1px; background: var(--text); }
.mlegend i.up { background: color-mix(in srgb, var(--text) 10%, transparent); border: 1.5px solid var(--muted); }
.mdetail { margin-top: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); display: grid; gap: 8px; }
.mdetail:empty { display: none; }
.mdetail__head { display: flex; align-items: center; gap: 8px; }
.mdetail__bal { margin-left: auto; font-size: 13px; color: var(--muted); }
.mdetail__bal b { font-size: 17px; margin-left: 4px; }
.mdetail__rows { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px 14px; }
.mdetail__row { display: grid; grid-template-columns: auto 1fr; align-items: center; align-content: start; column-gap: 6px; font-size: 12.5px; color: var(--muted); }
.mdetail__row i { width: 8px; height: 8px; border-radius: 2px; }
.mdetail__row b { grid-column: 1 / -1; font-size: 15px; color: var(--text); font-variant-numeric: tabular-nums; }
.mdetail__row small { grid-column: 1 / -1; font-size: 11px; }
.mdetail__note { font-size: 12px; color: var(--muted); }
.seg { display: inline-flex; background: var(--surface-2); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 5px 11px; border-radius: 7px; font-size: 12.5px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.tablewrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 10px 14px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--border); }
.table th:first-child, .table td:first-child { text-align: left; padding-left: 18px; }
.table th:last-child, .table td:last-child { padding-right: 18px; }
.table th { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); }
.table tbody tr:hover { background: var(--surface-2); }
.table tr.is-current td { background: color-mix(in srgb, var(--ball) 12%, transparent); }
.table tfoot td { font-weight: 700; border-bottom: 0; background: var(--surface-2); }
.table td.left { text-align: left; }
/* Khách quen (tab Thống kê) */
#reg-sum { margin-right: auto; }
#reg-seg button[data-n]::after { content: " " attr(data-n); font-weight: 500; opacity: .7; }
.regs { padding: 4px 10px 12px; }
/* Cột cố định (không auto) để dải 6 tháng của mọi hàng thẳng cột với trục tháng ở đầu */
.reg { --ring: var(--surface); display: grid; grid-template-columns: 22px 34px 230px minmax(0, 1fr) 92px 44px;
  align-items: center; gap: 10px 14px; padding: 8px; border-radius: var(--radius-sm); color: inherit; text-decoration: none; }
.reg + .reg { border-top: 1px solid var(--border); }
.reg:hover { --ring: var(--surface-2); background: var(--surface-2); }
.reg--axis { padding-top: 2px; padding-bottom: 6px; }
.reg--axis:hover { --ring: var(--surface); background: none; }
.reg__legend { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 11px; color: var(--muted); }
.reg__legend span { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.reg__legend i { width: 8px; height: 8px; border-radius: 50%; }
.reg__track { position: relative; height: 22px; min-width: 0; }
.reg__track::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: var(--border); }
.reg__track s { position: absolute; top: 4px; bottom: 4px; width: 1px; background: var(--border); }
.reg__track i { position: absolute; top: 50%; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; border-radius: 50%;
  box-shadow: 0 0 0 2px var(--ring); }
.reg__track em { position: absolute; left: 0; top: 50%; transform: translateY(-50%); padding: 0 4px 0 0; background: var(--ring);
  font-size: 10.5px; font-style: normal; color: var(--muted); font-variant-numeric: tabular-nums; }
.reg__track--axis { height: 14px; }
.reg__track--axis::before { display: none; }
.reg__track--axis b { position: absolute; top: 0; padding-left: 3px; border-left: 1px solid var(--border-strong);
  font-size: 10.5px; font-weight: 500; line-height: 14px; color: var(--muted); white-space: nowrap; }
.reg__pill { justify-self: end; }
.reg__left { display: flex; align-items: center; gap: 10px; font-size: 12px; font-weight: 600; color: var(--text-2);
  white-space: nowrap; font-variant-numeric: tabular-nums; }
.reg__left .fillbar__track { flex: 1; max-width: 260px; }
@media (max-width: 860px) {
  .reg { grid-template-columns: 22px 34px minmax(0, 1fr) auto 40px; gap: 4px 10px; }
  .reg__rank, .reg__img { grid-row: span 2; }
  .reg__track, .reg__left { grid-row: 2; grid-column: 3 / -1; }
  .reg__track { height: 16px; }
  .reg--axis .reg__legend { grid-column: 3 / -1; }
  .reg__track--axis { height: 14px; }
}
.reg__rank { color: var(--muted); font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
.reg__img { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: var(--surface-2);
  display: grid; place-items: center; font-weight: 700; color: var(--muted); }
.reg__main { display: grid; min-width: 0; }
.reg__main b, .reg__main span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reg__n { font-size: 12px; color: var(--muted); white-space: nowrap; }
.reg__n b { font-size: 16px; color: var(--text); margin-right: 1px; font-variant-numeric: tabular-nums; }
.reg__more { display: block; margin: 8px auto 0; }
.heat { display: grid; gap: 4px; font-size: 12px; min-width: 360px; }
.heat__row { display: grid; gap: 4px; align-items: stretch; }
.heat__label { display: flex; align-items: center; font-weight: 600; color: var(--text-2); }
.heat__head { text-align: center; color: var(--muted); font-weight: 600; padding-bottom: 2px; }
.heat__cell { border-radius: 8px; padding: 8px 4px; text-align: center; background: var(--surface-2); color: var(--muted); }
.heat__cell b { display: block; font-size: 14px; color: var(--text); font-weight: 700; }
.heat__cell span { display: block; font-size: 11px; color: var(--text-2); white-space: nowrap; }
.inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 14px; }
.lots { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
/* Lô bóng: form 1 hàng (chọn nhanh số tiền · ngày · loại · Ghi), danh sách mỗi lô 1 hàng, chạm → khung sửa */
.lots__sum { font-size: 12.5px; color: var(--muted); margin: -6px 0 10px; }
.lots__sum:empty { display: none; }
.lots__sum b { color: var(--text); }
.ballform { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; }
.ballform__amt { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ballform__chips { display: flex; gap: 6px; }
.ballform__chips button { height: 32px; padding: 0 11px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-weight: 600; font-size: 13px; cursor: pointer; font-variant-numeric: tabular-nums; }
.ballform__chips button.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent, #fff); }
.ballform input { height: 32px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); outline: none; font: inherit; font-size: 13px; }
.ballform input:focus { border-color: var(--text-2); }
#ball-amount { width: 96px; }
.lotlist { display: grid; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.lotrow { display: grid; grid-template-columns: 92px 150px 1fr 14px; align-items: center; gap: 10px; padding: 11px 14px; border: 0; border-top: 1px solid var(--border); background: transparent; color: var(--text); text-align: left; font: inherit; cursor: pointer; }
.lotrow:first-child { border-top: 0; }
.lotrow:hover { background: var(--surface-2); }
.lotrow__date { font-weight: 600; font-size: 13.5px; }
.lotrow__amt { font-weight: 700; font-size: 16px; letter-spacing: -.01em; display: grid; line-height: 1.2; }
.lotrow__amt small { font-weight: 500; font-size: 11px; color: var(--muted); letter-spacing: 0; }
.lotrow__info { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; min-width: 0; }
.lotrow__info b { color: var(--text); }
.lotrow__chev { color: var(--muted); font-size: 18px; line-height: 1; }
.balledit__sum { margin-bottom: 10px; }
.balledit { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 12px; margin-bottom: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.balledit [data-kind] { grid-column: 1 / -1; justify-self: start; }
.balledit .field { min-width: 0; }
.balledit .field input { width: 100%; min-width: 0; height: 38px; display: block; }
.balledit__btns { grid-column: 1 / -1; display: flex; gap: 8px; }
.lot { border: 1px solid var(--border); border-radius: 12px; padding: 14px; display: grid; gap: 6px; }
.lot__amt { font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.stat-big { display: grid; gap: 4px; }
.botctl { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.stat-big b { font-size: 24px; letter-spacing: -.02em; }

.tabbar { display: none; }
.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.setgroup { display: grid; gap: 10px; align-content: start; }
.setgroup__head { display: grid; gap: 2px; }
.setgroup__head b { font-weight: 600; font-size: 14.5px; }
.setlist { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.setrow {
  width: 100%; display: flex; align-items: center; gap: 14px; padding: 13px 16px; text-align: left;
  background: var(--surface); border: 0; cursor: pointer; transition: background .12s;
}
.setrow + .setrow { border-top: 1px solid var(--border); }
.setrow:hover { background: var(--surface-2); }
.setrow.is-busy { opacity: .6; pointer-events: none; }
.setrow__text { display: grid; gap: 2px; flex: 1; min-width: 0; }
.setrow__text > span:first-child { font-weight: 500; }
.setrow__text .small { color: var(--muted); }
.switch { width: 42px; height: 26px; border-radius: 99px; background: var(--border-strong); position: relative; flex: none; transition: background .18s; }
.switch i { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .18s; }
.setrow.is-on .switch { background: var(--accent); }
.setrow.is-on .switch i { transform: translateX(16px); }
.setrow--wd { cursor: default; }
.setrow--wd:hover { background: var(--surface); }
.setrow--wd { flex-wrap: wrap; row-gap: 8px; }
.setrow--wd .setrow__text { flex: 1 0 auto; white-space: nowrap; }
.wdpick { display: flex; flex-wrap: wrap; gap: 4px; margin-left: auto; }
.wdpick button {
  min-width: 32px; padding: 0 7px; height: 30px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; transition: background .12s, color .12s;
}
.wdpick button:hover { background: var(--surface-2); }
.wdpick button.is-on { background: var(--accent); border-color: var(--accent); color: var(--on-accent, #fff); }
.wdpick button.is-busy { opacity: .5; pointer-events: none; }
.tuning { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start;
  margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--border); }
.tuning__col { display: grid; gap: 24px; align-content: start; }
.setsec { display: grid; gap: 10px; margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--border); }
.setsec--split { grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
.setsec--split .setrow--wd .setrow__text { white-space: normal; flex: 1 1 200px; }
.tuning .setrow--wd .setrow__text { white-space: normal; flex: 1 1 200px; }
@media (max-width: 860px) { .settings, .tuning, .setsec--split { grid-template-columns: 1fr; gap: 20px; } .tuning__col { gap: 20px; } }
/* Giá event | TennisBear: tiêu đề 2 bên cao bằng nhau (subgrid) → 2 danh sách luôn bắt đầu cùng một dòng,
   kể cả khi tiêu đề giá xuống dòng vì màn hẹp */
@media (min-width: 861px) {
  .setsec--split { grid-template-rows: auto auto; row-gap: 10px; }
  .setsec--split > #prices-form, .setsec--split > .tuning__col, .setsec--split > .tuning__col > .setgroup {
    grid-row: span 2; grid-template-rows: subgrid; row-gap: 10px; align-self: stretch; }
  .setsec--split > .tuning__col > .setgroup > .setgroup__head { align-self: start; }
}
@media (max-width: 520px) {
  .heat { --heat-label: 36px; --heat-min: 0px; min-width: 0; gap: 3px; }
  .heat__row { gap: 3px; }
  .heat__cell { padding: 6px 2px; }
  .heat__cell b { font-size: 13px; }
  .heat__cell span { font-size: 10px; }
}

/* ─── Responsive ─── */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--2-1, .grid--3 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  /* 7 ngày → 来月 → Bot */
  .grid--fit > .stack { display: contents; }
  .card--month { order: 1; }
  #health-mini { order: 2; }
  .app { grid-template-columns: 1fr; background: none; }
  .cal__nav h2 { font-size: 15px; min-width: 0; }
  .chip--full { background: var(--green); } .chip--mid { background: var(--lime); }
  .chip--low { background: var(--amber); } .chip--zero { background: var(--red); } .chip--join { background: var(--violet); }
  .side { display: none; }
  .main { padding: 18px 16px calc(148px + env(safe-area-inset-bottom)); gap: 14px; }
  .grid, .kpis { gap: 14px; }
  .grid--2 { grid-template-columns: 1fr; }
  h1 { font-size: 20px; }
  .tabbar {
    display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px);
    border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .tabbar a { display: grid; justify-items: center; gap: 2px; font-size: 11px; font-weight: 600; color: var(--muted); padding: 4px 0; position: relative; }
  .tabbar a svg { width: 21px; height: 21px; }
  .tabbar a.on { color: var(--text); }
  .tabbar a.on svg { color: var(--green); }
  .tabbar .badge { position: absolute; top: 0; left: 55%; height: 16px; padding: 0 5px; font-size: 10px; }
  .cal__day { min-height: 74px; padding: 4px 3px; gap: 3px; }
  .chip { font-size: 0; padding: 0; height: 6px; border-left: 0; border-radius: 3px; }
  .chip b, .chip span { display: none; }
  .chip--nocourt { height: 6px; border-width: 1.5px; }
  .chip--off, .chip--join.chip--off { background: var(--muted); opacity: .45; }
  .chip--hidden::after { display: none; }
  .cal__wd { padding: 7px 4px; text-align: center; }
  .cal__num { margin: 0 auto 2px; }
  .cal__more { display: none; }
  .legend { gap: 10px; }
  /* Điện thoại: hiện trên đầu — ở dưới thì đè nút chat và nội dung khung chi tiết */
  .toasts { right: 12px; left: 12px; width: auto; top: calc(12px + env(safe-area-inset-top)); bottom: auto; }
  .toast { animation-name: slidedown; }
  .row { flex-wrap: wrap; }
  .row__actions { width: 100%; justify-content: flex-start; padding-left: 64px; }
  .top__right > .btn span { display: none; }
}
@media (max-width: 480px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi__value { font-size: 22px; }
  .kpi--hero { grid-column: 1 / -1; }
  .kpi:last-child { grid-column: 1 / -1; }
  .kpi:last-child .meter { max-width: 100%; }
  .kpi__label { font-size: 12px; }
  .card { padding: 15px; }
  .chart { height: 250px; }
  .lotrow { grid-template-columns: auto 1fr 14px; grid-template-areas: "date amt chev" "info info chev"; row-gap: 6px; padding: 11px 12px; }
  .lotrow__date { grid-area: date; }
  .lotrow__amt { grid-area: amt; justify-self: end; text-align: right; }
  .lotrow__info { grid-area: info; }
  .lotrow__chev { grid-area: chev; }
  #ball-amount { width: 84px; }
  .ballform > [type=submit] { order: 1; }  /* điện thoại: Ghi cạnh số tiền, ngày + loại dòng dưới (trước: 3 dòng) */
  #ball-date { order: 2; flex: 0 0 140px; }
  #ball-kind { order: 3; }
  .mkpis { gap: 6px; }
  .mkpi { padding: 8px 9px; }
  .mkpi__label, .mkpi__sub { font-size: 10.5px; }
  .mkpi__value { font-size: 15px; }
  .mdetail__rows { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mlegend { gap: 4px 8px; font-size: 11px; }
  .mlegend span { gap: 4px; }
}

/* ═══════════════════════════════════════════════════════════════════════
   GRAND SLAM — 4 bộ màu theo giải (data-slam) × sáng / tối (data-theme).
   Chất liệu: bảng điểm truyền hình (Barlow Condensed), vạch vôi sân, bóng optic yellow.
   ═══════════════════════════════════════════════════════════════════════ */
:root {
  --display: 'Barlow Condensed', 'Inter', 'Hiragino Sans', system-ui, sans-serif;
  --ball: #d8f23a;
  --ball-ink: #1f2600;
  --line: rgba(255, 255, 255, .9);       /* vạch vôi */
  --accent: #0d5c3a; --accent-2: #4b2c83; --accent-soft: #e2eee6; --accent-ink: #0d5c3a;
  --on-accent: #ffffff;
  --bg: #f6f4ec; --surface: #fffdf8; --surface-2: #efece2; --surface-3: #e6e2d5;
  --border: #e4dfd1; --border-strong: #cfc8b6;
}
:root[data-slam="rg"]  { --accent: #b84a26; --accent-2: #0f4d3a; --accent-soft: #f8e6dd; --accent-ink: #a8421f;
  --bg: #f8f3ee; --surface: #fffcf9; --surface-2: #f2ebe4; --surface-3: #e9dfd5; --border: #e8ddd2; --border-strong: #d6c6b6; }
:root[data-slam="uso"] { --accent: #1c3f94; --accent-2: #3f8a35; --accent-soft: #e2e9f8; --accent-ink: #1c3f94;
  --bg: #f3f5f9; --surface: #ffffff; --surface-2: #eaeef5; --surface-3: #dfe5ef; --border: #dde3ee; --border-strong: #c3ccdc; }
:root[data-slam="ao"]  { --accent: #0068b3; --accent-2: #0096c7; --accent-soft: #dcecf8; --accent-ink: #005a9c;
  --bg: #f2f7fb; --surface: #ffffff; --surface-2: #e8f1f8; --surface-3: #dbe8f2; --border: #d9e7f2; --border-strong: #bcd3e4; }

:root[data-theme="dark"] {
  --accent: #3fb27a; --accent-2: #a58bdf; --accent-soft: rgba(63, 178, 122, .15); --accent-ink: #5cc993;
  --bg: #0b120e; --surface: #111a15; --surface-2: #17221c; --surface-3: #1f2c25; --border: #22302a; --border-strong: #31423a;
}
:root[data-theme="dark"][data-slam="rg"]  { --accent: #e3764d; --accent-2: #46b08a; --accent-soft: rgba(227, 118, 77, .15); --accent-ink: #f08a62;
  --bg: #120e0c; --surface: #1a1411; --surface-2: #221a16; --surface-3: #2b211c; --border: #33271f; --border-strong: #46372d; }
:root[data-theme="dark"][data-slam="uso"] { --accent: #6b93f5; --accent-2: #74c463; --accent-soft: rgba(107, 147, 245, .16); --accent-ink: #8eabf7;
  --bg: #0a0e18; --surface: #111727; --surface-2: #171f33; --surface-3: #1e2840; --border: #243050; --border-strong: #33416a; }
:root[data-theme="dark"][data-slam="ao"]  { --accent: #3fa9f5; --accent-2: #4fd3f2; --accent-soft: rgba(63, 169, 245, .16); --accent-ink: #6cbdf7;
  --bg: #07111a; --surface: #0d1a26; --surface-2: #132332; --surface-3: #1a2d3f; --border: #1e3447; --border-strong: #2c4861; }

/* ─── Chữ: tiêu đề + số kiểu bảng điểm ─── */
h1 { font-family: var(--display); font-weight: 700; font-size: 30px; letter-spacing: .01em; text-transform: uppercase; line-height: 1.05; }
.card__head h2 {
  font-family: var(--display); font-weight: 700; font-size: 15px; letter-spacing: .08em; text-transform: uppercase;
  display: flex; align-items: center; gap: 9px;
}
.card__head h2::before { content: ""; width: 3px; height: 15px; background: var(--accent); flex: none; }
.kpi__value, .stat-big b, .cal-sum b, .lot__amt, .datebox b, .cal__nav h2 {
  font-family: var(--display); font-weight: 700; letter-spacing: 0;
}
.kpi__value { font-size: 40px; line-height: 1; }
.kpi__value small { font-family: var(--font); font-size: 14px; }
.kpi__label { text-transform: uppercase; letter-spacing: .07em; font-size: 11.5px; font-weight: 600; }
.datebox b { font-size: 19px; }
.stat-big b { font-size: 30px; }
.cal-sum b { font-size: 24px; }
.lot__amt { font-size: 26px; }
.table th { font-family: var(--display); font-size: 12.5px; letter-spacing: .08em; }

/* ─── Bóng: phẳng, 1 đường may ─── */
.brand__ball {
  background: var(--ball) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32' fill='none' stroke='%23ffffff' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M6.5 5.5c5 4.2 5 16.8 0 21M25.5 5.5c-5 4.2-5 16.8 0 21'/%3E%3C/svg%3E") center / 100% no-repeat;
  box-shadow: none;
}
.brand__ball::before, .brand__ball::after { display: none; }
.brand { font-family: var(--display); font-size: 21px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.brand--lg { font-size: 30px; }

/* ─── Điều hướng: vạch vôi bên trái mục đang mở ─── */
.nav a { position: relative; border-radius: 6px; }
.nav a.on { background: var(--accent-soft); color: var(--accent-ink); }
.nav a.on::before { content: ""; position: absolute; left: -14px; top: 6px; bottom: 6px; width: 3px; background: var(--accent); }
.nav a.on svg { color: var(--accent-ink); }
.tabbar a.on, .tabbar a.on svg { color: var(--accent-ink); }
.tabbar a.on::before { content: ""; position: absolute; top: -7px; left: 30%; right: 30%; height: 3px; background: var(--accent); }

/* ─── Thẻ lãi: cùng kiểu các thẻ khác (nền, viền, bố cục) — chỉ khác biểu tượng bóng + nhãn trích ─── */
.kpi--hero, :root[data-theme="dark"] .kpi--hero {
  background: var(--surface); background-image: none; color: var(--text); border: 1px solid var(--border);
}
.kpi--hero::before, .kpi--hero::after { display: none; }
.kpi--hero .kpi__label, .kpi--hero .kpi__foot, .kpi--hero .kpi__value small { color: var(--muted); }
.kpi--hero .kpi__foot b { color: var(--text); }
.kpi--hero .delta.up { color: var(--green-ink); }
.kpi--hero .delta.down { color: var(--red-ink); }
.kpi__icon--ball, :root[data-theme="dark"] .kpi__icon--ball { background: var(--ball); color: var(--ball-ink); }
.kpi--hero .kpi__share { margin-top: 2px; }

/* Thanh tiến độ + nút chính theo màu giải */
.meter > i { background: var(--accent); }
.btn--primary { background: var(--accent); color: var(--on-accent); }
:root[data-theme="dark"] .btn--primary { color: #0b0f0d; }
.seg button.on { color: var(--accent-ink); }
.datebox.is-today { background: var(--ball); color: var(--ball-ink); }
.cal__day.today .cal__num { background: var(--ball); color: var(--ball-ink); }
.table tr.is-current td { background: var(--accent-soft); }
.card { box-shadow: none; }
.kpi__icon--green { background: var(--accent-soft); color: var(--accent-ink); }

/* Điểm nhấn theo màu giải — vàng bóng chỉ còn ở logo; xanh/vàng/đỏ của chú thích độ đông giữ nguyên (có nghĩa) */
:root[data-theme="dark"] { --on-accent: #0b0f0d; }
.pill--ball { background: var(--accent-soft); color: var(--accent-ink); }
.kpi__icon--ball, :root[data-theme="dark"] .kpi__icon--ball { background: var(--accent); color: var(--on-accent); }
.kpi__icon--amber { background: color-mix(in srgb, var(--accent-2) 16%, transparent); color: var(--accent-2); }
.meter--alt > i { background: var(--accent-2); }
.datebox.is-today, .cal__day.today .cal__num { background: var(--accent); color: var(--on-accent); }
.datebox.is-today span { color: var(--on-accent); }
.banner--live { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.livebar__pulse { background: var(--accent); animation-name: live-pulse-accent; }
@keyframes live-pulse-accent { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); } 100% { box-shadow: 0 0 0 10px transparent; } }
.lv-ic--accent { background: var(--accent-soft); color: var(--accent-ink); }

/* ─── Chọn giao diện (giải + sáng/tối) ─── */
.appearance { position: relative; }
.appearance__menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 50; width: 260px; padding: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg);
  display: grid; gap: 12px;
}
.appearance__title { font-family: var(--display); font-size: 12.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.slams { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.slam {
  display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; font-size: 12.5px; font-weight: 600; text-align: left;
}
.slam.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.slam i { width: 22px; height: 22px; border-radius: 5px; flex: none; }
.modes { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--surface-2); border-radius: 8px; padding: 3px; }
.modes button { border: 0; background: transparent; padding: 6px 0; border-radius: 6px; font-size: 12.5px; font-weight: 600; color: var(--muted); cursor: pointer; }
.modes button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.appearance__logout { display: none; }
@media (max-width: 860px) {
  .appearance__logout { display: flex; }
  .appearance__menu {
    position: fixed; left: 12px; right: 12px; top: auto; width: auto;
    bottom: calc(78px + env(safe-area-inset-bottom)); padding: 16px; animation: slidein .18s ease;
  }
}

/* ═══ Chữ dễ đọc: chỉ con số dùng font bảng điểm; tiêu đề viết thường (tiếng Việt có dấu) ═══ */
h1 { font-family: var(--font); font-size: 26px; font-weight: 700; letter-spacing: -.02em; text-transform: none; line-height: 1.2; }
.card__head h2 { font-family: var(--font); font-size: 15px; font-weight: 600; letter-spacing: -.005em; text-transform: none; }
.card__head h2::before { display: none; }
.kpi__label { text-transform: none; letter-spacing: 0; font-size: 13px; font-weight: 500; }
.table th { font-family: var(--font); font-size: 11.5px; letter-spacing: .04em; }
.appearance__title { font-family: var(--font); text-transform: none; letter-spacing: 0; font-size: 12.5px; }
.stack { display: grid; gap: 18px; align-content: start; }
.card--alert { border-color: color-mix(in srgb, var(--red) 40%, var(--border)); }
@media (max-width: 860px) { .stack { gap: 14px; } h1 { font-size: 23px; } }
.stat-big b.is-text { font-family: var(--font); font-size: 22px; font-weight: 700; letter-spacing: -.02em; display: flex; align-items: center; }

/* ─── Thu / chi / lãi từng event ─── */
.money { font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.money.off { color: var(--muted); }
.row__aside { gap: 3px; }
.kv__hr { grid-column: 1 / -1; border: 0; border-top: 1px solid var(--border); margin: 4px 0 0; }
.select {
  height: 32px; padding: 0 30px 0 10px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface);
  font: inherit; font-size: 13px; font-weight: 600; color: var(--text); appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; background-size: 14px;
}
.table--events td { vertical-align: top; }
.table--events td:first-child { white-space: normal; min-width: 220px; }
.table--events td:first-child a:hover b { text-decoration: underline; }
.table--events tr.is-upcoming td { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }

/* Thời tiết trong khung giờ chơi (7 ngày tới / trước) */
.wx { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; color: var(--muted); white-space: nowrap; vertical-align: -2px; font-variant-numeric: tabular-nums; }
.wx__pop { display: inline-flex; align-items: center; gap: 1px; }
.wi { width: 18px; height: 18px; flex: none; }
.wi--drop { width: 12px; height: 12px; }
.wi-sun { stroke: var(--amber); }
.wi-cloud { stroke: var(--muted); }
.wi-rain { stroke: var(--blue); }
.wi-snow { stroke: var(--blue); stroke-width: 1.4; }
@media (hover: none) { [data-tip] { cursor: pointer; -webkit-tap-highlight-color: transparent; } }
/* Tooltip tự vẽ ([data-tip]): card theo theme, bật ra nhẹ (spring), mũi tên; % mưa từng giờ là cột nhỏ */
.tip { position: fixed; left: 0; top: 0; z-index: 1000; min-width: 150px; max-width: min(230px, calc(100vw - 16px)); padding: 8px 9px 7px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); color: var(--text); font-size: 11px; line-height: 1.3; pointer-events: none; box-shadow: 0 12px 30px -10px rgb(0 0 0 / .28), 0 2px 6px rgb(0 0 0 / .06); opacity: 0; visibility: hidden; transform: translateY(-6px) scale(.96); transform-origin: var(--ax, 50%) top; transition: opacity .12s ease, transform .12s ease, visibility 0s .12s; }
.tip__hint { margin-top: 6px; padding-top: 5px; border-top: 1px solid var(--border); color: var(--muted); font-size: 10.5px; }
.tip__radar { pointer-events: auto; display: block; margin-top: 7px; padding: 7px 8px; border-radius: 8px; background: var(--surface-2); color: var(--text); font-weight: 600; text-align: center; text-decoration: none; }
.tip.tip--up { transform: translateY(6px) scale(.96); transform-origin: var(--ax, 50%) bottom; }
.tip.is-on { opacity: 1; visibility: visible; transform: none; transition: opacity .16s ease, transform .26s cubic-bezier(.2, 1.3, .4, 1); }
.tip::after { content: ""; position: absolute; left: var(--ax, 50%); top: -5px; width: 8px; height: 8px; margin-left: -4px; background: var(--surface); border: solid var(--border); border-width: 1px 0 0 1px; border-radius: 3px 0 0 0; transform: rotate(45deg); }
.tip.tip--up::after { top: auto; bottom: -5px; border-width: 0 1px 1px 0; border-radius: 0 0 3px 0; }
.tip__head { display: flex; align-items: center; gap: 7px; }
.tip__head .wi { width: 22px; height: 22px; color: color-mix(in srgb, var(--muted) 30%, transparent); }
.tip__ttl { display: grid; flex: 1; min-width: 0; }
.tip__ttl b { font-size: 12px; }
.tip__ttl span { font-size: 10px; color: var(--muted); }
.tip__head em { font-style: normal; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tip__bars { display: flex; justify-content: center; gap: 4px; margin-top: 6px; padding: 5px 4px 4px; border-radius: 8px; background: var(--surface-2); }
.tip__bars > div { flex: 1; max-width: 40px; display: grid; justify-items: center; gap: 2px; min-width: 28px; }
.tip__bars b { font-size: 10.5px; font-variant-numeric: tabular-nums; }
.tip__bars span { display: flex; align-items: flex-end; width: 8px; height: 20px; border-radius: 4px; background: color-mix(in srgb, var(--blue) 14%, transparent); overflow: hidden; }
.tip__bars i { width: 100%; border-radius: 4px; background: var(--blue); transform-origin: bottom; }
.tip.is-on .tip__bars i { animation: tip-bar .45s cubic-bezier(.2, .9, .3, 1) both; }
.tip__bars .is-wet b { color: var(--red-ink); }
.tip__bars .is-wet span { background: color-mix(in srgb, var(--red) 14%, transparent); }
.tip__bars .is-wet i { background: var(--red); }
.tip__bars small { font-size: 9.5px; color: var(--muted); white-space: nowrap; }
.tip__foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 5px; padding: 0 2px; font-size: 10.5px; color: var(--muted); }
.tip__foot b { color: var(--text); font-variant-numeric: tabular-nums; }
@keyframes tip-bar { from { transform: scaleY(0); } }
@media (prefers-reduced-motion: reduce) { .tip, .tip.is-on { transition: none; } .tip.is-on .tip__bars i { animation: none; } }
.wx--wet .wx__pop { color: var(--red-ink); font-weight: 700; }
.wx--wet .wi--drop .wi-rain { stroke: var(--red-ink); fill: color-mix(in srgb, var(--red) 25%, transparent); }

/* Giá & số người event */
.prices__head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 8px 12px; }
.prices__save { display: flex; align-items: center; gap: 8px; }
.prices__date { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.prices__date input { height: 32px; padding: 0 10px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-size: 13px; }
.prices__list { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.prices__row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 13px 16px; background: var(--surface); }
.prices__row + .prices__row { border-top: 1px solid var(--border); }
.prices__label { display: grid; gap: 2px; min-width: 0; }
.prices__label b { font-weight: 500; }
/* ô số kèm đơn vị bên trong: [ 1500 円 ] */
.punit { display: flex; align-items: center; height: 34px; padding-right: 10px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--surface); transition: border-color .15s, box-shadow .15s; }
.punit:focus-within { border-color: var(--text-2); box-shadow: 0 0 0 3px var(--surface-3); }
.punit input { width: 62px; height: 100%; padding: 0 4px 0 10px; border: 0; background: transparent; outline: none;
  color: var(--text); font: inherit; text-align: right; font-variant-numeric: tabular-nums; }
.punit span { font-size: 12px; color: var(--muted); }
.setsec--split .setrow, .prices__row { min-height: 68px; }
/* nút đồng hồ cạnh 適用: đang đặt → 「12〜2月」 + đồng hồ xanh, chưa đặt → 「時間帯別」 */
.prices__season { gap: 5px; padding: 0 10px; font-variant-numeric: tabular-nums; }
.prices__season svg { width: 15px; height: 15px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; flex: none; }
.prices__season.is-set svg { stroke: var(--green); }
/* nhãn 「🕒 12〜2月は別」 cạnh tên event tập: mùa này số người / giá theo khung giờ (bấm → mở bảng) */
.prices__tag { display: inline-flex; align-items: center; gap: 3px; margin-left: 8px; padding: 1px 7px 1px 5px; border: 0;
  border-radius: 999px; background: var(--green-soft); color: var(--green-ink); font: inherit; font-size: 11.5px;
  font-weight: 500; vertical-align: 1px; cursor: pointer; font-variant-numeric: tabular-nums; }
.prices__tag svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
/* Theo khung giờ: cửa sổ nhỏ (điện thoại: tấm trượt từ dưới lên) */
.season { width: min(420px, 100%); }
.season h3 { font-size: 16px; }
.season__period { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.season__period select { height: 34px; padding: 0 8px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-size: 14px; }
.season__grid { display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr); gap: 8px 10px; align-items: center; }
.season__grid b { font-weight: 500; font-variant-numeric: tabular-nums; padding-right: 6px; }
.season__grid .punit input { width: 100%; }
.season__grid input::placeholder { color: var(--muted); opacity: .6; }
@media (max-width: 640px) {
  .prices__row { grid-template-columns: 1fr 1fr; }
  .prices__label { grid-column: 1 / -1; }
  .prices__save { width: 100%; }
  .prices__date { flex: 1; min-width: 0; }
  .prices__date input { flex: 1; width: 0; min-width: 0; }
  .modal--sheet { place-items: end stretch; padding: 0; background: rgba(0, 0, 0, .5); }
  .modal--sheet .modal__card { width: 100%; border-radius: 18px 18px 0 0; border-top: 1px solid var(--border);
    padding: 20px 16px calc(16px + env(safe-area-inset-bottom)); animation: sheetin .22s ease; max-height: 90dvh; overflow: auto; }
  .season__grid .punit input, .season__period select { font-size: 16px; }  /* < 16px → iPhone tự phóng to khi gõ */
  .punit input { width: 100%; }
}
/* Điện thoại: bảng bỏ cột phụ để thấy Lãi không cần kéo ngang */
@media (max-width: 640px) {
  #tbl-months :is(th, td):nth-child(n+2):nth-child(-n+4), #tbl-months :is(th, td):nth-child(6), #tbl-months td .small,
  #tbl-events :is(th, td):nth-child(3), #tbl-events :is(th, td):nth-child(4) { display: none; }
  .table th, .table td { padding-inline: 8px; }
  #tbl-months .pill { display: none; }
  #tbl-months tfoot td:first-child { white-space: normal; }
  .table--events td:first-child { min-width: 0; }
  #tbl-bookings :is(th, td):nth-child(3) { display: none; }
}
.row__tags { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; margin-block: 2px; min-width: 0; }

/* ─── Tổng quan trên màn rộng: 7 ngày 1 dòng / buổi, cao bằng cột phải (cuộn trong khung) ─── */
@media (min-width: 1101px) {
  .grid--2-1 > .card--agenda { contain: size; display: flex; flex-direction: column; min-height: 520px; }
  .card--agenda #agenda { flex: 1; min-height: 0; overflow-y: auto; margin-right: -8px; padding-right: 8px; scrollbar-width: thin; }
  .list--agenda .row { padding: 8px 0; }
  .list--agenda .row__main { grid-template-columns: 104px minmax(0, 1fr); align-items: center; column-gap: 12px; }
  .list--agenda .row__sub { grid-column: 1 / -1; }
  .list--agenda .row__tags { margin: 0; }
  .list--agenda .row__aside { grid-template-columns: auto 92px; align-items: center; column-gap: 14px; }
  .list--agenda .datebox { width: 64px; display: flex; justify-content: center; align-items: baseline; gap: 4px; padding: 6px 0; }
  .list--agenda .datebox b { font-size: 16px; display: inline; }
  .stack { display: flex; flex-direction: column; }
  .stack > .card--month { flex: 1; display: flex; flex-direction: column; min-height: 0; }
  .card--month #month { flex: 1; min-height: 0; overflow-y: auto; }
  /* Vừa đúng phần còn lại của màn hình: 7 ngày cuộn trong khung, biểu đồ lấp chỗ trống, không kéo dài trang */
  .grid--fit { height: max(480px, calc(100vh - 310px)); }
  .grid--fit > .stack { min-height: 0; }
}
@media (min-width: 1500px) {  /* đủ rộng: sân giờ · nhãn + thời tiết · tên event trên 1 dòng */
  .list--agenda .row__main { grid-template-columns: 104px 176px minmax(0, 1fr); }
  .list--agenda .row__sub { grid-column: auto; }
}

/* ─── Lịch: thời tiết + lãi trong ngày ─── */
.dot--zero { background: var(--red); }
.cal__head { display: flex; align-items: center; justify-content: space-between; gap: 4px; min-height: 24px; }
.cal__wx { display: inline-flex; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cal__wx .wi { width: 16px; height: 16px; }
.cal__wx b { font-weight: 600; }
.cal__wx.wet b { color: var(--red-ink); font-weight: 700; }
.cal__net { margin-top: auto; align-self: flex-end; font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }
.cal-sum { align-items: end; }
.cal-sum b small { font-size: 13px; color: var(--muted); font-weight: 600; margin-left: 1px; }
.cal-sum__main b { font-size: 26px; }
@media (max-width: 860px) {
  .cal__wx b, .cal__net { display: none; }
  .cal__wx .wi { width: 14px; height: 14px; }
  .cal__head { min-height: 20px; }
}
@media (max-width: 640px) {
  .setrow--wd .wdpick { width: 100%; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; }
  .setrow--wd .wdpick button { padding: 0; font-size: 12px; letter-spacing: -.02em; }
}
#modal-text { white-space: pre-line; }

/* Danh sách dài (captcha, sân bot đặt): cao cố định rồi cuộn trong khung, tiêu đề bảng dính trên */
.scrollbox { max-height: 340px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.scrollbox .table thead th { position: sticky; top: 0; z-index: 1; }
.scrollbox--tall { max-height: min(480px, 62vh); }  /* bảng tháng / từng buổi: cuộn trong thẻ, tiêu đề + dòng tổng luôn hiện */
.scrollbox .table tfoot td { position: sticky; bottom: 0; z-index: 1; box-shadow: 0 -1px 0 var(--border); }
/* 2 cột: khung bảng cao bằng thẻ bên cạnh (height 0 + flex 1 → không tự đẩy hàng lưới cao lên) */
@media (min-width: 861px) {
  .card--fill { display: flex; flex-direction: column; }
  .card--fill .scrollbox { flex: 1 1 0; height: 0; min-height: 200px; max-height: none; }
}

/* Thống kê: 主催 vs 参加 — 3 ô tiền thật + cột 参加 tô tím trong bảng tháng */
.wallet { padding: 0 18px 14px; }
.wallet__tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.wallet__tile { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; display: grid; gap: 4px; min-width: 0; }
.wallet__tile span { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.wallet__tile b { font-size: 22px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
.wallet__tile small { font-size: 11.5px; overflow-wrap: anywhere; }
.wallet__tile--org { border-top: 3px solid var(--accent); }
.wallet__tile--join { border-top: 3px solid var(--violet); }
.wallet__all { margin: 10px 0 0; }
/* nền tím dark mode trong suốt → lót nền thẻ bên dưới, không thì dòng cuộn qua tiêu đề dính sẽ hiện xuyên */
#tbl-months th.c-join { background: linear-gradient(var(--violet-soft), var(--violet-soft)) var(--surface-2); color: var(--violet-ink); }
#tbl-months :is(th, td):nth-child(6), #tbl-months :is(th, td):nth-child(8) { border-left: 1px solid var(--border); }
.table--events tr.is-join td:first-child { box-shadow: inset 3px 0 var(--violet); }
.table--events tr.is-org td:first-child { box-shadow: inset 3px 0 var(--accent); }
@media (max-width: 640px) {
  .wallet__tiles { grid-template-columns: 1fr; gap: 8px; }
  .wallet__tile { grid-template-columns: 1fr auto; align-items: baseline; padding: 10px 12px; column-gap: 10px; }
  .wallet__tile b { font-size: 18px; text-align: right; }
  .wallet__tile small { grid-column: 1 / -1; }
  .wallet__tile--org, .wallet__tile--join { border-top: 1px solid var(--border); border-left: 3px solid var(--accent); }
  .wallet__tile--join { border-left-color: var(--violet); }
}

/* Ngày riêng (tab Lịch): 休み / 予定あり — nhãn trong ô ngày + khối chọn ở đầu drawer */
.cal__plan { font-size: 10.5px; font-weight: 700; line-height: 1; padding: 3px 5px; border-radius: 5px; margin-right: auto; margin-left: 2px; }
.cal__plan--free { background: var(--accent-soft); color: var(--accent-ink); }
.cal__plan--busy { background: color-mix(in srgb, var(--blue) 16%, transparent); color: var(--blue); }
.cal__plan--far { background: var(--violet-soft); color: var(--violet-ink); }
.cal__plan:has(+ .cal__plan) { margin-right: 0; }
.dayplan__far { display: grid; gap: 8px; padding-top: 10px; border-top: 1px dashed var(--border); }
.dayplan__far .wdpick { margin-left: 0; }
/* 6 khung giờ 遠征 cùng 1 hàng, ô đều nhau (trước 19~21 rơi xuống dòng 2) */
.dayplan__far > .wdpick { display: grid; grid-template-columns: repeat(6, 1fr); }
.dayplan__far > .wdpick button { min-width: 0; padding: 0; font-size: 12px; letter-spacing: -.02em; }
.dayplan__far .wdpick button.is-on { background: var(--violet); border-color: var(--violet); color: var(--surface); }
.farrow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dayplan { display: grid; gap: 10px; padding: 12px 14px; margin-bottom: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.dayplan.is-busy { opacity: .6; pointer-events: none; }
.dayplan:empty { display: none; }
.dayplan__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.dayplan__head .seg { background: var(--surface); }
.dayplan__head .seg button.on { background: var(--surface-2); }
.dayplan__slots { display: grid; gap: 6px; }
.dayplan__slots .wdpick { margin-left: 0; }
.wdpick button.is-off { background: color-mix(in srgb, var(--blue) 16%, transparent); border-color: var(--blue); color: var(--blue); text-decoration: line-through; }
/* Ngày bot không tìm sân (theo cài đặt + 休み / 予定あり): sọc mờ */
.cal__day.nohunt { background-image: repeating-linear-gradient(135deg, transparent 0 7px, color-mix(in srgb, var(--muted) 10%, transparent) 7px 8px); }
.cal__day.nohunt .cal__num { opacity: .55; }
.dot--nohunt { background: repeating-linear-gradient(135deg, var(--muted) 0 1.5px, transparent 1.5px 3.5px); }
.cal__plan { white-space: nowrap; }
/* Chọn nhiều ngày: chạm / kéo qua các ngày rồi bấm 休み · 予定あり · 通常 */
.cal.is-selecting { touch-action: none; user-select: none; -webkit-user-select: none; }
.cal.is-selecting .cal__day { cursor: cell; }
.cal__day.is-sel { box-shadow: inset 0 0 0 2px var(--accent); background-color: var(--accent-soft); }
#cal-select.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent, #fff); }
.calsel { position: sticky; bottom: 12px; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; border: 1px solid var(--accent); border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow); }
.calsel[hidden] { display: none; }
.calsel__txt { display: grid; gap: 2px; }
.calsel__btns { display: flex; gap: 6px; flex-wrap: wrap; }
@media (max-width: 860px) { .calsel { bottom: calc(76px + env(safe-area-inset-bottom)); } }
@media (max-width: 640px) {
  .cal__plan-2 { display: none; }
  .cal__nav h2 { white-space: nowrap; font-size: 14px; font-family: var(--font); font-weight: 700; letter-spacing: 0; }
}
/* Mở từ màn hình chính (thanh trạng thái trong suốt): chừa chỗ cho giờ / pin ở trên — trong Chrome inset = 0, không đổi gì */
@media (max-width: 860px) {
  .main { padding-top: max(18px, calc(8px + env(safe-area-inset-top))); }
}
/* iOS 26 mở từ màn hình chính: hệ thống làm mờ dải dưới thanh trạng thái (~35px dưới safe-area) → đẩy tiêu đề xuống khỏi dải mờ */
@media (max-width: 860px) and (display-mode: standalone) {
  .main { padding-top: calc(env(safe-area-inset-top) + 34px); }
}

/* Điện thoại: tiêu đề + nút cùng 1 hàng (giờ cập nhật · giao diện · làm mới chỉ còn icon), mô tả xuống dòng dưới */
@media (max-width: 860px) {
  .top { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 2px 10px; }
  .top > div:first-child { display: contents; }
  .top h1 { grid-column: 1; grid-row: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .top .muted { grid-column: 1 / -1; grid-row: 2; margin: 0; font-size: 12.5px; }
  .top__right { grid-column: 2; grid-row: 1; gap: 6px; }
  .top__right > .btn { width: 34px; height: 34px; padding: 0; justify-content: center; }  /* chỉ nút làm mới — không bóp nút Đăng xuất trong menu */
  .sync { font-variant-numeric: tabular-nums; }
  /* thanh tab: phần chừa cho vạch Home không cần đủ 34px như trước (dưới chữ trống nhiều) */
  .tabbar { padding-bottom: max(6px, calc(env(safe-area-inset-bottom) - 12px)); }
}

/* Điện thoại: khung chi tiết ngày = tấm trượt từ dưới lên — đầu khung dính (nút ✕ luôn thấy), chạm vùng tối / kéo xuống để đóng */
@keyframes sheetin { from { transform: translateY(48px); opacity: 0; } }
@media (max-width: 640px) {
  .drawer__scrim { background: rgba(0, 0, 0, .5); }
  .drawer__panel {
    top: max(44px, calc(env(safe-area-inset-top) + 34px)); left: 0; width: 100%; border-left: 0;
    border-top: 1px solid var(--border); border-radius: 18px 18px 0 0;
    padding: 0 16px calc(20px + env(safe-area-inset-bottom)); overscroll-behavior: contain; animation: sheetin .22s ease;
  }
  .drawer__head {
    position: sticky; top: 0; z-index: 2; margin: 0 -16px 12px; padding: 20px 12px 10px 16px;
    background: var(--surface); border-bottom: 1px solid var(--border); touch-action: none;
  }
  .drawer__head::before { content: ""; position: absolute; top: 7px; left: 50%; width: 38px; height: 4px; margin-left: -19px; border-radius: 2px; background: var(--border-strong); }
  .drawer__head h3 { font-size: 16px; }
  .drawer__head .iconbtn { width: 36px; height: 36px; border-radius: 50%; background: var(--surface-2); color: var(--text); }
  .dayplan__head { gap: 8px; }
  .cal__day { min-height: 66px; }
}
@media (max-width: 480px) {
  /* .card { padding: 15px } ở trên đè mất card--flush → lịch bị thụt 15px mỗi bên, trên đầu trống */
  .card.card--flush { padding: 0; }
  .cal__bar { padding: 12px 12px; gap: 10px; }
  /* tóm tắt tháng: số tiền 1 hàng, 4 số nhỏ 1 hàng (trước: 「buổi sân」 rớt xuống dòng riêng, khoảng trống lớn) */
  .cal-sum { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px 8px; }
  .cal-sum__main { grid-column: 1 / -1; }
  .cal-sum span { font-size: 11.5px; }
}
.cal-sum__unit { font-style: normal; }
@media (max-width: 480px) {
  .cal-sum { align-items: start; }
  .cal-sum__unit { display: none; }
}

/* ═══ Chữ & icon (theo Apple HIG): câu ngắn, ghi chú dài gấp vào 「Cách tính」, tiêu đề bảng không viết hoa ═══ */
.table th { text-transform: none; letter-spacing: 0; font-size: 12px; }
.howto { padding: 10px 18px 14px; font-size: 12.5px; color: var(--muted); }
.howto summary { cursor: pointer; width: max-content; font-weight: 600; list-style: none; display: inline-flex; align-items: center; gap: 4px; }
.howto summary::-webkit-details-marker { display: none; }
.howto summary::before { content: ""; width: 6px; height: 6px; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: rotate(-45deg); transition: transform .15s; margin-right: 2px; }
.howto[open] summary::before { transform: rotate(45deg); }
.howto ul { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 2px; }
.botctl .btn svg { width: 14px; height: 14px; }
.tip__radar svg { width: 12px; height: 12px; vertical-align: -1px; }
@media (max-width: 640px) {
  /* từng buổi: màu vạch trái đã cho biết 主催 / 参加 → bỏ nhãn; tên event 1 dòng, cắt đuôi */
  .table--events .pill { display: none; }
  .table--events td:first-child { max-width: 0; width: 60%; white-space: normal; }
  .table--events .ev-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  /* Bot: số dư 2 dịch vụ / số lần thắng captcha đứng cạnh nhau */
  .bot-top { grid-template-columns: 1fr 1fr; }
  .bot-top > :first-child { grid-column: 1 / -1; }
  .bot-top .stat-big b { font-size: 22px; }
  .grid--pair { grid-template-columns: 1fr 1fr; gap: 10px; }
  .grid--pair .lot__amt { font-size: 17px; }
}
@media (max-width: 640px) {
  .table--events td:first-child { width: 100%; }  /* max-width 0 + width 100%: cột tên co giãn, cột số giữ đủ rộng */
  .table--events td:first-child > a { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; }  /* tên sân dài (スポートピア) → … thay vì đè cột 客 */
}

/* ═══ Cảm giác app iPhone ═══ */
/* bỏ ô xám khi chạm, không hiện menu giữ lâu / bôi chữ trên nút và thanh tab */
a, button, .cal__day { -webkit-tap-highlight-color: transparent; }
.tabbar a, .btn, .iconbtn, .seg button { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.tabbar a svg { transition: transform .12s; }
.tabbar a:active svg { transform: scale(.88); }
/* lịch: trình duyệt lo cuộn dọc, cử chỉ ngang để JS đổi tháng (thẻ lịch overflow hidden → phần trượt ra bị cắt gọn) */
.cal { touch-action: pan-y; }
.cal.is-selecting { touch-action: none; }
/* kéo xuống để làm mới (chỉ khi mở kiểu app) */
.ptr {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 6px); z-index: 35; width: 34px; height: 34px;
  display: grid; place-items: center; border-radius: 50%; background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow); color: var(--muted); opacity: 0; transform: translate(-50%, 0); pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.ptr svg { width: 18px; height: 18px; fill: currentColor; }
.ptr.is-ready, .ptr.is-spin { color: var(--accent-ink); }
.ptr.is-spin { transform: translate(-50%, 42px); }
.ptr.is-spin svg { animation: ptr-spin .8s linear infinite; }
@keyframes ptr-spin { to { transform: rotate(360deg); } }

/* Lịch: chú thích màu — màn rộng luôn hiện; điện thoại ẩn sau nút ⓘ, bấm mới hiện (gọn, chữ nhỏ) */
#cal-legend-btn { display: none; }
@media (max-width: 640px) {
  #cal-legend-btn { display: inline-grid; margin-left: auto; }
  #cal-legend-btn.on { background: var(--accent-soft); color: var(--accent-ink); }
  .cal__nav { width: 100%; }
  .cal__bar .legend { display: none; }
  .cal__bar.show-legend .legend { display: flex; gap: 6px 12px; font-size: 11.5px; animation: fadein .15s; }
  /* ô ngày hẹp: số + thời tiết hàng trên, nhãn 休 / 予 xuống hàng dưới (trước: 3 thứ chen 1 hàng, icon mây bị cắt) */
  .cal__head { flex-wrap: wrap; row-gap: 0; }
  .cal__head::after { content: ""; order: 2; flex-basis: 100%; height: 0; }
  .cal__head .cal__plan { order: 3; margin: 1px 0 0; }
}

/* ─── Ngôn ngữ (dashboard/static/i18n.js) ─── */
.i18n-wait body { visibility: hidden; }  /* 日本語: chờ dịch xong mới hiện */
.modes--2 { grid-template-columns: repeat(2, 1fr); }

/* ─── Cài đặt (⚙): Mac = menu thả xuống · điện thoại = tấm trượt từ dưới lên, cùng kiểu khung chi tiết ngày ─── */
.appearance__head, .appearance__scrim { display: none; }
#btn-appearance.on { background: var(--surface-2); color: var(--text); }
@media (max-width: 860px) {
  .appearance__scrim {
    display: block; position: fixed; inset: 0; z-index: 55; background: rgba(0, 0, 0, .5);
    backdrop-filter: blur(2px); animation: fadein .15s; touch-action: none;
  }
  .appearance__menu {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: auto; z-index: 56;
    border: 0; border-top: 1px solid var(--border); border-radius: 18px 18px 0 0;
    padding: 0 16px calc(14px + env(safe-area-inset-bottom)); gap: 10px;
    box-shadow: 0 -12px 40px rgb(0 0 0 / .35); animation: sheetin .22s ease;
  }
  .appearance__head {
    display: flex; position: relative; justify-content: space-between; align-items: center;
    margin: 0 -16px 2px; padding: 20px 12px 10px 16px; border-bottom: 1px solid var(--border); touch-action: none;
  }
  .appearance__head::before { content: ""; position: absolute; top: 7px; left: 50%; width: 38px; height: 4px; margin-left: -19px; border-radius: 2px; background: var(--border-strong); }
  .appearance__head b { font-size: 16px; }
  .appearance__head .iconbtn { width: 36px; height: 36px; border-radius: 50%; background: var(--surface-2); color: var(--text); }
  .appearance__title { margin-top: 6px; font-size: 13px; }
  .slam { padding: 11px 10px; font-size: 14px; }
  .modes button { padding: 9px 0; font-size: 14px; }
  .appearance__logout { justify-content: center; margin-top: 8px; padding: 11px; font-size: 14px; color: var(--red); }
}
@media (min-width: 861px) { .appearance__menu { width: 330px; } }  /* Mac: tên giải 1 dòng */
/* Đổi ngôn ngữ: cả trang mờ chuyển nhanh (i18n.js · View Transitions) */
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .22s; }

/* ─── Trợ lý chat (static/chat.js): Mac = khung nổi góc phải · điện thoại = tấm trượt gần kín màn hình ─── */
.chatfab {
  position: fixed; right: 24px; bottom: 24px; z-index: 45; width: 52px; height: 52px; border-radius: 50%; border: 0;
  display: grid; place-items: center; background: var(--accent); color: var(--on-accent, #fff); cursor: pointer;
  box-shadow: 0 10px 28px -8px color-mix(in srgb, var(--accent) 70%, transparent), 0 2px 6px rgb(0 0 0 / .15);
  transition: transform .15s ease;
}
.chatfab { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.chatfab:hover { transform: translateY(-2px); }
.chatfab:active { transform: scale(.94); }
.chatfab.is-drag { transform: scale(1.1); cursor: grabbing; transition: none; opacity: .9; }
.chatfab svg { width: 22px; height: 22px; }
.app:has(#cal-selbar:not([hidden])) .chatfab { display: none; }  /* đang chọn nhiều ngày: thanh chọn ở đáy */
body:has(#drawer:not([hidden])) .chatfab { display: none; }  /* khung chi tiết ngày: nút chat che số tiền cột phải */
.chat__scrim { display: none; }
.chat {
  position: fixed; right: 24px; bottom: 24px; z-index: 57; width: 400px; height: min(640px, calc(100vh - 48px));
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow-lg), 0 24px 60px -20px rgb(0 0 0 / .35); overflow: hidden; animation: chatin .2s ease;
  transition: transform .18s ease;
}
@keyframes chatin { from { opacity: 0; transform: translateY(14px) scale(.98); } }
.chat__head {
  display: flex; align-items: center; gap: 4px; padding: 12px 10px 12px 16px; border-bottom: 1px solid var(--border); flex: none;
}
.chat__title { display: grid; gap: 1px; margin-right: auto; min-width: 0; }
.chat__title b { font-size: 15px; }
.chat__title span { font-size: 11.5px; color: var(--muted); }
.chat__head .iconbtn svg { width: 17px; height: 17px; }
.chat__log { flex: 1; overflow-y: auto; padding: 16px 14px 8px; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; }
.chat__empty { margin: auto 0 4px; display: grid; gap: 12px; }
.chat__hello { font-size: 14px; color: var(--muted); text-align: center; }
.chat__note { font-size: 12.5px; padding: 9px 11px; border-radius: 10px; background: var(--amber-soft); color: var(--text); }
.chat__sugs { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; }
.chat__sug {
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); border-radius: 999px;
  padding: 7px 12px; font: inherit; font-size: 12.5px; font-weight: 500; cursor: pointer;
}
.chat__sug:hover { background: var(--surface-2); }
.msg { max-width: 88%; font-size: 13.5px; line-height: 1.5; overflow-wrap: anywhere; }
.msg--me { align-self: flex-end; background: var(--accent); color: var(--on-accent, #fff); padding: 8px 12px; border-radius: 16px 16px 4px 16px; }
.msg--ai { align-self: flex-start; background: var(--surface-2); padding: 9px 13px; border-radius: 16px 16px 16px 4px; }
.msg__body p { margin: 0; }
.msg__body p + p, .msg__body p + ul, .msg__body p + ol, .msg__body ul + p, .msg__body ol + p, .msg__body .msg__table + p { margin-top: 6px; }
.msg__body ul, .msg__body ol { margin: 4px 0 0; padding-left: 18px; }
.msg__body li + li { margin-top: 2px; }
.msg__body code { font-family: var(--mono, monospace); font-size: 12px; background: color-mix(in srgb, var(--text) 8%, transparent); padding: 1px 4px; border-radius: 4px; }
.msg__h { font-weight: 700; }
.msg__table { overflow-x: auto; margin-top: 6px; }
.msg__table table { border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.msg__table th, .msg__table td { padding: 4px 8px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.msg__table th { font-weight: 600; color: var(--muted); }
.msg__err { color: var(--red-ink, var(--red)); font-size: 12.5px; }
.msg__status { display: none; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.msg.is-typing .msg__status { display: flex; }
.msg.is-typing.has-text:not(.is-tool) .msg__status { display: none; }
.msg.is-typing.has-text .msg__status { margin-top: 6px; }
.dots { display: inline-flex; gap: 3px; }
.dots b { width: 5px; height: 5px; border-radius: 50%; background: currentColor; animation: dot 1s infinite ease-in-out; }
.dots b:nth-child(2) { animation-delay: .15s; } .dots b:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.chat__form { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px 12px; border-top: 1px solid var(--border); flex: none; }
.chat__form textarea {
  flex: 1; resize: none; min-height: 40px; max-height: 132px; padding: 9px 12px; border-radius: 20px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-size: 14px; line-height: 1.4; outline: none;
}
.chat__form textarea:focus { border-color: var(--accent); }
.chat__send {
  flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer;
  background: var(--accent); color: var(--on-accent, #fff);
}
.chat__send svg { width: 18px; height: 18px; }
.chat__form.is-busy .chat__send { background: var(--text); color: var(--surface); }
@media (max-width: 860px) {
  .chatfab { right: 16px; bottom: calc(80px + env(safe-area-inset-bottom)); width: 50px; height: 50px; }
  .chat__scrim {
    display: block; position: fixed; inset: 0; z-index: 55; background: rgba(0, 0, 0, .5); backdrop-filter: blur(2px);
    animation: fadein .15s; touch-action: none;
  }
  .chat {
    left: 0; right: 0; width: auto; top: max(12px, env(safe-area-inset-top)); bottom: var(--kb, 0px); height: auto;
    border: 0; border-top: 1px solid var(--border); border-radius: 18px 18px 0 0; animation: sheetin .22s ease;
  }
  .chat__head { position: relative; padding: 20px 10px 10px 16px; touch-action: none; }
  .chat__head::before { content: ""; position: absolute; top: 7px; left: 50%; width: 38px; height: 4px; margin-left: -19px; border-radius: 2px; background: var(--border-strong); }
  .chat__head .iconbtn { width: 36px; height: 36px; border-radius: 50%; background: var(--surface-2); color: var(--text); margin-left: 4px; }
  .chat__form { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  html.chat-open, html.chat-open body { overflow: hidden; }
  .msg { font-size: 14.5px; }
  .chat__form textarea { font-size: 16px; }  /* < 16px → iPhone tự phóng to khi gõ */
}

.kpi__short { display: none; }  /* chữ ngắn chỉ hiện ở iPhone (ô hẹp) */
/* iPhone: 3 ô phụ (sân · khách · độ đông) gọn 1 hàng dưới ô lợi nhuận — trước: độ đông 90 ngày chiếm riêng 1 hàng to,
   đẩy 「Cần gom khách」 xuống khỏi màn hình đầu. Đặt cuối file để thắng cỡ chữ theme phía trên. */
@media (max-width: 480px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .kpis > .kpi--hero { grid-column: 1 / -1; }
  .kpis > .kpi:last-child:not(.kpi--hero) { grid-column: auto; }
  .kpis > .kpi:not(.kpi--hero) { padding: 11px 10px; gap: 5px; }
  .kpis > .kpi:not(.kpi--hero) .kpi__icon { display: none; }
  .kpis > .kpi:not(.kpi--hero) .kpi__label { display: block; min-height: 0; font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .kpis > .kpi:not(.kpi--hero) .kpi__value { font-size: 27px; }
  .kpis > .kpi:not(.kpi--hero) .kpi__value small { font-size: 12px; }
  .kpis > .kpi:not(.kpi--hero) .kpi__foot { font-size: 11px; line-height: 1.35; }
  .kpis > .kpi:not(.kpi--hero) .kpi__foot .pill { font-size: 10.5px; padding: 2px 7px; }
  .kpi__long { display: none; }
  .kpi__short { display: inline; }
  .kpi__nowrap { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
}
