/* ============================================================
   Bloom Salon — Design System
   Editorial premium look: deep ink sidebar, ivory canvas,
   rose–gold accent, Fraunces display + Inter body.
   ============================================================ */

:root {
  --ink-900: #17151f;
  --ink-800: #201d2b;
  --ink-700: #2a2638;
  --ink-600: #3a3550;
  --ink-100: #e9e6f2;

  --canvas: #faf7f2;
  --surface: #ffffff;
  --line: #eae5dc;
  --line-strong: #ddd5c8;

  --rose: #c4586e;
  --rose-deep: #a83e55;
  --rose-soft: #f7e6ea;
  --gold: #b98a3d;
  --gold-soft: #f5ecdc;
  --sage: #5f7d64;
  --sage-soft: #e7efe8;
  --sky: #4a6d8c;
  --sky-soft: #e5edf4;
  --danger: #b13a3a;
  --danger-soft: #f7e4e4;

  --text: #26222e;
  --text-soft: #6b6577;
  --text-faint: #9a94a6;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(23, 21, 31, .05), 0 2px 8px rgba(23, 21, 31, .04);
  --shadow-md: 0 4px 12px rgba(23, 21, 31, .07), 0 12px 32px rgba(23, 21, 31, .06);

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Inter", -apple-system, "Segoe UI", sans-serif;

  --sidebar-w: 248px;
}

* { box-sizing: border-box; }

html { font-size: 15px; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--canvas);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .font-display { font-family: var(--font-display); font-weight: 600; letter-spacing: -.01em; }

a { color: var(--rose-deep); text-decoration: none; }
a:hover { color: var(--rose); }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--ink-900) 0%, var(--ink-800) 100%);
  color: var(--ink-100);
  display: flex; flex-direction: column;
  position: fixed; inset: 0 auto 0 0;
  z-index: 1030;
  transition: transform .25s ease;
}

.brand {
  display: flex; align-items: center; gap: .65rem;
  padding: 1.35rem 1.4rem 1.1rem;
}
.brand-mark {
  width: 38px; height: 38px; border-radius: 12px;
  background: linear-gradient(135deg, var(--rose) 0%, var(--gold) 100%);
  display: grid; place-items: center;
  color: #fff; font-size: 1.15rem;
  box-shadow: 0 4px 14px rgba(196, 88, 110, .4);
}
.brand-name { font-family: var(--font-display); font-size: 1.3rem; color: #fff; line-height: 1; }
.brand-sub { font-size: .68rem; letter-spacing: .18em; text-transform: uppercase; color: var(--text-faint); }

.nav-section { padding: .35rem 1.4rem .3rem; font-size: .66rem; letter-spacing: .16em; text-transform: uppercase; color: #6f6a80; margin-top: .8rem; }

.side-nav { list-style: none; margin: 0; padding: 0 .75rem; }
.side-nav a {
  display: flex; align-items: center; gap: .7rem;
  padding: .56rem .7rem; margin: .1rem 0;
  border-radius: var(--radius-sm);
  color: #b9b3c9; font-size: .92rem; font-weight: 500;
}
.side-nav a i { font-size: 1.05rem; width: 1.25rem; text-align: center; opacity: .85; }
.side-nav a:hover { background: var(--ink-700); color: #fff; }
.side-nav a.active {
  background: linear-gradient(90deg, rgba(196, 88, 110, .28), rgba(185, 138, 61, .12));
  color: #fff;
  box-shadow: inset 2px 0 0 var(--rose);
}

.sidebar-footer { margin-top: auto; padding: 1rem 1.4rem 1.2rem; border-top: 1px solid var(--ink-700); font-size: .8rem; color: #8d879e; }

.main-col { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: .8rem 1.8rem;
  background: rgba(250, 247, 242, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 1020;
}

.global-search { position: relative; flex: 1; max-width: 430px; }
.global-search input {
  width: 100%; border: 1px solid var(--line-strong); border-radius: 999px;
  padding: .5rem 1rem .5rem 2.4rem; background: var(--surface);
  font-size: .9rem; outline: none; transition: border-color .15s, box-shadow .15s;
}
.global-search input:focus { border-color: var(--rose); box-shadow: 0 0 0 3px rgba(196, 88, 110, .14); }
.global-search > i { position: absolute; left: .95rem; top: 50%; transform: translateY(-50%); color: var(--text-faint); }

.search-pop {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  max-height: 420px; overflow: auto; display: none; z-index: 1050;
}
.search-pop.open { display: block; }
.search-pop .group-label { padding: .55rem .95rem .25rem; font-size: .66rem; letter-spacing: .14em; text-transform: uppercase; color: var(--text-faint); }
.search-pop a { display: flex; justify-content: space-between; gap: .6rem; padding: .5rem .95rem; color: var(--text); font-size: .88rem; }
.search-pop a:hover { background: var(--rose-soft); }
.search-pop .muted { color: var(--text-faint); font-size: .8rem; }

.topbar .user-chip { display: flex; align-items: center; gap: .6rem; margin-left: auto; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--ink-600), var(--ink-800));
  color: #fff; display: grid; place-items: center; font-size: .8rem; font-weight: 600;
}

/* ---------- Page scaffolding ---------- */
.page { padding: 1.6rem 1.8rem 3rem; max-width: 1280px; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 1rem; margin-bottom: 1.4rem; }
.page-head h1 { font-size: 1.7rem; margin: 0; }
.page-head .subtitle { color: var(--text-soft); font-size: .92rem; margin-top: .25rem; }
.page-head .actions { margin-left: auto; display: flex; gap: .6rem; }

/* ---------- Cards ---------- */
.card-panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 1.25rem 1.4rem; margin-bottom: 1.3rem;
}
.card-panel .panel-title { font-family: var(--font-display); font-size: 1.08rem; margin: 0 0 .9rem; display: flex; align-items: center; gap: .5rem; }
.card-panel .panel-title i { color: var(--rose); }

/* KPI cards */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .9rem; margin-bottom: 1.4rem; }
.kpi-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1rem 1.15rem;
  box-shadow: var(--shadow-sm); display: block; color: var(--text);
  transition: transform .15s ease, box-shadow .15s ease;
}
a.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); color: var(--text); }
.kpi-card .kpi-icon {
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center; font-size: 1rem;
  background: var(--rose-soft); color: var(--rose-deep); margin-bottom: .6rem;
}
.kpi-card:nth-child(2) .kpi-icon { background: var(--sky-soft); color: var(--sky); }
.kpi-card:nth-child(3) .kpi-icon { background: var(--sage-soft); color: var(--sage); }
.kpi-card:nth-child(4) .kpi-icon { background: var(--gold-soft); color: var(--gold); }
.kpi-card:nth-child(5) .kpi-icon { background: var(--danger-soft); color: var(--danger); }
.kpi-card:nth-child(6) .kpi-icon { background: var(--ink-100); color: var(--ink-600); }
.kpi-value { font-family: var(--font-display); font-size: 1.45rem; font-weight: 600; line-height: 1.1; }
.kpi-label { font-size: .78rem; color: var(--text-soft); margin-top: .15rem; }
.kpi-delta { font-size: .75rem; margin-top: .3rem; }
.kpi-delta.up { color: var(--sage); }
.kpi-delta.down { color: var(--danger); }
.kpi-delta.flat { color: var(--text-faint); }

/* ---------- Tables ---------- */
.table-panel { padding: 0; overflow: hidden; }
.table-panel .panel-title { padding: 1.1rem 1.4rem 0; }
.table-wrap { overflow-x: auto; }
table.data {
  width: 100%; border-collapse: collapse; font-size: .89rem;
}
table.data th {
  text-align: left; padding: .7rem 1rem;
  font-size: .68rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--text-faint); border-bottom: 1px solid var(--line);
  background: #fdfcf9; white-space: nowrap;
}
table.data td { padding: .72rem 1rem; border-bottom: 1px solid #f2eee7; vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: #fbf8f2; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data th.num { text-align: right; }

/* ---------- Badges & status ---------- */
.badge-soft {
  display: inline-flex; align-items: center; gap: .3rem;
  border-radius: 999px; padding: .22rem .6rem;
  font-size: .72rem; font-weight: 600; letter-spacing: .02em;
}
.st-pending    { background: var(--gold-soft); color: #8a6420; }
.st-confirmed  { background: var(--sky-soft); color: var(--sky); }
.st-checkedin  { background: #ece7f6; color: #5c4a91; }
.st-inservice  { background: var(--rose-soft); color: var(--rose-deep); }
.st-completed  { background: var(--sage-soft); color: var(--sage); }
.st-cancelled  { background: #efedeb; color: var(--text-faint); }
.st-noshow     { background: var(--danger-soft); color: var(--danger); }
.st-draft      { background: #efedeb; color: var(--text-faint); }

/* ---------- Buttons ---------- */
.btn { font-family: var(--font-body); border-radius: var(--radius-sm); font-weight: 600; font-size: .88rem; }
.btn-bloom {
  background: linear-gradient(135deg, var(--rose) 0%, var(--rose-deep) 100%);
  border: none; color: #fff;
  box-shadow: 0 3px 10px rgba(196, 88, 110, .35);
}
.btn-bloom:hover { background: var(--rose-deep); color: #fff; transform: translateY(-1px); }
.btn-quiet { background: var(--surface); border: 1px solid var(--line-strong); color: var(--text); }
.btn-quiet:hover { border-color: var(--rose); color: var(--rose-deep); background: var(--rose-soft); }
.btn-ghost-danger { background: transparent; border: 1px solid var(--danger-soft); color: var(--danger); }
.btn-ghost-danger:hover { background: var(--danger-soft); color: var(--danger); }

/* ---------- Forms ---------- */
.form-label { font-size: .78rem; font-weight: 600; letter-spacing: .04em; color: var(--text-soft); margin-bottom: .3rem; }
.form-control, .form-select {
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  font-size: .9rem; padding: .5rem .75rem; background: var(--surface); color: var(--text);
}
.form-control:focus, .form-select:focus { border-color: var(--rose); box-shadow: 0 0 0 3px rgba(196, 88, 110, .14); }

/* ---------- Alerts / insights ---------- */
.alert-row {
  display: flex; align-items: center; gap: .75rem;
  padding: .65rem .9rem; border-radius: var(--radius-sm);
  font-size: .88rem; margin-bottom: .5rem; color: var(--text);
}
.alert-row i { font-size: 1rem; }
.alert-row.warning { background: var(--gold-soft); }
.alert-row.warning i { color: var(--gold); }
.alert-row.danger { background: var(--danger-soft); }
.alert-row.danger i { color: var(--danger); }
.alert-row.info { background: var(--sky-soft); }
.alert-row.info i { color: var(--sky); }

.insight-row { display: flex; gap: .7rem; padding: .55rem 0; border-bottom: 1px dashed var(--line); font-size: .88rem; }
.insight-row:last-child { border-bottom: 0; }
.insight-row i { color: var(--gold); margin-top: .1rem; }

/* ---------- Timeline (today's appointments) ---------- */
.appt-row {
  display: flex; align-items: center; gap: .9rem;
  padding: .7rem .4rem; border-bottom: 1px solid #f2eee7;
  color: var(--text); border-radius: var(--radius-sm);
}
.appt-row:last-child { border-bottom: 0; }
.appt-row:hover { background: #fbf8f2; color: var(--text); }
.appt-time { min-width: 74px; flex: 0 0 auto; font-variant-numeric: tabular-nums; font-weight: 600; font-size: .86rem; color: var(--ink-600); }
.appt-body { flex: 1; min-width: 0; display: block; }
.appt-client { font-weight: 600; font-size: .92rem; display: block; }
.appt-meta { color: var(--text-soft); font-size: .8rem; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt-row .badge-soft { flex: 0 0 auto; }
.appt-go { color: var(--text-faint); font-size: .85rem; flex: 0 0 auto; }

/* ---------- Trend bars ---------- */
.trend { display: flex; align-items: flex-end; gap: .55rem; height: 120px; padding: .4rem 0 0; }
.trend .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .35rem; height: 100%; justify-content: flex-end; }
.trend .bar {
  width: 100%; max-width: 42px; border-radius: 6px 6px 3px 3px;
  background: linear-gradient(180deg, var(--rose) 0%, var(--rose-deep) 100%);
  opacity: .85; min-height: 3px;
}
.trend .bar-label { font-size: .68rem; color: var(--text-faint); }

/* ---------- Autocomplete ---------- */
.ac-wrap { position: relative; }
.ac-pop {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-md);
  max-height: 300px; overflow: auto; display: none; z-index: 1060;
}
.ac-pop.open { display: block; }
.ac-item { padding: .55rem .85rem; cursor: pointer; font-size: .88rem; display: flex; justify-content: space-between; gap: .5rem; }
.ac-item:hover, .ac-item.hover { background: var(--rose-soft); }
.ac-item .muted { color: var(--text-faint); font-size: .78rem; }
.ac-item .exact { color: var(--sage); font-size: .7rem; font-weight: 700; }

/* ---------- Multi-select service picker (booking) ---------- */
.svc-picker {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  max-height: 300px; overflow-y: auto; background: #fdfcf9;
}
.svc-group {
  padding: .5rem .85rem .25rem;
  font-size: .64rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--text-faint); font-weight: 700;
  position: sticky; top: 0; background: #fdfcf9; z-index: 1;
}
.svc-item {
  display: flex; align-items: center; gap: .6rem;
  padding: .5rem .85rem; margin: 0; cursor: pointer;
  border-bottom: 1px solid #f2eee7; font-size: .88rem;
}
.svc-item:hover { background: var(--rose-soft); }
.svc-item.checked { background: #fbf3ec; }
.svc-item input { accent-color: var(--rose-deep); width: 16px; height: 16px; flex: 0 0 auto; }
.svc-item .svc-name { flex: 1; min-width: 0; font-weight: 500; }
.svc-item .svc-meta { flex: 0 0 auto; color: var(--text-soft); font-size: .78rem; font-variant-numeric: tabular-nums; }
.svc-tag {
  display: inline-block; margin-left: .35rem;
  border-radius: 999px; padding: .08rem .5rem;
  font-size: .62rem; font-weight: 700; letter-spacing: .04em; vertical-align: middle;
}
.svc-tag.g0 { background: var(--ink-100); color: var(--ink-600); }
.svc-tag.g1 { background: var(--rose-soft); color: var(--rose-deep); }
.svc-tag.g2 { background: var(--sky-soft); color: var(--sky); }
.svc-tag.g3 { background: var(--gold-soft); color: var(--gold); }

.sel-row {
  display: flex; align-items: center; gap: .6rem;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: .55rem .7rem; margin-bottom: .5rem; background: var(--surface);
}
.sel-row .sel-info { flex: 1; min-width: 0; }
.sel-row .sel-name { font-weight: 600; font-size: .88rem; }
.sel-row .sel-meta { color: var(--text-soft); font-size: .76rem; }
.sel-row .sel-staff { flex: 0 0 190px; }
.sel-row .sel-rm { flex: 0 0 auto; }

@media (max-width: 900px) {
  .sel-row { flex-wrap: wrap; }
  .sel-row .sel-staff { flex: 1 1 100%; order: 3; }
}

/* ---------- Bill builder ---------- */
.bill-line { display: grid; grid-template-columns: 1.6fr 1fr .55fr .8fr .8fr .9fr auto; gap: .55rem; align-items: center; margin-bottom: .55rem; }
.benefit-chip {
  display: inline-flex; align-items: center; gap: .35rem;
  background: var(--gold-soft); color: #7c5a1e;
  border-radius: 999px; padding: .3rem .7rem; font-size: .78rem; font-weight: 600;
  margin: 0 .35rem .35rem 0;
}
.total-strip {
  background: var(--ink-900); color: #fff; border-radius: var(--radius);
  padding: 1rem 1.3rem; display: flex; flex-wrap: wrap; gap: 1.6rem; align-items: center;
}
.total-strip .lbl { font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: #9a94a6; }
.total-strip .val { font-family: var(--font-display); font-size: 1.25rem; }
.total-strip .grand { color: #f0c987; font-size: 1.55rem; }

/* ---------- Invoice print ---------- */
.invoice-sheet { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 2.2rem; max-width: 800px; }
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .main-col { margin-left: 0; }
  .page { padding: 0; max-width: none; }
  .invoice-sheet { border: none; padding: 0; }
  body { background: #fff; }
}

/* ---------- Login ---------- */
.login-hero {
  min-height: 100vh; display: grid; place-items: center;
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(196, 88, 110, .18), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(185, 138, 61, .16), transparent 60%),
    var(--ink-900);
}
.login-card {
  width: min(410px, 92vw); background: var(--surface);
  border-radius: 20px; padding: 2.4rem 2.2rem; box-shadow: 0 30px 80px rgba(0, 0, 0, .45);
}

/* ---------- Misc ---------- */
.text-soft { color: var(--text-soft); }
.text-faint { color: var(--text-faint); }
.mono { font-variant-numeric: tabular-nums; }
.pill-filters { display: flex; flex-wrap: wrap; gap: .45rem; }
.pill-filters a {
  border: 1px solid var(--line-strong); border-radius: 999px;
  padding: .32rem .85rem; font-size: .8rem; font-weight: 600; color: var(--text-soft);
}
.pill-filters a.active { background: var(--ink-900); border-color: var(--ink-900); color: #fff; }
.pill-filters a:hover:not(.active) { border-color: var(--rose); color: var(--rose-deep); }

.empty-state { text-align: center; padding: 2.6rem 1rem; color: var(--text-faint); }
.empty-state i { font-size: 2rem; display: block; margin-bottom: .6rem; opacity: .6; }

.section-cols { display: grid; grid-template-columns: 1.7fr 1fr; gap: 1.3rem; align-items: start; }

@media (max-width: 1100px) {
  .section-cols { grid-template-columns: 1fr; }
}

/* ---------- Popup (dialog) mode: create screens opened via window.open ---------- */
.popup-mode .sidebar,
.popup-mode .topbar,
.popup-mode .bottom-nav { display: none !important; }
.popup-mode .main-col { margin-left: 0; }
.popup-mode .page { padding: 1.2rem 1.4rem 2rem; max-width: none; }
.popup-close {
  position: fixed; top: .8rem; right: .9rem; z-index: 2000;
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--text-soft); display: grid; place-items: center;
  box-shadow: var(--shadow-md); cursor: pointer;
}
.popup-close:hover { color: var(--danger); border-color: var(--danger); }

/* ============================================================
   Mobile experience — app-like shell with bottom tab bar
   ============================================================ */

/* Bottom navigation (hidden on desktop) */
.bottom-nav { display: none; }

/* Visibility helpers switched at the app breakpoint */
.mobile-only { display: none !important; }

/* Next-7-days strip */
.day-strip {
  display: flex; gap: .55rem; overflow-x: auto;
  padding: .25rem .1rem .5rem; scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.day-strip::-webkit-scrollbar { display: none; }
.day-pill {
  min-width: 64px; flex: 0 0 auto; text-align: center;
  border: 1px solid var(--line); border-radius: 14px;
  padding: .55rem .4rem .5rem; background: var(--surface);
  color: var(--text); box-shadow: var(--shadow-sm);
}
.day-pill .dp-dow { font-size: .62rem; letter-spacing: .14em; text-transform: uppercase; color: var(--text-faint); }
.day-pill .dp-num { font-family: var(--font-display); font-size: 1.25rem; font-weight: 600; line-height: 1.15; }
.day-pill .dp-count { font-size: .68rem; color: var(--text-soft); }
.day-pill.today {
  background: linear-gradient(135deg, var(--ink-900), var(--ink-700));
  border-color: var(--ink-900); color: #fff;
}
.day-pill.today .dp-dow { color: #cfc9de; }
.day-pill.today .dp-count { color: #f0c987; }
.day-pill.busy .dp-count { color: var(--rose-deep); font-weight: 700; }
.day-pill.today.busy .dp-count { color: #f0c987; }

/* Quick actions grid (dashboard, mobile) */
.quick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .7rem; }
.quick-tile {
  display: flex; flex-direction: column; align-items: center; gap: .45rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .9rem .3rem;
  box-shadow: var(--shadow-sm); color: var(--text);
  font-size: .74rem; font-weight: 600; text-align: center;
}
.quick-tile i {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; font-size: 1.15rem;
  background: var(--rose-soft); color: var(--rose-deep);
}
.quick-tile:nth-child(2) i { background: var(--sky-soft); color: var(--sky); }
.quick-tile:nth-child(3) i { background: var(--sage-soft); color: var(--sage); }
.quick-tile:nth-child(4) i { background: var(--gold-soft); color: var(--gold); }
.quick-tile:active { transform: scale(.97); }

/* Mobile record cards (replace tables on small screens) */
.m-list { display: flex; flex-direction: column; gap: .7rem; }
.m-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .9rem 1rem;
  box-shadow: var(--shadow-sm); color: var(--text); display: block;
}
.m-card-top { display: flex; align-items: center; gap: .7rem; }
.m-card-top .avatar { flex: 0 0 auto; }
.m-card-name { font-weight: 700; font-size: .95rem; line-height: 1.2; }
.m-card-sub { color: var(--text-soft); font-size: .78rem; }
.m-card-top .badge-soft { margin-left: auto; flex: 0 0 auto; }
.m-card-body { margin-top: .55rem; font-size: .85rem; color: var(--text-soft); display: flex; flex-wrap: wrap; gap: .25rem .9rem; }
.m-card-body i { color: var(--text-faint); margin-right: .25rem; }
.m-card-foot {
  margin-top: .6rem; padding-top: .6rem; border-top: 1px dashed var(--line);
  display: flex; align-items: center; gap: .5rem;
}
.m-card-amount { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; }
.m-card-foot .btn { margin-left: auto; }

/* Module grid (More page) */
.module-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; }
.module-tile {
  display: flex; flex-direction: column; align-items: center; gap: .5rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.05rem .4rem;
  box-shadow: var(--shadow-sm); color: var(--text);
  font-size: .8rem; font-weight: 600;
}
.module-tile i {
  width: 44px; height: 44px; border-radius: 13px;
  display: grid; place-items: center; font-size: 1.25rem;
  background: var(--ink-100); color: var(--ink-600);
}
.module-tile:active { transform: scale(.97); }
.module-tile:nth-child(6n+1) i { background: var(--rose-soft); color: var(--rose-deep); }
.module-tile:nth-child(6n+2) i { background: var(--sky-soft); color: var(--sky); }
.module-tile:nth-child(6n+3) i { background: var(--sage-soft); color: var(--sage); }
.module-tile:nth-child(6n+4) i { background: var(--gold-soft); color: var(--gold); }
.module-tile:nth-child(6n+5) i { background: var(--danger-soft); color: var(--danger); }

@media (min-width: 901px) {
  .module-grid { grid-template-columns: repeat(6, 1fr); }
}

@media (max-width: 900px) {
  html { font-size: 14.5px; }
  body { overflow-x: hidden; }

  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; box-shadow: var(--shadow-md); }
  .main-col { margin-left: 0; }
  .page { padding: .9rem .85rem calc(86px + env(safe-area-inset-bottom)); max-width: 100vw; }
  .bill-line { grid-template-columns: 1fr 1fr; }

  .desktop-only { display: none !important; }
  .mobile-only { display: initial !important; }
  div.mobile-only { display: block !important; }
  .quick-grid.mobile-only { display: grid !important; }
  .m-list.mobile-only { display: flex !important; }

  /* ---- Topbar: [menu] [search] [avatar] — quick add & logout live elsewhere ---- */
  .topbar { padding: .55rem .85rem; gap: .6rem; }
  .topbar .dropdown { display: none; }             /* Quick Add → quick tiles + bottom nav */
  .topbar .user-chip form { display: none; }       /* Sign out → More page */
  .global-search { max-width: none; }
  .global-search input { padding: .5rem .9rem .5rem 2.3rem; }

  /* ---- Page headers ---- */
  .page-head { margin-bottom: .9rem; gap: .6rem; }
  .page-head h1 { font-size: 1.3rem; }
  .page-head .subtitle { font-size: .82rem; margin-top: .1rem; }
  .page-head .actions { width: 100%; margin-left: 0; }
  .page-head .actions .btn { flex: 1; white-space: nowrap; }
  .dash-head { margin-bottom: .6rem; }

  /* ---- Panels: tighter rhythm ---- */
  .card-panel { padding: .95rem 1rem; margin-bottom: .85rem; border-radius: 16px; }
  .card-panel .panel-title { font-size: .98rem; margin-bottom: .65rem; }
  .table-panel .panel-title { padding: .95rem 1rem 0; }
  .empty-state { padding: 1.6rem .8rem; font-size: .85rem; }

  /* ---- KPI tiles: compact stat style (label-over-value, small corner icon) ---- */
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: .6rem; margin-bottom: .85rem; }
  .kpi-card { position: relative; padding: .7rem .8rem; display: flex; flex-direction: column; border-radius: 14px; }
  .kpi-card .kpi-icon {
    position: absolute; top: .6rem; right: .6rem;
    width: 26px; height: 26px; border-radius: 8px; font-size: .78rem;
    margin-bottom: 0; opacity: .9;
  }
  .kpi-label {
    order: -1; margin: 0 1.9rem .2rem 0;
    font-size: .62rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
    color: var(--text-faint);
  }
  .kpi-value { font-size: 1.3rem; }
  .kpi-delta { font-size: .7rem; margin-top: .15rem; }

  /* ---- Collapsible filter forms (pills stay, full form behind "Filters") ---- */
  .filter-card .filter-form { display: none; }
  .filter-card .filter-form.open { display: flex; }

  /* ---- Day strip ---- */
  .day-strip { margin: 0 -0.85rem .35rem; padding: .15rem .85rem .45rem; }
  .day-pill { min-width: 58px; padding: .45rem .35rem .4rem; border-radius: 12px; }
  .day-pill .dp-num { font-size: 1.15rem; }

  /* ---- Quick tiles ---- */
  .quick-grid { gap: .55rem; }
  .quick-tile { padding: .7rem .2rem; gap: .35rem; font-size: .68rem; border-radius: 14px; }
  .quick-tile i { width: 34px; height: 34px; border-radius: 10px; font-size: 1rem; }
  .quick-tile span, .quick-tile { white-space: nowrap; }

  /* ---- Dashboard panel order: appointments → alerts → insights → trend ---- */
  .dash-cols { display: flex; flex-direction: column; gap: 0; align-items: stretch; }
  .dash-cols > div { display: contents; }
  .panel-appts { order: 1; }
  .panel-alerts { order: 2; }
  .panel-insights { order: 3; }
  .panel-trend { order: 4; }

  /* ---- Appointment rows: two-line card, chip wraps below ---- */
  .appt-row { flex-wrap: wrap; gap: .3rem .6rem; padding: .65rem .15rem; }
  .appt-time { min-width: 0; }
  .appt-time::after { content: ""; }
  .appt-row .badge-soft { margin-left: auto; }
  .appt-go { display: none; }
  .appt-body { flex-basis: 100%; order: 3; }
  .appt-meta { white-space: normal; }

  .trend { height: 88px; }
  .alert-row { font-size: .84rem; padding: .6rem .75rem; }
  .insight-row { font-size: .84rem; }

  .section-cols { gap: 0; }
  .section-cols > div > .card-panel:last-child { margin-bottom: .85rem; }

  /* Line-remove buttons: compact, right-aligned instead of full-width */
  .btn-ghost-danger.w-100, .btn-ghost-danger.rm {
    width: auto !important; margin-left: auto; display: block; padding: .35rem .9rem;
  }

  /* Larger touch targets */
  .btn { padding: .55rem .9rem; }
  .btn-sm { padding: .4rem .7rem; }
  .form-control, .form-select { padding: .6rem .8rem; font-size: 16px; } /* 16px prevents iOS zoom */

  /* Bottom tab bar */
  .bottom-nav {
    display: flex;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1040;
    background: rgba(255, 255, 255, .96);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
    padding: .35rem .3rem calc(.35rem + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 20px rgba(23, 21, 31, .07);
  }
  .bottom-nav a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: .12rem;
    padding: .3rem 0 .15rem; border-radius: 10px;
    color: var(--text-faint); font-size: .64rem; font-weight: 600; letter-spacing: .02em;
  }
  .bottom-nav a i { font-size: 1.25rem; line-height: 1; }
  .bottom-nav a.active { color: var(--rose-deep); }
  .bottom-nav a.active i { transform: translateY(-1px); }
  .bottom-nav a:active { background: var(--rose-soft); }
}
