/* ==========================================================================
   Sazi ERP — white premium UI
   ========================================================================== */

:root {
  --bg: #f6f6f9;
  --surface: #ffffff;
  --surface-2: #fafafc;
  --line: #ececf2;
  --line-strong: #dcdce6;
  --text: #0e0f1f;
  --text-2: #3d3f55;
  --muted: #74768c;
  --faint: #a3a5b8;

  --accent: #2a1696;          /* derived from the Weboweb indigo */
  --accent-2: #1d0a7a;
  --accent-soft: #f0eefc;
  --accent-ring: rgba(42, 22, 150, .16);
  --brand-red: #dc1a28;

  --green: #0f8a5f;  --green-soft: #e8f6ef;
  --amber: #b26a00;  --amber-soft: #fdf3e2;
  --red: #c8283a;    --red-soft: #fdecee;
  --blue: #1f63d6;   --blue-soft: #eaf1fd;
  --grey-soft: #f1f1f5;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow-xs: 0 1px 2px rgba(16, 17, 40, .04);
  --shadow-sm: 0 1px 2px rgba(16, 17, 40, .04), 0 2px 8px rgba(16, 17, 40, .04);
  --shadow-md: 0 10px 30px -10px rgba(16, 17, 40, .18), 0 2px 6px rgba(16, 17, 40, .05);
  --shadow-lg: 0 24px 60px -20px rgba(16, 17, 40, .30);

  --sidebar: 264px;
  --font: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: var(--font);        /* one typeface everywhere; numbers use tabular figures instead */
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.55 var(--font); letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.02em; color: var(--text); }
p { margin: 0; }
.num, td.num, .money { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12.5px; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.ic { width: 18px; height: 18px; flex: none; }

/* ------------------------------------------------------------------ shell */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar); z-index: 40;
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 18px 14px 14px;
}
.sb-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px 14px; }
.brand img { height: 30px; width: auto; }
.sidebar .sb-close { display: none; }
.demo-pill {
  display: flex; align-items: center; gap: 8px; margin: 0 6px 14px; padding: 8px 12px;
  border-radius: 999px; background: linear-gradient(135deg, #f4f2fe, #fdf1f2);
  border: 1px solid #ebe7fb; font-size: 12px; color: var(--text-2);
}
.demo-pill strong { color: var(--accent-2); font-weight: 700; }
.demo-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand-red); box-shadow: 0 0 0 3px rgba(220, 26, 40, .14); flex: none; }
.nav { flex: 1; overflow-y: auto; padding: 0 2px; scrollbar-width: thin; }
.nav-group { font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; font-weight: 700; color: var(--faint); padding: 16px 12px 6px; }
.nav-link {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; margin: 1px 0;
  border-radius: 10px; color: var(--text-2); font-weight: 550; font-size: 13.5px;
  transition: background .15s, color .15s;
}
.nav-link .ic { color: var(--faint); transition: color .15s; }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link:hover .ic { color: var(--text-2); }
.nav-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.nav-link.active .ic { color: var(--accent); }
.sb-foot { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 8px; }
.me { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 12px; }
.me-meta { flex: 1; min-width: 0; }
.me-name { font-weight: 650; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-role { font-size: 11.5px; color: var(--muted); }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #5b45d8); color: #fff; font-weight: 700; font-size: 12.5px; letter-spacing: .02em;
}
.avatar-sm { width: 32px; height: 32px; font-size: 11.5px; }
.avatar-soft { background: var(--accent-soft); color: var(--accent); }

.main { flex: 1; margin-left: var(--sidebar); min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: 64px; display: flex; align-items: center; gap: 14px;
  padding: 0 28px; background: rgba(246, 246, 249, .82); backdrop-filter: saturate(1.6) blur(14px); -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid transparent;
}
.topbar.scrolled { border-bottom-color: var(--line); }
.topbar .menu-btn, .topbar-logo { display: none; }
.topbar-logo img { height: 22px; width: auto; }
.search {
  flex: 1; max-width: 460px; display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 11px; box-shadow: var(--shadow-xs);
  transition: border-color .15s, box-shadow .15s;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); }
.search .ic { color: var(--faint); width: 17px; height: 17px; }
.search input { flex: 1; border: 0; outline: 0; background: transparent; font: inherit; color: var(--text); min-width: 0; }
.search kbd { font: 11px var(--mono); color: var(--faint); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.content { padding: 8px 28px 40px; flex: 1; width: 100%; max-width: 1440px; }
.foot { padding: 18px 28px 26px; color: var(--faint); font-size: 12px; }
.foot a { color: var(--muted); }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 14px 0 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 26px; font-weight: 750; letter-spacing: -0.03em; line-height: 1.2; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumb { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; font-weight: 600; margin-bottom: 8px; }
.crumb .ic { width: 15px; height: 15px; }
.crumb:hover { color: var(--accent); }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px;
  border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  font: 600 13.5px var(--font); cursor: pointer; white-space: nowrap; box-shadow: var(--shadow-xs);
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s, color .15s;
}
.btn:hover { border-color: #c9c9d6; background: var(--surface-2); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 0; box-shadow: 0 0 0 4px var(--accent-ring); }
.btn .ic { width: 17px; height: 17px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(29, 10, 122, .2), inset 0 1px 0 rgba(255, 255, 255, .12); }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--grey-soft); border-color: transparent; }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: var(--red-soft); border-color: #f5c9cf; color: var(--red); }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
.btn-success:hover { background: #0b744f; border-color: #0b744f; color: #fff; }
.btn-wa { color: #128c4b; }
.btn-wa:hover { background: #e9f8ef; border-color: #bfe8cf; color: #0e7a40; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn-lg { height: 48px; padding: 0 22px; font-size: 15px; border-radius: 12px; }
.btn-block { width: 100%; }
.btn.disabled { opacity: .45; pointer-events: none; }
.icon-btn {
  width: 36px; height: 36px; display: inline-grid; place-items: center; border-radius: 10px; border: 0; background: transparent;
  color: var(--muted); cursor: pointer; transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--grey-soft); color: var(--text); }

/* ------------------------------------------------------------------ dropdown */
.dropdown { position: relative; }
.menu {
  position: absolute; top: calc(100% + 8px); left: 0; min-width: 220px; z-index: 50; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(-4px) scale(.98); pointer-events: none; transition: opacity .14s, transform .14s;
}
.menu-right { left: auto; right: 0; }
.dropdown.open .menu { opacity: 1; transform: none; pointer-events: auto; }
.menu a, .menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: 8px; border: 0; background: none;
  color: var(--text-2); font: 550 13.5px var(--font); text-align: left; cursor: pointer;
}
.menu a:hover, .menu button:hover { background: var(--surface-2); color: var(--text); }
.menu .ic { color: var(--faint); width: 17px; height: 17px; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.menu .danger { color: var(--red); }
.menu .danger .ic { color: var(--red); }

/* ------------------------------------------------------------------ cards & stats */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 0; }
.card-head h2, .card-head h3 { font-size: 15px; font-weight: 700; }
.card-head .hint { color: var(--muted); font-size: 12.5px; }
.card-body { padding: 18px 20px 20px; }
.content > .card + .card, .content > form.card + .card { margin-top: 18px; }
.grid { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); align-content: start; }
.grid > * { min-width: 0; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.stat { padding: 18px 20px; position: relative; overflow: hidden; }
.stat-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.stat-label .ic { width: 16px; height: 16px; }
.stat-ic { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.stat-ic.green { background: var(--green-soft); color: var(--green); }
.stat-ic.amber { background: var(--amber-soft); color: var(--amber); }
.stat-ic.red { background: var(--red-soft); color: var(--red); }
.stat-value { font-size: 26px; font-weight: 750; letter-spacing: -0.03em; margin-top: 12px; font-variant-numeric: tabular-nums; }
.stat-foot { margin-top: 6px; font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; font-size: 12px; padding: 1px 7px; border-radius: 999px; }
.delta .ic { width: 13px; height: 13px; }
.delta.up { color: var(--green); background: var(--green-soft); }
.delta.down { color: var(--red); background: var(--red-soft); }

/* ------------------------------------------------------------------ toolbar */
.toolbar { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; padding: 3px; background: var(--grey-soft); border-radius: 11px; overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: 6px 12px; border-radius: 8px; color: var(--muted); font-weight: 600; font-size: 13px; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.tabs a:hover { color: var(--text); }
.tabs a.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); }
.tabs .count { font-size: 11px; color: var(--faint); font-weight: 700; }
.tabs a.on .count { color: var(--accent); }
.toolbar .filter { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.mini-search { display: flex; align-items: center; gap: 6px; height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.mini-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); }
.mini-search .ic { width: 16px; height: 16px; color: var(--faint); }
.mini-search input { border: 0; outline: 0; font: inherit; width: 200px; background: transparent; color: var(--text); }

/* ------------------------------------------------------------------ list (table → cards on mobile) */
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: separate; border-spacing: 0; }
.list th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; color: var(--faint);
  padding: 11px 16px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap;
}
.list td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; color: var(--text-2); }
.list tbody tr { transition: background .12s; }
.list tbody tr:hover { background: #fbfbfe; }
.list tbody tr:last-child td { border-bottom: 0; }
.list tr[data-href] { cursor: pointer; }
.list .r, .list th.r { text-align: right; }
.list .c { text-align: center; }
.list .t-main { color: var(--text); font-weight: 650; }
.list .t-sub { color: var(--muted); font-size: 12.5px; margin-top: 1px; }
.list .amount { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.list .row-actions { display: flex; gap: 2px; justify-content: flex-end; }
.who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.who > div { min-width: 0; }
.doc-no { font-family: var(--mono); font-size: 13px; color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; }

.pager { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px; }
.pager > div { display: flex; gap: 6px; }

/* ------------------------------------------------------------------ badges */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 999px;
  font-size: 12px; font-weight: 650; white-space: nowrap; background: var(--grey-soft); color: var(--text-2);
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge-sent, .badge-dispatched { background: var(--blue-soft); color: var(--blue); }
.badge-accepted, .badge-paid, .badge-delivered, .badge-active { background: var(--green-soft); color: var(--green); }
.badge-partial { background: var(--amber-soft); color: var(--amber); }
.badge-overdue, .badge-declined, .badge-inactive { background: var(--red-soft); color: var(--red); }
.badge-expired, .badge-void, .badge-draft { background: var(--grey-soft); color: var(--muted); }
.badge-role { background: var(--accent-soft); color: var(--accent); }
.badge-role::before { display: none; }
.tag { display: inline-flex; padding: 2px 8px; border-radius: 6px; background: var(--grey-soft); color: var(--text-2); font-size: 12px; font-weight: 600; }

/* ------------------------------------------------------------------ forms */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field label, .label { display: block; font-size: 12.5px; font-weight: 650; color: var(--text-2); margin-bottom: 6px; }
.field .help { font-size: 12px; color: var(--muted); margin-top: 5px; }
.input, .field input:not([type=checkbox]):not([type=radio]):not([type=file]), .field select, .field textarea {
  width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface);
  font: 14px var(--font); color: var(--text); outline: 0; transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none; appearance: none;
}
.field textarea, textarea.input { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.55; }
.field select, select.input {
  padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2374768c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); }
.input::placeholder, .field ::placeholder { color: var(--faint); }
.field input[type=file] { font: 13px var(--font); color: var(--muted); }
.check { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-weight: 550; color: var(--text-2); }
.check input { width: 17px; height: 17px; accent-color: var(--accent); }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 14px; }

/* line items editor */
.lines { width: 100%; border-collapse: separate; border-spacing: 0; }
.lines th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 700; text-align: left; padding: 0 6px 8px; }
.lines td { padding: 4px 6px; vertical-align: top; }
.lines .input { height: 40px; }
.lines textarea.input { min-height: 40px; height: 40px; padding-top: 9px; resize: none; overflow: hidden; }
.lines .w-qty { width: 92px; } .lines .w-price { width: 130px; } .lines .w-amt { width: 130px; } .lines .w-x { width: 40px; }
.lines .line-amt { height: 40px; display: flex; align-items: center; justify-content: flex-end; font-weight: 700; font-variant-numeric: tabular-nums; padding-right: 4px; }
.lines tr.dragging { opacity: .5; }
.totals { margin-left: auto; width: 100%; max-width: 340px; }
.totals .tr { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; color: var(--text-2); gap: 12px; }
.totals .tr .input { width: 110px; height: 36px; text-align: right; }
.totals .grand { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 12px; font-size: 18px; font-weight: 750; color: var(--text); }

/* ------------------------------------------------------------------ toasts / alerts */
.toast {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 12px; margin-bottom: 16px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); font-weight: 550; animation: toastIn .3s ease;
}
.toast span { flex: 1; }
.toast-success { border-color: #c8ead9; background: #f4fbf7; color: #0b6b4a; }
.toast-error { border-color: #f5c9cf; background: #fff6f7; color: #a51f30; }
.toast-info { border-color: #d9d3fb; background: #f7f5ff; color: var(--accent); }
.toast-x { border: 0; background: none; cursor: pointer; color: inherit; opacity: .6; display: grid; padding: 2px; }
.toast-x:hover { opacity: 1; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-6px); } }

/* WhatsApp + PDF helper card (app.js [data-wa-pdf]) */
.wa-note {
  position: fixed; right: 20px; bottom: 20px; z-index: 300; width: min(380px, calc(100vw - 32px));
  display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid #bfe8cf; box-shadow: var(--shadow-lg); animation: toastIn .3s ease; transition: opacity .4s;
}
.wa-note.out { opacity: 0; pointer-events: none; }
.wa-note-ic { flex: none; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: #e9f8ef; color: #128c4b; }
.wa-note-ic svg { width: 19px; height: 19px; }
.wa-note-body { flex: 1; min-width: 0; }
.wa-note-body strong { display: block; font-size: 13.5px; overflow-wrap: anywhere; }
.wa-note-body p { margin: 3px 0 10px; color: var(--text-2); font-size: 12.5px; line-height: 1.45; }
.wa-note-act { display: flex; gap: 8px; flex-wrap: wrap; }
.wa-note .toast-x { color: var(--muted); }
.note { display: flex; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); color: var(--text-2); font-size: 13px; }
.note .ic { color: var(--accent); margin-top: 1px; }

/* ------------------------------------------------------------------ empty */
.empty { text-align: center; padding: 56px 20px; }
.empty-ic { width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 16px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.empty-ic .ic { width: 26px; height: 26px; }
.empty h3 { font-size: 16px; margin-bottom: 4px; }
.empty p { color: var(--muted); margin-bottom: 16px; }

/* ------------------------------------------------------------------ dashboard */
.hello { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { font: 11px var(--font); fill: var(--faint); }
.chart .grid-line { stroke: var(--line); }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.chart-tip {
  position: fixed; z-index: 60; pointer-events: none; padding: 10px 12px; border-radius: 10px; background: #12132a; color: #fff;
  font-size: 12.5px; box-shadow: var(--shadow-lg); opacity: 0; transition: opacity .12s; min-width: 160px;
}
.chart-tip b { display: block; margin-bottom: 4px; }
.chart-tip div { display: flex; justify-content: space-between; gap: 14px; }
.funnel { display: grid; gap: 14px; }
.funnel-row .top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.funnel-row .top b { font-variant-numeric: tabular-nums; }
.bar { height: 8px; border-radius: 99px; background: var(--grey-soft); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 99px; background: var(--accent); }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.feed li:last-child { border-bottom: 0; }
.feed .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-top: 7px; flex: none; box-shadow: 0 0 0 4px var(--accent-soft); }
.feed .when { font-size: 12px; color: var(--faint); }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.quick a {
  display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 14px; border-radius: 12px; border: 1px solid var(--line);
  color: var(--text-2); font-weight: 600; font-size: 13px; transition: border-color .15s, box-shadow .15s, transform .15s;
}
.quick a:hover { border-color: #d6d0fb; box-shadow: var(--shadow-md); transform: translateY(-1px); color: var(--text); }
.quick .ic { width: 20px; height: 20px; color: var(--accent); }

/* ------------------------------------------------------------------ detail view */
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 10px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--text); font-weight: 550; word-break: break-word; }
.side-actions { display: grid; gap: 8px; }
.side-actions .btn { justify-content: flex-start; }
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline li { position: relative; padding: 0 0 16px 26px; font-size: 13px; }
.timeline li::before { content: ''; position: absolute; left: 6px; top: 16px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.timeline .tdot { position: absolute; left: 0; top: 3px; width: 13px; height: 13px; border-radius: 50%; border: 3px solid var(--accent-soft); background: var(--accent); }
.timeline .tdot.green { background: var(--green); border-color: var(--green-soft); }
.timeline .tdot.grey { background: var(--faint); border-color: var(--grey-soft); }
.progress-pay { margin-top: 14px; }
.copy-field { display: flex; gap: 6px; }
.copy-field input { flex: 1; min-width: 0; height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 9px; font: 12px var(--mono); color: var(--muted); background: var(--surface-2); }

/* ------------------------------------------------------------------ paper (document preview) */
.paper-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 8px; }
.paper-scroll { overflow-x: auto; }
.paper { min-width: 680px; padding: 44px 48px; color: #1b1c30; }

/* ------------------------------------------------------------------ modal */
.modal { position: fixed; inset: 0; z-index: 70; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal.open { display: flex; }
.modal-bg { position: absolute; inset: 0; background: rgba(14, 15, 31, .38); backdrop-filter: blur(3px); animation: fade .2s; }
.modal-card { position: relative; width: 100%; max-width: 520px; max-height: calc(100vh - 40px); overflow: auto; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); animation: pop .22s cubic-bezier(.2, .9, .3, 1.2); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 20px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }

/* ------------------------------------------------------------------ signature pad */
.sigpad { position: relative; border: 1.5px dashed var(--line-strong); border-radius: 14px; background: #fcfcfe; touch-action: none; }
.sigpad canvas { display: block; width: 100%; height: 200px; cursor: crosshair; }
.sigpad .sig-hint { position: absolute; inset: 0; display: grid; place-items: center; color: var(--faint); pointer-events: none; font-weight: 600; }
.sigpad .sig-line { position: absolute; left: 24px; right: 24px; bottom: 44px; border-bottom: 1px solid var(--line-strong); pointer-events: none; }
.sigpad.has-ink .sig-hint { display: none; }

/* ------------------------------------------------------------------ auth */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; background: var(--surface); }
.auth-side {
  position: relative; overflow: hidden; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; color: #fff;
  background: radial-gradient(1200px 600px at -10% -10%, #4b33d6 0%, transparent 55%), radial-gradient(900px 500px at 120% 120%, #e2384a 0%, transparent 50%), linear-gradient(160deg, #1d0a7a, #140663);
}
.auth-side::after { content: ''; position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px); background-size: 44px 44px; mask-image: linear-gradient(180deg, transparent, #000 30%, #000 70%, transparent); pointer-events: none; }
.auth-side > * { position: relative; z-index: 1; }
.auth-side h2 { color: #fff; font-size: 38px; line-height: 1.12; font-weight: 750; letter-spacing: -0.035em; max-width: 460px; }
.auth-side p { color: rgba(255, 255, 255, .72); max-width: 420px; margin-top: 14px; font-size: 15px; }
.auth-feats { display: grid; gap: 10px; margin-top: 30px; }
.auth-feats div { display: flex; gap: 10px; align-items: center; color: rgba(255, 255, 255, .88); font-weight: 550; }
.auth-feats .ic { color: #b8adff; }
.auth-chip { display: inline-flex; gap: 8px; align-items: center; padding: 7px 14px; border-radius: 999px; background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .16); font-size: 12.5px; font-weight: 600; width: fit-content; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-box { width: 100%; max-width: 400px; }
.auth-box .logo { height: 34px; width: auto; margin-bottom: 36px; }
.auth-box h1 { font-size: 28px; font-weight: 750; letter-spacing: -0.03em; }
.auth-box .lead { color: var(--muted); margin: 6px 0 28px; }
.auth-box .field { margin-bottom: 16px; }
.demo-creds { margin-top: 24px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.demo-creds button { display: flex; width: 100%; justify-content: space-between; align-items: center; padding: 11px 14px; border: 0; border-bottom: 1px solid var(--line); background: var(--surface); font: 13px var(--font); cursor: pointer; color: var(--text-2); }
.demo-creds button:last-child { border-bottom: 0; }
.demo-creds button:hover { background: var(--surface-2); }
.demo-creds .mono { color: var(--muted); }

/* ------------------------------------------------------------------ public sign page */
.public { background: var(--bg); min-height: 100vh; }
.public-top { background: var(--surface); border-bottom: 1px solid var(--line); }
.public-top .in { max-width: 920px; margin: 0 auto; padding: 14px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.public-top img { height: 26px; width: auto; }
.public-body { max-width: 920px; margin: 0 auto; padding: 24px 20px 60px; }
.sign-banner { display: flex; align-items: center; gap: 14px; padding: 18px 20px; margin-bottom: 18px; }
.sign-banner .big { font-size: 22px; font-weight: 750; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.sig-typed { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; color: #1d0a7a; }

/* ------------------------------------------------------------------ tabbar (mobile) */
.tabbar { display: none; }
.scrim { display: none; }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1200px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main { grid-template-columns: minmax(0, 1fr) 320px; }
}
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); transition: transform .26s cubic-bezier(.2, .8, .2, 1); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .sidebar .sb-close { display: inline-grid; }
  .scrim { position: fixed; inset: 0; z-index: 35; background: rgba(14, 15, 31, .32); opacity: 0; pointer-events: none; transition: opacity .2s; display: block; }
  .sidebar.open + .scrim { opacity: 1; pointer-events: auto; }
  .main { margin-left: 0; }
  .topbar .menu-btn { display: inline-grid; }
  .grid-main { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  body { font-size: 14.5px; }
  .topbar { padding: 0 12px; gap: 8px; height: 58px; background: rgba(255, 255, 255, .9); border-bottom-color: var(--line); }
  .topbar-logo { display: block; }
  .search { display: none; }
  .hide-sm, .hide-md { display: none !important; }
  .content { padding: 4px 16px 100px; }
  .foot { display: none; }
  .page-head { margin: 14px 0 16px; align-items: flex-start; }
  .page-head h1 { font-size: 22px; }
  .page-actions { width: 100%; }
  .page-actions > .btn, .page-actions > .dropdown { flex: 1; }
  .page-actions > .dropdown > .btn { width: 100%; }
  .stats { gap: 10px; }
  .stat { padding: 14px; }
  .stat-value { font-size: 20px; }
  .grid-2, .grid-3, .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .card-head { padding: 16px 16px 0; }
  .card-body { padding: 16px; }
  .quick { grid-template-columns: repeat(3, 1fr); }
  .toolbar { padding: 12px; }
  .toolbar .filter { margin-left: 0; width: 100%; }
  .mini-search { flex: 1; }
  .mini-search input { width: 100%; }
  .kv { grid-template-columns: 110px 1fr; }

  /* list rows → cards */
  table.list thead { display: none; }
  table.list, .list tbody { display: block; }
  .list tbody tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center;
    padding: 14px 14px; border-bottom: 1px solid var(--line);
  }
  .list tbody tr:last-child { border-bottom: 0; }
  .list td { display: none; padding: 0; border: 0; }
  .list td.m-main { display: block; grid-column: 1; grid-row: 1; min-width: 0; }
  .list td.m-end { display: block; grid-column: 2; grid-row: 1; text-align: right; }
  .list td.m-sub { display: block; grid-column: 1; grid-row: 2; color: var(--muted); font-size: 12.5px; }
  .list td.m-badge { display: block; grid-column: 2; grid-row: 2; text-align: right; }
  .list td.m-main .t-main { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .list .who .avatar { width: 34px; height: 34px; }

  .lines thead { display: none; }
  .lines, .lines tbody { display: block; }
  .lines tr { display: grid; grid-template-columns: 1fr 1fr 1fr 36px; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; background: var(--surface-2); }
  .lines td { padding: 0; width: auto !important; }
  .lines td.cell-desc { grid-column: 1 / -1; }
  .lines td.cell-amt { grid-column: 1 / 4; }
  .lines td.cell-x { grid-column: 4; grid-row: 3; }
  .lines td.cell-amt .line-amt { justify-content: flex-start; }
  .lines td.cell-amt .line-amt::before { content: 'Amount'; color: var(--muted); font-weight: 600; margin-right: auto; font-size: 12.5px; }
  .lines td[data-l]::before { content: attr(data-l); display: block; font-size: 11px; font-weight: 700; color: var(--faint); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
  .totals { max-width: none; }

  .form-actions { position: sticky; bottom: 70px; z-index: 5; border-radius: 0 0 var(--radius) var(--radius); }
  .form-actions .btn { flex: 1; }

  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }

  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; height: calc(64px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom); background: rgba(255, 255, 255, .94); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
  }
  .tabbar a, .tabbar button {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; background: none;
    color: var(--faint); font: 600 11px var(--font); cursor: pointer;
  }
  .tabbar .ic { width: 21px; height: 21px; }
  .tabbar .on { color: var(--accent); }

  .modal { align-items: flex-end; padding: 0; }
  .modal-card { max-width: none; border-radius: 20px 20px 0 0; max-height: 92vh; }
  .paper { padding: 28px 24px; }
  .sigpad canvas { height: 180px; }
  .sign-banner { flex-wrap: wrap; }
}

@media print {
  .sidebar, .topbar, .tabbar, .foot, .page-head, .no-print, .toast { display: none !important; }
  .main { margin: 0; }
  .content { padding: 0; }
  .paper-wrap { border: 0; box-shadow: none; padding: 0; }
  body { background: #fff; }
}

/* permissions matrix */
.perm { width: 100%; border-collapse: collapse; font-size: 13px; }
.perm th { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 700; text-align: left; padding: 0 6px 10px; }
.perm td { padding: 10px 6px; border-top: 1px solid var(--line); color: var(--text-2); }
.perm .c { text-align: center; }
.perm .ic { width: 16px; height: 16px; }

.stat-foot { flex-wrap: wrap; }
.card-head { flex-wrap: wrap; }
@media (max-width: 760px) {
  .chart text { font-size: 20px; }
  .legend { width: 100%; }
  .stat-foot { font-size: 12px; }
  .stat-label { font-size: 12px; align-items: flex-start; }
  .stat-ic { width: 26px; height: 26px; }
}
@media (max-width: 760px) {
  .form-grid > * { grid-column: 1 / -1 !important; }
  .form-actions { padding: 12px; gap: 8px; }
  .form-actions a.btn-ghost { display: none; }
  .form-actions .btn { padding: 0 10px; }
  .main { overflow-x: clip; }
}
@media (max-width: 760px) {
  .paper-scroll { overflow: hidden; }
  .paper-wrap { padding: 0; }
  .paper { zoom: .46; min-width: 680px; padding: 36px 40px; }
}
@media (max-width: 359px) { .paper { zoom: .4; } }

/* ------------------------------------------------------------------ filter bar */
.filterbar { border-bottom: 1px solid var(--line); }
.filterbar .toolbar { border-bottom: 0; }
.filterbar .filter { flex-wrap: wrap; }
.fbtn b { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--accent); color: #fff; font-size: 11px; }
.fbtn.on { border-color: #cfc8f7; background: var(--accent-soft); color: var(--accent); }
.sort-sel { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 4px 0 10px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface); color: var(--muted); box-shadow: var(--shadow-xs); }
.sort-sel .ic { width: 15px; height: 15px; }
.sort-sel select { border: 0; outline: 0; background: transparent; font: 600 13px var(--font); color: var(--text-2); cursor: pointer; padding-right: 4px; max-width: 170px; }
.fpanel { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px; padding: 0 16px 14px; }
.fl { display: flex; flex-direction: column; gap: 4px; min-width: 150px; }
.fl > span { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); }
.fl .input { height: 36px; font-size: 13px; }
.fl select.input { min-width: 170px; }
.fl[hidden] { display: none; }
.fl-range { display: flex; align-items: center; gap: 6px; }
.fl-range .input { width: 100px; }
.fl-range i { color: var(--faint); font-style: normal; }
.fl-actions { flex-direction: row; min-width: 0; margin-left: auto; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 14px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 8px 0 11px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-size: 12.5px; font-weight: 600; border: 1px solid #e2ddfb; }
.chip .ic { width: 13px; height: 13px; opacity: .7; }
.chip:hover { background: #e6e2fb; }
.list-summary { display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.list-summary b { color: var(--text); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ photos */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.photo { position: relative; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface-2); }
.photo img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.photo .cap { padding: 8px; }
.photo .cap .input { height: 32px; font-size: 12.5px; }
.photo .cap-text { padding: 8px 10px; font-size: 12.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.photo .rm { position: absolute; top: 6px; right: 6px; display: flex; align-items: center; gap: 4px; padding: 4px 8px; border-radius: 8px; background: rgba(255,255,255,.92); font-size: 12px; font-weight: 600; color: var(--red); cursor: pointer; box-shadow: var(--shadow-sm); border: 0; }
.photo .rm input { accent-color: var(--red); }
.photo.removing img { opacity: .35; filter: grayscale(1); }
.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 22px; border: 1.5px dashed var(--line-strong); border-radius: 14px; background: var(--surface-2); color: var(--muted); text-align: center; cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.dropzone .ic { width: 26px; height: 26px; color: var(--accent); }
.dropzone strong { color: var(--text); }
.dropzone input { display: none; }
.pending { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; margin-top: 10px; }
.pending img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }

@media (max-width: 760px) {
  .fpanel { display: none; padding: 0 12px 12px; }
  .fpanel.open { display: grid; grid-template-columns: 1fr 1fr; }
  .fl { min-width: 0; }
  .fl select.input { min-width: 0; }
  .fl-amt, .fl-actions { grid-column: 1 / -1; }
  .fl-range .input { flex: 1; width: auto; }
  .fl-actions .btn { flex: 1; }
  .chips { padding: 0 12px 12px; }
  .sort-sel select { max-width: 110px; }
  .filterbar .filter { flex-wrap: nowrap; }
  .fbtn span { display: none; }
  .photos { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 761px) {
  .fpanel { display: none; }
  .fpanel.open { display: flex; }
}
@media (max-width: 760px) {
  .filterbar .filter { flex-wrap: wrap; }
  .filterbar .mini-search { flex: 1 1 100%; }
  .filterbar .sort-sel { flex: 1; }
  .filterbar .sort-sel select { max-width: none; flex: 1; }
  .fl-range .input { min-width: 0; }
  .fl-actions { margin-left: 0; }
}

/* ------------------------------------------------------------------ client form */
.client-form .card-body { padding: 24px 26px 26px; }
.fsec + .fsec { margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--line); }
.fsec-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.fsec-head .stat-ic { width: 38px; height: 38px; border-radius: 11px; }
.fsec-head h3 { font-size: 15px; font-weight: 700; }
.fsec-head p { color: var(--muted); font-size: 12.5px; margin-top: 1px; }
.req { color: var(--brand-red); }
.input-ic { position: relative; }
.input-ic > .ic { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--faint); pointer-events: none; transition: color .15s; }
.input-ic:focus-within > .ic { color: var(--accent); }
.field .input-ic input:not([type=checkbox]):not([type=radio]):not([type=file]) { padding-left: 40px; }
.client-form .field textarea { min-height: 116px; }

.cprev-wrap { position: sticky; top: 84px; display: grid; gap: 14px; }
.cprev { overflow: hidden; }
.cprev-band { height: 72px; background: linear-gradient(135deg, var(--accent-2), #5b45d8 70%, #7c6af0); }
.cprev-avatar { width: 60px; height: 60px; font-size: 19px; margin: -30px 0 0 22px; border: 4px solid var(--surface); box-sizing: content-box; position: relative; }
.cprev-name { padding: 12px 22px 0; font-size: 18px; font-weight: 750; letter-spacing: -0.02em; line-height: 1.3; word-break: break-word; }
.cprev-uen { padding: 2px 22px 0; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cprev-rows { list-style: none; margin: 16px 0 0; padding: 14px 22px 4px; border-top: 1px solid var(--line); display: grid; gap: 11px; }
.cprev-rows li { display: flex; gap: 10px; font-size: 13px; color: var(--text-2); min-width: 0; }
.cprev-rows .ic { width: 16px; height: 16px; color: var(--accent); margin-top: 2px; }
.cprev-rows span { white-space: pre-line; word-break: break-word; min-width: 0; }
.cprev .is-empty { color: var(--faint); }
.cprev-name.is-empty { color: var(--muted); }
.cprev-meter { margin: 14px 22px 0; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.cprev-meter-top { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.cprev-meter-top b { color: var(--text); font-variant-numeric: tabular-nums; }
.cprev-meter .bar { height: 6px; border-radius: 99px; background: var(--grey-soft); overflow: hidden; }
.cprev-meter .bar span { display: block; height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--accent), #5b45d8); transition: width .25s ease; }
.cprev-actions { display: grid; gap: 8px; padding: 18px 22px 22px; }
.client-form .note .ic { width: 17px; height: 17px; }

@media (min-width: 1025px) { .client-form .form-actions-compact { display: none; } }
@media (max-width: 1024px) {
  .cprev-wrap { position: static; order: -1; }
  .cprev-actions { display: none; }
  .cprev-rows, .cprev-meter { display: none; }
  .cprev { display: grid; grid-template-columns: auto 1fr; align-items: center; padding-bottom: 16px; }
  .cprev-band { grid-column: 1 / -1; height: 46px; }
  .cprev-avatar { grid-row: span 2; margin: -22px 0 0 18px; width: 48px; height: 48px; font-size: 16px; }
  .cprev-name { padding: 8px 18px 0 14px; font-size: 16px; }
  .cprev-uen { grid-column: 2; padding: 0 18px 0 14px; }
}
@media (max-width: 760px) {
  .client-form .card-body { padding: 18px 16px 20px; }
  .client-form .field[style*="span 2"] { grid-column: auto !important; }
  .cprev-wrap .note { display: none; }
}

/* ------------------------------------------------------------------ document actions */
.tool-group { display: flex; gap: 0; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-xs); overflow: hidden; }
.tool-group > form { display: contents; }
.tool-group .btn-tool { height: 40px; border: 0; border-radius: 0; box-shadow: none; padding: 0 12px; gap: 7px; font-size: 13px; background: transparent; }
.tool-group .btn-tool + .btn-tool, .tool-group form .btn-tool, .tool-group form + .btn-tool { border-left: 1px solid var(--line); }
.tool-group .btn-tool:hover { background: var(--grey-soft); }
.tool-group .btn-wa:hover { background: #e9f8ef; }
.tool-group .btn-danger:hover { background: var(--red-soft); }
.list .row-actions form { display: contents; }
.list .row-actions .icon-btn { width: 32px; height: 32px; }
.list .row-actions .icon-btn .ic { width: 17px; height: 17px; }
.list .row-actions .ic-wa:hover { background: #e9f8ef; color: #128c4b; }
.list .row-actions .ic-del:hover { background: var(--red-soft); color: var(--red); }
.icon-btn.is-off { opacity: .35; cursor: not-allowed; }
@media (max-width: 1200px) { .tool-group .btn-tool span { display: none; } .tool-group .btn-tool { padding: 0 11px; } }
@media (max-width: 760px) {
  .page-actions > .tool-group { flex: 1 1 100%; }
  .tool-group .btn-tool { flex: 1; justify-content: center; }
  .list .row-actions { justify-content: flex-start; flex-wrap: wrap; }
}

/* ------------------------------------------------------------------ email signature */
.sig-mode { display: flex; gap: 20px; flex-wrap: wrap; margin-bottom: 10px; }
.field textarea.is-auto { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
.mail-mock { border: 1px solid var(--line); border-radius: 12px; padding: 0 18px 18px; font-size: 13px; color: var(--text-2); line-height: 1.6; overflow: hidden; }
.mail-mock-bar { height: 4px; background: var(--accent-2); margin: 0 -18px 14px; }
.mail-mock-co { font-weight: 800; color: var(--accent-2); }
.mail-mock-h { font-size: 16px; font-weight: 750; color: var(--text); margin: 6px 0 8px; }
.mail-mock p { margin: 0 0 8px; }
.mail-sig { margin-top: 14px; color: var(--muted); font-size: 12.5px; line-height: 1.55; white-space: normal; word-break: break-word; }
.mail-sig b { color: var(--text); font-size: 13.5px; }
.me-link { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; color: inherit; border-radius: 10px; }
.me-link:hover .me-name { color: var(--accent); }
a.avatar:hover { color: #fff; box-shadow: 0 0 0 3px var(--accent-ring); }

/* ------------------------------------------------------------------ email composer */
.modal-card.modal-mail { max-width: 980px; display: flex; flex-direction: column; overflow: hidden; }
.modal-mail .modal-head { flex: none; }
.mc-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); flex: 1; min-height: 0; overflow: auto; }
.mc-form { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.mc-msg { flex: 1; display: flex; flex-direction: column; }
.mc-msg textarea { flex: 1; min-height: 200px; }
.mc-checks { display: grid; gap: 8px; font-size: 13.5px; }
.mc-edit { font-size: 12.5px; font-weight: 600; margin-left: 2px; }
.mc-note { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.mc-note .ic { width: 15px; height: 15px; color: var(--accent); flex: none; }

.mc-preview { padding: 20px; background: var(--surface-2); border-left: 1px solid var(--line); }
.mc-preview-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); margin-bottom: 8px; }
.mc-mail { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; font-size: 13px; line-height: 1.6; color: var(--text-2); }
.mc-head-row { display: flex; gap: 8px; font-size: 12.5px; color: var(--text-2); min-width: 0; }
.mc-head-row span { width: 52px; flex: none; color: var(--faint); }
.mc-head-row b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.mc-form, .mc-preview, .mc-mail { min-width: 0; }
.mc-head-last { padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.mc-text { word-break: break-word; }
.mc-link { margin-top: 12px; }
.mc-link span { color: #1a56db; text-decoration: underline; }
.mc-sigprev { margin-top: 14px; font-size: 12.5px; color: var(--muted); }
.mc-sigprev b { color: var(--text); font-weight: 600; }
.mc-file { display: inline-flex; align-items: center; gap: 6px; margin-top: 14px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 12px; color: var(--text-2); }
.mc-file .ic { width: 14px; height: 14px; color: var(--muted); }
[data-mp-show][hidden], [data-hide-empty][hidden] { display: none !important; }

.mc-actions { flex: none; align-items: center; border-radius: 0; }
.mc-from { margin-right: auto; font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 860px) {
  .mc-grid { grid-template-columns: minmax(0, 1fr); overflow-x: hidden; }
  .mc-preview { border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 760px) {
  .modal-card.modal-mail { max-height: 94vh; }
  .mc-form, .mc-preview { padding: 16px; }
  .mc-from { display: none; }
  .modal-mail .mc-actions { position: static; bottom: auto; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
}

/* ------------------------------------------------------------------ sign-in code */
.otp-ic { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); margin-bottom: 18px; }
.otp-ic .ic { width: 24px; height: 24px; }
.otp-boxes { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.otp-box { width: 100%; height: 58px; text-align: center; font: 700 24px var(--font); color: var(--text); border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); outline: 0; transition: border-color .15s, box-shadow .15s; font-variant-numeric: tabular-nums; }
.otp-box:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); }
.otp-foot { display: flex; justify-content: center; align-items: center; gap: 10px; margin-top: 18px; }
.otp-link { border: 0; background: none; padding: 0; font: 600 13px var(--font); color: var(--accent); cursor: pointer; }
.otp-link:disabled { color: var(--faint); cursor: default; }
.login-msg:empty { display: none; }
.login-msg .toast { margin-bottom: 16px; }
.otp-panel { margin-top: 22px; padding-top: 22px; border-top: 1px solid var(--line); opacity: 0; transform: translateY(-6px); transition: opacity .25s ease, transform .25s ease; }
.otp-panel.is-in { opacity: 1; transform: none; }
.otp-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.otp-head > .ic { width: 38px; height: 38px; padding: 9px; border-radius: 11px; background: var(--accent-soft); color: var(--accent); flex: none; }
.otp-head b { display: block; font-size: 14.5px; color: var(--text); }
.otp-head span { font-size: 12.5px; color: var(--muted); }
.otp-hint { font-size: 12px; color: var(--muted); text-align: center; margin-top: 12px; }
form.is-done .btn-primary { background: var(--green); border-color: var(--green); box-shadow: none; opacity: 1; }
form.is-done .btn-primary .ic { display: none; }
.auth-box form.is-done .field input[readonly] { background: var(--surface-2); color: var(--muted); }
.btn.is-busy { opacity: .85; cursor: progress; }
@keyframes otp-shake { 10%, 90% { transform: translateX(-2px); } 30%, 70% { transform: translateX(5px); } 50% { transform: translateX(-5px); } }
.otp-panel.shake .otp-boxes { animation: otp-shake .4s ease; }
.otp-panel.shake .otp-box { border-color: var(--red); }

/* ------------------------------------------------------------------ company signature (settings) */
.sig-set { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 18px; align-items: start; }
.sig-doc { border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; background: #fff; }
.sig-doc-img { height: 84px; display: flex; align-items: flex-end; font-size: 12.5px; }
.sig-doc-img img { max-height: 84px; max-width: 100%; width: auto; }
.sig-doc-line { border-top: 1px solid #b9bbcb; margin-top: 4px; }
.sig-doc-cap { font-size: 11.5px; color: var(--muted); margin-top: 6px; line-height: 1.5; }
.sig-doc-cap b { color: var(--text-2); }
.sig-current .help { margin-top: 8px; }
.sig-new .sigpad canvas { height: 150px; }
.sig-or { display: flex; align-items: center; gap: 10px; margin: 12px 0 8px; font-size: 12px; color: var(--faint); }
.sig-or::before, .sig-or::after { content: ''; flex: 1; border-top: 1px solid var(--line); }
.sig-new input[type=file] { font: 13px var(--font); color: var(--muted); }
.sig-on { display: flex; flex-wrap: wrap; gap: 10px 22px; padding-top: 4px; }
@media (max-width: 760px) { .sig-set { grid-template-columns: 1fr; } }
