/* ====== الديوانة التونسية — نظام إدارة الشركات ====== */
/* Premium official palette derived from the Douane seal: navy + gold + red + cream */

:root {
  /* Brand — red */
  --tn-red: #c8102e;
  --tn-red-deep: #9c0c23;
  --tn-red-soft: #fbe9eb;
  --tn-red-line: #efc3c9;

  /* Brand — navy (from seal background) */
  --navy: #013a6b;
  --navy-deep: #012647;
  --navy-2: #024d8c;
  --navy-soft: #eef3f8;

  /* Brand — gold (from seal medallion) */
  --gold: #b88a2e;
  --gold-bright: #e7c969;
  --gold-deep: #8a6618;
  --gold-soft: #f7efdb;
  --gold-grad: linear-gradient(135deg, #e7c969 0%, #b88a2e 45%, #8a6618 100%);

  /* Neutrals (warm-cream balance) */
  --ink: #1b2128;
  --ink-soft: #4b545e;
  --muted: #8a929c;
  --line: #e8eaee;
  --line-strong: #d6dae0;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --surface-3: #eef0f4;
  --bg: #f1f3f6;
  --cream: #faf7f1;

  /* Status accents — shared chroma/lightness, varied hue */
  --ok: oklch(0.6 0.13 150);
  --ok-soft: oklch(0.96 0.03 150);
  --warn: oklch(0.68 0.13 65);
  --warn-soft: oklch(0.96 0.05 72);

  /* System */
  --radius: 16px;
  --radius-sm: 11px;
  --radius-lg: 24px;
  --shadow-sm: 0 1px 2px rgba(18, 22, 26, 0.05), 0 1px 3px rgba(18, 22, 26, 0.04);
  --shadow: 0 6px 18px rgba(18, 22, 26, 0.08), 0 2px 6px rgba(18, 22, 26, 0.04);
  --shadow-lg: 0 24px 60px rgba(1, 38, 71, 0.22), 0 6px 18px rgba(18, 22, 26, 0.1);
  --ring: 0 0 0 4px rgba(200, 16, 46, 0.14);
  --font: "Tajawal", "Cairo", system-ui, sans-serif;
  --font-head: "Cairo", "Tajawal", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body { direction: rtl; }

button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--tn-red); color: #fff; }

/* ---------- Brand: official seal (logo on navy disc) ---------- */
.seal {
  --s: 46px;
  width: var(--s); height: var(--s);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #024d8c 0%, #013a6b 60%, #012647 100%);
  display: grid; place-items: center; flex: none;
  box-shadow: 0 0 0 1.5px var(--gold), 0 0 0 3px rgba(231,201,105,0.25), 0 4px 12px rgba(1,38,71,0.3);
  overflow: hidden;
}
.seal img { width: 100%; height: 100%; object-fit: cover; display: block; }
.seal--sm { --s: 40px; }
.seal--lg { --s: 132px; box-shadow: 0 0 0 2px var(--gold-bright), 0 0 0 7px rgba(231,201,105,0.18), 0 14px 40px rgba(1,38,71,0.5); }

/* ---------- Accurate Tunisian flag ---------- */
.flag {
  --fw: 40px;
  width: var(--fw); height: calc(var(--fw) * 0.667);
  border-radius: 5px; flex: none;
  box-shadow: var(--shadow-sm); border: 1px solid rgba(0,0,0,0.08);
  overflow: hidden; background: #c8102e;
}
.flag svg { width: 100%; height: 100%; display: block; }
.flag--lg { --fw: 64px; border-radius: 7px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  padding: 0 18px; height: 44px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink);
  font-weight: 700; font-size: 15px; cursor: pointer;
  transition: transform .12s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease, color .15s ease;
  white-space: nowrap;
}
.btn:hover { box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn svg { width: 18px; height: 18px; }

.btn--primary {
  background: linear-gradient(180deg, #d2153a 0%, var(--tn-red) 55%, var(--tn-red-deep) 100%);
  border-color: var(--tn-red-deep); color: #fff;
  box-shadow: 0 6px 16px rgba(200, 16, 46, 0.3);
}
.btn--primary:hover { box-shadow: 0 9px 24px rgba(200,16,46,0.4); filter: brightness(1.04); }

.btn--navy { background: var(--navy); border-color: var(--navy-deep); color: #fff; box-shadow: 0 6px 16px rgba(1,38,71,0.25); }
.btn--navy:hover { background: var(--navy-deep); box-shadow: 0 9px 22px rgba(1,38,71,0.34); }

.btn--danger { background: var(--tn-red); border-color: var(--tn-red-deep); color: #fff; box-shadow: 0 6px 16px rgba(200,16,46,0.3); }
.btn--danger:hover { background: var(--tn-red-deep); }

.btn--ghost { background: transparent; border-color: transparent; }
.btn--ghost:hover { background: var(--surface-3); box-shadow: none; }

.btn--lg { height: 52px; font-size: 16px; padding: 0 26px; }
.btn--block { width: 100%; }

/* small action buttons */
.act {
  width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface);
  display: grid; place-items: center; cursor: pointer; color: var(--ink-soft);
  transition: all .14s ease;
}
.act svg { width: 17px; height: 17px; }
.act:hover { background: var(--surface-3); transform: translateY(-1px); }
.act--edit:hover { color: var(--navy); border-color: #b9d2ea; background: var(--navy-soft); }
.act--del:hover { color: #fff; background: var(--tn-red); border-color: var(--tn-red); }
.act--note:hover { color: var(--gold-deep); border-color: #e3cf94; background: var(--gold-soft); }
.act.has-note { color: var(--gold-deep); border-color: #e3cf94; background: var(--gold-soft); }

/* ---------- Inputs ---------- */
.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font-size: 13.5px; font-weight: 700; color: var(--ink-soft); }
.field .req { color: var(--tn-red); margin-inline-start: 2px; }
.input, .textarea, select.input {
  width: 100%; background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 0 14px; height: 46px; outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.textarea { height: auto; padding: 12px 14px; resize: vertical; min-height: 120px; line-height: 1.7; }
.input:focus, .textarea:focus, select.input:focus { border-color: var(--tn-red); box-shadow: var(--ring); }
.input::placeholder, .textarea::placeholder { color: var(--muted); }
input[type="date"].input { color: var(--ink); }

/* ---------- Card ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

/* gold hairline divider */
.gold-rule { height: 2px; background: var(--gold-grad); border-radius: 2px; opacity: .85; }

/* ---------- Top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 30; background: rgba(255,255,255,0.94); backdrop-filter: saturate(160%) blur(10px); border-bottom: 1px solid var(--line); }
.topbar::after { content: ""; display: block; height: 3px; background: var(--gold-grad); }
.topbar__inner { max-width: 1200px; margin: 0 auto; padding: 12px 24px; display: flex; align-items: center; gap: 16px; }
.topbar__brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar__titles { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.topbar__titles .t1 { font-family: var(--font-head); font-weight: 800; font-size: 16px; line-height: 1.2; color: var(--navy-deep); white-space: nowrap; }
.topbar__titles .t2 { font-size: 12px; color: var(--muted); white-space: nowrap; }
.topbar__spacer { flex: 1; }
.topbar__user { display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.topbar__user .avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--navy-soft); color: var(--navy); display: grid; place-items: center; font-weight: 800; font-size: 14px; border: 1px solid #cfe0f0; }
.topbar__user .name { font-weight: 700; font-size: 14px; }
.topbar__user .role { font-size: 11.5px; color: var(--muted); }

/* ---------- Page shell ---------- */
.page { max-width: 1200px; margin: 0 auto; padding: 28px 24px 64px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font-family: var(--font-head); font-size: 27px; font-weight: 800; margin: 0; letter-spacing: -0.01em; color: var(--navy-deep); }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.page-head .grow { flex: 1; }

/* ---------- Badge ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.badge--active  { background: var(--ok-soft);      color: oklch(0.44 0.12 150); }
.badge--stopped { background: var(--warn-soft);    color: oklch(0.48 0.12 58); }
.badge--navy    { background: var(--navy-soft);    color: var(--navy-deep); }
.badge--gold    { background: var(--gold-soft);    color: var(--gold-deep); }
.badge--danger  { background: var(--tn-red-soft);  color: var(--tn-red-deep); }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.search { position: relative; flex: 1; min-width: 240px; }
.search svg { position: absolute; inset-inline-start: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.search .input { padding-inline-start: 42px; height: 50px; }

.stat-chips { display: flex; gap: 10px; flex-wrap: wrap; }
.chip { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 14px; display: flex; align-items: center; gap: 9px; box-shadow: var(--shadow-sm); }
.chip .num { font-family: var(--font-head); font-weight: 800; font-size: 18px; color: var(--navy-deep); }
.chip .lbl { font-size: 12.5px; color: var(--muted); }
.chip .ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; }
.chip .ic svg { width: 16px; height: 16px; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table.tbl { width: 100%; border-collapse: collapse; min-width: 880px; }
.tbl thead th { text-align: right; font-size: 12.5px; font-weight: 800; color: #fff; background: linear-gradient(180deg, var(--navy-2), var(--navy)); padding: 15px 16px; white-space: nowrap; }
.tbl thead th:first-child { border-start-start-radius: var(--radius); }
.tbl thead th:last-child { border-start-end-radius: var(--radius); }
.tbl tbody td { padding: 14px 16px; border-bottom: none; font-size: 14px; vertical-align: middle; }
.tbl tbody tr { transition: background .12s ease; border-bottom: 1px solid var(--line); }
.tbl tbody tr:hover { background: var(--navy-soft); }
.tbl tbody tr:last-child { border-bottom: none; }
.tbl .co-name { font-weight: 800; color: var(--ink); }
.tbl .co-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tbl .code { font-family: var(--font-head); font-weight: 700; letter-spacing: 0.02em; color: var(--navy-deep); }
.tbl .actions { display: flex; gap: 7px; justify-content: flex-start; }

.empty { padding: 64px 20px; text-align: center; color: var(--muted); }
.empty .em-ic { width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 14px; background: var(--surface-3); display: grid; place-items: center; color: var(--muted); }
.empty .em-ic svg { width: 26px; height: 26px; }
.empty h3 { color: var(--ink-soft); margin: 0 0 6px; font-size: 17px; }
.empty p { margin: 0; }

/* ---------- Modal / popups ---------- */
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(1, 22, 41, 0.5); backdrop-filter: blur(4px); display: none; align-items: center; justify-content: center; padding: 24px; }
.overlay.open { display: flex; animation: fade .15s ease; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 540px; overflow: hidden; animation: pop .2s cubic-bezier(.2,.8,.3,1); }
@keyframes pop { from { transform: translateY(14px) scale(.97); opacity: 0; } }
.modal__head { position: relative; padding: 22px 22px 20px; display: flex; align-items: center; gap: 14px; background: linear-gradient(180deg, var(--navy) 0%, var(--navy-deep) 100%); color: #fff; }
.modal__head::after { content: ""; position: absolute; inset-inline: 0; bottom: 0; height: 3px; background: var(--gold-grad); }
.modal__head h3 { margin: 0; font-family: var(--font-head); font-size: 18px; font-weight: 800; color: #fff; }
.modal__head .sub { font-size: 12.5px; color: rgba(255,255,255,0.7); margin-top: 3px; }
.modal__head .x { margin-inline-start: auto; background: rgba(255,255,255,0.12); border-color: transparent; color: #fff; }
.modal__head .x:hover { background: rgba(255,255,255,0.22); }
.modal__head.head--danger { background: linear-gradient(180deg, var(--tn-red) 0%, var(--tn-red-deep) 100%); }
.modal__body { padding: 22px; }
.modal__foot { padding: 16px 22px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-start; background: var(--surface-2); }

.modal__icon { width: 46px; height: 46px; border-radius: 12px; background: rgba(255,255,255,0.14); display: grid; place-items: center; flex: none; }
.modal__icon svg { width: 24px; height: 24px; color: #fff; }

.note-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.note-meta .pill { background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; font-size: 12.5px; color: var(--ink-soft); }
.note-meta .pill b { color: var(--navy-deep); font-weight: 800; }
.note-box { background: var(--gold-soft); border: 1px solid #ecdcb4; border-inline-start: 4px solid var(--gold); border-radius: var(--radius-sm); padding: 16px 18px; line-height: 1.9; font-size: 14.5px; color: var(--ink-soft); white-space: pre-wrap; max-height: 320px; overflow-y: auto; }
.note-box.empty-note { background: var(--surface-2); border-color: var(--line); border-inline-start-color: var(--line-strong); color: var(--muted); font-style: italic; }

.warn-row { display: flex; gap: 14px; align-items: flex-start; }
.warn-row .wic { width: 44px; height: 44px; border-radius: 12px; background: var(--tn-red-soft); color: var(--tn-red); display: grid; place-items: center; flex: none; }
.warn-row .wic svg { width: 22px; height: 22px; }
.warn-row p { margin: 0; line-height: 1.8; color: var(--ink-soft); }

/* ---------- Login ---------- */
.login-stage { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.login-art { position: relative; color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden;
  background: radial-gradient(120% 90% at 75% 12%, #024d8c 0%, var(--navy) 45%, var(--navy-deep) 100%); }
.login-art::before { content: ""; position: absolute; inset: 0; background-image: repeating-linear-gradient(45deg, rgba(231,201,105,0.05) 0 1px, transparent 1px 24px); }
.login-art::after { content: ""; position: absolute; inset-inline: 0; bottom: 0; height: 5px; background: var(--gold-grad); }
.login-art__top, .login-art__mid, .login-art__bot { position: relative; z-index: 1; }
.login-art .seal-row { display: flex; align-items: center; gap: 18px; }
.login-art__mid h2 { font-family: var(--font-head); font-size: 36px; font-weight: 800; line-height: 1.25; margin: 0 0 16px; letter-spacing: -0.01em; }
.login-art__mid .accent { color: var(--gold-bright); }
.login-art__mid p { font-size: 16px; line-height: 1.85; color: rgba(255,255,255,0.82); max-width: 440px; margin: 0; }
.login-art__bot { font-size: 13px; color: rgba(255,255,255,0.72); display: flex; align-items: center; gap: 10px; }
.login-art__bot .gline { width: 30px; height: 2px; background: var(--gold-grad); }

.login-panel { background: var(--surface); display: flex; align-items: center; justify-content: center; padding: 40px; }
.login-form { width: 100%; max-width: 384px; }
.login-form .brand-mini { display: flex; align-items: center; gap: 12px; margin-bottom: 30px; }
.login-form h1 { font-family: var(--font-head); font-size: 25px; font-weight: 800; margin: 0 0 6px; color: var(--navy-deep); }
.login-form .lead { color: var(--muted); font-size: 14px; margin: 0 0 26px; }
.login-form .field { margin-bottom: 16px; }
.login-form .hint { margin-top: 18px; font-size: 12.5px; color: var(--muted); text-align: center; line-height: 1.7; }
.login-form .err { background: var(--tn-red-soft); border: 1px solid var(--tn-red-line); color: var(--tn-red-deep); border-radius: var(--radius-sm); padding: 11px 14px; font-size: 13.5px; font-weight: 600; margin-bottom: 16px; display: none; }
.login-form .err.show { display: block; }

/* ---------- Form page ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 20px; }
.form-grid .full { grid-column: 1 / -1; }
.form-section-title { font-family: var(--font-head); font-weight: 800; font-size: 14px; color: var(--navy-deep); margin: 0 0 2px; grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; }
.form-section-title .n { width: 22px; height: 22px; border-radius: 6px; background: var(--gold-grad); color: #fff; display: grid; place-items: center; font-size: 12px; flex: none; }
.form-section-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.form-actions { display: flex; gap: 12px; margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--line); align-items: center; }

.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.breadcrumb a:hover { color: var(--tn-red); }
.breadcrumb svg { width: 14px; height: 14px; }

/* ---------- Toast ---------- */
.toast { position: fixed; inset-block-end: 24px; inset-inline-start: 50%; transform: translate(-50%, 20px); background: var(--navy-deep); color: #fff; padding: 13px 20px; border-radius: 999px; font-weight: 700; font-size: 14px; box-shadow: var(--shadow-lg); z-index: 80; opacity: 0; pointer-events: none; transition: all .25s ease; display: flex; align-items: center; gap: 9px; border: 1px solid rgba(231,201,105,0.35); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast svg { width: 18px; height: 18px; color: var(--gold-bright); }

/* ---------- FAB (Floating Action Button — mobile only) ---------- */
.fab {
  display: none;
  position: fixed; inset-block-end: 20px; inset-inline-end: 20px; z-index: 50;
  width: 58px; height: 58px; border-radius: 50%;
  background: linear-gradient(180deg, #d2153a 0%, var(--tn-red) 55%, var(--tn-red-deep) 100%);
  color: #fff; box-shadow: 0 8px 24px rgba(200,16,46,.45);
  align-items: center; justify-content: center;
  transition: transform .15s ease, box-shadow .15s ease;
}
.fab svg { width: 26px; height: 26px; }
.fab:hover { transform: scale(1.08); box-shadow: 0 12px 32px rgba(200,16,46,.55); }

/* ════════════════════════════════════════════════════════
   LAYOUT CLASSES (responsive-dependent)
════════════════════════════════════════════════════════ */
.charts-grid {
  display: grid; grid-template-columns: 1fr 1.8fr; gap: 20px; margin-bottom: 22px;
}
.profile-forms-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 20px;
}

/* ════════════════════════════════════════════════════════
   RESPONSIVE — Tablet large (≤ 1024px)
════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .stat-chips { flex-wrap: wrap; }
  .charts-grid { grid-template-columns: 1fr 1fr; }
}

/* ════════════════════════════════════════════════════════
   RESPONSIVE — Tablet / phablet (≤ 768px)
════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* Login */
  .login-stage { grid-template-columns: 1fr; }
  .login-art   { display: none; }
  .login-panel { padding: 28px 22px; min-height: 100vh; }
  .login-form  { max-width: 100%; }

  /* Topbar */
  .topbar__inner    { padding: 10px 14px; gap: 8px; }
  .topbar__titles .t2 { display: none; }
  .topbar__titles .t1 { font-size: 14px; }
  .topbar__user .meta { display: none; }
  .btn-label-full   { display: none; }

  /* Page shell */
  .page         { padding: 18px 14px 72px; }
  .page-head    { flex-direction: column; align-items: flex-start; gap: 12px; }
  .page-head h1 { font-size: 22px; }

  /* Stats chips — horizontal scroll */
  .stat-chips { display: flex; flex-wrap: nowrap; overflow-x: auto;
                -webkit-overflow-scrolling: touch; gap: 8px;
                padding-bottom: 4px; width: 100%; }
  .stat-chips::-webkit-scrollbar { display: none; }
  .chip { flex-shrink: 0; }

  /* Toolbar */
  .toolbar { flex-direction: column; align-items: stretch; gap: 8px; }
  .search  { min-width: 0; width: 100%; }
  .toolbar > .btn, .toolbar > a.btn { align-self: flex-start; }

  /* Filter panel */
  .filter-row    { flex-direction: column; gap: 8px; }
  .filter-group  { width: 100%; }
  .filter-select { width: 100%; height: 46px; }

  /* Form */
  .form-grid { grid-template-columns: 1fr; }
  .form-actions { flex-wrap: wrap; gap: 8px; }
  .form-actions .btn { flex: 1; min-width: 110px; justify-content: center; }
  .form-actions span[style*="flex:1"] { display: none; }

  /* Draft banner */
  .draft-banner { flex-direction: column; align-items: flex-start; }

  /* FAB visible on mobile, hide toolbar add button */
  .fab { display: flex; }
  .toolbar-add-btn { display: none; }

  /* Profile */
  .profile-hero  { padding: 18px; }
  .profile-forms-grid { grid-template-columns: 1fr; }

  /* Admin charts */
  .charts-grid { grid-template-columns: 1fr; }

  /* Table → card mode */
  .table-wrap { overflow: visible; }
  table.tbl, .tbl thead, .tbl tbody, .tbl th, .tbl td, .tbl tr { display: block; min-width: 0; }
  .tbl thead { display: none; }
  .tbl tbody tr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; padding: 6px 4px; box-shadow: var(--shadow-sm); }
  .tbl tbody td { border: none; padding: 9px 14px; display: flex; justify-content: space-between; gap: 12px; align-items: center; min-height: 44px; }
  .tbl tbody td::before { content: attr(data-label); font-weight: 800; color: var(--ink-soft); font-size: 12px; flex-shrink: 0; }
  .tbl tbody td.actions { justify-content: flex-end; padding-top: 12px; border-top: 1px solid var(--line); margin-top: 4px; }
  .tbl tbody td.actions::before { display: none; }
  .tbl .co-cell { text-align: left; }

  /* Modal → bottom sheet */
  .overlay { padding: 0; align-items: flex-end; background: rgba(1,22,41,.6); }
  .modal   { border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
             max-width: 100% !important; margin: 0; animation: slideUp .25s ease; }
  @keyframes slideUp { from { transform: translateY(100%); opacity: 0; } }

  /* Attachment inline grid */
  .notes-attach-grid { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); }
  .notes-attach-preview { height: 76px; }

  /* Toast */
  .toast { inset-inline-start: 14px; inset-inline-end: 14px; transform: translateY(20px);
           inset-block-end: 80px; border-radius: var(--radius-sm); }
  .toast.show { transform: translateY(0); }
}

/* ════════════════════════════════════════════════════════
   RESPONSIVE — Phone (≤ 480px)
════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  /* Topbar: ultra compact */
  .topbar__inner { gap: 6px; padding: 8px 12px; }
  .seal.seal--sm { --s: 34px; }
  .flag { --fw: 30px; }
  .topbar__titles .t1 { font-size: 13px; }
  .topbar__user { padding: 4px; gap: 0; }
  .topbar__user .avatar { width: 30px; height: 30px; font-size: 12px; }
  .btn { padding: 0 12px; height: 40px; font-size: 14px; }
  .btn--lg { height: 46px; padding: 0 18px; }

  /* Page */
  .page { padding: 14px 12px 80px; }
  .page-head h1 { font-size: 20px; }

  /* Stats: 2×N grid */
  .stat-chips { display: grid; grid-template-columns: 1fr 1fr;
                overflow: visible; flex-wrap: unset; }
  .chip { flex-shrink: unset; }
  .chip .num { font-size: 16px; }

  /* Table actions: smaller touch targets */
  .act { width: 40px; height: 40px; border-radius: 10px; }

  /* Form progress */
  .progress-wrap { padding: 10px 14px; }
  #progressDots  { gap: 4px; }

  /* Profile hero: stack vertically */
  .profile-hero > div[style] { flex-direction: column; align-items: center; text-align: center; }

  /* Attachment grid: 3 cols on phone */
  .notes-attach-grid { grid-template-columns: repeat(3, 1fr); }

  /* Filter badge */
  .filter-badge { min-width: 18px; height: 18px; }

  /* Admin hero buttons: stack */
  .page-head > a.btn { width: 100%; justify-content: center; }

  /* Breadcrumb: truncate */
  .breadcrumb { font-size: 12px; flex-wrap: wrap; }

  /* Card padding reduce */
  .card[style*="padding:26px"] { padding: 18px !important; }
  .card[style*="padding:24px"] { padding: 16px !important; }
  .card[style*="padding:22px"] { padding: 14px !important; }

  /* Print controls */
  .print-controls { padding: 10px 14px; flex-wrap: wrap; gap: 8px; }
  .ctrl-btns { width: 100%; justify-content: flex-end; }
}

/* ════════════════════════════════════════════════════════
   PROGRESS BAR
════════════════════════════════════════════════════════ */
.progress-wrap { padding: 14px 20px; margin-bottom: 14px; }
.progress-track { height: 10px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress-fill  { height: 100%; border-radius: 999px; transition: width .4s ease, background .4s ease; background: var(--navy); }

/* ════════════════════════════════════════════════════════
   DRAFT RECOVERY BANNER
════════════════════════════════════════════════════════ */
.draft-banner {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px;
  padding: 14px 18px; margin-bottom: 14px;
  background: var(--gold-soft); border: 1px solid #ecdcb4;
  border-inline-start: 4px solid var(--gold); border-radius: var(--radius-sm);
}

/* ════════════════════════════════════════════════════════
   PROFILE PAGE
════════════════════════════════════════════════════════ */
.profile-hero { padding: 24px 28px; margin-bottom: 0; }

.profile-avatar-wrap {
  position: relative; width: 96px; height: 96px;
  border-radius: 50%; cursor: pointer; flex: none;
  box-shadow: 0 0 0 3px var(--gold), 0 0 0 6px rgba(184,138,46,.18), var(--shadow);
  overflow: hidden;
}
.profile-avatar-img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.profile-avatar-placeholder {
  width: 100%; height: 100%; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-head); font-weight: 800; font-size: 38px; color: #fff;
}
.profile-avatar-overlay {
  position: absolute; inset: 0; border-radius: 50%;
  background: rgba(1,38,71,.62); color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-size: 11px; font-weight: 700;
  opacity: 0; transition: opacity .2s ease;
}
.profile-avatar-overlay svg { width: 22px; height: 22px; }
.profile-avatar-wrap:hover .profile-avatar-overlay { opacity: 1; }

.pwd-wrap { position: relative; }
.pwd-wrap .input { padding-inline-end: 44px; }
.pwd-eye {
  position: absolute; inset-inline-end: 0; top: 0; height: 46px; width: 44px;
  background: transparent; border: none; cursor: pointer; color: var(--muted);
  display: grid; place-items: center; transition: color .15s;
}
.pwd-eye svg { width: 18px; height: 18px; }
.pwd-eye:hover { color: var(--navy); }

.pwd-strength-bar { height: 5px; background: var(--surface-3); border-radius: 999px; overflow: hidden; margin-top: 6px; }
.pwd-strength-bar div { height: 100%; border-radius: 999px; transition: width .3s ease, background .3s ease; }

/* ════════════════════════════════════════════════════════
   ATTACHMENTS
════════════════════════════════════════════════════════ */
.attach-list { padding: 16px 20px; display: flex; flex-direction: column; gap: 10px; }

.attach-item {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--surface-2);
  transition: background .15s;
}
.attach-item:hover { background: var(--navy-soft); }

.attach-thumb-wrap {
  width: 52px; height: 52px; border-radius: 8px; overflow: hidden; flex: none;
  background: var(--surface-3); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  text-decoration: none; transition: transform .15s;
}
.attach-thumb-wrap:hover { transform: scale(1.05); }
.attach-thumb-wrap--file { background: var(--navy-soft); }
.attach-thumb { width: 100%; height: 100%; object-fit: cover; display: block; }

.attach-info { flex: 1; min-width: 0; }
.attach-name { font-weight: 700; font-size: 13.5px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attach-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }

.attach-actions { display: flex; gap: 6px; flex: none; }

.attach-upload-area { border-top: 1px solid var(--line); }
.attach-drop-inner {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 28px 20px; cursor: pointer;
  transition: background .15s;
  text-align: center;
}
.attach-drop-inner:hover { background: var(--surface-2); }
.attach-drop-icon {
  width: 52px; height: 52px; border-radius: 14px;
  background: var(--navy-soft); color: var(--navy);
  display: grid; place-items: center; margin-bottom: 4px;
}
.attach-drop-icon svg { width: 26px; height: 26px; }
.attach-upload-area.dragging { background: var(--gold-soft); }
.attach-upload-area.dragging .attach-drop-inner { background: transparent; }

/* small util */
.btn--sm { height: 36px; font-size: 13px; padding: 0 14px; }
}

/* ════════════════════════════════════════════════════════
   INLINE NOTES ATTACHMENTS
════════════════════════════════════════════════════════ */

/* header label */
.notes-attach-label {
  display: flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 800; color: var(--navy-deep);
  margin-bottom: 12px;
}
.notes-attach-label svg { width: 15px; height: 15px; color: var(--gold); flex: none; }

/* thumbnail grid */
.notes-attach-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

/* individual card */
.notes-attach-card {
  border: 1px solid var(--line); border-radius: 10px;
  overflow: hidden; background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s, transform .15s;
  display: flex; flex-direction: column;
}
.notes-attach-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }

/* preview area (image or file icon) */
.notes-attach-preview {
  display: flex; align-items: center; justify-content: center;
  height: 90px; overflow: hidden; position: relative;
  background: var(--surface-3); text-decoration: none;
  cursor: zoom-in;
}
.notes-attach-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.notes-attach-preview--file { cursor: pointer; background: var(--navy-soft); }
.notes-attach-ext {
  font-family: var(--font-head); font-weight: 800; font-size: 16px;
  color: var(--navy); letter-spacing: .03em;
}

/* hover overlay on preview */
.notes-attach-overlay {
  position: absolute; inset: 0;
  background: rgba(1,38,71,.45); color: #fff;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .2s;
}
.notes-attach-overlay svg { width: 22px; height: 22px; }
.notes-attach-preview:hover .notes-attach-overlay { opacity: 1; }

/* card footer */
.notes-attach-card-foot {
  display: flex; align-items: center; gap: 4px;
  padding: 5px 7px; border-top: 1px solid var(--line);
  background: var(--surface-2);
}
.notes-attach-fname {
  flex: 1; min-width: 0; font-size: 11px; font-weight: 700;
  color: var(--ink-soft); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.notes-attach-del {
  width: 22px; height: 22px; border-radius: 6px; border: none;
  background: transparent; cursor: pointer; color: var(--muted);
  display: grid; place-items: center; flex: none; padding: 0;
  transition: color .14s, background .14s;
}
.notes-attach-del svg { width: 12px; height: 12px; }
.notes-attach-del:hover { color: #fff; background: var(--tn-red); }

/* compact drop zone */
@keyframes spin { to { transform: rotate(360deg); } }

/* ════════════════════════════════════════════════════════
   FIELD HINTS
════════════════════════════════════════════════════════ */
.field-hint {
  font-size: 11.5px; color: var(--muted); margin-top: 4px;
  display: flex; align-items: center; gap: 4px;
}
.field-hint::before {
  content: "ⓘ"; font-size: 12px; color: var(--navy); flex: none;
}

/* ════════════════════════════════════════════════════════
   AGENT AUTOCOMPLETE
════════════════════════════════════════════════════════ */
.autocomplete-list {
  position: absolute; top: calc(100% + 2px);
  inset-inline-start: 0; inset-inline-end: 0; z-index: 30;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
  overflow: hidden; animation: slideIn .15s ease;
}
.autocomplete-item {
  padding: 10px 14px; cursor: pointer; font-size: 14px;
  transition: background .1s; display: flex; align-items: center; gap: 8px;
}
.autocomplete-item::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--navy); flex: none; opacity: .4;
}
.autocomplete-item:hover, .autocomplete-item:focus {
  background: var(--navy-soft); color: var(--navy-deep); outline: none;
}
.autocomplete-item:hover::before, .autocomplete-item:focus::before { opacity: 1; }

/* ════════════════════════════════════════════════════════
   HELP FAB + HELP MODAL
════════════════════════════════════════════════════════ */
.help-fab {
  position: fixed; bottom: 20px; left: 20px; z-index: 50;
  width: 50px; height: 50px; border-radius: 50%; border: none;
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  color: var(--navy-deep); cursor: pointer;
  box-shadow: 0 6px 20px rgba(184,138,46,.45);
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s ease, box-shadow .15s ease;
}
.help-fab svg { width: 24px; height: 24px; }
.help-fab:hover { transform: scale(1.1); box-shadow: 0 10px 28px rgba(184,138,46,.55); }

.help-section-title {
  font-family: var(--font-head); font-weight: 800; font-size: 13px;
  color: var(--navy-deep); margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px;
}
.help-section-title::before {
  content: ""; width: 4px; height: 16px; border-radius: 2px;
  background: var(--gold-grad); flex: none;
}

.help-actions-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.help-action-card {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 14px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  text-decoration: none; text-align: center; transition: box-shadow .15s, transform .15s;
  background: var(--surface);
}
.help-action-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.help-action-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: grid; place-items: center; flex: none;
}
.help-action-icon svg { width: 20px; height: 20px; }
.help-action-label { font-weight: 800; font-size: 13.5px; color: var(--navy-deep); }
.help-action-desc  { font-size: 11.5px; color: var(--muted); line-height: 1.5; }

.help-btns-list { display: flex; flex-direction: column; gap: 12px; }
.help-btn-row { display: flex; align-items: center; gap: 12px; }
.help-btn-row .act { flex: none; }

.help-shortcuts { display: flex; flex-direction: column; gap: 8px; }
.help-shortcut-row { display: flex; align-items: center; gap: 12px; font-size: 13.5px; }
kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 28px; padding: 0 8px;
  background: var(--surface-3); border: 1px solid var(--line-strong);
  border-bottom-width: 2px; border-radius: 6px;
  font-family: monospace; font-size: 12px; font-weight: 700;
  color: var(--navy-deep); flex: none;
}

.help-tips { display: flex; flex-direction: column; gap: 9px; }
.help-tip { display: flex; align-items: flex-start; gap: 9px; font-size: 13.5px; color: var(--ink-soft); line-height: 1.6; }
.help-tip-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; margin-top: 6px; }

/* ════════════════════════════════════════════════════════
   QUICK START BANNER
════════════════════════════════════════════════════════ */
.quickstart-banner {
  border-radius: var(--radius); overflow: hidden; margin-bottom: 20px;
  background: linear-gradient(135deg, #012647 0%, #013a6b 50%, #024d8c 100%);
  box-shadow: 0 8px 32px rgba(1,38,71,.25);
  position: relative;
}
.quickstart-banner::before {
  content: ""; position: absolute; inset: 0;
  background-image: repeating-linear-gradient(45deg, rgba(231,201,105,.04) 0 1px, transparent 1px 28px);
}
.quickstart-banner::after {
  content: ""; position: absolute; inset-inline: 0; bottom: 0;
  height: 4px; background: var(--gold-grad);
}
.qs-inner   { padding: 22px 24px; position: relative; z-index: 1; }
.qs-header  { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.qs-title   { font-family: var(--font-head); font-size: 18px; font-weight: 800; color: #fff; }
.qs-sub     { font-size: 13px; color: rgba(255,255,255,.7); margin-top: 3px; }
.qs-close   { width: 34px; height: 34px; border-radius: 8px; border: none; background: rgba(255,255,255,.12); color: #fff; cursor: pointer; display: grid; place-items: center; flex: none; transition: background .15s; }
.qs-close:hover { background: rgba(255,255,255,.22); }

.qs-steps { display: flex; align-items: stretch; gap: 8px; flex-wrap: wrap; }
.qs-step {
  flex: 1; min-width: 120px; display: flex; flex-direction: column;
  align-items: center; gap: 6px; padding: 16px 10px;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.15);
  border-radius: 12px; text-decoration: none; color: #fff;
  text-align: center; transition: background .15s, transform .15s;
  cursor: default;
}
a.qs-step, button.qs-step { cursor: pointer; }
a.qs-step:hover, button.qs-step:hover { background: rgba(255,255,255,.18); transform: translateY(-2px); }
.qs-step-num {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--tn-red); color: #fff;
  display: grid; place-items: center; font-size: 11px; font-weight: 800; flex: none;
}
.qs-step--help .qs-step-num { background: var(--gold-grad); color: var(--navy-deep); }
.qs-step-label { font-weight: 800; font-size: 13px; }
.qs-step-desc  { font-size: 11px; color: rgba(255,255,255,.65); line-height: 1.5; }
.qs-arrow { color: rgba(255,255,255,.4); font-size: 18px; display: flex; align-items: center; flex: none; }

/* ════════════════════════════════════════════════════════
   RECENTLY VIEWED CHIPS
════════════════════════════════════════════════════════ */
.recent-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border: 1px solid var(--line);
  border-radius: 999px; background: var(--surface);
  font-size: 12.5px; font-weight: 700; color: var(--ink-soft);
  text-decoration: none; transition: all .15s;
  box-shadow: var(--shadow-sm); max-width: 200px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.recent-chip:hover { border-color: var(--navy); background: var(--navy-soft); color: var(--navy-deep); }

.notes-attach-dropzone {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px; border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-sm); cursor: pointer;
  transition: border-color .15s, background .15s;
  font-size: 13.5px;
}
.notes-attach-dropzone svg { width: 20px; height: 20px; color: var(--muted); flex: none; }
.notes-attach-dropzone:hover { border-color: var(--navy); background: var(--navy-soft); }
.notes-attach-dropzone:hover svg { color: var(--navy); }
.notes-attach-dropzone.dragging { border-color: var(--gold); background: var(--gold-soft); }
.notes-attach-types { font-size: 11.5px; color: var(--muted); margin-inline-start: auto; }

/* new-mode hint */
.notes-attach-hint {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 14px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px dashed var(--line-strong);
  color: var(--muted); font-size: 13px;
}
.notes-attach-hint svg { width: 16px; height: 16px; flex: none; }

/* ════════════════════════════════════════════════════════
   FILTER PANEL
════════════════════════════════════════════════════════ */
.filter-panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 14px 18px;
  margin-bottom: 16px; box-shadow: var(--shadow-sm);
}
.filter-row { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-label { font-size: 11.5px; font-weight: 700; color: var(--muted); }
.filter-select { height: 40px; width: auto; min-width: 130px; }
.filter-fav-label {
  display: flex; align-items: center; gap: 6px; cursor: pointer;
  font-weight: 700; font-size: 13px; color: var(--gold-deep);
  padding: 0 10px; height: 40px; border: 1px solid #e3cf94;
  border-radius: var(--radius-sm); background: var(--gold-soft);
  white-space: nowrap;
}
.filter-badge {
  display: inline-grid; place-items: center; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; color: var(--navy-deep);
  font-size: 11px; font-weight: 800;
}

/* ════════════════════════════════════════════════════════
   FAVORITES
════════════════════════════════════════════════════════ */
.fav-btn {
  width: 28px; height: 28px; border-radius: 8px; border: none;
  background: transparent; cursor: pointer; color: var(--muted);
  display: grid; place-items: center; transition: transform .15s, color .15s;
  padding: 0;
}
.fav-btn svg { width: 16px; height: 16px; transition: all .2s; }
.fav-btn:hover { transform: scale(1.2); }
.fav-btn--active { color: var(--gold); }
.row--fav { background: linear-gradient(90deg, rgba(247,239,219,.5), transparent) !important; }
.row--fav:hover { background: linear-gradient(90deg, rgba(236,220,180,.6), var(--navy-soft)) !important; }

/* ════════════════════════════════════════════════════════
   ALERT BADGES
════════════════════════════════════════════════════════ */
.alert-pulse {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--warn); color: #fff; font-size: 10px; font-weight: 800;
  animation: pulse-warn 1.6s ease-in-out infinite;
}
.alert-pulse--red { background: var(--tn-red); animation: pulse-red 1.6s ease-in-out infinite; }
@keyframes pulse-warn {
  0%,100% { box-shadow: 0 0 0 0 rgba(212,134,42,.5); }
  50%      { box-shadow: 0 0 0 5px rgba(212,134,42,0); }
}
@keyframes pulse-red {
  0%,100% { box-shadow: 0 0 0 0 rgba(200,16,46,.5); }
  50%      { box-shadow: 0 0 0 5px rgba(200,16,46,0); }
}
.chip--alert { cursor: default; border-color: var(--tn-red-line); }

/* ════════════════════════════════════════════════════════
   DUPLICATE WARNING
════════════════════════════════════════════════════════ */
.dup-warning {
  display: flex; align-items: center; gap: 8px; margin-top: 6px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  background: var(--warn-soft); border: 1px solid #f0d29a; color: oklch(0.45 0.12 58);
  font-size: 13px; font-weight: 600; animation: slideIn .2s ease;
}
.dup-warning svg { width: 16px; height: 16px; flex: none; }
.dup-warning a { color: var(--navy); font-weight: 800; text-decoration: underline; margin-inline-start: 4px; }
@keyframes slideIn { from { opacity:0; transform:translateY(-4px); } }
@keyframes spin    { to { transform: rotate(360deg); } }

/* ════════════════════════════════════════════════════════
   HISTORY (form)
════════════════════════════════════════════════════════ */
.history-list { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow-y: auto; }
.history-item {
  padding: 10px 14px; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.history-item .h-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.history-item .h-change { display: flex; align-items: center; gap: 8px; font-size: 13px; flex-wrap: wrap; }
.h-old-val { padding: 2px 8px; border-radius: 4px; background: var(--tn-red-soft); color: var(--tn-red-deep); text-decoration: line-through; font-size: 12.5px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.h-new-val { padding: 2px 8px; border-radius: 4px; background: var(--ok-soft); color: oklch(0.44 0.12 150); font-size: 12.5px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
