/* ============================================================
   Nammastack CRM — design system.
   Ported from the Folio prototype (styles.css + inline component
   styles). Restrained slate palette, blue used sparingly, spacious.
   ============================================================ */

:root {
  /* Brand palette */
  --slate-900: #0F172A;
  --slate-800: #1E293B;
  --slate-700: #334155;
  --slate-600: #475569;
  --slate-500: #64748B;
  --slate-400: #94A3B8;
  --slate-300: #CBD5E1;
  --slate-200: #E2E8F0;
  --slate-150: #EBF0F5;
  --slate-100: #F1F5F9;
  --slate-50:  #F8FAFC;
  --white: #FFFFFF;

  /* Accent */
  --accent: #2563EB;
  --accent-hover: #1D4ED8;
  --accent-soft: #EFF4FF;
  --accent-border: #C7D7FE;

  /* Semantic */
  --success: #16A34A;
  --success-soft: #ECFDF3;
  --success-border: #ABEFC6;
  --warning: #D97706;
  --warning-soft: #FFFAEB;
  --warning-border: #FEDF89;
  --danger: #DC2626;
  --danger-soft: #FEF3F2;
  --danger-border: #FECDCA;
  --info: #2563EB;
  --info-soft: #EFF4FF;
  --violet: #7C3AED;
  --violet-soft: #F5F3FF;

  /* Surface tokens */
  --bg: var(--slate-50);
  --surface: var(--white);
  --surface-2: var(--slate-50);
  --border: var(--slate-200);
  --border-strong: var(--slate-300);
  --text: var(--slate-900);
  --text-muted: var(--slate-500);
  --text-subtle: var(--slate-400);

  /* Typography — Google Sans (matches the original Folio design) */
  --font-sans: 'Google Sans', 'Google Sans Text', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Google Sans', -apple-system, sans-serif;
  --font-mono: 'Google Sans Code', ui-monospace, 'SF Mono', Menlo, monospace;

  /* Radii */
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-2xl: 20px;
  --r-full: 999px;

  /* Shadows — soft, premium */
  --shadow-xs: 0 1px 2px rgba(15,23,42,0.04);
  --shadow-sm: 0 1px 3px rgba(15,23,42,0.06), 0 1px 2px rgba(15,23,42,0.04);
  --shadow-md: 0 4px 12px -2px rgba(15,23,42,0.08), 0 2px 6px -2px rgba(15,23,42,0.05);
  --shadow-lg: 0 12px 28px -6px rgba(15,23,42,0.14), 0 6px 12px -6px rgba(15,23,42,0.08);
  --shadow-xl: 0 24px 56px -12px rgba(15,23,42,0.22), 0 10px 24px -12px rgba(15,23,42,0.12);
  --ring: 0 0 0 3px rgba(37,99,235,0.16);

  /* Layout */
  --sidebar-w: 256px;
  --topbar-h: 64px;
  --content-max: 1240px;

  /* Density */
  --row-h: 56px;
  --pad-card: 24px;
  --gap: 24px;
}

[data-density="compact"] { --row-h: 46px; --pad-card: 18px; --gap: 16px; }
[data-density="comfy"]   { --row-h: 64px; --pad-card: 28px; --gap: 28px; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,h2,h3,h4,h5 { margin: 0; font-family: var(--font-display); font-weight: 600; letter-spacing: -0.016em; color: var(--text); }
p { margin: 0; }
button { font-family: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
input, select, textarea { font-family: inherit; }
table { border-collapse: collapse; }

.tnum { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; }
.mono { font-family: var(--font-mono); }
.ico { flex: none; display: block; }
/* The [hidden] attribute must always win — author display rules (.btn, .card,
   flex utilities…) would otherwise keep hidden elements visible. */
[hidden] { display: none !important; }

::selection { background: var(--accent-soft); }

*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--slate-300); border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--slate-400); background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

:focus-visible:not(input):not(textarea):not(select) { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: none; }

/* ---------- Animations ---------- */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: scale(1); } }
@keyframes slideInRight { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes slideInLeft { from { transform: translateX(-100%); } to { transform: translateX(0); } }
@keyframes viewIn { from { transform: translateY(9px); opacity: .4; } to { transform: translateY(0); opacity: 1; } }
.view-enter { animation: viewIn 0.34s cubic-bezier(0.22,1,0.36,1) both; }

.noscroll::-webkit-scrollbar { display: none; }
.noscroll { scrollbar-width: none; }

/* ---------- Atoms ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 9px; border-radius: var(--r-full);
  font-size: 12px; font-weight: 550; line-height: 1; white-space: nowrap;
}
.dot { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.count-pill { font-size: 13px; font-weight: 600; color: var(--slate-500); background: var(--slate-100); padding: 2px 9px; border-radius: 999px; }

.avatar {
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; letter-spacing: -0.02em; flex: none; overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12);
}

/* ============================================================
   App shell
   ============================================================ */
.shell { display: flex; min-height: 100vh; align-items: stretch; }
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
main#main-scroll { flex: 1; overflow-y: auto; padding: 28px 32px 32px; display: flex; flex-direction: column; }
.content-wrap { width: 100%; max-width: var(--content-max); margin: 0 auto; flex: 1 0 auto; }
.app-footer {
  margin: 36px auto 0; width: 100%; max-width: var(--content-max); padding-top: 18px;
  border-top: 1px solid var(--border); text-align: center; font-size: 12.5px; color: var(--slate-400);
}
.app-footer strong { font-weight: 600; color: var(--slate-500); }

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w); flex: none; height: 100vh; position: sticky; top: 0; left: 0; z-index: 30;
  background: var(--slate-50); border-right: 1px solid var(--border); display: flex; flex-direction: column;
}
.sidebar-brand { height: var(--topbar-h); display: flex; align-items: center; gap: 11px; padding: 0 18px; flex: none; }
.brand-mark {
  border-radius: 9px; background: var(--slate-900); display: flex; align-items: center; justify-content: center; flex: none;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08), 0 1px 2px rgba(15,23,42,0.2);
}
.brand-name { font-size: 15px; font-weight: 700; letter-spacing: -0.02em; color: var(--slate-900); white-space: nowrap; }

.workspace-switch {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 9px; border-radius: var(--r-md);
  border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-xs); cursor: pointer;
}
.workspace-switch .ws-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.workspace-switch .ws-plan { font-size: 11px; color: var(--slate-400); }

.nav { flex: 1; overflow-y: auto; padding: 0 12px; display: flex; flex-direction: column; gap: 14px; }
.nav-group-label { font-size: 10.5px; font-weight: 650; color: var(--slate-400); text-transform: uppercase; letter-spacing: 0.07em; padding: 4px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; width: 100%; height: 38px; padding: 0 10px;
  border-radius: var(--r-md); border: none; position: relative; background: transparent;
  color: var(--slate-500); transition: all .13s; font-weight: 500; font-size: 13.5px; text-align: left;
}
.nav-item .ico { color: var(--slate-400); }
.nav-item:hover { background: rgba(15,23,42,0.04); }
.nav-item.active {
  background: var(--surface); box-shadow: var(--shadow-xs), inset 0 0 0 1px var(--border);
  color: var(--slate-900); font-weight: 560;
}
.nav-item.active .ico { color: var(--accent); }
.nav-item span.label { flex: 1; white-space: nowrap; overflow: hidden; }
.nav-badge { font-size: 11px; font-weight: 600; color: var(--danger); background: var(--danger-soft); box-shadow: inset 0 0 0 1px var(--danger-border); padding: 1px 6px; border-radius: 999px; }

.sidebar-foot { padding: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.month-card { padding: 10px 12px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--border); }
.portal-link {
  display: flex; align-items: center; gap: 11px; height: 38px; padding: 0 10px; border-radius: var(--r-md);
  border: 1px solid var(--border); background: var(--surface); color: var(--slate-600); font-size: 13px; font-weight: 540; cursor: pointer; width: 100%;
}
.portal-link:hover { background: var(--slate-50); }

/* ---------- Sidebar collapse (desktop icon rail) ---------- */
.collapse-btn {
  width: 38px; height: 38px; flex: none; border: 1px solid var(--border); background: var(--surface);
  border-radius: var(--r-md); display: inline-flex; align-items: center; justify-content: center;
  color: var(--slate-500); box-shadow: var(--shadow-xs); cursor: pointer;
}
.collapse-btn:hover { color: var(--slate-800); }
.collapse-btn .ico { transition: transform .18s ease; }
html.sidebar-collapsed .collapse-btn .ico { transform: rotate(180deg); }
.sidebar.desktop { transition: width .18s ease; }
html.sidebar-collapsed .sidebar.desktop { width: 72px; }
html.sidebar-collapsed .sidebar.desktop .brand-name,
html.sidebar-collapsed .sidebar.desktop .nav-group-label,
html.sidebar-collapsed .sidebar.desktop .nav-item .label,
html.sidebar-collapsed .sidebar.desktop .nav-badge,
html.sidebar-collapsed .sidebar.desktop .sidebar-foot { display: none; }
html.sidebar-collapsed .sidebar.desktop .sidebar-brand { justify-content: center; padding: 0; }
html.sidebar-collapsed .sidebar.desktop .nav-item { justify-content: center; padding: 0; gap: 0; }
@media (max-width: 860px) { .collapse-btn { display: none; } }

/* ---------- Topbar ---------- */
.topbar {
  height: var(--topbar-h); position: sticky; top: 0; z-index: 40; background: rgba(248,250,252,0.82);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; padding: 0 24px;
}
.topbar h1 { font-size: 16px; font-weight: 650; letter-spacing: -0.015em; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-trigger {
  margin-left: auto; display: flex; align-items: center; gap: 9px; height: 38px; width: 300px; padding: 0 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-xs); color: var(--slate-400); cursor: pointer;
}
.search-trigger span.q { flex: 1; text-align: left; font-size: 13.5px; }
.kbd { font-family: var(--font-mono); font-size: 11px; color: var(--slate-400); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; background: var(--slate-50); }
.topbar-icons { display: flex; align-items: center; gap: 4px; }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 3px; padding-right: 8px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-xs); cursor: pointer; }
.mobile-menu-btn { border: 1px solid var(--border); background: var(--surface); border-radius: var(--r-md); width: 38px; height: 38px; display: none; align-items: center; justify-content: center; color: var(--slate-600); }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 14px;
  border-radius: var(--r-md); font-size: 13.5px; font-weight: 560; border: 1px solid transparent;
  transition: all .14s ease; white-space: nowrap; letter-spacing: -0.005em; cursor: pointer; color: var(--slate-700);
  background: var(--surface);
}
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; gap: 6px; }
.btn-lg { height: 44px; padding: 0 18px; font-size: 14.5px; gap: 8px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: 0 1px 2px rgba(15,23,42,0.12), inset 0 1px 0 rgba(255,255,255,0.16); }
.btn-primary:hover:not([disabled]) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--slate-700); border-color: var(--border); box-shadow: var(--shadow-xs); }
.btn-secondary:hover:not([disabled]) { background: var(--slate-50); border-color: var(--border-strong); }
.btn-ghost { background: transparent; color: var(--slate-600); border-color: transparent; box-shadow: none; }
.btn-ghost:hover:not([disabled]) { background: var(--slate-100); }
.btn-soft { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.btn-soft:hover:not([disabled]) { background: #E4ECFE; }
.btn-dark { background: var(--slate-900); color: #fff; border-color: var(--slate-900); box-shadow: 0 1px 2px rgba(15,23,42,0.18), inset 0 1px 0 rgba(255,255,255,0.1); }
.btn-dark:hover:not([disabled]) { background: var(--slate-800); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: var(--danger-border); }
.btn-danger:hover:not([disabled]) { background: var(--danger-soft); }

.icon-btn {
  width: 36px; height: 36px; border-radius: var(--r-md); display: inline-flex; align-items: center; justify-content: center;
  background: transparent; color: var(--slate-500); border: 1px solid transparent; transition: all .14s; position: relative; flex: none;
}
.icon-btn:hover { background: var(--slate-100); }
.icon-btn.bordered { background: var(--surface); border-color: var(--border); color: var(--slate-600); }
.icon-btn.sm { width: 30px; height: 30px; }
.icon-btn .badge-dot { position: absolute; top: 7px; right: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 2px var(--surface); }

/* ============================================================
   Cards & sections
   ============================================================ */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm); transition: box-shadow .16s, border-color .16s, transform .16s; padding: var(--pad-card);
}
.card.pad-0 { padding: 0; }
.card.hover:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.card.clickable { cursor: pointer; }

.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.section-head h3 { font-size: 14.5px; font-weight: 620; }
.section-action { display: inline-flex; align-items: center; gap: 4px; border: none; background: transparent; color: var(--accent); font-size: 12.5px; font-weight: 560; cursor: pointer; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h2 { font-size: 22px; font-weight: 680; letter-spacing: -0.02em; }
.page-head .sub { font-size: 14px; color: var(--slate-500); margin-top: 4px; }
.page-head .actions { display: flex; gap: 10px; flex-wrap: wrap; }
.back-link { display: inline-flex; align-items: center; gap: 6px; border: none; background: transparent; color: var(--slate-500); font-size: 13px; font-weight: 500; cursor: pointer; width: fit-content; }
.back-link:hover { color: var(--slate-700); }

.stack { display: flex; flex-direction: column; gap: var(--gap); }
.stack-20 { display: flex; flex-direction: column; gap: 20px; }
.grid-kpi { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--gap); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.split-grid { display: grid; grid-template-columns: minmax(0,1.62fr) minmax(0,1fr); gap: var(--gap); }
.split-grid.wide-left { grid-template-columns: minmax(0,1.7fr) minmax(0,1fr); align-items: flex-start; }
.split-grid.even { grid-template-columns: minmax(0,1fr) minmax(0,1fr); align-items: flex-start; }

/* ---------- KPI cards ---------- */
.kpi-card { display: flex; flex-direction: column; gap: 14px; }
.kpi-top { display: flex; align-items: flex-start; justify-content: space-between; }
.kpi-icon { width: 34px; height: 34px; border-radius: var(--r-md); background: var(--slate-100); display: flex; align-items: center; justify-content: center; color: var(--slate-500); }
.kpi-label { font-size: 13px; font-weight: 540; color: var(--slate-500); }
.kpi-value { font-size: 27px; font-weight: 700; letter-spacing: -0.025em; line-height: 1.05; }
.kpi-sub { font-size: 12.5px; color: var(--slate-400); margin-top: 4px; }
.kpi-mini { display: flex; align-items: center; gap: 13px; }
.kpi-mini .mini-icon { width: 38px; height: 38px; border-radius: var(--r-md); display: flex; align-items: center; justify-content: center; flex: none; }
.kpi-mini .mini-label { font-size: 12px; color: var(--slate-500); }
.kpi-mini .mini-value { font-size: 18px; font-weight: 680; letter-spacing: -0.02em; }

/* ============================================================
   Forms
   ============================================================ */
.field { display: block; }
.field > .label { font-size: 12.5px; font-weight: 560; color: var(--slate-600); margin-bottom: 7px; letter-spacing: -0.005em; }
.field .req { color: var(--danger); margin-left: 3px; }
.field .hint { font-size: 12px; color: var(--slate-400); margin-top: 6px; }

.input-wrap {
  display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-xs); transition: all .14s;
}
.input-wrap:focus-within { border-color: var(--accent); box-shadow: var(--ring); }
.input-wrap.disabled { background: var(--slate-50); }
.input-wrap .ico { color: var(--slate-400); }
.input-wrap .affix { color: var(--slate-400); font-size: 13.5px; }
.input-wrap input { flex: 1; border: none; outline: none; background: transparent; font-size: 13.5px; color: var(--text); min-width: 0; }
.input-wrap input.r { text-align: right; }
.input-wrap input.c { text-align: center; }

textarea.input {
  width: 100%; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  box-shadow: var(--shadow-xs); transition: all .14s; resize: vertical; font-size: 13.5px; color: var(--text); outline: none; line-height: 1.55;
}
textarea.input:focus { border-color: var(--accent); box-shadow: var(--ring); }

.select-wrap { position: relative; }
.select-wrap select {
  width: 100%; height: 40px; padding: 0 34px 0 12px; appearance: none; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-xs); font-size: 13.5px; color: var(--text); outline: none; cursor: pointer;
}
.select-wrap select:focus { border-color: var(--accent); box-shadow: var(--ring); }
.select-wrap .chev { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); color: var(--slate-400); pointer-events: none; }

.checkbox {
  width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--border-strong); background: var(--surface);
  display: inline-flex; align-items: center; justify-content: center; transition: all .12s; flex: none; cursor: pointer; padding: 0; color: #fff;
}
.checkbox.checked { border-color: var(--accent); background: var(--accent); }

.toggle { width: 38px; height: 22px; border-radius: 999px; border: none; padding: 2px; transition: background .18s; background: var(--slate-300); display: flex; align-items: center; }
.toggle.on { background: var(--accent); }
.toggle .knob { width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .18s cubic-bezier(.4,1.4,.5,1); }
.toggle.on .knob { transform: translateX(16px); }

/* ---------- Segmented control ---------- */
.segmented { display: inline-flex; background: var(--slate-100); border-radius: var(--r-md); padding: 3px; gap: 2px; }
.segmented a, .segmented button {
  height: 30px; padding: 0 12px; border-radius: var(--r-sm); border: none; font-size: 13px; font-weight: 550;
  background: transparent; color: var(--slate-500); transition: all .14s; display: inline-flex; align-items: center; gap: 6px;
}
.segmented .active { background: var(--surface); color: var(--slate-900); box-shadow: var(--shadow-xs); }
.segmented .seg-count { color: var(--slate-400); font-weight: 500; }
.segmented .active .seg-count { color: var(--slate-500); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tab {
  padding: 0 4px 12px; margin: 0 8px; border: none; background: transparent; font-size: 13.5px; font-weight: 500;
  color: var(--slate-500); border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all .14s;
  display: inline-flex; align-items: center; gap: 7px;
}
.tab.active { font-weight: 600; color: var(--slate-900); border-bottom-color: var(--accent); }
.tab-count { font-size: 11.5px; font-weight: 600; color: var(--slate-400); background: var(--slate-100); padding: 1px 6px; border-radius: 999px; }
.tab.active .tab-count { color: var(--accent); background: var(--accent-soft); }

/* ---------- Progress ---------- */
.progress { height: 6px; background: var(--slate-150); border-radius: 999px; overflow: hidden; width: 100%; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .5s cubic-bezier(.22,1,.36,1); }

/* ---------- Toolbar / lists ---------- */
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.toolbar .search { width: 280px; max-width: 100%; }
.toolbar .right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

/* ---------- Table ---------- */
.table-scroll { overflow-x: auto; }
/* While a row dropdown is open, stop the scroll box from clipping it. */
.table-scroll.menu-open { overflow: visible; }
table.data { width: 100%; min-width: 640px; }
table.data thead th {
  text-align: left; padding: 11px 16px; font-size: 11.5px; font-weight: 600; color: var(--slate-400);
  text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; border-bottom: 1px solid var(--border); background: var(--slate-50);
}
table.data thead th.r { text-align: right; }
table.data thead th a { display: inline-flex; align-items: center; gap: 5px; color: inherit; cursor: pointer; user-select: none; }
table.data tbody td { padding: 0 16px; border-bottom: 1px solid var(--border); height: var(--row-h); font-size: 13.5px; color: var(--slate-700); }
table.data tbody td.r { text-align: right; }
table.data tbody tr { transition: background .12s; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr.clickable:hover { background: var(--slate-50); }
.cell-strong { font-weight: 600; color: var(--slate-900); }
.cell-muted { color: var(--slate-500); }
/* Injected by JS for the mobile card view; hidden on desktop so it adds no column. */
.m-more { display: none; }
.cust-cell { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cust-cell .nm { font-size: 13.5px; font-weight: 600; color: var(--slate-900); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cust-cell .sb { font-size: 12px; color: var(--slate-400); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.list-foot { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-top: 1px solid var(--border); }
.bulk-bar { display: flex; align-items: center; gap: 14px; padding: 12px 20px; background: var(--accent-soft); border-bottom: 1px solid var(--accent-border); }

/* ---------- Empty state ---------- */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 56px 20px; text-align: center; }
.empty-state .ic { width: 52px; height: 52px; border-radius: var(--r-lg); background: var(--slate-100); display: flex; align-items: center; justify-content: center; color: var(--slate-400); margin-bottom: 16px; }
.empty-state h4 { font-size: 15px; font-weight: 600; }
.empty-state p { font-size: 13.5px; color: var(--slate-500); margin-top: 5px; max-width: 320px; }

/* ============================================================
   Dropdown menu
   ============================================================ */
.menu { position: relative; display: inline-block; }
.menu-panel {
  position: absolute; top: calc(100% + 6px); width: 200px; z-index: 60; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); padding: 6px;
  animation: scaleIn .12s ease; transform-origin: top right;
}
.menu-panel.left { left: 0; transform-origin: top left; }
.menu-panel.right { right: 0; }
.menu-panel[hidden] { display: none; }
.menu-header { font-size: 11px; font-weight: 600; color: var(--slate-400); text-transform: uppercase; letter-spacing: 0.05em; padding: 6px 10px 4px; }
.menu-divider { height: 1px; background: var(--border); margin: 6px 8px; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: var(--r-sm);
  border: none; background: transparent; font-size: 13.5px; color: var(--slate-700); text-align: left; transition: background .12s; font-weight: 500; cursor: pointer;
}
.menu-item .ico { color: var(--slate-500); }
.menu-item:hover { background: var(--slate-100); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger .ico { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger-soft); }

/* ---------- Notifications panel ---------- */
.notif-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 6px 8px 10px; }
.notif-head > span { font-size: 11px; font-weight: 600; color: var(--slate-400); text-transform: uppercase; letter-spacing: 0.05em; }
.notify-toggle { position: relative; width: 28px; height: 28px; border: none; background: transparent; border-radius: var(--r-sm); display: inline-flex; align-items: center; justify-content: center; color: var(--slate-500); cursor: pointer; }
.notify-toggle:hover { background: var(--slate-100); color: var(--slate-800); }
.notify-toggle.muted { color: var(--slate-400); }
.notify-toggle.muted::after { content: ''; position: absolute; left: 5px; right: 5px; top: 50%; height: 1.7px; background: var(--danger); transform: translateY(-50%) rotate(-45deg); border-radius: 2px; }
.notif-list { max-height: 322px; overflow-y: auto; }
.notif-item { display: flex; gap: 11px; align-items: flex-start; padding: 9px 10px; border-radius: var(--r-md); }
.notif-item:hover { background: var(--slate-100); }
.notif-ic { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex: none; margin-top: 1px; }
.notif-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.notif-text { font-size: 13px; line-height: 1.4; color: var(--slate-600); }
.notif-text b { font-weight: 600; color: var(--slate-900); }
.notif-time { font-size: 11.5px; color: var(--slate-400); }
.notif-foot { margin-top: 6px; border-top: 1px solid var(--border); border-radius: 0; color: var(--accent); font-weight: 540; }
.notif-foot .ico { color: var(--accent); }

/* ---------- Rich text editor + rendered rich content ---------- */
.rt-section { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
.rt-section-head { display: flex; gap: 8px; align-items: center; }
.rt-grip { color: var(--slate-300); display: flex; }
.rt-editor { border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; background: #fff; }
.rt-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 6px; border-bottom: 1px solid var(--border); background: var(--slate-50); }
.rt-btn { min-width: 28px; height: 28px; padding: 0 7px; border: none; background: transparent; border-radius: var(--r-sm); color: var(--slate-600); font-size: 12.5px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.rt-btn:hover { background: var(--slate-150); color: var(--slate-900); }
.rt-btn.active { background: var(--accent); color: #fff; }
.rt-sep { width: 1px; height: 18px; background: var(--border); margin: 0 4px; }
.rt-area { min-height: 120px; max-height: 440px; overflow-y: auto; padding: 12px 14px; font-size: 13.5px; line-height: 1.6; color: var(--text); outline: none; }
.rt-area:empty:before { content: attr(data-placeholder); color: var(--slate-400); }
.rt-source { width: 100%; min-height: 170px; border: none; padding: 12px 14px; font-family: var(--font-mono); font-size: 12px; line-height: 1.55; outline: none; resize: vertical; background: var(--slate-900); color: #E2E8F0; display: block; }
.rt-source[hidden] { display: none; }
.rt-area[hidden] { display: none; }

.rt-area h2, .rich h2 { font-size: 18px; font-weight: 680; margin: 12px 0 6px; letter-spacing: -0.01em; }
.rt-area h3, .rich h3 { font-size: 15px; font-weight: 640; margin: 10px 0 4px; }
.rt-area p, .rich p { margin: 0 0 8px; }
.rt-area ul, .rt-area ol, .rich ul, .rich ol { margin: 0 0 8px; padding-left: 22px; }
.rt-area li, .rich li { margin: 2px 0; }
.rt-area a, .rich a { color: var(--accent); text-decoration: underline; }
.rt-area blockquote, .rich blockquote { margin: 8px 0; padding: 6px 14px; border-left: 3px solid var(--slate-300); color: var(--slate-500); }
.rt-area hr, .rich hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.rt-area img, .rich img { max-width: 100%; height: auto; border-radius: var(--r-sm); }
.rt-cols, .rich .rt-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 10px 0; }
.rt-area .rt-cols > div { border: 1px dashed var(--border); border-radius: var(--r-sm); padding: 8px 10px; min-height: 40px; }
.rt-area table, .rich table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 13px; }
.rt-area th, .rt-area td, .rich th, .rich td { border: 1px solid var(--border); padding: 7px 9px; text-align: left; vertical-align: top; }
.rt-area th, .rich th { background: var(--slate-50); font-weight: 600; }
@media (max-width: 560px) { .rt-cols, .rich .rt-cols { grid-template-columns: 1fr; } }
.rt-tablepick { position: fixed; z-index: 80; background: #fff; border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-lg); padding: 10px; }
.rt-tablepick[hidden] { display: none; }
.rt-tp-grid { display: grid; grid-template-columns: repeat(10, 17px); grid-auto-rows: 17px; gap: 3px; }
.rt-tp-grid i { width: 17px; height: 17px; border: 1px solid var(--slate-200, #E2E8F0); border-radius: 3px; cursor: pointer; background: var(--slate-50); }
.rt-tp-grid i.on { background: var(--accent); border-color: var(--accent); }
.rt-tp-label { text-align: center; font-size: 12px; font-weight: 540; color: var(--slate-500); margin-top: 9px; }
.menu-item .sc { margin-left: auto; font-family: var(--font-mono); font-size: 11px; color: var(--slate-400); }

/* ============================================================
   Modal & sheet
   ============================================================ */
.overlay {
  position: fixed; inset: 0; z-index: 200; background: rgba(15,23,42,0.32); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center; padding: 7vh 20px 20px; animation: fadeIn .16s; overflow-y: auto;
}
.overlay[hidden] { display: none; }
.modal {
  width: 100%; max-width: 540px; background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-xl);
  animation: scaleIn .18s cubic-bezier(.22,1,.36,1); overflow: hidden;
}
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 17px; font-weight: 650; }
.modal-head .sub { font-size: 13px; color: var(--slate-500); margin-top: 3px; }
.modal-body { padding: 22px 24px; max-height: 64vh; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--border); background: var(--slate-50); }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ============================================================
   Activity timeline
   ============================================================ */
.timeline { position: relative; }
.timeline .rail { position: absolute; left: 15px; top: 6px; bottom: 14px; width: 1.5px; background: var(--border); }
.timeline .ev { display: flex; gap: 12px; padding: 8px 0; position: relative; }
.timeline .ev-icon { width: 32px; height: 32px; border-radius: 50%; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-xs); display: flex; align-items: center; justify-content: center; flex: none; z-index: 1; }
.timeline .ev-text { font-size: 13px; line-height: 1.4; }
.timeline .ev-text b { font-weight: 600; }
.timeline .ev-meta { display: flex; align-items: center; gap: 8px; margin-top: 2px; font-size: 11.5px; color: var(--slate-400); }

/* ============================================================
   Invoice document
   ============================================================ */
.doc { padding: 0; overflow: hidden; }
.doc-strip { height: 4px; }
.doc-body { padding: 36px; }
.doc-head { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 16px; }
.doc-title { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.doc-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; margin: 32px 0; padding-top: 24px; border-top: 1px solid var(--border); }
.doc-meta-label { font-size: 11px; font-weight: 600; color: var(--slate-400); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 8px; }
.doc-amount { font-size: 26px; font-weight: 720; letter-spacing: -0.025em; }
table.doc-items { width: 100%; }
table.doc-items th { font-size: 11px; font-weight: 600; color: var(--slate-400); text-transform: uppercase; letter-spacing: 0.04em; padding: 0 0 10px; border-bottom: 1px solid var(--border); }
table.doc-items td { padding: 14px 0; font-size: 13.5px; border-bottom: 1px solid var(--border); }
.doc-totals { width: 280px; margin-left: auto; }
.doc-row { display: flex; justify-content: space-between; align-items: baseline; padding: 7px 0; font-size: 13.5px; }
.doc-notes { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--slate-500); line-height: 1.6; }

/* ============================================================
   Toasts
   ============================================================ */
.toaster { position: fixed; bottom: 24px; right: 24px; z-index: 400; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; }
.toast { display: flex; align-items: center; gap: 11px; background: var(--slate-900); color: #fff; padding: 12px 16px; border-radius: var(--r-lg); box-shadow: var(--shadow-xl); animation: fadeInUp .22s; min-width: 260px; max-width: 380px; }
.toast .msg { font-size: 13.5px; font-weight: 500; flex: 1; }

/* ============================================================
   Command palette
   ============================================================ */
.cmd-overlay { position: fixed; inset: 0; z-index: 300; background: rgba(15,23,42,0.3); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); display: flex; justify-content: center; align-items: flex-start; padding: 12vh 20px 20px; animation: fadeIn .14s; }
.cmd-overlay[hidden] { display: none; }
.cmd { width: 100%; max-width: 580px; background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-xl); overflow: hidden; animation: scaleIn .16s; }
.cmd-input { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.cmd-input input { flex: 1; border: none; outline: none; font-size: 15.5px; background: transparent; color: var(--text); }
.cmd-results { max-height: 380px; overflow-y: auto; padding: 8px; }
.cmd-group-label { font-size: 11px; font-weight: 600; color: var(--slate-400); text-transform: uppercase; letter-spacing: 0.05em; padding: 6px 10px 4px; }
.cmd-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 10px; border-radius: var(--r-md); border: none; background: transparent; text-align: left; cursor: pointer; }
.cmd-item:hover, .cmd-item.cmd-active { background: var(--slate-100); }
.cmd-item .ci-icon { width: 30px; height: 30px; border-radius: var(--r-sm); background: var(--slate-100); display: flex; align-items: center; justify-content: center; color: var(--slate-500); flex: none; }
.cmd-item .ci-title { font-size: 13.5px; font-weight: 500; color: var(--slate-800); }
.cmd-item .ci-sub { font-size: 12px; color: var(--slate-400); }

/* ============================================================
   Builder live preview
   ============================================================ */
.builder-preview { position: sticky; top: 84px; display: flex; flex-direction: column; gap: 14px; }
.preview-doc { padding: 0; overflow: hidden; box-shadow: var(--shadow-lg); }
.line-row { display: grid; grid-template-columns: 1fr 52px 96px 30px; gap: 8px; padding: 5px 8px; align-items: center; }
.line-head { display: grid; grid-template-columns: 1fr 52px 96px 30px; gap: 8px; padding: 0 8px 8px; font-size: 11px; font-weight: 600; color: var(--slate-400); text-transform: uppercase; letter-spacing: 0.04em; }

/* ---------- Invoice templates (Classic · Modern · Minimal) ---------- */
.pv-strip { height: 3px; background: var(--accent); transition: height .2s, background .2s; }
.pv-title { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; color: var(--slate-900); transition: color .2s; }
.pv-amount { transition: color .2s; }

/* Template option menu — check only on the active row */
.template-option .ico { color: var(--accent); visibility: hidden; }
.template-option.active .ico { visibility: visible; }

/* Modern: thicker gradient strip, accent headline + totals */
.preview-doc[data-theme="modern"] .pv-strip,
.doc[data-theme="modern"] .doc-strip { height: 7px; background: linear-gradient(90deg, var(--accent), #7DA2FF) !important; }
.preview-doc[data-theme="modern"] .pv-title,
.preview-doc[data-theme="modern"] .pv-amount,
.preview-doc[data-theme="modern"] #pv-total-line,
.doc[data-theme="modern"] .doc-title,
.doc[data-theme="modern"] .doc-amount { color: var(--accent); }

/* Minimal: no strip, lighter monochrome headline */
.preview-doc[data-theme="minimal"] .pv-strip { height: 0; }
.doc[data-theme="minimal"] .doc-strip { height: 1px !important; opacity: .4; }
.preview-doc[data-theme="minimal"] .pv-title,
.doc[data-theme="minimal"] .doc-title { color: var(--slate-400); font-weight: 500; letter-spacing: 0; }

/* Inline live preview: render the document larger on roomy screens
   (zoom scales layout + type proportionally; disabled on small screens
   so it never overflows). */
@media (min-width: 960px) {
  #doc-preview-panel .preview-doc { zoom: 1.4; }
}
@media (min-width: 900px) and (max-width: 959.98px) {
  #doc-preview-panel .preview-doc { zoom: 1.2; }
}

/* ---------- Settings ---------- */
.settings-grid { display: grid; grid-template-columns: 220px 1fr; gap: 24px; align-items: flex-start; }
.settings-nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 84px; }
.settings-nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: var(--r-md); border: none; background: transparent; color: var(--slate-500); font-size: 13.5px; font-weight: 500; cursor: pointer; }
.settings-nav a .ico { color: var(--slate-400); }
.settings-nav a.active { background: var(--surface); box-shadow: var(--shadow-xs), inset 0 0 0 1px var(--border); color: var(--slate-900); font-weight: 560; }
.settings-nav a.active .ico { color: var(--accent); }
.settings-row { display: flex; align-items: center; gap: 20px; padding: 18px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.settings-row:last-of-type { border-bottom: none; }
.settings-row .sr-label { flex: 1; min-width: 200px; }
.settings-row .sr-label .t { font-size: 13.5px; font-weight: 560; color: var(--slate-800); }
.settings-row .sr-label .d { font-size: 12.5px; color: var(--slate-400); margin-top: 2px; line-height: 1.45; }
.settings-row .sr-control { min-width: 220px; max-width: 320px; flex: 1; }
.gateway-card { display: flex; align-items: center; gap: 14px; padding: 16px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
.gateway-card .gc-icon { width: 42px; height: 42px; border-radius: var(--r-md); display: flex; align-items: center; justify-content: center; }
.gc-icon { display: flex; align-items: center; justify-content: center; flex: none; }

/* Inline gateway configuration panel */
.gw-panel { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 14px; animation: fadeIn .16s ease; }
.gw-config { display: grid; grid-template-columns: 268px 1fr; gap: 32px; align-items: start; }
.gw-config-aside { border-right: 1px solid var(--border); padding-right: 30px; }
.gw-config-main { max-width: 520px; }
@media (max-width: 820px) {
  .gw-config { grid-template-columns: 1fr; gap: 22px; }
  .gw-config-aside { border-right: none; padding-right: 0; border-bottom: 1px solid var(--border); padding-bottom: 22px; }
}
.profile-stats { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--border); }
.profile-stats > div { padding: 18px 24px; border-right: 1px solid var(--border); }
.profile-stats > div:last-child { border-right: none; }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background:
  radial-gradient(1200px 600px at 50% -10%, #EEF3FF 0%, transparent 60%), var(--slate-50); }
.auth-card { width: 100%; max-width: 400px; }
.auth-brand { display: flex; align-items: center; gap: 11px; justify-content: center; margin-bottom: 28px; }
.demo-note { margin-top: 18px; padding: 12px 14px; background: var(--slate-50); border: 1px solid var(--border); border-radius: var(--r-md); font-size: 12.5px; color: var(--slate-500); line-height: 1.5; }
.demo-note b { color: var(--slate-700); }

/* ---------- Installer ---------- */
.install-wrap { min-height: 100vh; display: flex; align-items: flex-start; justify-content: center; padding: 44px 24px; background:
  radial-gradient(1200px 600px at 50% -10%, #EEF3FF 0%, transparent 60%), var(--slate-50); }
.install-card { width: 100%; max-width: 660px; }
.install-brand { display: flex; align-items: center; gap: 11px; justify-content: center; margin-bottom: 22px; }
.install-steps { display: flex; align-items: center; margin-bottom: 26px; }
.install-steps .st { display: flex; align-items: center; gap: 9px; flex: none; }
.install-steps .num { width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 640; background: var(--slate-150); color: var(--slate-500); flex: none; }
.install-steps .lbl { font-size: 12.5px; font-weight: 540; color: var(--slate-500); white-space: nowrap; }
.install-steps .st.done .num, .install-steps .st.active .num { background: var(--accent); color: #fff; }
.install-steps .st.active .lbl, .install-steps .st.done .lbl { color: var(--slate-800); }
.install-steps .bar { flex: 1; height: 2px; background: var(--slate-150); margin: 0 10px; min-width: 12px; }
.install-steps .st.done + .bar { background: var(--accent); }
.req-list { display: flex; flex-direction: column; }
.req-row { display: flex; align-items: center; gap: 12px; padding: 11px 2px; border-bottom: 1px solid var(--border); }
.req-row:last-child { border-bottom: none; }
.req-ic { width: 26px; height: 26px; border-radius: 7px; display: flex; align-items: center; justify-content: center; flex: none; }
.req-ic.ok { background: #ECFDF3; color: #16A34A; }
.req-ic.bad { background: #FEF3F2; color: #DC2626; }
.req-ic.warn { background: #FFFAEB; color: #D97706; }
.req-row .rl { font-size: 13.5px; font-weight: 540; color: var(--slate-800); }
.req-row .rh { font-size: 12px; color: var(--slate-400); margin-top: 1px; word-break: break-all; }
.db-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.db-card { border: 1.5px solid var(--border); border-radius: var(--r-md); padding: 15px; cursor: pointer; transition: all .14s; background: #fff; }
.db-card:hover { border-color: var(--slate-300); }
.db-card.sel { border-color: var(--accent); box-shadow: var(--ring); }
.db-card h4 { font-size: 14px; font-weight: 620; display: flex; align-items: center; gap: 8px; color: var(--slate-800); }
.db-card p { font-size: 12px; color: var(--slate-500); margin-top: 6px; line-height: 1.5; }
.license-ok { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: #ECFDF3; border: 1px solid #ABEFC6; border-radius: var(--r-md); font-size: 13px; color: #166534; }
@media (max-width: 580px) { .db-choice { grid-template-columns: 1fr; } .install-steps .lbl { display: none; } .install-steps .bar { margin: 0 6px; } }

/* ---------- Portal header ---------- */
.portal-top {
  position: sticky; top: 0; z-index: 50; height: 68px;
  display: flex; align-items: center; gap: 14px; padding: 0 28px; color: var(--slate-800);
  background:
    radial-gradient(460px 140px at 6% -40%, rgba(37,99,235,0.06), transparent 72%),
    var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}
.portal-top .brand-mark { box-shadow: 0 0 0 4px rgba(37,99,235,0.10); }
.portal-brand-name { font-size: 15px; font-weight: 680; letter-spacing: -0.01em; line-height: 1; color: var(--slate-900); }
.portal-chip {
  font-size: 9.5px; font-weight: 650; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent);
  background: var(--accent-soft); border: 1px solid var(--accent-border); padding: 4px 9px; border-radius: 999px; white-space: nowrap;
}
.portal-help {
  display: inline-flex; align-items: center; gap: 7px; color: var(--slate-500);
  font-size: 13px; font-weight: 500; padding: 8px 12px; border-radius: var(--r-md); transition: all .14s;
}
.portal-help:hover { color: var(--slate-800); background: var(--slate-100); }
.portal-back {
  display: inline-flex; align-items: center; gap: 6px; background: var(--surface);
  border: 1px solid var(--border); color: var(--slate-700); font-size: 12.5px; font-weight: 500;
  padding: 8px 13px; border-radius: var(--r-md); cursor: pointer; transition: all .14s; box-shadow: var(--shadow-xs);
}
.portal-back:hover { background: var(--slate-50); color: var(--slate-900); border-color: var(--border-strong); }
.portal-account {
  display: flex; align-items: center; gap: 10px; padding: 4px 11px 4px 4px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); cursor: pointer; transition: all .14s; box-shadow: var(--shadow-xs);
}
.portal-account:hover { background: var(--slate-50); border-color: var(--border-strong); }
.portal-account .acct-name { font-size: 13px; font-weight: 600; line-height: 1.15; color: var(--slate-800); }
.portal-account .acct-sub { font-size: 11px; color: var(--slate-400); line-height: 1.25; }
.portal-top .avatar { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px rgba(15,23,42,0.05); }
@media (max-width: 680px) {
  .portal-top { padding: 0 16px; gap: 10px; height: 60px; }
  .portal-help, .portal-chip, .portal-account .acct-text, .portal-back span { display: none; }
  .portal-back { padding: 8px 9px; }
}

/* ---------- Portal body ---------- */
.portal-wrap { max-width: 1080px; margin: 0 auto; padding: 32px 24px 64px; }
.portal-dropzone {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 16px 18px;
  border: 1.5px dashed var(--border-strong); border-radius: var(--r-lg); background: var(--slate-50);
  cursor: pointer; transition: border-color .14s, background .14s;
}
.portal-dropzone:hover { border-color: var(--accent); background: var(--accent-soft); }
.portal-dropzone-ic {
  width: 42px; height: 42px; flex: none; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--surface); border: 1px solid var(--border); color: var(--accent);
}
/* Range slider (project completion %) */
.range-input { width: 100%; height: 28px; accent-color: var(--accent); cursor: pointer; }
.pay-method { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: var(--r-md); background: var(--surface); cursor: pointer; }
.pay-method.sel { border-color: var(--accent); background: var(--accent-soft); }
.pay-method.sel .ico { color: var(--accent); }

/* ---------- Flash ---------- */
.amount-box { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; background: var(--slate-50); border-radius: var(--r-md); border: 1px solid var(--border); }

/* ============================================================
   Responsive
   ============================================================ */
.mobile-only { display: none !important; }
/* FABs hidden by default; the ≤600px block below reveals them. Declared here
   (before the media queries) so the show rules win on source order. */
.fab-menu, .fab-create { display: none; }

@media (max-width: 1180px) { .split-grid, .split-grid.wide-left { grid-template-columns: 1fr; } }
@media (max-width: 1024px) {
  .grid-kpi { grid-template-columns: repeat(2, 1fr); }
  main#main-scroll { padding: 24px 22px 56px; }
  .split-grid.even { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar.desktop { display: none; }
  .mobile-only { display: inline-flex !important; }
  .mobile-menu-btn { display: inline-flex; }
  .search-trigger { width: 40px; }
  .search-trigger span.q, .search-trigger .kbd { display: none; }
  .settings-grid { grid-template-columns: 1fr; }
  .settings-nav { position: static; flex-direction: row; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 6px; }
  .settings-nav a { white-space: nowrap; }
  .form-grid-2, .grid-3 { grid-template-columns: 1fr; }
  .profile-stats { grid-template-columns: repeat(2, 1fr); }
  .profile-stats > div { border-right: none; border-bottom: 1px solid var(--border); }
  .doc-grid { grid-template-columns: 1fr; gap: 16px; }
}
@media (max-width: 600px) {
  .grid-kpi { grid-template-columns: 1fr; }
  /* Phones: drop the cramped header entirely; floating buttons take over. */
  .topbar { display: none; }
  .fab-menu { display: inline-flex; }
  .fab-create { display: block; }
  main#main-scroll { padding: 78px 16px 96px; }
  .profile-stats { grid-template-columns: 1fr; }
  .doc-body { padding: 22px; }
}

/* ---------- Mobile drawer ---------- */
.drawer-overlay { position: fixed; inset: 0; z-index: 100; background: rgba(15,23,42,0.4); backdrop-filter: blur(2px); animation: fadeIn .16s; }
.drawer-overlay[hidden] { display: none; }
.drawer { width: 256px; height: 100%; animation: slideInLeft .24s; }
.drawer .sidebar { position: static; height: 100%; }

/* ---------- Drawer account footer (phones only) ---------- */
.drawer-account { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.drawer-acct { display: flex; align-items: center; gap: 11px; padding: 6px 8px; border-radius: var(--r-md); text-decoration: none; }
.drawer-acct:hover { background: var(--slate-50); }
.drawer-acct-meta { display: flex; flex-direction: column; min-width: 0; }
.drawer-acct-name { font-size: 13.5px; font-weight: 600; color: var(--slate-800); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drawer-acct-role { font-size: 11.5px; color: var(--slate-400); text-transform: capitalize; }
.drawer-signout { color: var(--danger); }
.drawer-signout .ico { color: var(--danger); }
.drawer-signout:hover { background: var(--danger-soft); border-color: var(--danger-soft); }

/* ---------- Floating action buttons (phones only; topbar is hidden ≤600px) ---------- */
.fab-menu {
  position: fixed; top: 12px; left: 12px; z-index: 90; width: 44px; height: 44px; border-radius: 50%;
  align-items: center; justify-content: center; background: var(--surface); color: var(--slate-700);
  border: 1px solid var(--border); box-shadow: var(--shadow-md); cursor: pointer;
}
.fab-menu:active { transform: scale(0.95); }
.fab-create { position: fixed; right: 18px; bottom: 18px; z-index: 90; }
.fab-btn {
  width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff; border: none; cursor: pointer;
  box-shadow: 0 8px 22px rgba(37,99,235,0.42), inset 0 1px 0 rgba(255,255,255,0.18);
  transition: transform .12s ease, background .14s ease;
}
.fab-btn:hover { background: var(--accent-hover); }
.fab-btn:active { transform: scale(0.94); }
.fab-create .menu-panel { bottom: calc(100% + 12px); top: auto; right: 0; transform-origin: bottom right; }

/* ---------- Mobile list tables → stacked cards (phones) ---------- */
@media (max-width: 600px) {
  .table-scroll { overflow: visible; }
  table.data, table.mcards { min-width: 0 !important; width: 100%; display: block; }
  table.data > thead, table.mcards > thead { display: none; }
  table.data > tbody, table.mcards > tbody { display: block; }
  /* Flat list items separated by a single divider — the outer .card is the only
     frame, so there are no nested/double borders. */
  table.data > tbody > tr, table.mcards > tbody > tr {
    display: flex; flex-wrap: wrap; align-items: center; column-gap: 10px; row-gap: 0;
    border-bottom: 1px solid var(--border); padding: 14px 16px;
  }
  table.data > tbody > tr:last-child, table.mcards > tbody > tr:last-child { border-bottom: 0; }
  tr.is-open { background: var(--slate-50); }
  table.data > tbody > tr > td, table.mcards > tbody > tr > td {
    height: auto !important; min-height: 0 !important;
    padding: 0 !important; border: 0 !important; font-size: 13.5px; color: var(--slate-700); white-space: normal;
  }
  /* Always-visible header line: just the primary identity · actions · chevron.
     Everything else (amount included) lives in the expandable details. */
  td.m-primary { display: block; order: 0; flex: 1 1 auto; min-width: 0; font-weight: 600; color: var(--slate-900); }
  .m-actions   { display: block; order: 2; flex: 0 0 auto; }
  .m-more      { display: block; order: 3; flex: 0 0 auto; }
  .m-toggle {
    width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface);
    display: inline-flex; align-items: center; justify-content: center; color: var(--slate-500); cursor: pointer; padding: 0;
  }
  .m-toggle .ico { transition: transform .2s ease; }
  tr.is-open .m-toggle { color: var(--accent); border-color: var(--accent-border); background: var(--accent-soft); }
  tr.is-open .m-toggle .ico { transform: rotate(180deg); }
  /* Hidden detail columns: revealed as divided label·value rows when open */
  td.m-extra { order: 4; flex-basis: 100%; display: none; }
  tr.is-open > td.m-extra {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 24px;
    padding: 12px 0 !important; border-top: 1px solid var(--border) !important;
  }
  tr.is-open > td.m-extra:nth-of-type(2) { margin-top: 7px; }
  td.m-extra::before {
    content: attr(data-label); flex: none; color: var(--slate-400); font-weight: 540; font-size: 12.5px; white-space: nowrap;
  }
  td.m-extra > * { text-align: right; margin-left: auto; }
  /* Complex cells (progress bars etc.) stack: label on top, content full-width. */
  tr.is-open > td.m-extra.m-block { flex-direction: column; align-items: stretch; gap: 6px; }
  td.m-extra.m-block::before { text-align: left; }
  td.m-extra.m-block > * { text-align: left !important; margin-left: 0 !important; width: 100%; }

  /* Filter tabs & segmented controls: swipeable single-row strips, not wrapped/cut off. */
  .tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex: none; white-space: nowrap; }
  .segmented { display: flex; max-width: 100%; min-width: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .segmented::-webkit-scrollbar { display: none; }
  .segmented a, .segmented button { flex: none; white-space: nowrap; }
}

@media print {
  .sidebar, .topbar, .toaster, .no-print { display: none !important; }
  main#main-scroll { padding: 0 !important; overflow: visible !important; }
  body { background: #fff; }
  .card { box-shadow: none; border-color: #e5e7eb; }
}
