/* ==========================================================================
   Elite Braid — Espace pro
   Two themes share one set of tokens: "wine" (Wine & Paper) and "road" (Open Road).
   ========================================================================== */

:root,
:root[data-theme="wine"] {
  --bg: #f6f0e8;
  --surface: #fffcf8;
  --surface-2: #f3ebe1;
  --surface-3: #ece1d4;
  --ink: #2b1b20;
  --ink-2: #5a464c;
  --muted: #8c787e;
  --line: #e6d9cc;
  --line-strong: #d6c4b4;
  --brand: #6d2939;
  --brand-strong: #561e2c;
  --brand-soft: #f3e2e4;
  --brand-ink: #fff8f4;
  --accent: #b88a3e;
  --accent-soft: #f6ebd6;
  --sidebar-bg: #3a1520;
  --sidebar-bg-2: #4a1d2a;
  --sidebar-ink: #f8ece6;
  --sidebar-muted: #caa9af;
  --sidebar-active: rgba(255, 236, 228, 0.12);
  --sidebar-line: rgba(255, 236, 228, 0.1);
  --focus: rgba(109, 41, 57, 0.28);
  --shadow-sm: 0 1px 2px rgba(58, 21, 32, 0.06), 0 1px 1px rgba(58, 21, 32, 0.04);
  --shadow: 0 10px 30px -12px rgba(58, 21, 32, 0.22);
  --shadow-lg: 0 24px 60px -18px rgba(58, 21, 32, 0.35);
}

:root[data-theme="road"] {
  --bg: #f1ede5;
  --surface: #ffffff;
  --surface-2: #f2eee7;
  --surface-3: #e7e0d4;
  --ink: #1d262b;
  --ink-2: #47535a;
  --muted: #7a858b;
  --line: #e1dacd;
  --line-strong: #cfc6b6;
  --brand: #b4532a;
  --brand-strong: #923f1d;
  --brand-soft: #f8e5da;
  --brand-ink: #fffaf6;
  --accent: #2f6b6e;
  --accent-soft: #dcebea;
  --sidebar-bg: #1e292f;
  --sidebar-bg-2: #26343b;
  --sidebar-ink: #eef1ef;
  --sidebar-muted: #9aa8ae;
  --sidebar-active: rgba(240, 179, 139, 0.14);
  --sidebar-line: rgba(238, 241, 239, 0.08);
  --focus: rgba(180, 83, 42, 0.3);
  --shadow-sm: 0 1px 2px rgba(29, 38, 43, 0.06), 0 1px 1px rgba(29, 38, 43, 0.04);
  --shadow: 0 10px 30px -12px rgba(29, 38, 43, 0.22);
  --shadow-lg: 0 24px 60px -18px rgba(29, 38, 43, 0.35);
}

:root {
  --success: #3d7057;
  --success-soft: #e2efe7;
  --warning: #a8650f;
  --warning-soft: #f8ead2;
  --danger: #a5343b;
  --danger-soft: #f8e1e1;
  --info: #3b5f86;
  --info-soft: #e1e9f3;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --font-ui: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --sidebar-w: 256px;
  --topbar-h: 68px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

h1, h2, h3, h4 { margin: 0; line-height: 1.2; font-weight: 600; }
.display { font-family: var(--font-display); font-weight: 500; letter-spacing: -0.01em; }
.eyebrow { margin: 0; font-size: 11.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }
.ink-2 { color: var(--ink-2); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* ---------- Icons ---------- */
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 22px; height: 22px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 38px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: 13.5px; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled, .btn[aria-busy="true"] { opacity: 0.6; cursor: default; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(0.95); background: var(--success); }
.btn-sm { min-height: 32px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }
.btn-icon { width: 38px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }
.btn-block { width: 100%; }
.btn .badge-dot { margin-left: 2px; }
.btn-group { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; min-width: 0; }
.field > span, .field-label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field small, .hint { font-size: 12px; color: var(--muted); }
.input, .field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), .field select, .field textarea, .select {
  width: 100%; min-height: 40px; padding: 8px 12px;
  border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--surface); color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field textarea { min-height: 84px; resize: vertical; line-height: 1.45; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus, .select:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--focus);
}
.form-grid { display: grid; gap: 14px; }
.form-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); align-items: start; }
.form-section { display: grid; gap: 14px; padding: 18px 0; border-top: 1px solid var(--line); }
.form-section:first-of-type { border-top: 0; padding-top: 0; }
.form-section > header { display: grid; gap: 2px; }
.form-section > header h3 { font-size: 15px; }
.form-section > header p { margin: 0; font-size: 12.5px; color: var(--muted); }
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 13.5px; }
.check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--brand); flex: none; }
.check small { display: block; color: var(--muted); font-size: 12px; }
.check-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 14px; cursor: pointer; }
.switch input { appearance: none; width: 40px; height: 23px; border-radius: 999px; background: var(--line-strong); position: relative; flex: none; transition: background 0.15s; cursor: pointer; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform 0.15s; }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { transform: translateX(17px); }
.switch strong { display: block; font-size: 13.5px; }
.switch small { color: var(--muted); font-size: 12px; }
.input-icon { position: relative; }
.input-icon .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-icon input { padding-left: 36px !important; }
.form-error { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--danger-soft); color: var(--danger); font-size: 13px; }

/* ---------- Chips & segmented ---------- */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px;
  border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface);
  font-size: 12.5px; font-weight: 600; color: var(--ink-2); white-space: nowrap;
}
.chip:hover { background: var(--surface-2); }
.chip.active { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.chip .count { font-weight: 700; opacity: 0.7; }
.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font-weight: 600; font-size: 12.5px; color: var(--ink-2); }
.seg button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px;
  border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap;
  background: var(--surface-3); color: var(--ink-2);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.85; }
.badge.plain::before { display: none; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-brand { background: var(--brand-soft); color: var(--brand); }
.badge-accent { background: var(--accent-soft); color: color-mix(in srgb, var(--accent) 80%, var(--ink)); }
.badge-dot { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--brand); color: var(--brand-ink); font-size: 11px; font-weight: 700; }

/* ---------- Avatar ---------- */
.avatar {
  --c: var(--brand);
  display: inline-grid; place-items: center; flex: none;
  width: 36px; height: 36px; border-radius: 50%;
  background: color-mix(in srgb, var(--c) 16%, var(--surface));
  color: color-mix(in srgb, var(--c) 85%, var(--ink));
  font-weight: 700; font-size: 13px; letter-spacing: 0.02em;
  border: 1px solid color-mix(in srgb, var(--c) 28%, transparent);
}
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
.avatar-lg { width: 56px; height: 56px; font-size: 19px; }
.avatar-xl { width: 76px; height: 76px; font-size: 25px; }
.dot { --c: var(--brand); width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex: none; display: inline-block; }

/* ==========================================================================
   Login
   ========================================================================== */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--brand) 18%, transparent), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, color-mix(in srgb, var(--accent) 20%, transparent), transparent 60%),
    var(--bg);
}
.login-card {
  width: min(440px, 100%); padding: 36px 32px 30px; border-radius: 22px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-lg);
  display: grid; gap: 18px;
}
.login-brand { display: flex; align-items: center; gap: 12px; }
.login-brand img { width: 48px; height: 48px; border-radius: 14px; object-fit: cover; }
.login-brand strong { display: block; font-family: var(--font-display); font-size: 19px; font-weight: 500; }
.login-card h1 { font-family: var(--font-display); font-weight: 500; font-size: 28px; }
.login-card p { margin: 0; color: var(--muted); }
.login-mode { display: grid; grid-template-columns: 1fr 1fr; }
.login-mode button { flex: 1; }

/* ==========================================================================
   Shell
   ========================================================================== */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 18px; padding: 18px 14px;
  background: linear-gradient(180deg, var(--sidebar-bg), var(--sidebar-bg-2));
  color: var(--sidebar-ink);
}
.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 4px 6px 2px; color: inherit; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.sidebar-brand:hover { text-decoration: none; }
.sidebar-brand img { width: 38px; height: 38px; border-radius: 11px; object-fit: cover; }
.sidebar-brand strong { display: block; font-family: var(--font-display); font-weight: 500; font-size: 16px; line-height: 1.15; }
.sidebar-brand small { color: var(--sidebar-muted); font-size: 11.5px; }
.scope-picker { display: grid; gap: 6px; padding: 10px; border-radius: 12px; background: var(--sidebar-active); }
.scope-picker label { font-size: 10.5px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--sidebar-muted); }
.scope-picker select {
  width: 100%; min-height: 36px; padding: 6px 10px; border-radius: 9px;
  border: 1px solid var(--sidebar-line); background: rgba(0, 0, 0, 0.18); color: var(--sidebar-ink);
}
.scope-picker select option { color: #222; }
.nav { display: grid; gap: 2px; }
.nav-label { margin: 12px 10px 4px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--sidebar-muted); }
.nav a {
  display: flex; align-items: center; gap: 11px; min-height: 40px; padding: 0 10px; border-radius: 10px;
  color: var(--sidebar-ink); opacity: 0.86; font-weight: 500; font-size: 14px;
}
.nav a:hover { background: var(--sidebar-active); opacity: 1; text-decoration: none; }
.nav a.active { background: var(--sidebar-active); opacity: 1; font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.nav a .badge-dot { margin-left: auto; background: var(--accent); color: #1a1a1a; }
.sidebar-foot { margin-top: auto; display: grid; gap: 8px; padding-top: 12px; border-top: 1px solid var(--sidebar-line); }
.me { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 12px; color: inherit; }
.me:hover { background: var(--sidebar-active); text-decoration: none; }
.me strong { display: block; font-size: 13.5px; }
.me small { display: block; color: var(--sidebar-muted); font-size: 11.5px; }
.sidebar .avatar { border-color: var(--sidebar-line); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; min-height: var(--topbar-h);
  display: flex; align-items: center; gap: 14px; padding: 12px clamp(16px, 3vw, 32px);
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-title { min-width: 0; flex: 1; }
.topbar-title h1 { font-family: var(--font-display); font-weight: 500; font-size: 24px; letter-spacing: -0.01em; }
.topbar-title p { margin: 0; color: var(--muted); font-size: 12.5px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.search-box { position: relative; width: min(280px, 32vw); }
.search-box input { width: 100%; min-height: 38px; padding: 0 12px 0 36px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); }
.search-box input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--focus); }
.search-box .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 40; max-height: 420px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px;
}
.search-results button { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 0; border-radius: 9px; background: transparent; text-align: left; }
.search-results button:hover, .search-results button.active { background: var(--surface-2); }
.search-results .group { padding: 8px 10px 4px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.menu-toggle { display: none; }
.scope-banner {
  display: flex; align-items: center; gap: 10px; padding: 8px clamp(16px, 3vw, 32px);
  background: var(--accent-soft); color: color-mix(in srgb, var(--accent) 70%, var(--ink)); font-size: 13px; font-weight: 600;
  border-bottom: 1px solid var(--line);
}
.scope-banner .btn { margin-left: auto; }

.view { padding: clamp(16px, 3vw, 32px); display: grid; gap: 22px; align-content: start; min-width: 0; }
.view-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.view-head h2 { font-family: var(--font-display); font-weight: 500; font-size: 22px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.toolbar .search-box { width: min(300px, 100%); }
.toolbar .spacer { flex: 1; }

.bottom-nav { display: none; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); min-width: 0; }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card-head h3 { font-size: 15.5px; }
.card-head p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.card-body { padding: 16px 20px; }
.card-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.card.flat { box-shadow: none; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); align-items: start; }
.stack { display: grid; gap: 12px; }
.stack-sm { display: grid; gap: 6px; }
.row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; }
.wrap { flex-wrap: wrap; }

/* ---------- KPI tiles ---------- */
.stats { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.stat { padding: 16px 18px; display: grid; gap: 4px; }
.stat .label { font-size: 12.5px; font-weight: 600; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.stat .value { font-family: var(--font-display); font-weight: 500; font-size: 28px; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.stat .delta { font-size: 12px; color: var(--muted); }
.stat .delta.up { color: var(--success); }
.stat .delta.down { color: var(--danger); }

/* ---------- Action cards ---------- */
.actions-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.action-card {
  display: grid; gap: 4px; padding: 14px 16px; border-radius: 14px; text-align: left;
  border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow-sm);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.action-card:hover { transform: translateY(-1px); box-shadow: var(--shadow); border-color: var(--line-strong); }
.action-card .count { font-family: var(--font-display); font-size: 26px; font-weight: 500; line-height: 1; }
.action-card strong { font-size: 13.5px; }
.action-card small { color: var(--muted); font-size: 12px; }
.action-card.tone-warning .count { color: var(--warning); }
.action-card.tone-brand .count { color: var(--brand); }
.action-card.tone-info .count { color: var(--info); }
.action-card.tone-danger .count { color: var(--danger); }
.action-card.is-zero { opacity: 0.6; box-shadow: none; }
.all-clear { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-radius: 14px; background: var(--success-soft); color: var(--success); font-weight: 600; }

/* ---------- Lists ---------- */
.list { display: grid; }
.list-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 20px; min-width: 0;
  border-bottom: 1px solid var(--line); background: transparent; border-left: 0; border-right: 0; border-top: 0;
  text-align: left; width: 100%; color: inherit;
}
.list-item:last-child { border-bottom: 0; }
button.list-item:hover, a.list-item:hover, .list-item.clickable:hover { background: var(--surface-2); text-decoration: none; cursor: pointer; }
.main-col { display: grid; gap: 1px; min-width: 0; }
.list-item .main-col { flex: 1; }
.list-item .main-col strong { font-size: 14px; }
.list-item .main-col span { font-size: 12.5px; color: var(--muted); }
.list-item .side-col { display: grid; justify-items: end; gap: 3px; text-align: right; flex: none; }
.time-pill { flex: none; width: 62px; text-align: center; padding: 6px 0; border-radius: 10px; background: var(--surface-2); font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; }
.time-pill small { display: block; font-weight: 500; font-size: 11px; color: var(--muted); }
.date-pill { flex: none; width: 50px; text-align: center; padding: 5px 0; border-radius: 10px; background: var(--brand-soft); color: var(--brand); line-height: 1.1; }
.date-pill b { display: block; font-family: var(--font-display); font-size: 19px; font-weight: 500; }
.date-pill small { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 11.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding: 10px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.clickable:hover td { background: var(--surface-2); cursor: pointer; }
.table .right { text-align: right; }

.empty {
  display: grid; justify-items: center; gap: 8px; padding: 36px 20px; text-align: center; color: var(--muted);
}
.empty .icon { width: 30px; height: 30px; color: var(--line-strong); }
.empty strong { color: var(--ink-2); font-size: 15px; }
.empty p { margin: 0; max-width: 380px; font-size: 13px; }

.notice { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; font-size: 13px; background: var(--info-soft); color: var(--info); }
.notice.warning { background: var(--warning-soft); color: var(--warning); }
.notice.danger { background: var(--danger-soft); color: var(--danger); }
.notice.success { background: var(--success-soft); color: var(--success); }
.notice .icon { margin-top: 1px; }
.notice p { margin: 0; }
.notice strong { display: block; }

/* ---------- Drawer ---------- */
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(20, 12, 14, 0.38); backdrop-filter: blur(2px); animation: fade 0.18s ease; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 61; width: min(560px, 100vw);
  background: var(--bg); box-shadow: var(--shadow-lg); display: flex; flex-direction: column;
  animation: slide-in 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.drawer.wide { width: min(820px, 100vw); }
.drawer-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 22px; background: var(--surface); border-bottom: 1px solid var(--line); }
.drawer-head .titles { flex: 1; min-width: 0; }
.drawer-head h2 { font-family: var(--font-display); font-weight: 500; font-size: 22px; }
.drawer-head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px 22px; display: grid; gap: 18px; align-content: start; }
.drawer-foot { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; padding: 14px 22px; background: var(--surface); border-top: 1px solid var(--line); }
.drawer-foot .left { margin-right: auto; }
.drawer-tabs { display: flex; gap: 4px; padding: 0 22px; background: var(--surface); border-bottom: 1px solid var(--line); overflow-x: auto; }
.drawer-tabs button, .tabs button {
  border: 0; background: none; padding: 12px 10px; font-weight: 600; font-size: 13px; color: var(--muted);
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.drawer-tabs button.active, .tabs button.active { color: var(--ink); border-bottom-color: var(--brand); }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); overflow-x: auto; }

.section { display: grid; gap: 10px; }
.section > h4 { font-size: 11.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 18px; }
.kv div { display: grid; gap: 1px; min-width: 0; }
.kv dt, .kv span.k { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.kv dd, .kv span.v { margin: 0; font-size: 13.5px; overflow-wrap: anywhere; }
dl.kv { margin: 0; }

.timeline { display: grid; gap: 0; }
.timeline-item { display: grid; grid-template-columns: 18px 1fr; gap: 10px; padding-bottom: 12px; position: relative; }
.timeline-item::before { content: ""; position: absolute; left: 8px; top: 16px; bottom: 0; width: 2px; background: var(--line); }
.timeline-item:last-child::before { display: none; }
.timeline-item .bullet { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-strong); background: var(--surface); margin-top: 1px; }
.timeline-item.done .bullet { background: var(--success); border-color: var(--success); }
.timeline-item strong { font-size: 13px; display: block; }
.timeline-item small { color: var(--muted); font-size: 12px; }

/* ---------- Dialog ---------- */
/* Popups: centered, never wider than the screen; a long message scrolls inside, buttons stay in view. */
.dialog-wrap { position: fixed; inset: 0; z-index: 80; display: grid; grid-template-columns: minmax(0, 460px); justify-content: center; align-items: center; padding: max(18px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom)); background: rgba(20, 12, 14, 0.45); animation: fade 0.15s ease; }
.dialog { width: 100%; min-width: 0; max-height: calc(100vh - 36px); max-height: calc(100dvh - 36px); overflow-y: auto; overscroll-behavior: contain; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 22px; display: grid; gap: 14px; animation: pop 0.18s ease; }
.dialog h3 { font-family: var(--font-display); font-weight: 500; font-size: 20px; }
.dialog p { margin: 0; color: var(--ink-2); white-space: pre-line; overflow-wrap: anywhere; }
.dialog .btn-group { justify-content: flex-end; }
.dialog > .btn-group:last-child { position: sticky; bottom: -22px; margin: 0 -22px -22px; padding: 12px 22px 22px; background: var(--surface); }

/* ---------- Toast ---------- */
.toasts { position: fixed; z-index: 90; bottom: 20px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; width: min(440px, calc(100vw - 32px)); pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 12px; pointer-events: auto;
  background: var(--ink); color: var(--surface); box-shadow: var(--shadow-lg); font-size: 13.5px; font-weight: 500;
  animation: pop 0.2s ease;
}
.toast.success .icon { color: #8fd3ad; }
.toast.error { background: var(--danger); color: #fff; }
.toast button { margin-left: auto; border: 0; background: transparent; color: inherit; opacity: 0.7; }

.loading-bar { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 100; overflow: hidden; }
.loading-bar::after { content: ""; position: absolute; inset: 0; width: 40%; background: var(--accent); animation: loading 1s ease-in-out infinite; }
.skeleton { border-radius: 10px; background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(0.98); } }
@keyframes slide-in { from { transform: translateX(40px); opacity: 0; } }
@keyframes loading { 0% { left: -40%; } 100% { left: 100%; } }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ==========================================================================
   Agenda
   ========================================================================== */
.agenda-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.agenda-toolbar h3 { font-family: var(--font-display); font-weight: 500; font-size: 19px; min-width: 200px; }
.agenda { --hour-h: 56px; display: grid; grid-template-columns: 54px repeat(var(--days, 7), minmax(110px, 1fr)); overflow-x: auto; }
.agenda-head { position: sticky; top: 0; z-index: 2; padding: 10px 8px; text-align: center; background: var(--surface); border-bottom: 1px solid var(--line); border-left: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.agenda-head strong { display: block; font-family: var(--font-display); font-weight: 500; font-size: 20px; color: var(--ink); }
.agenda-head.today strong { color: var(--brand); }
.agenda-head.today { box-shadow: inset 0 -2px 0 var(--brand); }
.agenda-head.closed { background: var(--surface-2); }
.agenda-corner { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; }
.agenda-hours { position: relative; }
.agenda-hours span { position: absolute; right: 8px; transform: translateY(-50%); font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.agenda-col { position: relative; border-left: 1px solid var(--line); background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--hour-h) - 1px), var(--line) calc(var(--hour-h) - 1px), var(--line) var(--hour-h)); }
.agenda-col.closed { background-color: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.agenda-col.today { background-color: color-mix(in srgb, var(--brand-soft) 35%, transparent); }
.agenda-slot { position: absolute; left: 0; right: 0; border: 0; background: transparent; }
.agenda-slot:hover { background: color-mix(in srgb, var(--brand) 6%, transparent); }
.agenda-event {
  --c: var(--brand);
  position: absolute; left: 4px; right: 4px; z-index: 1; overflow: hidden; text-align: left;
  padding: 5px 7px; border-radius: 8px; border: 0; border-left: 3px solid var(--c);
  background: color-mix(in srgb, var(--c) 14%, var(--surface)); color: var(--ink);
  font-size: 11.5px; line-height: 1.3; box-shadow: var(--shadow-sm);
}
.agenda-event:hover { box-shadow: var(--shadow); z-index: 3; }
.agenda-event strong { display: block; font-size: 12px; }
.agenda-event span { color: var(--ink-2); }
.agenda-event.pending { background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--c) 10%, var(--surface)) 0 6px, var(--surface) 6px 12px); }
.agenda-event.completed { opacity: 0.6; }
.agenda-event.awaiting_payment { opacity: 0.75; border-left-style: dashed; background: var(--surface); }
.agenda-block { position: absolute; left: 0; right: 0; background: repeating-linear-gradient(45deg, var(--surface-3) 0 5px, transparent 5px 10px); border-top: 1px dashed var(--line-strong); border-bottom: 1px dashed var(--line-strong); font-size: 10.5px; color: var(--muted); padding: 2px 6px; overflow: hidden; }
.now-line { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger); z-index: 2; }
.now-line::before { content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12.5px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

.month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.month-grid .dow { padding: 8px; font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid var(--line); }
.month-cell { min-height: 104px; padding: 6px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); display: grid; align-content: start; gap: 3px; background: var(--surface); border-top: 0; border-left: 0; text-align: left; }
.month-cell:nth-child(7n + 7) { border-right: 0; }
.month-cell.out { background: var(--surface-2); color: var(--muted); }
.month-cell.today .d { background: var(--brand); color: var(--brand-ink); }
.month-cell .d { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; font-weight: 600; font-size: 12.5px; }
.month-cell .ev { --c: var(--brand); display: block; font-size: 11px; padding: 2px 5px; border-radius: 5px; background: color-mix(in srgb, var(--c) 14%, var(--surface)); border-left: 2px solid var(--c); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.month-cell .more { font-size: 11px; color: var(--muted); padding-left: 4px; }
.month-cell:hover { background: var(--surface-2); }

/* ==========================================================================
   Catalogue
   ========================================================================== */
.tiles { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.tile { overflow: hidden; display: flex; flex-direction: column; text-align: left; padding: 0; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); transition: box-shadow 0.15s, transform 0.15s; }
.tile:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.tile-media { position: relative; aspect-ratio: 4 / 3; background: var(--surface-2); }
.tile-media img { width: 100%; height: 100%; object-fit: cover; }
.tile-media .badges { position: absolute; top: 10px; left: 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.tile-media .badge { background: rgba(255, 255, 255, 0.92); }
.tile-body { padding: 14px 16px; display: grid; gap: 6px; flex: 1; align-content: start; }
.tile-body h3 { font-size: 15px; }
.tile-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12.5px; color: var(--muted); }
.tile-meta b { color: var(--ink); font-weight: 700; }
.tile-foot { padding: 10px 16px; border-top: 1px solid var(--line); display: flex; gap: 6px; flex-wrap: wrap; }
.gallery-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.gallery-card { position: relative; border-radius: 14px; overflow: hidden; background: var(--surface-2); aspect-ratio: 1; border: 1px solid var(--line); padding: 0; }
.gallery-card img { width: 100%; height: 100%; object-fit: cover; }
.gallery-card .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 26px 10px 8px; background: linear-gradient(transparent, rgba(0, 0, 0, 0.65)); color: #fff; font-size: 12px; text-align: left; }
.gallery-card .cap strong { display: block; font-size: 12.5px; }
.gallery-card .badges { position: absolute; top: 8px; left: 8px; display: flex; gap: 4px; }
.gallery-card .badge { background: rgba(255, 255, 255, 0.92); }

/* Drag to reorder (A.sortable): hold, lift, slide, settle */
.is-sortable > [data-sort-id] { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; transition: transform 0.28s ease, box-shadow 0.2s; }
.is-sortable > [data-sort-id] img { -webkit-user-drag: none; pointer-events: none; }
@media (hover: hover) { .is-sortable > [data-sort-id] { cursor: grab; } }
.is-sortable > .sort-pressing { transform: scale(0.95); }
.sort-placeholder { outline: 2px dashed var(--brand) !important; outline-offset: -2px !important; background: color-mix(in srgb, var(--brand) 9%, var(--surface)) !important; box-shadow: none !important; }
.sort-placeholder > * { opacity: 0.16; transition: opacity 0.15s; }
.sort-ghost { position: fixed; z-index: 1000; margin: 0; pointer-events: none; will-change: transform; }
.sort-ghost.settle { transition: transform 0.26s cubic-bezier(0.2, 0.8, 0.2, 1); }
.sort-ghost > * { width: 100% !important; height: 100% !important; margin: 0 !important; animation: sort-lift 0.2s cubic-bezier(0.2, 0.8, 0.2, 1) forwards; }
.sort-ghost.settle > * { animation: sort-settle 0.26s cubic-bezier(0.2, 0.8, 0.2, 1) forwards; }
@keyframes sort-lift {
  from { transform: scale(0.95); box-shadow: 0 0 0 rgba(0, 0, 0, 0); }
  to { transform: scale(1.07) rotate(-2deg); box-shadow: 0 22px 44px -12px rgba(0, 0, 0, 0.45), 0 0 0 3px var(--brand); }
}
@keyframes sort-settle {
  from { transform: scale(1.07) rotate(-2deg); box-shadow: 0 22px 44px -12px rgba(0, 0, 0, 0.45), 0 0 0 3px var(--brand); }
  to { transform: none; box-shadow: 0 0 0 0 rgba(0, 0, 0, 0); }
}
.sort-landed { animation: sort-landed 0.65s ease-out; }
@keyframes sort-landed {
  0% { box-shadow: 0 0 0 3px var(--brand); }
  100% { box-shadow: 0 0 0 12px color-mix(in srgb, var(--brand) 0%, transparent); }
}
html.sort-dragging, html.sort-dragging * { cursor: grabbing !important; }
.image-picker { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
.image-thumb { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); }
.image-thumb img { width: 100%; height: 100%; object-fit: cover; }
.image-thumb.cover { outline: 3px solid var(--brand); outline-offset: -3px; }
.image-thumb .thumb-actions { position: absolute; inset: auto 4px 4px 4px; display: flex; gap: 4px; justify-content: flex-end; }
.image-thumb .thumb-actions button { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 7px; border: 0; background: rgba(255, 255, 255, 0.94); color: var(--ink); padding: 0; }
.image-thumb .cover-tag { position: absolute; top: 4px; left: 4px; }
.upload-tile { display: grid; place-items: center; gap: 4px; aspect-ratio: 1; border-radius: 10px; border: 1.5px dashed var(--line-strong); color: var(--muted); font-size: 12px; text-align: center; cursor: pointer; background: var(--surface); padding: 6px; }
.upload-tile:hover { border-color: var(--brand); color: var(--brand); }
.upload-tile input { display: none; }
.extras-table { display: grid; gap: 8px; }
.extra-line { display: grid; grid-template-columns: 1.1fr 1.1fr 0.7fr 0.7fr 34px; gap: 8px; align-items: end; }
.extra-line .input { min-height: 36px; padding: 6px 10px; }

/* ==========================================================================
   Team
   ========================================================================== */
.city-block { display: grid; gap: 12px; }
.city-block > header { display: flex; align-items: center; gap: 10px; }
.city-block > header h3 { font-family: var(--font-display); font-weight: 500; font-size: 18px; }
.people { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.person { display: grid; gap: 12px; padding: 16px; text-align: left; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-sm); transition: box-shadow 0.15s, transform 0.15s; }
.person:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.person-head { display: flex; align-items: center; gap: 12px; }
.person-head strong { display: block; font-size: 15px; }
.person-head small { color: var(--muted); font-size: 12.5px; }
.person-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.person-stats div { padding: 8px; border-radius: 10px; background: var(--surface-2); text-align: center; }
.person-stats b { display: block; font-family: var(--font-display); font-size: 18px; font-weight: 500; }
.person-stats span { font-size: 11px; color: var(--muted); }
.profile-hero { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; padding: 22px; }
.profile-hero .titles { flex: 1; min-width: 200px; }
.profile-hero h2 { font-family: var(--font-display); font-weight: 500; font-size: 26px; }
.profile-hero .meta { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: 13px; margin-top: 4px; }
.profile-hero .meta span { display: inline-flex; align-items: center; gap: 5px; }

/* ==========================================================================
   Charts
   ========================================================================== */
.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 160px) 1fr auto; gap: 12px; align-items: center; font-size: 13px; }
.bar-row .track { display: block; height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar-row .fill { --c: var(--brand); display: block; height: 100%; border-radius: 999px; background: var(--c); }
.bar-row .val { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 64px; text-align: right; }
.columns { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 10px; align-items: end; height: 220px; padding-top: 10px; }
.column { display: grid; grid-template-rows: auto 1fr auto; height: 100%; gap: 6px; text-align: center; font-size: 11.5px; color: var(--muted); }
.column .bar-wrap { display: flex; align-items: flex-end; justify-content: center; min-height: 0; }
.column .bar { width: min(42px, 70%); border-radius: 8px 8px 3px 3px; background: var(--brand); min-height: 2px; position: relative; }
.column .bar.secondary { background: var(--accent); }
.column .amount { font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.column.current .bar { background: var(--brand-strong); }
.column.current .label { color: var(--ink); font-weight: 700; }
.donut-legend { display: grid; gap: 8px; }
.donut-legend div { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.donut-legend b { margin-left: auto; font-variant-numeric: tabular-nums; }
.split-bar { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: var(--surface-2); }
.split-bar span { --c: var(--brand); background: var(--c); }

/* ---------- Activity ---------- */
.activity { display: grid; }
.activity-item { display: grid; grid-template-columns: 28px 1fr; gap: 10px; padding: 10px 20px; border-bottom: 1px solid var(--line); font-size: 13px; }
.activity-item:last-child { border-bottom: 0; }
.activity-item small { color: var(--muted); font-size: 11.5px; }

/* ---------- Day strip (home) ---------- */
.team-today { display: grid; gap: 0; }

/* ---------- Copy field ---------- */
.copy-field { display: flex; gap: 8px; }
.copy-field input { flex: 1; min-width: 0; font-size: 12.5px; color: var(--ink-2); background: var(--surface-2) !important; }

/* ---------- Status stepper ---------- */
.stepper { display: flex; gap: 6px; flex-wrap: wrap; }
.stepper span { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; background: var(--surface-2); font-size: 12px; font-weight: 600; color: var(--muted); }
.stepper span.done { background: var(--success-soft); color: var(--success); }
.stepper span.current { background: var(--brand-soft); color: var(--brand); }

.risk { padding: 14px; border-radius: 12px; display: grid; gap: 8px; }
.risk.green { background: var(--success-soft); }
.risk.orange { background: var(--warning-soft); }
.risk.red { background: var(--danger-soft); }
.risk h4 { font-size: 14px; }
.risk ul { margin: 0; padding-left: 18px; font-size: 13px; }

.slot-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.slot-picker button { min-height: 32px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); font-weight: 600; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.slot-picker button.active { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }

.theme-cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.theme-card { display: grid; gap: 10px; padding: 12px; border-radius: 14px; border: 2px solid var(--line); background: var(--surface); text-align: left; }
.theme-card.active { border-color: var(--brand); }
.theme-card .swatches { display: flex; height: 44px; border-radius: 9px; overflow: hidden; }
.theme-card .swatches span { flex: 1; }
.theme-card strong { font-size: 13.5px; }
.theme-card small { color: var(--muted); font-size: 12px; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1180px) {
  .grid-main { grid-template-columns: minmax(0, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  :root { --topbar-h: 58px; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; z-index: 70; left: 0; top: 0; bottom: 0; width: min(300px, 86vw);
    transform: translateX(-100%); transition: transform 0.22s ease; box-shadow: var(--shadow-lg);
  }
  .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open::after { content: ""; position: fixed; inset: 0; z-index: 65; background: rgba(20, 12, 14, 0.4); }
  .menu-toggle { display: inline-flex; }
  .topbar { padding: 10px 14px; gap: 8px; }
  .topbar-title h1 { font-size: 20px; }
  .topbar-title p { display: none; }
  .topbar .search-box { display: none; }
  .topbar .hide-mobile { display: none; }
  .view { padding: 16px 16px 96px; gap: 18px; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .bottom-nav {
    position: fixed; z-index: 50; left: 0; right: 0; bottom: 0;
    display: grid; grid-template-columns: repeat(5, 1fr);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
  }
  .bottom-nav a { display: grid; justify-items: center; gap: 2px; padding: 6px 0; border-radius: 10px; color: var(--muted); font-size: 10.5px; font-weight: 600; position: relative; }
  .bottom-nav a:hover { text-decoration: none; }
  .bottom-nav a.active { color: var(--brand); }
  .bottom-nav a .badge-dot { position: absolute; top: 0; left: calc(50% + 6px); min-width: 17px; height: 17px; font-size: 10px; padding: 0 4px; }
  .bottom-nav .fab { align-self: center; justify-self: center; width: 48px; height: 48px; border-radius: 16px; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; box-shadow: var(--shadow); margin-top: -18px; }
  .drawer, .drawer.wide { width: 100vw; }
  .drawer-head, .drawer-body, .drawer-foot { padding-left: 16px; padding-right: 16px; }
  .card-head, .card-body, .list-item { padding-left: 16px; padding-right: 16px; }
  .extra-line { grid-template-columns: 1fr 1fr; }
  .extra-line .rm { grid-column: 2; justify-self: end; }
  .agenda { --hour-h: 52px; }
  .stat .value { font-size: 24px; }
  .toasts { bottom: 86px; }
  .table th, .table td { padding: 10px 12px; }
  .hide-sm { display: none !important; }
}

@media (max-width: 520px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 12px 14px; }
  .actions-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .person-stats b { font-size: 16px; }
  .bar-row { grid-template-columns: 90px 1fr auto; gap: 8px; }
  .month-cell { min-height: 64px; padding: 3px; }
  .month-cell .ev { display: none; }
  .month-cell .more { display: block; }
  .login-card { padding: 28px 20px 22px; }
}

.duration-warning { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 6px; padding: 8px 10px; border-radius: 10px; background: var(--warning-soft, #f8ead2); color: var(--warning, #a8650f); font-size: 12.5px; }
.duration-warning[hidden] { display: none; }
.duration-warning button { border: 0; background: none; padding: 0; color: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; }

.select-sm { width: auto; min-height: 32px; padding: 4px 30px 4px 10px; font-size: 13px; }

/* Diagnostics (hair diagnosis files and report editor) */
.diag-admin { display: grid; gap: 14px; }
.diag-editor [hidden] { display: none !important; }
.diag-admin-grid { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.3fr); gap: 16px; align-items: start; }
.diag-admin-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.diag-admin-photos a { display: grid; gap: 4px; color: inherit; text-decoration: none; font-size: 12px; text-align: center; }
.diag-admin-photos img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 10px; }
.diag-answers h4 { margin: 4px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.diag-answers dl { margin: 0; display: grid; grid-template-columns: minmax(120px, 0.9fr) 1.1fr; gap: 6px 12px; font-size: 13.5px; }
.diag-answers dt { color: var(--ink-2); }
.diag-answers dd { margin: 0; font-weight: 600; }
.diag-editor .diag-sub { margin: 10px 0 -4px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.diag-levels { display: flex; gap: 8px; flex-wrap: wrap; }
.diag-level input { position: absolute; opacity: 0; }
.diag-level span { display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 999px; border: 1.5px solid var(--line-strong); cursor: pointer; font-weight: 600; font-size: 13.5px; }
.diag-level span i { width: 10px; height: 10px; border-radius: 50%; }
.diag-level input:checked + span { border-color: var(--brand); background: var(--brand-soft); }
.diag-level input:focus-visible + span { outline: 3px solid var(--focus); }
.diag-area { display: grid; grid-template-columns: 110px 150px minmax(0, 1fr); gap: 8px; align-items: center; }
.diag-row { display: grid; grid-template-columns: minmax(120px, 0.6fr) minmax(0, 1.4fr) auto; gap: 8px; align-items: center; }
.diag-row[data-product] { grid-template-columns: minmax(150px, 1fr) minmax(0, 1fr) minmax(0, 1fr) auto; }
.diag-phase { display: grid; gap: 8px; padding: 12px; border-radius: 14px; background: var(--surface-2); }
.diag-phase > .btn { justify-self: start; }
.diag-services { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px; }
.diag-medical { padding: 12px 14px; border-radius: 12px; background: #eef3fb; }
.diag-foot { position: sticky; bottom: 0; background: var(--surface); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.diag-drafting { display: grid; justify-items: center; gap: 8px; padding: 48px 20px; text-align: center; }
.diag-drafting > .icon { width: 34px; height: 34px; color: var(--brand); animation: diag-pulse 1.6s ease-in-out infinite; }
.diag-bar { width: min(280px, 80%); height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.diag-bar span { display: block; width: 40%; height: 100%; border-radius: inherit; background: var(--brand); animation: diag-slide 1.4s ease-in-out infinite; }
.dot-inline { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; }
.diag-product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.diag-product { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px; text-align: left; cursor: pointer; }
.diag-product.inactive { opacity: 0.6; }
.diag-product .thumb { width: 56px; height: 56px; border-radius: 12px; background: var(--accent-soft); display: grid; place-items: center; overflow: hidden; }
.diag-product .thumb img { width: 100%; height: 100%; object-fit: cover; }
.diag-product .main-col { display: grid; gap: 2px; min-width: 0; }
.diag-product small { color: var(--muted); font-size: 12px; }
.diag-product-img { width: 64px; height: 64px; border-radius: 12px; object-fit: cover; }
@keyframes diag-pulse { 50% { transform: scale(1.15); opacity: 0.7; } }
@keyframes diag-slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }
@media (max-width: 1080px) { .diag-admin-grid { grid-template-columns: 1fr; } }
@media (max-width: 640px) {
  .diag-area { grid-template-columns: 1fr 1fr; }
  .diag-area input { grid-column: 1 / -1; }
  .diag-row, .diag-row[data-product] { grid-template-columns: 1fr auto; }
  .diag-row > :not(button) { grid-column: 1; }
  .diag-row > button { grid-column: 2; grid-row: 1; }
}

.login-card .link-btn { justify-self: center; border: 0; background: none; color: var(--brand); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; padding: 4px; }

.env-banner { position: sticky; top: 0; z-index: 200; display: flex; gap: 10px; align-items: center; padding: 10px 16px; background: #a5343b; color: #fff; font-size: 13.5px; }
.env-banner a { color: #fff; font-weight: 700; }

.settings-sub { margin: 8px 0 -4px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.settings-sub small { text-transform: none; letter-spacing: 0; font-weight: 400; }

/* Promotions */
.seg label { position: relative; }
.seg label input { position: absolute; opacity: 0; pointer-events: none; }
.seg label span { display: block; padding: 6px 12px; border-radius: 8px; font-weight: 600; font-size: 12.5px; color: var(--ink-2); cursor: pointer; }
.seg label input:checked + span { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.seg label input:focus-visible + span { outline: 3px solid var(--focus); }
.promo-code-tag { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; letter-spacing: 0.06em; }
.list-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; width: 100%; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); text-align: left; cursor: pointer; font: inherit; color: inherit; }
.list-row:hover { border-color: var(--brand); }
.list-row .main-col { display: grid; min-width: 0; }
[data-promo-fields][hidden], [data-promo-percent][hidden], [data-promo-price][hidden] { display: none !important; }

/* Phone notifications */
#pushBanner:empty { display: none; }
#pushBanner { padding: clamp(16px, 3vw, 32px) clamp(16px, 3vw, 32px) 0; }
.push-banner { align-items: center; margin: 0; background: var(--brand-soft); color: var(--ink); }
.push-banner > span { flex: 1; }
.push-banner .icon { color: var(--brand); }
@media (max-width: 560px) { .push-banner { flex-wrap: wrap; } .push-banner > span { flex: 1 1 calc(100% - 70px); } .push-banner .btn-primary, .push-banner a.btn { margin-left: 34px; } }
.push-steps { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-size: 13.5px; }
#pushCard .card-head h3 .icon { vertical-align: -2px; color: var(--brand); }

/* Messages (private chat with clients) */
.msg-layout { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: 16px; height: calc(100dvh - 190px); min-height: 460px; }
.msg-side, .msg-thread { display: flex; flex-direction: column; overflow: hidden; }
.msg-filters { padding: 12px; border-bottom: 1px solid var(--line); }
.msg-list { overflow-y: auto; flex: 1; }
.msg-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
.msg-row:hover { background: var(--surface-2); }
.msg-row.active { background: var(--brand-soft); }
.msg-row .main-col { display: grid; gap: 2px; min-width: 0; }
.msg-row-top { display: flex; justify-content: space-between; gap: 8px; }
.msg-row-top small { color: var(--muted); white-space: nowrap; font-size: 11.5px; }
.msg-row.unread strong { font-weight: 700; }
.msg-unread { width: 10px; height: 10px; border-radius: 50%; background: var(--brand); }
.msg-empty { display: grid; place-items: center; flex: 1; }
.msg-head { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.msg-head .main-col { display: grid; min-width: 0; }
.msg-back { display: none; }
.msg-context { margin: 0; padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); display: flex; gap: 6px; align-items: center; }
.msg-body { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px; background: var(--bg); }
.msg-bubble { max-width: min(78%, 560px); display: grid; gap: 3px; }
.msg-bubble p { margin: 0; padding: 10px 14px; border-radius: 16px; line-height: 1.5; overflow-wrap: anywhere; }
.msg-bubble small { color: var(--muted); font-size: 11.5px; padding: 0 6px; }
.msg-bubble.them { align-self: flex-start; }
.msg-bubble.them p { background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.msg-bubble.me { align-self: flex-end; text-align: right; }
.msg-bubble.me p { background: var(--brand); color: var(--brand-ink); border-bottom-right-radius: 5px; text-align: left; }
.msg-reply { display: grid; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--line); }
.msg-reply textarea { resize: vertical; min-height: 72px; }
.msg-quick { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; }
.msg-quick .chip { white-space: nowrap; }
.msg-reply-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
@media (max-width: 900px) {
  .msg-layout { grid-template-columns: 1fr; height: calc(100dvh - 210px); }
  .msg-layout .msg-thread { display: none; }
  .msg-layout.has-thread .msg-side { display: none; }
  .msg-layout.has-thread .msg-thread { display: flex; }
  .msg-back { display: inline-grid; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Hours + minutes duration picker */
.duration-input { display: grid; grid-template-columns: minmax(64px, 1fr) auto minmax(72px, 1fr) auto; gap: 8px; align-items: center; }
.duration-input > span { font-size: 13px; color: var(--muted); font-weight: 600; }

/* Collapsible card (e.g. notifications status once everything works) */
details.fold > summary { list-style: none; cursor: pointer; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold:not([open]) > summary { border-bottom: 0; }
details.fold > summary p { display: flex; align-items: center; gap: 6px; }
details.fold > summary p .icon { color: var(--success); }
details.fold .fold-icon { color: var(--muted); transition: transform 0.2s; }
details.fold[open] .fold-icon { transform: rotate(180deg); }

/* Stylist level picker (team form) */
.level-pick { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.level-option { position: relative; cursor: pointer; }
.level-option input { position: absolute; opacity: 0; pointer-events: none; }
.level-option > span { display: grid; gap: 3px; height: 100%; padding: 11px 13px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); font-size: 13.5px; transition: border-color 0.15s, background 0.15s; }
.level-option small { color: var(--muted); font-size: 12px; line-height: 1.35; }
.level-option input:checked + span { border-color: var(--brand); background: var(--brand-soft); }
.level-option input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Qui fait quoi: services x stylists */
.who-card { overflow: hidden; }
.who-wrap { overflow: auto; max-height: calc(100dvh - 230px); -webkit-overflow-scrolling: touch; }
.who-grid { width: max-content; min-width: 100%; }
.who-grid thead th { position: sticky; top: 0; z-index: 2; }
.who-grid .who-sticky { position: sticky; left: 0; z-index: 1; background: var(--surface); min-width: 180px; max-width: 240px; text-align: left; text-transform: none; letter-spacing: 0; font-size: 13.5px; color: inherit; border-right: 1px solid var(--line); }
.who-grid thead .who-sticky { z-index: 3; background: var(--surface-2); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.who-grid tbody .who-sticky { display: table-cell; font-weight: 400; }
.who-grid tbody .who-sticky strong { display: block; font-weight: 650; }
.who-grid tbody .who-sticky small { display: block; color: var(--muted); font-size: 12px; }
.who-head { text-align: center !important; min-width: 96px; text-transform: none !important; letter-spacing: 0 !important; }
.who-head a { display: grid; justify-items: center; gap: 4px; color: var(--ink, inherit); text-decoration: none; font-size: 12.5px; font-weight: 650; max-width: 110px; margin: 0 auto; }
.who-head small { display: block; font-weight: 500; font-size: 11px; color: var(--muted); }
.who-cell { text-align: center; vertical-align: top !important; padding: 8px 10px !important; min-width: 96px; }
.who-cell.on { background: color-mix(in srgb, var(--brand-soft) 55%, transparent); }
.who-toggle { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; cursor: pointer; }
.who-toggle:hover { background: var(--surface-2); }
.who-toggle input { width: 20px; height: 20px; margin: 0; accent-color: var(--brand); cursor: pointer; }
.who-rate { display: grid; gap: 1px; margin: 2px auto 0; padding: 3px 8px; border: 1px dashed var(--line); border-radius: 8px; background: transparent; color: inherit; font: inherit; font-size: 12.5px; font-weight: 650; cursor: pointer; }
.who-rate small { color: var(--muted); font-size: 11px; font-weight: 500; }
.who-rate.custom { border-style: solid; border-color: var(--brand); color: var(--brand); }
.who-rate:hover { border-color: var(--brand); }

/* Requests waiting for a stylist's answer (home) */
.request-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.request-row:last-child { border-bottom: 0; }
.request-row .main-col { flex: 1; min-width: 0; }
.request-row .btn-group { flex: none; }
.countdown { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 650; color: var(--warning); }
.countdown.late { color: var(--danger); }
.countdown.calm { color: var(--muted); }
@media (max-width: 640px) {
  .request-row { flex-wrap: wrap; }
  .request-row .btn-group { width: 100%; padding-left: 46px; }
  .who-grid .who-sticky { min-width: 140px; max-width: 160px; }
  .who-stats { display: none; }
}

/* First-login checklist (stylist home) */
.checklist { display: grid; gap: 2px; }
.checklist a, .checklist div { display: flex; align-items: center; gap: 10px; padding: 9px 16px; color: inherit; text-decoration: none; font-size: 13.5px; }
.checklist a:hover { background: var(--surface-2); }
.checklist .tick { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--line); flex: none; }
.checklist .done .tick { background: var(--success); border-color: var(--success); color: #fff; }
.checklist .done span:not(.tick) { color: var(--muted); text-decoration: line-through; }
.checklist .icon-arrow { margin-left: auto; color: var(--muted); }

/* City picker */
.city-field { position: relative; }
.city-box { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 42px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: text; }
.city-box:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--focus); }
.city-box .city-entry { flex: 1; min-width: 120px; border: 0; outline: 0; background: transparent; padding: 4px 2px; font: inherit; color: inherit; box-shadow: none; }
.city-chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 4px 3px 10px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-size: 13px; font-weight: 600; }
.city-chip button { display: inline-grid; place-items: center; width: 22px; height: 22px; border: 0; border-radius: 50%; background: transparent; color: inherit; cursor: pointer; }
.city-chip button:hover { background: rgba(0, 0, 0, 0.08); }
.city-menu { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px); display: grid; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12); max-height: 280px; overflow: auto; }
.city-menu.hidden { display: none; }
.city-menu button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 9px 10px; border: 0; border-radius: 8px; background: transparent; color: inherit; font: inherit; font-size: 14px; text-align: left; cursor: pointer; }
.city-menu button span { flex: 1; }
.city-menu button small { color: var(--muted); font-size: 12px; }
.city-menu button.active, .city-menu button:hover { background: var(--surface-2); }
.city-menu .icon { color: var(--muted); }
.city-empty { padding: 10px; color: var(--muted); font-size: 13px; }

/* Data & automatic checks (Réglages) */
.gauge { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.gauge > span { display: block; height: 100%; border-radius: inherit; background: var(--success); }
.gauge.warn > span { background: var(--warning); }
.status-line { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.status-line.ok { color: var(--success); }
.status-line.warn { color: var(--warning); }
.steps-list { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-size: 13.5px; }
.steps-list code { font-size: 12.5px; padding: 1px 6px; border-radius: 6px; background: var(--surface-2); word-break: break-all; }
.env-banner.is-test { background: #2f5d8a; }

/* Horaire: 2-week preview, week rows, absences, save bar */
.day-strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.day-tile { display: grid; gap: 2px; align-content: start; min-height: 78px; padding: 9px 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-size: 12.5px; }
.day-tile small { color: var(--muted); font-weight: 600; font-size: 11.5px; }
.day-tile strong { font-size: 13px; }
.day-tile .day-note { color: var(--muted); font-size: 11px; line-height: 1.3; }
.day-tile .day-count { margin-top: auto; display: inline-flex; align-items: center; gap: 3px; font-size: 11.5px; font-weight: 650; color: var(--brand); }
.day-tile.tone-rest { background: var(--surface-2); color: var(--muted); border-style: dashed; }
.day-tile.tone-away { background: var(--warning-soft); border-color: transparent; }
.day-tile.tone-away strong { color: var(--warning); }
.day-tile.tone-closed { background: var(--surface-2); border-color: transparent; }
.day-tile.tone-special { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.day-tile.clash { background: var(--danger-soft); }
.day-tile.clash .day-count { color: var(--danger); }

.week-rows { display: grid; gap: 4px; }
.week-row { display: grid; grid-template-columns: 150px auto 1fr; align-items: center; gap: 16px; min-height: 48px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.week-break { flex-wrap: nowrap; }
.week-row:last-child { border-bottom: 0; }
.week-row.off .week-day span { color: var(--muted); }
.week-day { display: flex; align-items: center; gap: 9px; font-weight: 650; font-size: 14px; cursor: pointer; }
.week-day input { width: 18px; height: 18px; accent-color: var(--brand); margin: 0; }
.week-hours, .week-break { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.week-hours input, .week-break input { width: 108px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font: inherit; font-size: 13.5px; color: inherit; }
.week-break input { width: 100px; }
.week-rest { grid-column: 2 / -1; }
.week-rows.is-locked { opacity: 0.6; }

.absence-form { display: grid; gap: 12px; padding: 14px; border-radius: 12px; background: var(--surface-2); }
.absence-list { display: grid; gap: 8px; }
.absence-list .field-label { font-size: 12px; font-weight: 700; color: var(--muted); }
.absence-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.absence-item .main-col { flex: 1; display: grid; gap: 2px; min-width: 0; font-size: 13.5px; }
.absence-item .main-col > span { color: var(--muted); }
.absence-icon { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--warning-soft); color: var(--warning); flex: none; }
.absence-icon.special { background: var(--brand-soft); color: var(--brand); }
.muted-list .absence-item { background: transparent; }

.segmented { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); gap: 2px; flex-wrap: wrap; }
.segmented button { padding: 7px 12px; border: 0; border-radius: 8px; background: transparent; font: inherit; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.segmented button.selected { background: var(--brand); color: var(--brand-ink, #fff); }

.save-bar { position: sticky; bottom: 12px; z-index: 20; display: none; align-items: center; gap: 10px; margin-left: auto; width: fit-content; max-width: 100%; padding: 10px 12px 10px 16px; border-radius: 14px; background: var(--ink); color: var(--surface); box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2); font-size: 13.5px; font-weight: 600; }
.save-bar.show { display: flex; }
.save-bar > span { display: inline-flex; align-items: center; gap: 6px; margin-right: 6px; }
.save-bar .btn-ghost { color: var(--surface); }

@media (max-width: 900px) {
  .day-strip { grid-template-columns: repeat(7, minmax(92px, 1fr)); overflow-x: auto; padding-bottom: 4px; }
}
@media (max-width: 640px) {
  .week-row { grid-template-columns: 1fr; gap: 6px; padding: 8px 0; }
  .week-rest { grid-column: auto; }
  .save-bar { bottom: 84px; left: 0; right: 0; margin: 0 auto; }
}

/* Wide content (14-day strip, tables) scrolls inside its card instead of widening the page. */
#view > *, #scheduleBody, #scheduleBody > *, #scheduleBody .grid > *, #scheduleBody .card { min-width: 0; }
#scheduleBody { display: grid; gap: 16px; }
@media (max-width: 640px) {
  .save-bar { flex-wrap: wrap; justify-content: flex-end; }
  .save-bar > span { width: 100%; }
  .week-hours input, .week-break input { width: 100%; min-width: 0; flex: 1; }
  .week-hours, .week-break { flex-wrap: nowrap; }
}
#scheduleBody .form-grid > *, .week-row > *, .week-rows { min-width: 0; }
.form-row.three { grid-template-columns: 1.4fr 1fr 1fr; }
@media (max-width: 640px) {
  .form-row.three { grid-template-columns: 1fr 1fr; }
  .form-row.three > :first-child { grid-column: 1 / -1; }
  .week-hours input, .week-break input { padding: 6px 4px; font-size: 13px; }
}

/* Profile photos */
.avatar.has-photo { padding: 0; overflow: hidden; background: var(--surface-2); }
.avatar.has-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-pick { align-items: center; gap: 12px; }

/* À valider */
.review-item { display: grid; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.review-item:last-child { border-bottom: 0; }
.diff { display: grid; gap: 8px; }
.diff-row { display: grid; grid-template-columns: 140px 1fr 1fr; gap: 10px; align-items: start; font-size: 13.5px; }
.diff-label { font-weight: 650; color: var(--muted); padding-top: 18px; }
.diff-old, .diff-new { display: grid; gap: 3px; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); white-space: pre-line; overflow-wrap: anywhere; }
.diff-new { background: var(--brand-soft); }
.diff-old small, .diff-new small { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.review-photo { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; }
.review-photos { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.review-photo-card { display: grid; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.review-photo-img { padding: 0; border: 0; background: none; cursor: zoom-in; }
.review-photo-img img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; border-radius: 10px; display: block; }

/* Départ d'une styliste */
.depart-list { display: grid; gap: 8px; }
.depart-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; }
.depart-row .main-col { flex: 1; min-width: 0; display: grid; gap: 2px; }
.depart-row select { width: auto; max-width: 260px; }

/* Portfolio upload */
.thumbs-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); }
.thumbs-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; }
.check.consent { padding: 12px; border-radius: 12px; background: var(--warning-soft); }

@media (max-width: 640px) {
  .diff-row { grid-template-columns: 1fr 1fr; }
  .diff-label { grid-column: 1 / -1; padding-top: 0; }
  .depart-row { flex-wrap: wrap; }
  .depart-row select { width: 100%; max-width: none; }
}

/* Salon: promotions, products, rules, announcements */
.code-pill { display: inline-flex; align-items: center; padding: 6px 10px; border-radius: 8px; border: 1.5px dashed var(--brand); color: var(--brand); font-weight: 800; letter-spacing: 0.06em; font-size: 13px; flex: none; }
/* Offer email preview (Clientes → Envoyer une offre) */
.offer-preview iframe { display: block; width: 100%; height: 560px; border: 1px solid var(--line); border-radius: 12px; background: #f6f0e8; }
.product-thumb { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; flex: none; }
.rules-list { margin: 0; padding-left: 18px; display: grid; gap: 6px; font-size: 13.5px; }
.team-rules { white-space: pre-line; font-size: 13.5px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); }
.announcement { display: grid; gap: 8px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.announcement header { display: grid; gap: 2px; }
.announcement p { margin: 0; white-space: pre-line; font-size: 14px; }
.announcement footer { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 8px; }
.announcement.unread { border-color: var(--brand); box-shadow: inset 3px 0 0 var(--brand); }
.announcement.pinned { background: var(--brand-soft); }
#announceForm .chip { cursor: pointer; }

/* Team table */
.segmented-admin { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); }
.segmented-admin button { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 0; border-radius: 8px; background: transparent; font: inherit; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.segmented-admin button.active { background: var(--brand); color: var(--brand-ink, #fff); }
.team-table th.sortable { cursor: pointer; user-select: none; }
.team-table th.sorted { color: var(--brand); }
.team-table td { white-space: nowrap; }
.meter { display: inline-block; width: 42px; height: 6px; border-radius: 99px; background: linear-gradient(90deg, var(--success) var(--v), var(--surface-2) var(--v)); vertical-align: middle; }
.bulk-bar { position: sticky; top: 8px; z-index: 15; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 14px; background: var(--ink); color: var(--surface); box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18); }
.bulk-bar .select { width: auto; }
.bulk-bar .btn-ghost { color: var(--surface); }

/* Team agenda: drag an appointment to another stylist */
.agenda-event[draggable="true"] { cursor: grab; }
.agenda-event.dragging { opacity: 0.5; }
.agenda-col.drop-target { background: color-mix(in srgb, var(--brand-soft) 70%, transparent); outline: 2px dashed var(--brand); outline-offset: -2px; }

/* Réglages in tabs (every field stays in the form, so one save keeps everything) */
.settings-tabs { margin-bottom: 4px; }
#settingsForm [data-stab] { display: none; }
#settingsForm[data-tab="company"] [data-stab="company"], #settingsForm[data-tab="booking"] [data-stab="booking"],
#settingsForm[data-tab="diagnosis"] [data-stab="diagnosis"], #settingsForm[data-tab="emails"] [data-stab="emails"],
#settingsForm[data-tab="auto"] [data-stab="auto"] { display: block; }
#settingsForm[data-tab="legal"] [data-stab="legal"] { display: block; }
#settingsForm[data-tab="emails"] details[data-stab="emails"] { display: block; }

/* Conditions (Réglages) and the stylist agreement screen */
.legal-doc-box { display: grid; gap: 8px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; }
body.agreement-open #app, body.agreement-open #loginView { display: none !important; }
.agreement-view { position: fixed; inset: 0; z-index: 500; overflow: auto; background: var(--bg, #f6efe7); padding: 24px 16px; }
.agreement-card { max-width: 760px; margin: 0 auto; display: grid; gap: 16px; padding: 24px; border-radius: 20px; background: var(--surface); box-shadow: 0 20px 50px rgba(0, 0, 0, 0.1); }
.agreement-card h1 { font-family: var(--font-display, Georgia, serif); font-weight: 500; font-size: 26px; margin: 4px 0; }
.agreement-doc { max-height: 52vh; overflow: auto; padding: 16px 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); }
.legal-title { font-family: var(--font-display, Georgia, serif); font-weight: 500; font-size: 22px; margin: 0; }
.legal-intro { font-weight: 600; }
.legal-section h3 { font-size: 15px; margin: 14px 0 6px; }
.legal-section p, .legal-section li { font-size: 14px; line-height: 1.55; }
.legal-section ul { margin: 0; padding-left: 20px; display: grid; gap: 4px; }

/* Click to enlarge */
[data-zoom] { cursor: zoom-in; }
.avatar[data-zoom]:hover, img[data-zoom]:hover { outline: 2px solid var(--brand); outline-offset: 2px; }
.zoom-view { display: grid; place-items: center; background: var(--surface-2); border-radius: 14px; overflow: hidden; }
.zoom-view img { max-width: 100%; max-height: 78vh; object-fit: contain; display: block; }
.review-photo-img { position: relative; }
.zoom-hint { position: absolute; right: 8px; bottom: 8px; display: inline-flex; align-items: center; gap: 4px; padding: 4px 8px; border-radius: 999px; background: rgba(0, 0, 0, 0.55); color: #fff; font-size: 12px; font-weight: 600; }
.review-photo { width: 96px; height: 96px; }

/* Asking for an online payment: set apart from "payment received" */
.paylink-block { display: grid; gap: 10px; padding: 12px 14px; border-radius: 12px; border: 1px dashed var(--line-strong, var(--line)); background: var(--surface-2, transparent); }

/* Payment card: what's left, a bar, how she paid in one tap, the rest folded away */
.pay-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 6px 16px; flex-wrap: wrap; }
.pay-big { display: flex; align-items: center; gap: 6px; font-size: 30px; line-height: 1.1; }
.pay-big .icon { width: 22px; height: 22px; }
.pay-of { display: grid; justify-items: end; gap: 1px; text-align: right; }
.pay-bar { height: 8px; border-radius: 999px; background: var(--warning-soft); overflow: hidden; }
.pay-bar span { display: block; height: 100%; min-width: 0; border-radius: 999px; background: var(--success); transition: width 0.4s ease; }
.pay-quick { display: grid; gap: 10px; padding: 14px; border-radius: 12px; background: var(--brand-soft); }
.pay-methods { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.pay-methods .btn { justify-content: center; min-height: 48px; background: var(--surface); font-weight: 650; }
.pay-methods .btn .icon { width: 18px; height: 18px; }
details.pay-fold { border-top: 1px solid var(--line); padding-top: 10px; }
details.pay-fold > summary { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); padding: 2px 0; }
details.pay-fold > summary:hover { color: var(--ink, inherit); }
details.pay-fold[open] > summary { margin-bottom: 10px; }
@media (prefers-reduced-motion: reduce) { .pay-bar span { transition: none; } }

/* Owner home: payments not recorded, by stylist */
.unrecorded-group { display: grid; gap: 4px; }
.unrecorded-group + .unrecorded-group { padding-top: 12px; border-top: 1px solid var(--line); }
.unrecorded-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 10px; border: 0; border-radius: 10px; background: transparent; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.unrecorded-row:hover, .unrecorded-row:focus-visible { background: var(--warning-soft); }
.unrecorded-row .main-col { flex: 1; min-width: 0; display: grid; gap: 1px; }
.unrecorded-due { color: var(--warning); white-space: nowrap; }
/* Settlements: appointments waiting for the client to pay (settled once paid) */
.settle-wait { display: inline-flex; align-items: center; gap: 5px; margin-top: 4px; font-size: 12.5px; font-weight: 600; color: var(--warning); }
.settle-wait .icon-sm { flex: none; }
.settle-wait-head { border-top: 1px solid var(--line); }

/* Login: FR / EN */
.login-brand .login-lang { margin-left: auto; align-self: flex-start; }
.login-brand .login-lang button { min-width: 38px; padding: 4px 8px; font-size: 12px; }

/* Promotions: ended ones folded under the current ones */
details.promo-history { margin: 0; padding: 10px 16px 4px; }
details.promo-history > summary .badge { margin-left: 2px; }
details.promo-history .table-wrap { margin: 0 -16px; }

/* Mes services: her own styles open her form */
.tile-button { width: 100%; font: inherit; color: inherit; cursor: pointer; }
.tile-button:hover { box-shadow: var(--shadow); transform: translateY(-1px); }

/* Her link to share (Espace pro home, Team page) and small text buttons */
.link-box { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; }
.link-box code { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 8px 12px; border-radius: 10px; background: var(--surface-2, #f3ebe1); font-size: 13.5px; }
.link-btn { border: 0; background: none; padding: 0; color: var(--brand); font: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* Her link and QR code (Ma page sur le site) */
.link-qr { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.qr-image { flex: none; width: 128px; height: 128px; padding: 6px; border-radius: 14px; background: #fff; border: 1px solid var(--line); }
.qr-image svg { display: block; width: 100%; height: 100%; }
.link-code { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 8px 12px; border-radius: 10px; background: var(--surface-2); font-size: 13.5px; }

/* Messages: a stylist application (what she told us, one tap to invite her) */
.application-card { display: grid; gap: 10px; margin: 12px 16px 0; padding: 14px 16px; border-radius: 14px; background: var(--brand-soft, #f3e2e4); }
.application-card .kv { margin: 0; }

/* "Voir son espace": a slim bar under the page header (in the page, never over its bottom). */
.preview-bar { position: sticky; top: var(--topbar-h, 64px); z-index: 29; display: flex; align-items: center; gap: 10px; padding: 8px 16px; background: #3a1520; color: #f8ece6; font-size: 13.5px; box-shadow: 0 8px 20px -14px rgba(40, 10, 18, 0.6); }
.preview-bar .preview-text { flex: 1; min-width: 0; line-height: 1.35; }
.preview-bar strong { color: #f1d7a6; }
.preview-bar .btn { flex: none; min-height: 34px; background: #f1d7a6; border-color: #f1d7a6; color: #3a1520; }
@media (max-width: 899px) {
  .preview-bar { padding: 6px 12px; font-size: 12.5px; }
  .preview-bar .preview-text > span:last-child { display: none; }
}

/* ---------------------------------------------------------------------------
   Phones (Espace pro): filters on one line you swipe, rows that wrap instead of squeezing,
   buttons that fit the screen. Computers: unchanged.
   --------------------------------------------------------------------------- */
@media (max-width: 900px) {
  /* Toolbars: the search on its own line, then the filters on one swipeable line. */
  .toolbar { gap: 8px; }
  .toolbar > .search-box { order: -1; flex: 1 1 100%; width: 100%; }
  .toolbar > .spacer { display: none; }
  .toolbar > .chips, .chips[role="tablist"], .chips.settings-tabs, .chips.msg-quick {
    flex: 1 1 100%; min-width: 0; max-width: 100%; flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain;
    scrollbar-width: none; padding-right: 26px; scroll-snap-type: x proximity;
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 30px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 30px), transparent);
  }
  .toolbar > .chips::-webkit-scrollbar, .chips[role="tablist"]::-webkit-scrollbar, .chips.settings-tabs::-webkit-scrollbar, .chips.msg-quick::-webkit-scrollbar { display: none; }
  .toolbar > .chips > .chip, .chips[role="tablist"] > .chip, .chips.settings-tabs > .chip, .chips.msg-quick > .chip { flex: none; white-space: nowrap; scroll-snap-align: start; }
  .toolbar > .btn, .toolbar > .select { flex: 1 1 auto; }
  /* Tabs: one line you swipe, no scrollbar. */
  .tabs, .drawer-tabs { scrollbar-width: none; }
  .tabs::-webkit-scrollbar, .drawer-tabs::-webkit-scrollbar { display: none; }
  .tabs button, .drawer-tabs button { flex: none; white-space: nowrap; }
  /* Titles with a button: the button goes under the title when they don't fit side by side. */
  .card-head, .row-between { flex-wrap: wrap; }
  .card-head > .btn, .card-head > .btn-group, .card-head > a.btn { flex: none; }
  /* À valider, lists: the buttons go under the text instead of squeezing it. */
  .request-row { flex-wrap: wrap; }
  .request-row .btn-group { flex: 1 1 100%; justify-content: flex-end; }
  .list-item:has(> .btn-group) { flex-wrap: wrap; }
  .list-item > .btn-group { flex: 1 1 100%; justify-content: flex-end; }
  /* A stylist's page: her buttons on their own full-width line. */
  .profile-hero { padding: 16px; gap: 12px; }
  .profile-hero > .btn-group { flex: 1 1 100%; }
  .profile-hero > .btn-group .btn { flex: 1 1 auto; }
  /* Panel footers with many buttons: they share the width, the main one stays last. */
  .drawer-foot { padding-top: 12px; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .drawer-foot .btn { flex: 1 1 auto; }
  .drawer-foot .left { margin-right: 0; }
  /* Long page titles are cut with "…" rather than pushing the buttons off. */
  .topbar-title h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  /* Tables scroll sideways smoothly. */
  .table-wrap { -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); gap: 12px; }
}
/* Small phones (iPhone SE, small Android). */
@media (max-width: 380px) {
  .btn { padding: 0 12px; }
  .btn-group .btn { white-space: normal; line-height: 1.2; min-height: 40px; }
  .view { padding-left: 12px; padding-right: 12px; }
  .card-head, .card-body, .list-item, .drawer-head, .drawer-body, .drawer-foot { padding-left: 12px; padding-right: 12px; }
  .stats { gap: 8px; }
  .stat { padding: 10px 12px; }
}

/* Things pinned to the bottom stay above the phone's tab bar; the selection bar stays under the header. */
@media (max-width: 900px) {
  .save-bar { bottom: calc(74px + env(safe-area-inset-bottom)); }
  .diag-foot { bottom: calc(66px + env(safe-area-inset-bottom)); }
}
.bulk-bar { top: calc(var(--topbar-h, 64px) + 8px); }

/* ---------------------------------------------------------------------------
   Messages: Clientes | Équipe, and the team chat (Audrey ↔ each stylist)
   --------------------------------------------------------------------------- */
.msg-switch { display: inline-flex; margin-bottom: 12px; }
.msg-switch a { position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 8px; font-weight: 600; font-size: 13px; color: var(--ink-2); text-decoration: none; }
.msg-switch a.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.msg-switch .badge-dot { position: static; margin-left: 2px; }
.icon-xs { width: 12px; height: 12px; }

/* Audrey's list: search, Toutes | Non lues, conversations first, then everyone A–Z */
.team-chat.solo { grid-template-columns: minmax(0, 1fr); max-width: 820px; }
.chat-layout .msg-side { min-height: 0; }
.team-tools { display: grid; gap: 10px; padding: 12px; border-bottom: 1px solid var(--line); background: var(--surface); }
.team-tools .search-box { width: 100%; }
.team-tools .chips { flex-wrap: nowrap; }
.team-list { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.team-section { position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; padding: 8px 14px; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); background: color-mix(in srgb, var(--surface-2) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.team-row { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: center; padding: 11px 14px; color: inherit; text-decoration: none; border-bottom: 1px solid var(--line); transition: background 0.15s; }
.team-row:hover { background: var(--surface-2); text-decoration: none; }
.team-row.active { background: var(--brand-soft); box-shadow: inset 3px 0 0 var(--brand); }
.team-row .avatar { width: 44px; height: 44px; font-size: 15px; }
.team-row-main { display: grid; gap: 3px; min-width: 0; }
.team-row-top, .team-row-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.team-row-top strong { font-weight: 600; }
.team-row-top small { flex: none; font-size: 11.5px; color: var(--muted); }
.team-row-bottom > span:first-child { font-size: 13px; color: var(--muted); }
.team-row-bottom .icon-xs { vertical-align: -1px; }
.team-row.unread strong { font-weight: 800; }
.team-row.unread .team-row-top small { color: var(--brand); font-weight: 700; }
.team-row.unread .team-row-bottom > span:first-child { color: var(--ink); font-weight: 600; }
.team-row-bottom .badge-dot { position: static; flex: none; }
.team-empty { padding: 28px 12px; }
.team-pick { display: grid; place-items: center; flex: 1; }

/* One conversation */
.chat-layout .msg-thread { display: flex; flex-direction: column; min-height: 0; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface); }
.chat-head .avatar { width: 38px; height: 38px; }
.chat-who { display: grid; min-width: 0; flex: 1; line-height: 1.25; }
.chat-who small { font-size: 11.5px; color: var(--muted); }
.chat-back { display: none; place-items: center; width: 36px; height: 36px; margin-left: -8px; border-radius: 10px; color: var(--ink); }
.chat-back:hover { background: var(--surface-2); }
.chat-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 14px 14px 18px; display: flex; flex-direction: column; gap: 2px; background: var(--bg); }
.chat-older { align-self: center; margin-bottom: 8px; }
.chat-hello { margin: auto; display: grid; justify-items: center; gap: 8px; max-width: 260px; text-align: center; color: var(--muted); font-size: 13.5px; }
.chat-hello .icon { width: 34px; height: 34px; color: var(--brand); opacity: 0.7; }
.chat-hello p { margin: 0; }
.chat-day { display: flex; justify-content: center; margin: 14px 0 8px; }
.chat-day span { padding: 3px 11px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); font-size: 11.5px; font-weight: 600; }
.bubble { align-self: flex-start; position: relative; max-width: min(78%, 520px); display: grid; gap: 3px; padding: 7px 11px 6px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 1px 1px rgb(0 0 0 / 0.03); }
.bubble.first { margin-top: 6px; }
.bubble:not(.mine):not(.last) { border-bottom-left-radius: 6px; }
.bubble:not(.mine):not(.first) { border-top-left-radius: 6px; }
.bubble.mine { align-self: flex-end; background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.bubble.mine:not(.last) { border-bottom-right-radius: 6px; }
.bubble.mine:not(.first) { border-top-right-radius: 6px; }
.bubble.last:not(.mine) { border-bottom-left-radius: 4px; }
.bubble.mine.last { border-bottom-right-radius: 4px; }
.bubble.pending { opacity: 0.7; }
.bubble p { margin: 0; font-size: 14.5px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble .bubble-photo { display: block; max-height: 320px; margin: -3px -7px 2px; width: calc(100% + 14px); min-width: 180px; border-radius: 14px; object-fit: cover; cursor: zoom-in; background: var(--surface-2); }
.bubble.photo-only { padding: 3px; max-width: min(70%, 300px); }
.bubble.photo-only .bubble-photo { margin: 0; width: 100%; }
.bubble.photo-only .bubble-grid { margin: 0; }
.bubble.photo-only .meta { position: absolute; right: 9px; bottom: 7px; padding: 1px 7px; border-radius: 999px; background: rgb(0 0 0 / 0.45); color: #fff; opacity: 1; }
.bubble .meta { display: inline-flex; align-items: center; gap: 3px; justify-self: end; font-size: 10.5px; opacity: 0.65; font-variant-numeric: tabular-nums; }
.chat-tick { display: inline-flex; }
.chat-tick .icon-xs + .icon-xs { margin-left: -7px; }
.chat-seen { align-self: flex-end; margin: 2px 4px 0; font-size: 11px; color: var(--muted); }
/* Several photos in one message */
.bubble-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; margin: -3px -7px 2px; width: min(260px, 62vw); border-radius: 14px; overflow: hidden; }
.bubble-grid span { position: relative; aspect-ratio: 1; background: var(--surface-2); }
.bubble-grid img { display: block; width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.bubble-grid.n3 span:first-child { grid-column: span 2; aspect-ratio: 2 / 1; }
.bubble-grid b { position: absolute; inset: 0; display: grid; place-items: center; background: rgb(0 0 0 / 0.45); color: #fff; font-size: 22px; font-weight: 700; cursor: zoom-in; }
/* Answering one message: the quote inside the answer, and the bar above the text box */
.bubble-quote { display: grid; gap: 1px; margin: -1px -4px 3px; padding: 6px 10px; border: 0; border-left: 3px solid var(--brand); border-radius: 10px; background: color-mix(in srgb, var(--brand) 9%, var(--surface-2)); color: var(--ink-2); font: inherit; font-size: 12.5px; text-align: left; cursor: pointer; min-width: 0; }
.bubble-quote strong { font-size: 11.5px; color: var(--brand); }
.bubble-quote span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.bubble.mine .bubble-quote { background: rgb(255 255 255 / 0.16); border-left-color: rgb(255 255 255 / 0.75); color: color-mix(in srgb, var(--brand-ink) 85%, transparent); }
.bubble.mine .bubble-quote strong { color: var(--brand-ink); }
.chat-replying { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; border-left: 3px solid var(--brand); border-radius: 10px; background: var(--surface-2); animation: pop 0.15s ease; }
.chat-replying-text { display: grid; min-width: 0; flex: 1; font-size: 12.5px; color: var(--ink-2); }
.chat-replying-text strong { font-size: 11.5px; color: var(--brand); }
.chat-replying-x { flex: none; display: grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; }
.chat-replying-x:hover { background: var(--surface); color: var(--ink); }
/* Swipe to answer, and the original blinking when its quote is tapped */
.bubble.swipe-ready::before { content: "↩"; position: absolute; left: -30px; top: 50%; transform: translateY(-50%); width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: var(--surface-2); color: var(--brand); font-size: 14px; }
.bubble.flash { animation: bubble-flash 1.2s ease; }
@keyframes bubble-flash { 0%, 60% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 35%, transparent); } 100% { box-shadow: 0 1px 1px rgb(0 0 0 / 0.03); } }
/* Back to the newest messages */
.chat-down-wrap { position: relative; height: 0; z-index: 2; }
.chat-down { position: absolute; right: 14px; bottom: 12px; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); box-shadow: var(--shadow); cursor: pointer; animation: pop 0.15s ease; }
.chat-down[hidden] { display: none; }
/* Photos waiting to be sent, and dropping photos on a computer */
.chat-preview { display: flex; gap: 10px; align-items: center; overflow-x: auto; padding: 8px 8px 2px 2px; }
.chat-preview[hidden] { display: none; }
.chat-thumb { position: relative; flex: none; }
.chat-thumb img { display: block; width: 72px; height: 72px; border-radius: 12px; object-fit: cover; border: 1px solid var(--line); }
.chat-thumb-count { flex: none; font-size: 12px; font-weight: 600; color: var(--muted); }
.chat-layout .msg-thread.drop-on, [data-team-thread].drop-on { outline: 2px dashed var(--brand); outline-offset: -6px; }
.chat-tick.read { color: #8fdcff; opacity: 1; }
.bubble:not(.mine) .chat-tick.read { color: #2b8ac6; }
.bubble a { color: inherit; text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }
.chat-new { display: flex; align-items: center; gap: 10px; margin: 12px 0 6px; color: var(--brand); font-size: 11.5px; font-weight: 700; }
.chat-new::before, .chat-new::after { content: ""; flex: 1; height: 1px; background: color-mix(in srgb, var(--brand) 35%, transparent); }
.chat-author { margin: 8px 6px 0; font-size: 11px; font-weight: 600; color: var(--muted); }
.chat-author.mine { align-self: flex-end; }
/* The small arrow that opens Copier / Supprimer (computers; long press on phones) */
.bubble-more { position: absolute; top: 4px; right: 4px; display: grid; place-items: center; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%; background: color-mix(in srgb, var(--surface) 85%, transparent); color: var(--ink-2); cursor: pointer; opacity: 0; transition: opacity 0.15s; }
.bubble.mine .bubble-more { background: color-mix(in srgb, var(--brand) 70%, #000 10%); color: var(--brand-ink); }
.bubble:hover .bubble-more, .bubble-more:focus-visible { opacity: 1; }
@media (hover: none) {
  .bubble-more { display: none; }
  .bubble { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
}
.chat-actions { display: flex; gap: 2px; flex: none; }
.team-tools-row { display: flex; gap: 8px; align-items: center; }
.team-tools-row .search-box { flex: 1; min-width: 0; }
.team-tools-row .btn { flex: none; }
.chat-quick { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -2px; padding: 0 2px 2px; }
.chat-quick::-webkit-scrollbar { display: none; }
.chat-quick .chip { white-space: nowrap; flex: none; }
.chat-form-foot { display: flex; justify-content: space-between; align-items: center; gap: 4px 12px; flex-wrap: wrap; padding: 0 4px; }
.chat-layout .application-card, .chat-layout .msg-context { flex: none; }
/* Copier / Supprimer: a sheet at the bottom on phones, a small card on computers */
.dialog.dialog-sheet { width: min(360px, calc(100vw - 32px)); padding: 10px; }
.chat-sheet { display: grid; gap: 4px; }
.chat-sheet-quote { margin: 4px 6px 8px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); font-size: 13.5px; color: var(--ink-2); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 140px; overflow: auto; }
.chat-sheet-btn { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 46px; padding: 0 14px; border: 0; border-radius: 12px; background: transparent; color: var(--ink); font: inherit; font-weight: 600; text-align: left; cursor: pointer; }
.chat-sheet-btn:hover { background: var(--surface-2); }
.chat-sheet-btn.danger { color: var(--danger); }
.chat-sheet-btn:last-child { justify-content: center; color: var(--muted); }
@media (max-width: 560px) {
  .dialog-wrap:has(.dialog-sheet) { align-items: flex-end; }
  .dialog.dialog-sheet { width: 100%; max-width: none; border-radius: 18px 18px 0 0; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
}

/* Writing */
.chat-form { display: grid; gap: 8px; padding: 8px 10px; border-top: 1px solid var(--line); background: var(--surface); }
.chat-compose { display: flex; align-items: flex-end; gap: 6px; }
.chat-compose textarea { flex: 1; min-height: 42px; max-height: 140px; padding: 10px 14px; border-radius: 21px; border: 1px solid var(--line-strong); background: var(--bg); color: var(--ink); font: inherit; font-size: 15px; line-height: 1.35; resize: none; overflow-y: auto; }
.chat-compose textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--focus); }
.chat-icon-btn, .chat-send { flex: none; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; border: 0; cursor: pointer; }
.chat-icon-btn { color: var(--ink-2); background: transparent; }
.chat-icon-btn:hover { background: var(--surface-2); color: var(--brand); }
.chat-send { background: var(--brand); color: var(--brand-ink); transition: transform 0.15s, opacity 0.15s; }
.chat-send:disabled { opacity: 0.35; cursor: default; }
.chat-send:not(:disabled):active { transform: scale(0.92); }
.chat-preview-x { position: absolute; top: -7px; right: -7px; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--surface); background: var(--ink); color: var(--surface); cursor: pointer; }

/* Phones: the list fills the screen; an open conversation takes the whole screen, like a messaging app */
@media (max-width: 900px) {
  .msg-switch { display: flex; }
  .msg-switch a { flex: 1; justify-content: center; }
  .chat-back { display: inline-grid; }
  .chat-compose textarea { font-size: 16px; } /* no zoom-in on iPhone */
  .team-row { padding-top: 12px; padding-bottom: 12px; }
  .team-tools-row .btn span { display: none; }
  .chat-form-foot > span { display: none; }
  body.chat-open .bottom-nav, body.chat-open .msg-switch { display: none; }
  body.chat-open .view { padding-bottom: 0; }
  body.chat-open .chat-layout.has-thread { height: calc(100dvh - var(--topbar-h, 64px) - 16px); min-height: 0; margin: 0 -16px; }
  body.chat-open .chat-layout.has-thread .msg-thread { border-radius: 0; border-left: 0; border-right: 0; border-bottom: 0; box-shadow: none; }
  body.chat-open .chat-form { padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .bubble { max-width: 84%; }
}
.chat-who .chat-silent { display: flex; align-items: flex-start; gap: 4px; margin-top: 2px; color: var(--warning); white-space: normal; line-height: 1.3; }
.chat-who .chat-silent .icon-xs { flex: none; margin-top: 1px; }
