/* =========================================================================
   SlotlyAI Business Dashboard — design system  (v2, refined)
   Light theme by default, dark mode via [data-theme="dark"].
   ========================================================================= */

:root {
  --brand-50:  #eef2ff;
  --brand-100: #e0e7ff;
  --brand-200: #c7d2fe;
  --brand-300: #a5b4fc;
  --brand-400: #818cf8;
  --brand-500: #6366f1;
  --brand-600: #4f46e5;
  --brand-700: #4338ca;

  --wa-green: #25d366;

  --bg:         #f4f5fa;
  --bg-grad:    radial-gradient(1200px 500px at 100% -10%, #eceeffcc, transparent 60%);
  --surface:    #ffffff;
  --surface-2:  #f7f8fb;
  --surface-3:  #f1f2f7;
  --border:     #e7e9f0;
  --border-2:   #eef0f5;

  --text:      #171a23;
  --text-soft: #5a6474;
  --text-mute: #939cac;

  --success:   #0ea472;
  --success-bg:#e4f7ef;
  --warning:   #e08600;
  --warning-bg:#fdf1de;
  --danger:    #e5484d;
  --danger-bg: #fdeceb;
  --info:      #3b74f5;
  --info-bg:   #e9f0fe;
  --neutral-bg:#eef0f5;

  --radius:    16px;
  --radius-sm: 10px;
  --radius-lg: 22px;

  --shadow-xs: 0 1px 2px rgba(20,26,45,.05);
  --shadow-sm: 0 1px 2px rgba(20,26,45,.05), 0 2px 6px rgba(20,26,45,.05);
  --shadow-md: 0 6px 16px rgba(20,26,45,.09);
  --shadow-lg: 0 18px 44px rgba(20,26,45,.18);

  --sidebar-w: 258px;
  --topbar-h: 66px;
  --content-max: 1200px;

  --font: "Inter", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

[data-theme="dark"] {
  --bg:         #0d1016;
  --bg-grad:    radial-gradient(1200px 500px at 100% -10%, #1c2140aa, transparent 60%);
  --surface:    #161a22;
  --surface-2:  #1c212b;
  --surface-3:  #222834;
  --border:     #2b313d;
  --border-2:   #242a35;

  --text:      #e9ebf1;
  --text-soft: #a7aec0;
  --text-mute: #6f7a8c;

  --success-bg:#0f3128;
  --warning-bg:#352a12;
  --danger-bg: #3a2020;
  --info-bg:   #16233c;
  --neutral-bg:#232935;

  --shadow-xs: 0 1px 2px rgba(0,0,0,.3);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.35);
  --shadow-md: 0 8px 22px rgba(0,0,0,.45);
  --shadow-lg: 0 22px 50px rgba(0,0,0,.6);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--brand-600); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 680; letter-spacing: -.015em; }
button { font-family: inherit; }
[hidden] { display: none !important; }
::selection { background: var(--brand-200); }

/* ---------- App boot ---------- */
.app-boot {
  position: fixed; inset: 0; display: grid; place-content: center; gap: 22px;
  justify-items: center; background: var(--bg); z-index: 9999;
}
.app-boot__logo { font-size: 27px; font-weight: 750; letter-spacing: -.025em; }
.app-boot__logo span { color: var(--brand-600); }
.spinner {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid var(--brand-100); border-top-color: var(--brand-600);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Auth screen (login / register) ---------- */
.auth-screen {
  min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr;
  background: var(--bg);
}
.auth-hero {
  background: linear-gradient(150deg, var(--brand-600), var(--brand-700) 60%, #3b2fae);
  color: #fff; padding: 56px 60px; display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.auth-hero::after {
  content: ""; position: absolute; right: -120px; bottom: -120px; width: 380px; height: 380px;
  border-radius: 50%; background: rgba(255,255,255,.08);
}
.auth-hero__brand { display: flex; align-items: center; gap: 12px; font-weight: 750; font-size: 20px; letter-spacing: -.02em; }
.auth-hero__brand .brand-mark { background: rgba(255,255,255,.16); box-shadow: none; }
.auth-hero__pitch h2 { font-size: 30px; line-height: 1.2; letter-spacing: -.02em; max-width: 15ch; }
.auth-hero__pitch p { margin-top: 14px; color: #dfe0ff; font-size: 14.5px; max-width: 40ch; }
.auth-hero__list { margin-top: 26px; display: flex; flex-direction: column; gap: 12px; }
.auth-hero__list div { display: flex; align-items: center; gap: 11px; font-size: 13.5px; color: #eef0ff; }
.auth-hero__list svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .9; }
.auth-hero__foot { font-size: 12px; color: #c8caf5; }

.auth-panel { display: flex; align-items: center; justify-content: center; padding: 40px 28px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 22px; }
.auth-card > p.sub { color: var(--text-soft); font-size: 13.5px; margin: 6px 0 22px; }
.auth-card form { margin-top: 4px; }
.auth-card .btn { width: 100%; margin-top: 6px; padding: 11px 16px; }
.auth-alt { margin-top: 18px; font-size: 13px; color: var(--text-soft); text-align: center; }
.auth-alt button { background: none; border: none; color: var(--brand-600); font-weight: 650; cursor: pointer; font-size: 13px; }
.auth-demo {
  margin-top: 18px; padding: 12px 14px; border: 1px dashed var(--border); border-radius: 12px;
  background: var(--surface-2); font-size: 12.5px; color: var(--text-soft);
}
.auth-demo b { color: var(--text); }
.auth-error {
  background: var(--danger-bg); color: var(--danger); border-radius: 10px;
  padding: 10px 13px; font-size: 12.5px; font-weight: 550; margin-bottom: 16px;
}
@media (max-width: 900px) {
  .auth-screen { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .auth-panel { padding: 32px 20px; }
}

/* ---------- Shell layout ---------- */
#app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  z-index: 60;
}
.sidebar__brand {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 18px 16px;
}
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(140deg, var(--brand-400), var(--brand-700));
  color: #fff; font-weight: 800; font-size: 19px;
  display: grid; place-content: center; flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(79,70,229,.35);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-name { font-size: 16.5px; font-weight: 750; letter-spacing: -.02em; }
.brand-name b { color: var(--brand-600); font-weight: 750; }
.brand-tag { font-size: 11px; color: var(--text-mute); font-weight: 500; white-space: nowrap; }
.sidebar__close.icon-btn { display: none; margin-left: auto; }

.nav { padding: 8px 12px; overflow-y: auto; flex: 1; }
.nav::-webkit-scrollbar { width: 6px; }
.nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.nav__section {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .09em; color: var(--text-mute); padding: 16px 12px 7px;
}
.nav a, .sidebar__footer a {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: 10px;
  color: var(--text-soft); font-weight: 550; font-size: 13.5px;
  margin-bottom: 1px; transition: background .13s, color .13s;
  white-space: nowrap;
}
.nav a svg, .sidebar__footer a svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .8; }
.nav a:hover, .sidebar__footer a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active {
  background: var(--brand-50); color: var(--brand-700); font-weight: 620;
}
.nav a.active svg { opacity: 1; }
.nav a.active::before {
  content: ""; position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 0 3px 3px 0; background: var(--brand-600);
}
[data-theme="dark"] .nav a.active { background: rgba(99,102,241,.16); color: var(--brand-300); }

.sidebar__footer {
  padding: 10px 12px 14px; border-top: 1px solid var(--border-2);
  display: flex; flex-direction: column; gap: 1px;
}

.sidebar-scrim {
  position: fixed; inset: 0; background: rgba(13,16,22,.5); backdrop-filter: blur(2px);
  z-index: 55; display: none;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ---------- Topbar ---------- */
.topbar {
  height: var(--topbar-h); flex-shrink: 0;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 40;
}
.topbar__menu.icon-btn { display: none; }
.topbar__biz { min-width: 0; }
.biz-switcher {
  appearance: none; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  font-weight: 650; font-size: 14px; font-family: inherit;
  padding: 8px 34px 8px 13px; border-radius: 10px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23939cac' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
  max-width: 260px; transition: border-color .13s, box-shadow .13s;
}
.biz-switcher:hover { border-color: var(--brand-300); }
.topbar__right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.topbar__date {
  font-size: 12.5px; color: var(--text-mute); white-space: nowrap; font-weight: 500;
  padding-right: 4px;
}

.wa-status {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 11px; border-radius: 999px;
  background: var(--neutral-bg); font-size: 12px; font-weight: 620;
  color: var(--text-soft); white-space: nowrap;
}
.wa-status .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-mute); }
.wa-status.is-connected { background: var(--success-bg); color: var(--success); }
.wa-status.is-connected .dot { background: var(--wa-green); box-shadow: 0 0 0 3px rgba(37,211,102,.2); }
.wa-status.is-disconnected { background: var(--danger-bg); color: var(--danger); }
.wa-status.is-disconnected .dot { background: var(--danger); }

.icon-btn {
  display: inline-grid; place-content: center;
  width: 37px; height: 37px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-soft); cursor: pointer; transition: background .13s, color .13s, border-color .13s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.icon-btn:active { transform: translateY(.5px); }

.avatar {
  width: 37px; height: 37px; border-radius: 50%;
  background: linear-gradient(140deg, var(--brand-400), var(--brand-700));
  color: #fff; font-weight: 700; font-size: 13px;
  display: grid; place-content: center; cursor: pointer; flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(79,70,229,.32);
}

/* ---------- Content ---------- */
.content { padding: 28px 30px 56px; max-width: var(--content-max); width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head__text h1 { font-size: 23px; line-height: 1.25; }
.page-head__text p { margin: 5px 0 0; color: var(--text-soft); font-size: 13.5px; max-width: 640px; }
.page-head__actions { margin-left: auto; display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: 10px; font-weight: 620; font-size: 13.5px;
  border: 1px solid transparent; cursor: pointer;
  transition: background .13s, box-shadow .13s, border-color .13s, transform .05s;
  white-space: nowrap;
}
.btn:active { transform: translateY(.5px); }
.btn svg { width: 16px; height: 16px; }
.btn--primary {
  background: linear-gradient(180deg, var(--brand-500), var(--brand-600));
  color: #fff; box-shadow: 0 3px 10px rgba(79,70,229,.32);
}
.btn--primary:hover { background: linear-gradient(180deg, var(--brand-600), var(--brand-700)); }
.btn--ghost { background: var(--surface); border-color: var(--border); color: var(--text); box-shadow: var(--shadow-xs); }
.btn--ghost:hover { background: var(--surface-2); border-color: var(--brand-300); }
.btn--subtle { background: var(--surface-2); color: var(--text-soft); }
.btn--subtle:hover { background: var(--surface-3); color: var(--text); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { filter: brightness(.94); }
.btn--sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; gap: 6px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card__head {
  padding: 16px 20px; border-bottom: 1px solid var(--border-2);
  display: flex; align-items: center; gap: 12px;
}
.card__head h3 { font-size: 15px; font-weight: 680; }
.card__head .card__action { margin-left: auto; }
.card__body { padding: 20px; }
.card__body--flush { padding: 0; }

/* ---------- KPI grid + secondary stat strip ---------- */
.kpi-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 16px;
}
.kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 17px 18px; box-shadow: var(--shadow-sm);
  transition: box-shadow .15s, transform .15s;
}
.kpi:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.kpi__label { font-size: 12.5px; color: var(--text-mute); font-weight: 600; display: flex; align-items: center; gap: 9px; }
.kpi__icon { width: 32px; height: 32px; border-radius: 10px; display: grid; place-content: center; flex-shrink: 0; }
.kpi__icon svg { width: 16px; height: 16px; }
.kpi__value { font-size: 28px; font-weight: 740; margin-top: 12px; letter-spacing: -.025em; line-height: 1; }
.kpi__sub { font-size: 11.5px; color: var(--text-mute); margin-top: 7px; }
.kpi--indigo .kpi__icon { background: var(--brand-50); color: var(--brand-600); }
.kpi--green  .kpi__icon { background: var(--success-bg); color: var(--success); }
.kpi--amber  .kpi__icon { background: var(--warning-bg); color: var(--warning); }
.kpi--red    .kpi__icon { background: var(--danger-bg); color: var(--danger); }
.kpi--blue   .kpi__icon { background: var(--info-bg); color: var(--info); }

.stat-strip {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  margin-bottom: 24px; overflow: hidden;
}
.stat { padding: 16px 20px; display: flex; align-items: center; gap: 13px; border-left: 1px solid var(--border-2); }
.stat:first-child { border-left: none; }
.stat__icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-content: center; flex-shrink: 0; background: var(--surface-2); color: var(--text-soft); }
.stat__icon.tone-green { background: var(--success-bg); color: var(--success); }
.stat__icon.tone-indigo { background: var(--brand-50); color: var(--brand-600); }
.stat__icon svg { width: 17px; height: 17px; }
.stat__meta { min-width: 0; }
.stat__value { font-size: 18px; font-weight: 720; letter-spacing: -.02em; }
.stat__label { font-size: 11.5px; color: var(--text-mute); font-weight: 550; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table-wrap::-webkit-scrollbar { height: 8px; }
.table-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 640px; }
table.data th {
  text-align: left; padding: 12px 18px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--text-mute);
  border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap;
}
table.data td { padding: 14px 18px; border-bottom: 1px solid var(--border-2); vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr { transition: background .1s; }
table.data tbody tr:hover { background: var(--surface-2); }
.cell-strong { font-weight: 620; }
.cell-mute { color: var(--text-mute); font-size: 12.5px; }
.row-actions { text-align: right; white-space: nowrap; }
.row-actions .btn { margin-left: 6px; }
.act-icons { display: inline-flex; gap: 4px; justify-content: flex-end; }
.act-ic {
  width: 30px; height: 30px; border-radius: 8px; display: inline-grid; place-content: center;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-soft);
  cursor: pointer; transition: background .12s, color .12s, border-color .12s;
}
.act-ic svg { width: 15px; height: 15px; }
.act-ic:hover { background: var(--surface-2); color: var(--text); }
.act-ic.danger:hover { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-bg); }
.act-ic.go:hover { background: var(--brand-50); color: var(--brand-600); border-color: var(--brand-100); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 640;
  background: var(--neutral-bg); color: var(--text-soft); line-height: 1.4;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--confirmed { background: var(--info-bg); color: var(--info); }
.badge--pending   { background: var(--warning-bg); color: var(--warning); }
.badge--completed { background: var(--success-bg); color: var(--success); }
.badge--cancelled { background: var(--danger-bg); color: var(--danger); }
.badge--noshow    { background: var(--neutral-bg); color: var(--text-mute); }
.badge--active    { background: var(--success-bg); color: var(--success); }
.badge--inactive  { background: var(--neutral-bg); color: var(--text-mute); }
.badge--wa        { background: var(--success-bg); color: var(--success); }
.badge--manual    { background: var(--brand-50); color: var(--brand-600); }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field > label { display: block; font-size: 12.5px; font-weight: 640; margin-bottom: 6px; color: var(--text); }
.field .hint { font-size: 11.5px; color: var(--text-mute); margin-top: 5px; }
.field .err { font-size: 11.5px; color: var(--danger); margin-top: 5px; display: none; font-weight: 550; }
.field.has-error .err { display: block; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger); }
input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--surface); color: var(--text);
  font-family: inherit; font-size: 13.5px; transition: border-color .13s, box-shadow .13s;
}
input::placeholder, textarea::placeholder { color: var(--text-mute); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand-400);
  box-shadow: 0 0 0 3.5px var(--brand-50);
}
[data-theme="dark"] input:focus, [data-theme="dark"] select:focus, [data-theme="dark"] textarea:focus {
  box-shadow: 0 0 0 3.5px rgba(99,102,241,.2);
}
textarea { resize: vertical; min-height: 78px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 11px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch__track {
  width: 42px; height: 24px; border-radius: 999px; background: var(--border);
  position: relative; transition: background .16s; flex-shrink: 0;
}
.switch__track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; transition: transform .16s; box-shadow: var(--shadow-sm);
}
.switch input:checked + .switch__track { background: var(--brand-600); }
.switch input:checked + .switch__track::after { transform: translateX(18px); }

/* ---------- Toolbar (search + filters) ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; align-items: center; }
.search { position: relative; flex: 1; min-width: 220px; max-width: 380px; }
.search input { padding-left: 36px; background: var(--surface); }
.search svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--text-mute); pointer-events: none;
}
.filter-select { min-width: 150px; width: auto; }
.chip-group { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  padding: 7px 13px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-soft); font-size: 12.5px; font-weight: 600;
  cursor: pointer; transition: background .12s, color .12s, border-color .12s;
}
.chip:hover { border-color: var(--brand-300); color: var(--text); }
.chip.active { background: var(--brand-600); color: #fff; border-color: var(--brand-600); }

/* ---------- Empty / error states ---------- */
.state { text-align: center; padding: 52px 24px; color: var(--text-soft); }
.state__icon {
  width: 60px; height: 60px; border-radius: 18px; margin: 0 auto 18px;
  background: var(--surface-2); display: grid; place-content: center;
}
.state__icon svg { width: 27px; height: 27px; color: var(--text-mute); }
.state h3 { font-size: 16.5px; color: var(--text); }
.state p { margin: 7px auto 20px; max-width: 400px; font-size: 13.5px; }
.state--error .state__icon { background: var(--danger-bg); }
.state--error .state__icon svg { color: var(--danger); }

/* ---------- Skeletons ---------- */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%; animation: shimmer 1.3s ease-in-out infinite;
  border-radius: 8px;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.skeleton-row { height: 48px; margin-bottom: 10px; }
.skeleton-kpi { height: 112px; border-radius: var(--radius); }

/* ---------- Toasts ---------- */
.toast-root {
  position: fixed; right: 22px; bottom: 22px; z-index: 9998;
  display: flex; flex-direction: column; gap: 10px; max-width: 380px;
}
.toast {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--text-mute);
  border-radius: 12px; padding: 13px 15px; box-shadow: var(--shadow-lg);
  display: flex; gap: 10px; align-items: flex-start;
  animation: toast-in .24s cubic-bezier(.2,.8,.3,1);
}
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.toast.leaving { opacity: 0; transform: translateY(8px); transition: .2s; }
.toast--success { border-left-color: var(--success); }
.toast--error   { border-left-color: var(--danger); }
.toast--info    { border-left-color: var(--info); }
.toast__body { font-size: 13px; }
.toast__title { font-weight: 660; margin-bottom: 2px; }
.toast__close { margin-left: auto; background: none; border: none; color: var(--text-mute); cursor: pointer; font-size: 16px; line-height: 1; }

/* ---------- Modal / drawer ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(13,16,22,.52);
  backdrop-filter: blur(3px);
  z-index: 9990; display: flex; animation: fade .16s ease;
}
@keyframes fade { from { opacity: 0; } }
.overlay--center { align-items: center; justify-content: center; padding: 20px; }
.overlay--right { justify-content: flex-end; }
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg); animation: modal-in .22s cubic-bezier(.2,.8,.3,1);
  border: 1px solid var(--border);
}
@keyframes modal-in { from { opacity: 0; transform: translateY(14px) scale(.97); } }
.drawer {
  background: var(--surface); width: 100%; max-width: 448px; height: 100vh;
  overflow-y: auto; box-shadow: var(--shadow-lg); animation: drawer-in .24s cubic-bezier(.2,.8,.3,1);
  border-left: 1px solid var(--border);
}
@keyframes drawer-in { from { transform: translateX(30px); opacity: .5; } }
.modal__head, .drawer__head {
  padding: 19px 22px; border-bottom: 1px solid var(--border-2);
  display: flex; align-items: center; gap: 12px; position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.modal__head h3, .drawer__head h3 { font-size: 16.5px; }
.modal__head .icon-btn, .drawer__head .icon-btn { margin-left: auto; width: 32px; height: 32px; }
.modal__body, .drawer__body { padding: 22px; }
.modal__foot {
  padding: 16px 22px; border-top: 1px solid var(--border-2);
  display: flex; gap: 10px; justify-content: flex-end; position: sticky; bottom: 0; background: var(--surface);
}

/* ---------- Definition list ---------- */
.dl { display: grid; grid-template-columns: 132px 1fr; gap: 11px 16px; font-size: 13.5px; }
.dl dt { color: var(--text-mute); font-weight: 520; }
.dl dd { margin: 0; font-weight: 560; }

/* ---------- Calendar ---------- */
.cal-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.cal-toolbar .seg { display: flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); }
.cal-toolbar .seg button { padding: 8px 15px; border: none; background: transparent; color: var(--text-soft); font-weight: 620; font-size: 12.5px; cursor: pointer; transition: background .12s; }
.cal-toolbar .seg button:hover { background: var(--surface-2); }
.cal-toolbar .seg button.active { background: var(--brand-600); color: #fff; }
.cal-grid-month { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.cal-dow { background: var(--surface-2); padding: 9px; text-align: center; font-size: 10.5px; font-weight: 700; color: var(--text-mute); text-transform: uppercase; letter-spacing: .05em; }
.cal-cell { background: var(--surface); min-height: 104px; padding: 7px 9px; font-size: 12px; }
.cal-cell.out { background: var(--surface-2); color: var(--text-mute); }
.cal-cell.today .cal-cell__n { background: var(--brand-600); color: #fff; }
.cal-cell__n { display: inline-grid; place-content: center; width: 23px; height: 23px; border-radius: 50%; font-weight: 660; margin-bottom: 5px; }
.cal-ev { background: var(--brand-50); color: var(--brand-700); border-radius: 6px; padding: 3px 7px; margin-bottom: 3px; font-size: 11px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.cal-ev:hover { background: var(--brand-100); }
[data-theme="dark"] .cal-ev { background: rgba(99,102,241,.18); color: var(--brand-300); }
.cal-day-list { display: flex; flex-direction: column; }
.cal-slot { display: grid; grid-template-columns: 84px 1fr; gap: 16px; padding: 13px 4px; border-bottom: 1px solid var(--border-2); }
.cal-slot:last-child { border-bottom: none; }
.cal-slot__t { font-size: 12.5px; font-weight: 660; color: var(--text-mute); padding-top: 2px; }
.cal-slot__ev { background: var(--surface-2); border: 1px solid var(--border-2); border-left: 3px solid var(--brand-500); border-radius: 10px; padding: 10px 13px; cursor: pointer; transition: background .12s; }
.cal-slot__ev:hover { background: var(--brand-50); }

/* ---------- Working hours ---------- */
.wh-row { display: grid; grid-template-columns: 130px 96px 1fr 1fr; gap: 16px; align-items: center; padding: 15px 0; border-bottom: 1px solid var(--border-2); }
.wh-row:last-child { border-bottom: none; }
.wh-row__day { font-weight: 640; }
.wh-row.closed input[type="time"] { opacity: .35; pointer-events: none; }

/* ---------- WhatsApp phone preview ---------- */
.wa-preview-wrap { display: flex; gap: 30px; flex-wrap: wrap; align-items: flex-start; }
.phone {
  width: 328px; flex-shrink: 0; background: #0b141a; border-radius: 38px; padding: 13px;
  box-shadow: var(--shadow-lg); border: 2px solid #1e2a33;
}
.phone__screen { background: #0b141a; border-radius: 26px; overflow: hidden; }
.phone__bar { background: #1f2c33; color: #e9edef; padding: 13px 16px; font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 10px; }
.phone__bar .av { width: 30px; height: 30px; border-radius: 50%; background: var(--wa-green); display: grid; place-content: center; color: #05330f; font-weight: 800; }
.phone__body {
  background: #0b141a url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40'%3E%3Ccircle cx='4' cy='4' r='1' fill='%23ffffff08'/%3E%3C/svg%3E");
  padding: 15px; height: 468px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px;
}
.wa-msg { max-width: 82%; padding: 8px 11px; border-radius: 10px; font-size: 12.5px; line-height: 1.5; color: #e9edef; white-space: pre-wrap; box-shadow: 0 1px 1px rgba(0,0,0,.2); }
.wa-msg--in { background: #1f2c33; align-self: flex-start; border-top-left-radius: 3px; }
.wa-msg--out { background: #005c4b; align-self: flex-end; border-top-right-radius: 3px; }
.wa-btns { display: flex; flex-direction: column; gap: 5px; align-self: stretch; }
.wa-btn { background: #1f2c33; color: #53bdeb; border: 1px solid #2a3942; border-radius: 8px; padding: 10px; font-size: 12.5px; font-weight: 600; text-align: center; cursor: pointer; transition: background .12s; }
.wa-btn:hover { background: #26343d; }
.wa-preview-note { flex: 1; min-width: 280px; }

/* ---------- Misc ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.grid-cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.list-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 17px; box-shadow: var(--shadow-sm); }
.list-card h4 { font-size: 14.5px; }
.list-card .meta { color: var(--text-mute); font-size: 12.5px; margin-top: 3px; }
.mono { font-variant-numeric: tabular-nums; }
details { border-bottom: 1px solid var(--border-2); }
details summary::-webkit-details-marker { display: none; }
details summary { list-style: none; }
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 20px; }
.pagination button { padding: 7px 12px; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; cursor: pointer; font-size: 12.5px; color: var(--text-soft); }
.pagination button.active { background: var(--brand-600); color: #fff; border-color: var(--brand-600); }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- Setup wizard ---------- */
.wiz { display: grid; grid-template-columns: 236px 1fr; gap: 24px; align-items: start; }
.wiz__rail {
  position: sticky; top: calc(var(--topbar-h) + 20px);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 18px;
}
.wiz__progress { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin-bottom: 10px; }
.wiz__progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand-500), var(--brand-600)); border-radius: 999px; transition: width .3s ease; }
.wiz__steps { display: flex; flex-direction: column; gap: 2px; }
.wiz__step {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
  padding: 9px 10px; border-radius: 10px; border: none; background: none; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--text-soft);
  transition: background .12s, color .12s;
}
.wiz__step:hover { background: var(--surface-2); color: var(--text); }
.wiz__step.is-active { background: var(--brand-50); color: var(--brand-700); }
[data-theme="dark"] .wiz__step.is-active { background: rgba(99,102,241,.16); color: var(--brand-300); }
.wiz__dot {
  width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-content: center; font-size: 11px; font-weight: 700;
  border: 2px solid var(--border); color: var(--text-mute); background: var(--surface);
}
.wiz__step.is-active .wiz__dot { border-color: var(--brand-500); color: var(--brand-600); }
.wiz__dot.is-done { background: var(--success); border-color: var(--success); color: #fff; }
.wiz__dot.is-done svg { width: 12px; height: 12px; }
.wiz__opt { margin-left: auto; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-mute); }

.wiz__main { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.wiz__head { padding: 22px 24px 18px; border-bottom: 1px solid var(--border-2); }
.wiz__head h2 { font-size: 19px; }
.wiz__head p { margin: 6px 0 0; color: var(--text-soft); font-size: 13.5px; max-width: 60ch; }
.wiz__panel { padding: 24px; }
.wiz__foot { padding: 16px 24px; border-top: 1px solid var(--border-2); display: flex; gap: 10px; align-items: center; }
.wiz__foot .spacer { flex: 1; }

.wiz-note { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; font-size: 12.5px; font-weight: 550; margin-bottom: 16px; }
.wiz-note svg { flex-shrink: 0; margin-top: 1px; }
.wiz-note--warn { background: var(--warning-bg); color: var(--warning); }
.wiz-note--ok { background: var(--success-bg); color: var(--success); }
.wiz-note--info { background: var(--info-bg); color: var(--info); }

.wiz-mini { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 2px; }
.wiz-pill { display: inline-flex; align-items: center; gap: 7px; padding: 6px 11px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border-2); font-size: 12.5px; font-weight: 600; }

.wiz-matrix { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
.wiz-matrix table { border-collapse: collapse; width: 100%; font-size: 13px; }
.wiz-matrix th, .wiz-matrix td { padding: 10px 12px; border-bottom: 1px solid var(--border-2); text-align: center; white-space: nowrap; }
.wiz-matrix thead th { background: var(--surface-2); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-mute); }
.wiz-matrix th:first-child, .wiz-matrix td:first-child { text-align: left; font-weight: 620; position: sticky; left: 0; background: var(--surface); }
.wiz-matrix thead th:first-child { background: var(--surface-2); }
.wiz-matrix tr:last-child td { border-bottom: none; }
.wiz-matrix input { width: 18px; height: 18px; }

.setup-banner {
  display: flex; align-items: center; gap: 14px; padding: 16px 18px; margin-bottom: 20px;
  border-radius: var(--radius); border: 1px solid var(--brand-100);
  background: linear-gradient(120deg, var(--brand-50), var(--surface));
}
[data-theme="dark"] .setup-banner { background: rgba(99,102,241,.1); border-color: rgba(99,102,241,.25); }
.setup-banner__txt { flex: 1; min-width: 0; }
.setup-banner__txt b { font-size: 14px; }
.setup-banner__txt p { margin: 3px 0 0; font-size: 12.5px; color: var(--text-soft); }
.setup-banner__bar { height: 6px; width: 140px; max-width: 40vw; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin-top: 8px; }
.setup-banner__bar > i { display: block; height: 100%; background: var(--brand-600); }

.nav a .nav-badge { margin-left: auto; background: var(--warning); color: #fff; font-size: 10.5px; font-weight: 700; border-radius: 999px; padding: 1px 7px; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 1000px) {
  .wiz { grid-template-columns: 1fr; }
  .wiz__rail { position: static; }
  .wiz__steps { flex-direction: row; overflow-x: auto; }
  .wiz__step .lbl { display: none; }
  .wiz__step { flex-shrink: 0; }
}
@media (max-width: 1000px) {
  .sidebar {
    position: fixed; left: 0; top: 0; transform: translateX(-100%);
    transition: transform .24s cubic-bezier(.2,.8,.3,1); box-shadow: var(--shadow-lg);
  }
  #app-shell.nav-open .sidebar { transform: translateX(0); }
  #app-shell.nav-open .sidebar-scrim { display: block; }
  .sidebar__close.icon-btn { display: inline-grid; }
  .topbar__menu.icon-btn { display: inline-grid; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .content { padding: 20px 16px 64px; }
  .topbar { padding: 0 14px; gap: 10px; }
  .topbar__date, .wa-status__label { display: none; }
  .biz-switcher { max-width: 148px; font-size: 13px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .kpi__value { font-size: 24px; }
  .stat-strip { grid-template-columns: 1fr; }
  .stat { border-left: none; border-top: 1px solid var(--border-2); }
  .stat:first-child { border-top: none; }
  .field-row { grid-template-columns: 1fr; }
  .wh-row { grid-template-columns: 1fr 1fr; gap: 10px 12px; }
  .wh-row__day { grid-column: 1 / -1; }
  .page-head__text h1 { font-size: 20px; }

  /* tables -> cards */
  table.data { min-width: 0; }
  table.data thead { display: none; }
  table.data, table.data tbody, table.data tr, table.data td { display: block; width: 100%; }
  table.data tr { border: 1px solid var(--border); border-radius: 14px; margin-bottom: 12px; padding: 8px 6px; background: var(--surface); }
  table.data td { border: none; padding: 8px 12px; display: flex; justify-content: space-between; gap: 12px; align-items: center; }
  table.data td::before {
    content: attr(data-label); font-weight: 660; color: var(--text-mute);
    font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  }
  table.data td.row-actions { justify-content: flex-end; padding-top: 10px; }
  table.data td.row-actions::before { display: none; }
  .row-actions .btn { margin-left: 0; margin-right: 6px; }
  .phone { width: 100%; }
}
