/* ============================================================
   Reegal Connect — App design system
   A mobile-app shell (top bar + bottom tabs + sheets + chat)
   that scales up to tablet/desktop without turning into a
   generic admin website.
   ============================================================ */

:root{
  --bg:#F4F2FB;
  --surface:#FFFFFF;
  --surface-2:#F7F6FC;
  --surface-3:#EFEBFB;
  --border:#E7E3F6;
  --text:#1C1830;
  --text-dim:#6B6580;
  --text-faint:#9A94AE;
  --primary:#6C4CF1;
  --primary-600:#5A3AE0;
  --primary-100:#EDE7FD;
  --accent:#FF9F43;
  --success:#1FAA6B;
  --success-100:#E4F8EE;
  --warning:#E8A100;
  --warning-100:#FFF3DC;
  --danger:#E64E5C;
  --danger-100:#FDEAEB;
  --info:#3B82D8;
  --info-100:#E8F1FD;
  --radius-xl:26px;
  --radius-lg:20px;
  --radius-md:14px;
  --radius-sm:10px;
  --shadow-soft:0 8px 24px -8px rgba(70,53,145,.16);
  --shadow-pop:0 16px 40px -12px rgba(70,53,145,.28);
  --topbar-h:64px;
  --nav-h:66px;
  --safe-t:env(safe-area-inset-top,0px);
  --safe-b:env(safe-area-inset-bottom,0px);
  --font:'Manrope','Segoe UI',system-ui,-apple-system,sans-serif;
  color-scheme:light;
}
:root:not([data-theme="light"]){
  @media (prefers-color-scheme: dark){
    --bg:#141221; --surface:#1D1A2E; --surface-2:#232037; --surface-3:#2B2745;
    --border:#332F4E; --text:#F1EFFB; --text-dim:#B3ADCB; --text-faint:#8B84A6;
    --primary:#8A6CFF; --primary-600:#7A5AFA; --primary-100:#2B2452;
    --success-100:#123326; --warning-100:#3A2E0A; --danger-100:#3A1B1F; --info-100:#152C40;
    color-scheme:dark;
  }
}
/* Explicit user choice (saved to localStorage) always wins over the OS preference above. */
:root[data-theme="dark"]{
  --bg:#141221; --surface:#1D1A2E; --surface-2:#232037; --surface-3:#2B2745;
  --border:#332F4E; --text:#F1EFFB; --text-dim:#B3ADCB; --text-faint:#8B84A6;
  --primary:#8A6CFF; --primary-600:#7A5AFA; --primary-100:#2B2452;
  --success-100:#123326; --warning-100:#3A2E0A; --danger-100:#3A1B1F; --info-100:#152C40;
  color-scheme:dark;
}
:root[data-theme="light"]{ color-scheme:light; }

*{box-sizing:border-box;}
html{scroll-padding-top:calc(var(--topbar-h) + var(--safe-t));-webkit-text-size-adjust:100%;}
body{
  margin:0;font-family:var(--font);background:var(--bg);color:var(--text);
  -webkit-font-smoothing:antialiased;line-height:1.45;
}
a{color:inherit;text-decoration:none;}
button{font-family:inherit;}
img{max-width:100%;display:block;}
input,select,textarea,button{font-family:inherit;font-size:15px;}
::selection{background:var(--primary-100);}

/* ---------------------------------- App shell ---------------------------------- */
.app-shell{min-height:100vh;display:flex;flex-direction:column;padding-top:var(--safe-t);}
.app-body{background:var(--bg);}
.app-main{flex:1;width:100%;max-width:640px;margin:0 auto;padding:0 14px calc(var(--nav-h) + var(--safe-b) + 22px);position:relative;}

/* Top app bar */
.topbar{
  position:sticky;top:var(--safe-t);z-index:40;display:flex;align-items:center;gap:10px;
  padding:14px 16px calc(14px);background:color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter:blur(14px);-webkit-backdrop-filter:blur(14px);margin:0 -14px 14px;
}
.topbar .tb-back,.topbar .tb-menu{
  width:38px;height:38px;flex:0 0 auto;border-radius:50%;display:flex;align-items:center;justify-content:center;
  background:var(--surface);border:1px solid var(--border);color:var(--text);box-shadow:var(--shadow-soft);
}
.topbar .tb-back svg,.topbar .tb-menu svg{width:19px;height:19px;}
.topbar .tb-titles{flex:1;min-width:0;}
.topbar .tb-eyebrow{font-size:11px;letter-spacing:.09em;color:var(--primary);font-weight:800;text-transform:uppercase;}
.topbar h1{font-size:19px;margin:1px 0 0;font-weight:800;letter-spacing:-.01em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.topbar p{margin:1px 0 0;font-size:12.5px;color:var(--text-dim);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.topbar .tb-actions{display:flex;align-items:center;gap:8px;flex:0 0 auto;}
.tb-icon-btn{
  position:relative;width:38px;height:38px;border-radius:50%;background:var(--surface);border:1px solid var(--border);
  display:flex;align-items:center;justify-content:center;color:var(--text);box-shadow:var(--shadow-soft);
}
.tb-icon-btn svg{width:18px;height:18px;}
.tb-dot{position:absolute;top:6px;right:7px;width:8px;height:8px;border-radius:50%;background:var(--danger);border:2px solid var(--surface);}
.tb-avatar-btn .avatar{width:38px;height:38px;font-size:14px;}

/* Bottom navigation (mobile: bar; desktop: floating rail handled by media query) */
.bottom-nav{
  position:fixed;left:0;right:0;bottom:0;z-index:50;display:flex;justify-content:space-around;align-items:stretch;
  padding:8px 6px calc(8px + var(--safe-b));background:color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter:blur(16px);-webkit-backdrop-filter:blur(16px);border-top:1px solid var(--border);
}
.bn-item{flex:1;display:flex;flex-direction:column;align-items:center;gap:3px;padding:6px 2px;border-radius:14px;color:var(--text-faint);position:relative;max-width:88px;margin:0 auto;}
.bn-item svg{width:22px;height:22px;transition:transform .18s ease;}
.bn-item span{font-size:10.5px;font-weight:700;}
.bn-item.active{color:var(--primary);}
.bn-item.active svg{transform:translateY(-1px);}
.bn-item .bn-badge{position:absolute;top:2px;right:14px;min-width:15px;height:15px;padding:0 3px;border-radius:8px;background:var(--danger);color:#fff;font-size:9px;font-weight:800;display:flex;align-items:center;justify-content:center;}
.bn-fab{
  width:52px;height:52px;border-radius:50%;background:linear-gradient(155deg,var(--primary),var(--primary-600));
  color:#fff;display:flex;align-items:center;justify-content:center;box-shadow:0 10px 24px -6px rgba(108,76,241,.55);
  margin-top:-30px;border:4px solid var(--bg);
}
.bn-fab svg{width:24px;height:24px;}

/* Floating action button (contextual, screen-specific) */
.fab{
  position:fixed;right:calc(16px + env(safe-area-inset-right,0px));bottom:calc(var(--nav-h) + var(--safe-b) + 18px);
  z-index:45;display:flex;align-items:center;gap:8px;padding:0 20px 0 16px;height:52px;border-radius:26px;
  background:linear-gradient(155deg,var(--primary),var(--primary-600));color:#fff;font-weight:800;font-size:14px;
  box-shadow:0 14px 28px -8px rgba(108,76,241,.55);border:none;
}
.fab svg{width:19px;height:19px;}

/* ---------------------------------- Cards & sections ---------------------------------- */
.section-title{font-size:13px;font-weight:800;color:var(--text-dim);text-transform:uppercase;letter-spacing:.06em;margin:22px 2px 10px;display:flex;align-items:center;justify-content:space-between;}
.section-title a{color:var(--primary);font-size:12.5px;text-transform:none;letter-spacing:0;font-weight:800;}
.card{background:var(--surface);border-radius:var(--radius-lg);padding:16px;box-shadow:var(--shadow-soft);border:1px solid var(--border);margin-bottom:14px;}
.card-flat{background:var(--surface-2);border-radius:var(--radius-lg);padding:16px;margin-bottom:14px;}
.card-head{display:flex;align-items:flex-start;justify-content:space-between;gap:10px;margin-bottom:12px;}
.card-head h2{font-size:15.5px;margin:0;font-weight:800;}
.card-head p{margin:2px 0 0;font-size:12.5px;color:var(--text-dim);}

/* Stat tiles */
.stat-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:10px;margin-bottom:6px;}
.stat-tile{border-radius:var(--radius-lg);padding:15px 14px;position:relative;overflow:hidden;box-shadow:var(--shadow-soft);}
.stat-tile .st-icon{width:34px;height:34px;border-radius:11px;display:flex;align-items:center;justify-content:center;margin-bottom:22px;}
.stat-tile .st-icon svg{width:17px;height:17px;}
.stat-tile strong{display:block;font-size:21px;font-weight:800;letter-spacing:-.02em;}
.stat-tile span{display:block;font-size:12px;color:var(--text-dim);margin-top:2px;font-weight:600;}
.stat-tile.violet{background:linear-gradient(155deg,var(--primary-100),var(--surface));}
.stat-tile.violet .st-icon{background:var(--primary);color:#fff;}
.stat-tile.green{background:linear-gradient(155deg,var(--success-100),var(--surface));}
.stat-tile.green .st-icon{background:var(--success);color:#fff;}
.stat-tile.amber{background:linear-gradient(155deg,var(--warning-100),var(--surface));}
.stat-tile.amber .st-icon{background:var(--warning);color:#fff;}
.stat-tile.blue{background:linear-gradient(155deg,var(--info-100),var(--surface));}
.stat-tile.blue .st-icon{background:var(--info);color:#fff;}
.stat-tile.rose{background:linear-gradient(155deg,var(--danger-100),var(--surface));}
.stat-tile.rose .st-icon{background:var(--danger);color:#fff;}

/* List rows */
.list{display:flex;flex-direction:column;gap:8px;}
.row{display:flex;align-items:center;gap:12px;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-md);padding:12px 13px;box-shadow:var(--shadow-soft);}
.row.link:active{transform:scale(.99);}
.row .row-icon{width:42px;height:42px;border-radius:13px;background:var(--surface-3);display:flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--primary);}
.row .row-icon svg{width:19px;height:19px;}
.row .row-body{flex:1;min-width:0;}
.row .row-body b{display:block;font-size:14.5px;font-weight:750;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.row .row-body span{display:block;font-size:12.5px;color:var(--text-dim);margin-top:1px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.row .row-body small{display:block;font-size:11.5px;color:var(--text-faint);margin-top:2px;}
.row .row-trail{flex:0 0 auto;text-align:right;display:flex;flex-direction:column;align-items:flex-end;gap:4px;}
.row .row-trail b{font-size:13.5px;font-weight:800;}
.row-chevron{color:var(--text-faint);flex:0 0 auto;}
.row-chevron svg{width:17px;height:17px;}

/* Avatars */
.avatar{
  width:40px;height:40px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;
  background:hsl(var(--hue,250) 70% 92%);color:hsl(var(--hue,250) 45% 38%);font-weight:800;font-size:14px;flex:0 0 auto;
}
.avatar.large{width:56px;height:56px;font-size:18px;}
.avatar.small{width:30px;height:30px;font-size:11px;}
.avatar-photo{padding:0;overflow:hidden;}
.avatar-photo img{width:100%;height:100%;object-fit:cover;}

/* Badges / chips */
.badge{display:inline-flex;align-items:center;padding:3px 10px;border-radius:20px;font-size:11px;font-weight:800;letter-spacing:.01em;}
.badge.success{background:var(--success-100);color:var(--success);}
.badge.warning{background:var(--warning-100);color:var(--warning);}
.badge.danger{background:var(--danger-100);color:var(--danger);}
.badge.neutral{background:var(--surface-3);color:var(--text-dim);}

.chip-row{display:flex;gap:8px;overflow-x:auto;padding:2px 2px 6px;margin:0 -2px 6px;scrollbar-width:none;}
.chip-row::-webkit-scrollbar{display:none;}
.chip{flex:0 0 auto;display:inline-flex;align-items:center;gap:6px;padding:8px 15px;border-radius:20px;background:var(--surface);border:1px solid var(--border);font-size:13px;font-weight:700;color:var(--text-dim);white-space:nowrap;}
.chip svg{width:15px;height:15px;flex:0 0 auto;}
.chip.active{background:var(--primary);border-color:var(--primary);color:#fff;}

/* Progress */
.progress-track{height:7px;border-radius:6px;background:var(--surface-3);overflow:hidden;}
.progress-track i{display:block;height:100%;border-radius:6px;background:linear-gradient(90deg,var(--primary),var(--accent));}

/* Buttons */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:7px;border:none;border-radius:var(--radius-md);
  padding:12px 18px;font-weight:800;font-size:14px;cursor:pointer;white-space:nowrap;}
.btn svg{width:17px;height:17px;}
.btn.primary{background:linear-gradient(155deg,var(--primary),var(--primary-600));color:#fff;box-shadow:0 10px 20px -8px rgba(108,76,241,.55);}
.btn.secondary{background:var(--surface-3);color:var(--text);}
.btn.ghost{background:transparent;color:var(--primary);}
.btn.dark{background:var(--text);color:var(--surface);}
.btn.danger-outline{background:var(--danger-100);color:var(--danger);}
.btn.small{padding:8px 13px;font-size:12.5px;border-radius:10px;}
.btn.xsmall{padding:6px 10px;font-size:11.5px;border-radius:9px;}
.btn.wide{width:100%;}
.btn[disabled]{opacity:.55;pointer-events:none;}

/* Forms */
.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px;}
.form-grid.single{grid-template-columns:1fr;}
.form-grid label{display:flex;flex-direction:column;gap:6px;font-size:12.5px;font-weight:700;color:var(--text-dim);}
.form-grid label.full{grid-column:1/-1;}
.form-grid input,.form-grid select,.form-grid textarea{
  background:var(--surface-2);border:1.5px solid var(--border);border-radius:var(--radius-md);padding:11px 13px;
  font-size:14.5px;color:var(--text);outline:none;width:100%;
}
.form-grid input:focus,.form-grid select:focus,.form-grid textarea:focus{border-color:var(--primary);background:var(--surface);}
.form-grid textarea{min-height:88px;resize:vertical;font-family:inherit;}
.form-grid .check-field{flex-direction:row;align-items:center;gap:8px;}
.form-grid .check-field input{width:auto;}
.form-actions{display:flex;gap:10px;margin-top:2px;flex-wrap:wrap;}
.form-actions.full{grid-column:1/-1;}
@media (max-width:520px){.form-grid{grid-template-columns:1fr;}}

/* Segmented filter bar */
.filterbar{margin-bottom:12px;}
.filterbar form{display:flex;gap:8px;flex-wrap:wrap;}
.filterbar input,.filterbar select{background:var(--surface);border:1.5px solid var(--border);border-radius:12px;padding:9px 12px;font-size:13.5px;flex:1;min-width:120px;}

/* Empty state */
.empty{padding:34px 12px;text-align:center;color:var(--text-faint);font-size:13.5px;}
.empty svg{width:34px;height:34px;margin-bottom:10px;opacity:.5;}

/* Flash / toast */
.flash{position:fixed;top:calc(var(--safe-t) + 8px);left:14px;right:14px;z-index:80;padding:13px 16px;border-radius:16px;
  font-size:13.5px;font-weight:700;box-shadow:var(--shadow-pop);animation:toast-in .25s ease;max-width:612px;margin:0 auto;}
.flash.success{background:var(--success);color:#fff;}
.flash.error{background:var(--danger);color:#fff;}
.flash.info{background:var(--primary);color:#fff;}
@keyframes toast-in{from{transform:translateY(-14px);opacity:0;}to{transform:translateY(0);opacity:1;}}

/* Bottom sheet */
.sheet-backdrop{position:fixed;inset:0;background:rgba(20,15,40,.45);z-index:90;opacity:0;pointer-events:none;transition:opacity .2s ease;}
.sheet-backdrop.open{opacity:1;pointer-events:auto;}
.sheet{position:fixed;left:0;right:0;bottom:0;z-index:91;background:var(--surface);border-radius:24px 24px 0 0;
  padding:10px 18px calc(20px + var(--safe-b));max-height:86vh;overflow-y:auto;transform:translateY(100%);transition:transform .28s cubic-bezier(.32,.72,0,1);
  box-shadow:0 -20px 50px -10px rgba(20,15,40,.35);max-width:640px;margin:0 auto;display: block;}
.sheet.open{transform:translateY(0);}
.sheet-handle{width:38px;height:5px;border-radius:4px;background:var(--border);margin:6px auto 14px;}
.sheet-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:14px;}
.sheet-head h3{margin:0;font-size:17px;font-weight:800;}
.sheet-close{width:32px;height:32px;border-radius:50%;background:var(--surface-3);display:flex;align-items:center;justify-content:center;border:none;color:var(--text);}
.sheet-close svg{width:16px;height:16px;}

/* Info banner */
.info-banner{background:var(--info-100);color:var(--info);padding:12px 14px;border-radius:var(--radius-md);font-size:13px;margin-bottom:14px;line-height:1.5;}
.info-banner b{color:inherit;}

/* Table wrap (used sparingly, styled as cards on mobile) */
.table-wrap{overflow-x:auto;border-radius:var(--radius-md);}
table{width:100%;border-collapse:collapse;font-size:13px;min-width:560px;}
table th{text-align:left;color:var(--text-faint);font-size:11px;text-transform:uppercase;letter-spacing:.05em;padding:8px 10px;border-bottom:1px solid var(--border);}
table td{padding:11px 10px;border-bottom:1px solid var(--border);vertical-align:middle;}
table td small{display:block;color:var(--text-faint);font-size:11px;}
table tr:last-child td{border-bottom:none;}

/* Two column layout (desktop) */
.two-col{display:grid;grid-template-columns:1fr;gap:14px;}
/* On the admin dashboard, the first column stacks bare .list/.empty sections next to
   the second column's already-carded ones (Recent activity, Unread messages) — give
   them the same contained card look so both sides carry equal visual weight. Scoped
   to .two-col only, so every other page's flat lists are untouched. */
.two-col > div:first-child > .list,
.two-col > div:first-child > .empty{
  background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-lg);
  box-shadow:var(--shadow-soft);margin-bottom:14px;
}
.two-col > div:first-child > .list{padding:8px;gap:6px;}
.two-col > div:first-child > .list > .row{box-shadow:none;border-color:var(--border);}
.two-col > div:first-child > .empty{padding:30px 16px;}

/* ---------------------------------- Chat screen ---------------------------------- */
.chat-shell{display:flex;flex-direction:column;height:calc(100vh - var(--topbar-h) - var(--nav-h) - var(--safe-t) - var(--safe-b) - 30px);margin:0 -14px;}
.chat-scroll{flex:1;overflow-y:auto;padding:6px 16px;display:flex;flex-direction:column;gap:3px;}
.chat-day{align-self:center;background:var(--surface-3);color:var(--text-dim);font-size:11px;font-weight:800;padding:5px 13px;border-radius:20px;margin:14px 0 10px;}
.msg-row{display:flex;margin:3px 0;max-width:100%;}
.msg-row.out{justify-content:flex-end;}
.msg-bubble{max-width:78%;padding:10px 14px;border-radius:18px;font-size:14px;line-height:1.42;box-shadow:0 2px 8px -4px rgba(20,15,40,.12);position:relative;}
.msg-row.in .msg-bubble{background:var(--surface);border:1px solid var(--border);border-bottom-left-radius:5px;}
.msg-row.out .msg-bubble{background:linear-gradient(155deg,var(--primary),var(--primary-600));color:#fff;border-bottom-right-radius:5px;}
.msg-bubble .msg-time{display:block;font-size:10px;margin-top:4px;opacity:.65;text-align:right;}
.msg-bubble .msg-file{display:flex;align-items:center;gap:8px;background:rgba(0,0,0,.06);padding:8px 10px;border-radius:12px;margin-bottom:6px;font-size:12.5px;font-weight:700;}
.msg-row.out .msg-bubble .msg-file{background:rgba(255,255,255,.18);}
.msg-bubble .msg-file svg{width:15px;height:15px;flex:0 0 auto;}
.msg-card{max-width:82%;background:var(--surface);border:1.5px solid var(--primary-100);border-radius:16px;padding:12px 13px;box-shadow:var(--shadow-soft);}
.msg-card b{display:block;font-size:13.5px;margin-bottom:2px;}
.msg-card span{display:block;font-size:12px;color:var(--text-dim);}
.msg-card .mc-tag{display:inline-block;margin-top:6px;font-size:10.5px;font-weight:800;color:var(--primary);background:var(--primary-100);padding:3px 9px;border-radius:20px;}
.chat-empty{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;color:var(--text-faint);gap:8px;text-align:center;padding:20px;}
.chat-empty svg{width:40px;height:40px;opacity:.4;}
.chat-input-bar{display:flex;align-items:flex-end;gap:8px;padding:10px 14px calc(10px + var(--safe-b));border-top:1px solid var(--border);background:var(--surface);}
.chat-input-bar .ci-attach{width:40px;height:40px;border-radius:50%;background:var(--surface-3);display:flex;align-items:center;justify-content:center;flex:0 0 auto;border:none;color:var(--text-dim);}
.chat-input-bar .ci-attach svg{width:18px;height:18px;}
.chat-input-bar textarea{flex:1;resize:none;border:1.5px solid var(--border);background:var(--surface-2);border-radius:20px;padding:10px 15px;font-size:14px;max-height:100px;outline:none;}
.chat-input-bar textarea:focus{border-color:var(--primary);}
.chat-input-bar .ci-send{width:42px;height:42px;border-radius:50%;background:linear-gradient(155deg,var(--primary),var(--primary-600));color:#fff;border:none;display:flex;align-items:center;justify-content:center;flex:0 0 auto;}
.chat-input-bar .ci-send svg{width:17px;height:17px;margin-left:-2px;}
.chat-attach-preview{display:flex;align-items:center;gap:8px;background:var(--surface-2);border:1px dashed var(--border);border-radius:12px;padding:8px 10px;margin:0 14px 8px;font-size:12.5px;}
.chat-attach-preview button{margin-left:auto;background:none;border:none;color:var(--danger);font-weight:800;}

/* Conversation list (admin inbox) */
.convo-row{display:flex;align-items:center;gap:12px;padding:12px 4px;border-bottom:1px solid var(--border);}
.convo-row:last-child{border-bottom:none;}
.convo-row .cr-body{flex:1;min-width:0;}
.convo-row .cr-body b{display:block;font-size:14px;font-weight:750;}
.convo-row .cr-body span{display:block;font-size:12.5px;color:var(--text-dim);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:230px;}
.convo-row .cr-meta{text-align:right;flex:0 0 auto;}
.convo-row .cr-meta small{display:block;color:var(--text-faint);font-size:11px;margin-bottom:4px;}

/* ---------------------------------- Auth screens ---------------------------------- */
.auth-body{background:linear-gradient(180deg,#2A1F5C,#1C1436 60%);min-height:100vh;}
.auth-wrap{max-width:440px;margin:0 auto;min-height:100vh;display:flex;flex-direction:column;padding:0 20px;}
.auth-hero{position:relative;padding:56px 4px 26px;color:#fff;}
.auth-hero .brand-mark{width:52px;height:52px;border-radius:16px;background:linear-gradient(155deg,var(--accent),#FFC168);color:#3A2200;font-weight:900;font-size:22px;display:flex;align-items:center;justify-content:center;margin-bottom:18px;}
.auth-hero h1{font-size:26px;font-weight:800;margin:0 0 8px;letter-spacing:-.01em;}
.auth-hero p{color:#D5CCFA;font-size:14px;margin:0;line-height:1.5;}
.auth-card{background:var(--surface);border-radius:28px 28px 0 0;padding:26px 22px 34px;flex:1;box-shadow:0 -20px 60px rgba(0,0,0,.25);}
.auth-card h2{margin:0 0 4px;font-size:19px;font-weight:800;}
.auth-card>p{margin:0 0 18px;font-size:13px;color:var(--text-dim);}
.auth-sep{text-align:center;color:var(--text-faint);font-size:12px;margin:18px 0 12px;position:relative;}
.auth-links{display:flex;flex-direction:column;gap:10px;}
.demo-box{margin-top:20px;background:var(--surface-2);border-radius:14px;padding:12px 14px;font-size:12px;color:var(--text-dim);display:flex;flex-direction:column;gap:4px;}
.demo-box b{color:var(--text);font-size:12.5px;}
.role-toggle{display:flex;background:var(--surface-2);border-radius:14px;padding:4px;margin-bottom:16px;}
.role-toggle a{flex:1;text-align:center;padding:9px;border-radius:11px;font-size:13px;font-weight:800;color:var(--text-dim);}
.role-toggle a.active{background:var(--surface);color:var(--primary);box-shadow:var(--shadow-soft);}

/* Standalone (error) pages */
.standalone{background:var(--bg);min-height:100vh;display:flex;align-items:center;justify-content:center;padding:24px;}
.standalone-card{background:var(--surface);border-radius:24px;padding:32px 26px;max-width:420px;text-align:center;box-shadow:var(--shadow-pop);}
.brand-mini{font-weight:900;color:var(--primary);font-size:13px;letter-spacing:.05em;text-transform:uppercase;margin-bottom:10px;}
.eyebrow{font-size:11px;letter-spacing:.09em;color:var(--text-faint);font-weight:800;text-transform:uppercase;}
.standalone-card h1{font-size:20px;margin:8px 0;}
.muted{color:var(--text-dim);}

/* Notification / activity rows */
.notice-row{display:flex;gap:12px;padding:12px 4px;border-bottom:1px solid var(--border);align-items:flex-start;}
.notice-row:last-child{border-bottom:none;}
.notice-row.unread{background:var(--primary-100);border-radius:14px;padding:12px;margin-bottom:2px;border-bottom:none;}
.notice-icon{width:36px;height:36px;border-radius:11px;background:var(--surface-3);display:flex;align-items:center;justify-content:center;color:var(--primary);flex:0 0 auto;}
.notice-icon svg{width:16px;height:16px;}
.notice-row b{font-size:13.5px;font-weight:750;}
.notice-row p{margin:2px 0;font-size:12.5px;color:var(--text-dim);}
.notice-row small{color:var(--text-faint);font-size:11px;}

/* Timeline (assignment updates) */
.timeline{display:flex;flex-direction:column;}
.timeline-item{display:flex;gap:12px;padding-bottom:16px;position:relative;}
.timeline-item:not(:last-child)::before{content:'';position:absolute;left:15px;top:32px;bottom:0;width:2px;background:var(--border);}
.timeline-dot{width:32px;height:32px;border-radius:50%;background:var(--primary-100);color:var(--primary);display:flex;align-items:center;justify-content:center;flex:0 0 auto;z-index:1;}
.timeline-dot svg{width:15px;height:15px;}
.timeline-body{flex:1;padding-top:3px;}
.timeline-body b{font-size:13.5px;}
.timeline-body p{margin:3px 0;font-size:13px;color:var(--text-dim);}
.timeline-body small{color:var(--text-faint);font-size:11px;}

/* Detail hero (project/assignment header) */
.detail-hero{background:linear-gradient(155deg,var(--primary),var(--primary-600));border-radius:var(--radius-xl);padding:20px;color:#fff;margin-bottom:16px;position:relative;overflow:hidden;}
.detail-hero .dh-code{font-size:11px;font-weight:800;letter-spacing:.08em;text-transform:uppercase;opacity:.75;}
.detail-hero h1{font-size:19px;margin:4px 0 10px;font-weight:800;}
.detail-hero .dh-meta{display:flex;gap:16px;flex-wrap:wrap;margin-top:14px;}
.detail-hero .dh-meta div{font-size:11px;opacity:.75;}
.detail-hero .dh-meta b{display:block;font-size:15px;font-weight:800;opacity:1;margin-top:1px;}
.detail-hero .progress-track{background:rgba(255,255,255,.25);margin-top:12px;}
.detail-hero .progress-track i{background:#fff;}

/* Tabs (segmented, sticky under hero) */
.seg-tabs{display:flex;gap:6px;overflow-x:auto;margin-bottom:14px;scrollbar-width:none;}
.seg-tabs::-webkit-scrollbar{display:none;}
.seg-tabs a{flex:0 0 auto;padding:9px 15px;border-radius:14px;font-size:13px;font-weight:800;color:var(--text-dim);background:var(--surface-2);}
.seg-tabs a.active{background:var(--text);color:var(--surface);}

/* Ledger / payment row */
.ledger-row{display:flex;align-items:center;gap:12px;padding:12px 4px;border-bottom:1px solid var(--border);}
.ledger-row:last-child{border-bottom:none;}
.ledger-row .lr-icon{width:38px;height:38px;border-radius:11px;display:flex;align-items:center;justify-content:center;flex:0 0 auto;}
.ledger-row .lr-icon svg{width:16px;height:16px;}
.ledger-row .lr-icon.credit{background:var(--success-100);color:var(--success);}
.ledger-row .lr-icon.debit{background:var(--danger-100);color:var(--danger);}
.ledger-row .lr-body{flex:1;min-width:0;}
.ledger-row .lr-body b{font-size:13.5px;display:block;}
.ledger-row .lr-body span{font-size:12px;color:var(--text-dim);display:block;}
.ledger-row .lr-amt{font-size:14px;font-weight:800;flex:0 0 auto;}
.ledger-row .lr-amt.credit{color:var(--success);}
.ledger-row .lr-amt.debit{color:var(--danger);}

/* Service / package cards */
.service-grid{display:grid;grid-template-columns:1fr;gap:12px;}
.service-card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-lg);padding:15px;box-shadow:var(--shadow-soft);}
.service-card .sc-top{display:flex;justify-content:space-between;align-items:center;margin-bottom:6px;}
.service-card .sc-cat{font-size:10.5px;font-weight:800;color:var(--primary);background:var(--primary-100);padding:3px 9px;border-radius:20px;text-transform:uppercase;letter-spacing:.04em;}
.service-card h3{font-size:15px;margin:2px 0 4px;}
.service-card p{font-size:12.5px;color:var(--text-dim);margin:0 0 10px;}

/* Task checkbox — big, unmistakable tap target */
.task-row{display:flex;align-items:center;gap:12px;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-md);padding:11px 13px;box-shadow:var(--shadow-soft);}
.task-checkbox{width:28px;height:28px;border-radius:50%;border:2px solid var(--border);background:var(--surface);display:flex;align-items:center;justify-content:center;flex:0 0 auto;color:transparent;cursor:pointer;}
.task-checkbox svg{width:15px;height:15px;}
.task-checkbox.done{background:var(--success);border-color:var(--success);color:#fff;}
.task-row .row-body{flex:1;min-width:0;}
.task-row .row-body b{display:block;font-size:14.5px;font-weight:750;}
.task-row .row-body b.done-text{text-decoration:line-through;color:var(--text-faint);font-weight:600;}
.task-row .row-body span{display:block;font-size:12px;color:var(--text-dim);margin-top:1px;}
.task-row .row-body small.tap-hint{display:block;font-size:11px;color:var(--primary);margin-top:2px;font-weight:700;}
.task-row .row-body small.done-hint{color:var(--success);}
.task-row .row-trail{flex:0 0 auto;text-align:right;}

/* Theme toggle */
.theme-row{display:flex;align-items:center;gap:12px;padding:11px 4px;}
.theme-row .row-icon{width:38px;height:38px;}
.theme-switch{position:relative;width:50px;height:28px;border-radius:16px;background:var(--surface-3);border:none;flex:0 0 auto;cursor:pointer;padding:0;}
.theme-switch .ts-knob{position:absolute;top:3px;left:3px;width:22px;height:22px;border-radius:50%;background:var(--surface);box-shadow:0 2px 6px rgba(0,0,0,.25);display:flex;align-items:center;justify-content:center;color:var(--text-dim);transition:transform .22s ease;}
.theme-switch .ts-knob svg{width:13px;height:13px;}
.theme-switch[data-on="1"]{background:var(--primary);}
.theme-switch[data-on="1"] .ts-knob{transform:translateX(22px);color:var(--primary);}
.theme-toggle-btn{background:var(--surface);}

/* Utility */
.muted-text{color:var(--text-dim);font-size:13px;}
.mt-0{margin-top:0;}
.hidden{display:none !important;}
.text-right{text-align:right;}
.rank-row{display:flex;justify-content:space-between;padding:9px 2px;border-bottom:1px solid var(--border);font-size:13px;}
.rank-row:last-child{border-bottom:none;}
.status-bars{display:flex;flex-direction:column;gap:10px;}
.status-bar div{display:flex;justify-content:space-between;font-size:12.5px;margin-bottom:4px;text-transform:capitalize;}
.status-bar span{display:block;height:7px;border-radius:6px;background:var(--surface-3);overflow:hidden;}
.status-bar span i{display:block;height:100%;background:linear-gradient(90deg,var(--primary),var(--accent));border-radius:6px;}

/* ---------------------------------- Desktop sidebar ---------------------------------- */
.side-rail{display:none;}

/* ---------------------------------- Responsive: tablet/desktop ---------------------------------- */
@media (min-width:900px){
  .app-shell{flex-direction:row;}
  .app-main{max-width:100%;flex:1;margin:0;padding:26px 40px calc(var(--safe-b) + 24px) 288px;}
  .topbar{margin:0 0 18px 0;max-width:none;}
  .bottom-nav{display:none;}
  .fab{right:calc(40px + env(safe-area-inset-right,0px));}

  .side-rail{
    display:flex;flex-direction:column;position:fixed;top:0;left:0;bottom:0;width:240px;
    padding:26px 16px 20px;border-right:1px solid var(--border);background:var(--surface);
    overflow-y:auto;z-index:40;
  }
  .side-brand{display:flex;align-items:center;gap:10px;padding:2px 6px 22px;}
  .side-brand .sb-mark{width:36px;height:36px;border-radius:11px;background:linear-gradient(155deg,var(--primary),var(--primary-600));color:#fff;display:flex;align-items:center;justify-content:center;font-weight:900;font-size:16px;flex:0 0 auto;}
  .side-brand b{display:block;font-size:14.5px;font-weight:800;}
  .side-brand span{display:block;font-size:11px;color:var(--text-faint);}
  .side-identity{display:flex;align-items:center;gap:10px;padding:10px;border-radius:14px;background:var(--surface-2);margin-bottom:18px;}
  .side-identity .id-body{min-width:0;}
  .side-identity b{display:block;font-size:13px;font-weight:750;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
  .side-identity span{display:block;font-size:11px;color:var(--text-faint);}
  .side-section-label{font-size:10.5px;font-weight:800;color:var(--text-faint);text-transform:uppercase;letter-spacing:.07em;margin:6px 10px 8px;}
  .side-nav{display:flex;flex-direction:column;gap:2px;margin-bottom:8px;}
  .side-link{display:flex;align-items:center;gap:11px;padding:9px 10px;border-radius:12px;color:var(--text-dim);font-size:13.5px;font-weight:700;position:relative;}
  .side-link svg{width:18px;height:18px;flex:0 0 auto;}
  .side-link:hover{background:var(--surface-2);}
  .side-link.active{background:var(--primary-100);color:var(--primary);}
  .side-link .sl-badge{margin-left:auto;min-width:18px;height:18px;padding:0 5px;border-radius:9px;background:var(--danger);color:#fff;font-size:10px;font-weight:800;display:flex;align-items:center;justify-content:center;}
  .side-divider{height:1px;background:var(--border);margin:14px 4px;}
  .side-logout{margin-top:auto;padding-top:14px;}

  .two-col{grid-template-columns:1.3fr .9fr;align-items:start;}
  .stat-grid{grid-template-columns:repeat(4,1fr);}
  .service-grid{grid-template-columns:repeat(2,1fr);}
  .sheet{left:auto;right:40px;bottom:24px;border-radius:24px;max-width:420px;box-shadow:var(--shadow-pop);display: none;}
  .flash{left:auto;right:40px;max-width:380px;}
  .chat-shell{height:calc(100vh - var(--topbar-h) - 44px);}
}
@media (min-width:1280px){
  .app-main{padding-left:312px;}
  .side-rail{width:264px;}
  .two-col{grid-template-columns:1.5fr 1fr;}
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce){*{animation-duration:.001ms !important;transition-duration:.001ms !important;}}