/* ==========================================================================
   سامانه بهای تمام شده و قیمت‌گذاری رستوران
   Design tokens: Royal Red / Ink / Charcoal / Gray / Warm White
   Signature motif: مهر (round official seal) — used in brand mark,
   report headers/watermarks and empty states.
   ========================================================================== */

@font-face {
  font-family: 'Vazirmatn';
  src: url('https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/fonts/webfonts/Vazirmatn-Regular.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/fonts/webfonts/Vazirmatn-Medium.woff2') format('woff2');
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/fonts/webfonts/Vazirmatn-SemiBold.woff2') format('woff2');
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/fonts/webfonts/Vazirmatn-Bold.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/fonts/webfonts/Vazirmatn-ExtraBold.woff2') format('woff2');
  font-weight: 800; font-style: normal; font-display: swap;
}

:root {
  /* --- Brand palette --- */
  --royal-red:      #7E1128;   /* primary brand — deep royal red / burgundy */
  --royal-red-dim:  #5C0C1D;   /* pressed / gradients */
  --red-bright:     #C81E3C;   /* accent — buttons, active states, alerts */
  --red-soft:       #F4DCE0;   /* tinted backgrounds for red accents */
  --ink:            #17151A;   /* near-black — sidebar, headers */
  --charcoal:       #26232A;   /* secondary dark surface */
  --charcoal-2:     #35313A;   /* hover on dark surfaces */
  --gray-900:       #2A282D;
  --gray-700:       #57545C;
  --gray-500:       #83808A;
  --gray-300:       #C8C4CB;
  --gray-200:       #E2DFE3;
  --gray-100:       #EFEDF0;
  --paper:          #FAF8F7;   /* app background — warm off-white */
  --white:          #FFFFFF;

  --pos: #1E7B4D;   /* positive / favorable variance */
  --neg: #B3271F;   /* negative / unfavorable variance */
  --warn-bg: #FBEFE3;
  --warn-fg: #8A4B12;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(23,21,26,.06), 0 1px 1px rgba(23,21,26,.04);
  --shadow-md: 0 6px 20px rgba(23,21,26,.10), 0 2px 6px rgba(23,21,26,.06);
  --shadow-lg: 0 16px 40px rgba(23,21,26,.16);

  --sidebar-w: 264px;
  --header-h: 68px;

  --font-ui: 'Vazirmatn', 'Segoe UI', Tahoma, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  background: var(--paper);
  color: var(--gray-900);
  direction: rtl;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 1, "ss01" 1;
}
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }
a { color: inherit; }

.num, td.num, .kpi-value, input[inputmode="decimal"] {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}
/* اعداد همیشه با ارقام غربی/انگلیسی و جهت چپ‌به‌راست نمایش داده شوند،
   حتی داخل فونت فارسی Vazirmatn و صفحه‌ای با lang="fa" */
.num-ltr, bdi[lang="en"], input[inputmode="decimal"] {
  font-feature-settings: "tnum" 1, "locl" 0;
  unicode-bidi: isolate;
  direction: ltr;
}

/* ---------- App shell ---------- */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  order: -1; /* در RTL، ترک اول شبکه = سمت راست؛ منو باید در ترک اول قرار گیرد */
  background: linear-gradient(175deg, var(--royal-red) 0%, var(--royal-red-dim) 62%, #3D0A15 100%);
  color: var(--gray-200);
  padding: 22px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-left: 1px solid rgba(0,0,0,.18);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 20px;
  margin-bottom: 10px;
  border-bottom: 1px solid rgba(0,0,0,.2);
}
.brand-mark {
  width: 42px; height: 42px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--white);
  overflow: hidden;
  box-shadow: 0 0 0 2px rgba(0,0,0,.35), 0 0 0 4px rgba(0,0,0,.12);
}
.brand-mark img { width: 100%; height: 100%; object-fit: contain; }
.brand-mark svg { width: 100%; height: 100%; display: block; padding: 6px; }
.org-logo-mark { background: var(--gray-100, #EFEDF0); box-shadow: none; }
.org-logo-empty { width: 100%; height: 100%; display: grid; place-items: center; color: var(--gray-400, #A8A5AC); }
.brand-text .t1 { font-weight: 800; font-size: 14.5px; color: var(--white); line-height: 1.3; }
.brand-text .t2 { font-weight: 500; font-size: 11px; color: rgba(255,255,255,.62); }

.nav-group-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: .04em;
  color: rgba(255,255,255,.5); text-transform: uppercase;
  margin: 16px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: rgba(255,255,255,.78); font-size: 13.5px; font-weight: 500;
  text-decoration: none; border: none; background: transparent; width: 100%;
  text-align: right; transition: background .15s, color .15s;
  position: relative;
}
.nav-item svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav-item:hover { background: rgba(0,0,0,.18); color: var(--white); }
.nav-item.active {
  background: rgba(0,0,0,.32);
  color: var(--white);
  font-weight: 700;
}
.nav-item.active::before {
  content: ""; position: absolute; right: 0; top: 8px; bottom: 8px; width: 3px;
  background: var(--white); border-radius: 3px 0 0 3px;
}
.nav-item .badge-dot {
  margin-inline-start: auto; width: 7px; height: 7px; border-radius: 50%;
  background: var(--white); display: none;
}
.nav-item.has-alert .badge-dot { display: inline-block; }

.sidebar-foot {
  margin-top: auto; padding: 14px 10px 4px;
  border-top: 1px solid rgba(0,0,0,.2);
  font-size: 11px; color: rgba(255,255,255,.55);
  display: flex; align-items: center; justify-content: space-between;
}
.period-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(0,0,0,.24); color: var(--white);
  padding: 5px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
}

/* ---------- Main column ---------- */
.main {
  display: flex; flex-direction: column; min-width: 0;
}
.topbar {
  height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px;
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  position: sticky; top: 0; z-index: 20;
}
.topbar-title { display: flex; flex-direction: column; gap: 2px; }
.topbar-title h1 { margin: 0; font-size: 17px; font-weight: 800; color: var(--ink); }
.topbar-title p { margin: 0; font-size: 12px; color: var(--gray-500); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.select-period {
  border: 1px solid var(--gray-200); background: var(--gray-100);
  border-radius: var(--radius-sm); padding: 8px 12px; font-size: 12.5px;
  font-family: inherit; font-weight: 600; color: var(--gray-900);
}

.content { padding: 24px 28px 60px; flex: 1; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  padding: 9px 16px; font-size: 13px; font-weight: 700;
  transition: transform .08s ease, box-shadow .15s, background .15s, border-color .15s;
  white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(180deg, var(--red-bright), var(--royal-red)); color: var(--white); box-shadow: var(--shadow-sm); }
.btn-primary:hover { box-shadow: var(--shadow-md); }
.btn-outline { background: var(--white); border-color: var(--gray-200); color: var(--gray-900); }
.btn-outline:hover { border-color: var(--royal-red); color: var(--royal-red); }
.btn-ghost { background: transparent; color: var(--gray-700); }
.btn-ghost:hover { background: var(--gray-100); }
.btn-dark { background: var(--ink); color: var(--white); }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn-icon { padding: 8px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- Cards & sections ---------- */
.card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
  overflow: hidden;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--gray-100);
  gap: 12px; flex-wrap: wrap;
}
.card-head h2 { margin: 0; font-size: 14.5px; font-weight: 800; color: var(--ink); display: flex; align-items: center; gap: 8px;}
.card-head h2::before { content: ""; width: 4px; height: 16px; background: var(--red-bright); border-radius: 3px; display: inline-block; }
.card-head p { margin: 2px 0 0; font-size: 12px; color: var(--gray-500); }
.card-body { padding: 18px 20px; }
.card-body.pad-0 { padding: 0; }

.section-note {
  font-size: 12px; color: var(--gray-500); background: var(--gray-100);
  border-radius: var(--radius-sm); padding: 10px 14px; margin: 12px 20px 18px;
  line-height: 1.8;
  border-right: 3px solid var(--gray-300);
}
.section-note.warn { background: var(--warn-bg); color: var(--warn-fg); border-color: #E5B27A; }
.section-note.info { background: var(--red-soft); color: var(--royal-red-dim); border-color: var(--royal-red); }

/* ---------- KPI grid ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.kpi-card {
  background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius-lg);
  padding: 16px 18px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.kpi-card::after {
  content: ""; position: absolute; inset-inline-end: -30px; top: -30px; width: 90px; height: 90px;
  border-radius: 50%; background: radial-gradient(circle, rgba(200,30,60,.10), transparent 70%);
}
.kpi-label { font-size: 12px; color: var(--gray-500); font-weight: 600; margin-bottom: 8px; }
.kpi-value { font-size: 21px; font-weight: 800; color: var(--ink); }
.kpi-sub { font-size: 11.5px; margin-top: 6px; font-weight: 600; }
.kpi-sub.pos { color: var(--pos); }
.kpi-sub.neg { color: var(--neg); }
.kpi-sub.neutral { color: var(--gray-500); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.dt { width: 100%; border-collapse: collapse; font-size: 12.8px; }
table.dt thead th {
  background: var(--gray-100); color: var(--gray-700);
  font-weight: 700; text-align: right; padding: 11px 12px;
  white-space: nowrap; border-bottom: 1px solid var(--gray-200);
  position: sticky; top: 0;
}
table.dt tbody td {
  padding: 9px 12px; border-bottom: 1px solid var(--gray-100);
  color: var(--gray-900); white-space: nowrap;
}
table.dt tbody tr:hover { background: #FBF7F5; }
table.dt tfoot td {
  padding: 11px 12px; font-weight: 800; background: var(--gray-100);
  border-top: 2px solid var(--gray-300); color: var(--ink);
}
table.dt td.calc { color: var(--gray-700); }
table.dt td.result { color: var(--royal-red); font-weight: 800; background: var(--red-soft); }
table.dt td.pos { color: var(--pos); font-weight: 700; }
table.dt td.neg { color: var(--neg); font-weight: 700; }
table.dt input, table.dt select {
  width: 100%; min-width: 78px; border: 1px solid transparent; background: transparent;
  padding: 5px 6px; border-radius: 5px; font-family: inherit; font-size: 12.8px; color: var(--gray-900);
}
table.dt input:hover, table.dt select:hover { border-color: var(--gray-300); background: var(--white); }
table.dt input:focus, table.dt select:focus { outline: none; border-color: var(--royal-red); background: var(--white); box-shadow: 0 0 0 3px var(--red-soft); }
table.dt tr.row-editable td { background: #FFFDFB; }

/* کنترل‌های فرم مستقل (بیرون از جدول) — مثل انتخاب محصول در BOM یا فرم افزودن ماده */
.form-select, .form-input {
  border: 1px solid var(--gray-200); background: var(--white); border-radius: 8px;
  padding: 7px 10px; font-family: inherit; font-size: 12.8px; color: var(--gray-900);
}
.form-select:focus, .form-input:focus {
  outline: none; border-color: var(--royal-red); box-shadow: 0 0 0 3px var(--red-soft);
}
.form-select:disabled, .form-input:disabled { color: var(--gray-500); background: var(--gray-100); }
.row-del {
  border: none; background: transparent; color: var(--gray-300); padding: 4px; border-radius: 6px;
}
.row-del:hover { color: var(--neg); background: #FBEAEA; }
.tag {
  display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 700;
}
.tag-excl { background: #E9F3EC; color: var(--pos); }
.tag-shared { background: var(--warn-bg); color: var(--warn-fg); }

.table-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; gap: 10px; flex-wrap:wrap; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 700; color: var(--gray-700); }
.field input, .field select, .field textarea {
  border: 1px solid var(--gray-200); border-radius: var(--radius-sm);
  padding: 9px 12px; font-family: inherit; font-size: 13px; background: var(--white); color: var(--gray-900);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--royal-red); box-shadow: 0 0 0 3px var(--red-soft);
}
.field-row { display: grid; gap: 14px; }

/* ---------- Empty state (with seal motif) ---------- */
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 48px 20px; color: var(--gray-500); }
.empty-state .seal { width: 64px; height: 64px; margin-bottom: 14px; opacity: .35; }
.empty-state h3 { margin: 0 0 4px; color: var(--gray-700); font-size: 14px; }
.empty-state p { margin: 0 0 16px; font-size: 12.5px; }

/* ---------- Toast ---------- */
.toast-stack { position: fixed; bottom: 22px, ; inset-inline-start: 22px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--ink); color: var(--white); padding: 12px 16px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); font-size: 12.8px; display: flex; align-items: center; gap: 10px;
  animation: toast-in .22s ease;
}
.toast.ok { border-inline-start: 4px solid #2FA968; }
.toast.err { border-inline-start: 4px solid var(--neg); }
@keyframes toast-in { from { opacity:0; transform: translateY(8px);} to {opacity:1; transform:none;} }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(23,21,26,.55); display: flex;
  align-items: center; justify-content: center; z-index: 500; padding: 20px;
}
.modal {
  background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 480px; overflow: hidden;
}
.modal-head { padding: 18px 20px; border-bottom: 1px solid var(--gray-100); display:flex; align-items:center; justify-content:space-between;}
.modal-head h3 { margin: 0; font-size: 15px; font-weight: 800; }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; max-height: 60vh; overflow-y: auto; }
.modal-foot { padding: 16px 20px; border-top: 1px solid var(--gray-100); display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- Two column layout ---------- */
.grid-2 { display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

/* ---------- Pricing recommendation "seal" card ---------- */
.reco-card {
  background: linear-gradient(160deg, var(--royal-red), var(--royal-red-dim) 65%, #2B0810 100%);
  color: var(--white); border-radius: var(--radius-lg); padding: 20px; position: relative; overflow: hidden;
}
.reco-card .seal-badge {
  position: absolute; left: -18px; top: -18px; width: 110px; height: 110px; opacity: .16;
}
.reco-card .seal-badge svg { width: 100%; height: 100%; display: block; }
.reco-price { font-size: 30px; font-weight: 800; margin: 6px 0; }
.reco-margin { display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,.12); padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }

/* ---------- Print / PDF helper (hidden, used by export renderer) ---------- */
.print-only { display: none; }

/* ---------- Chips / badges ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--gray-100); color: var(--gray-700); padding: 4px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; }
.chip.red { background: var(--red-soft); color: var(--royal-red); }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; top: 0; bottom: 0; right: 0; z-index: 400; transform: translateX(100%); transition: transform .2s; width: 82vw; max-width: 300px; height: 100%;}
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .content { padding: 16px; }
  .topbar { padding: 0 14px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
}
.hamburger { display: none; }
@media (max-width: 860px) { .hamburger { display: inline-flex; } }

/* ---------- Extra-small phones ---------- */
@media (max-width: 620px) {
  .topbar {
    height: auto; min-height: var(--header-h); flex-wrap: wrap;
    padding: 10px 14px; gap: 8px;
  }
  .topbar-title h1 { font-size: 15.5px; }
  .topbar-title p { display: none; } /* روی موبایل زیرعنوان صفحه برای صرفه‌جویی در فضا مخفی می‌شود */
  .topbar-actions { width: 100%; flex-wrap: wrap; gap: 8px; justify-content: flex-start; }
  .select-period { flex: 1 1 auto; min-width: 0; }
  #btnExportPdf { flex: none; }
  .user-menu { margin-inline-start: auto; }
  .user-menu-name { display: none; } /* فقط آواتار نمایش داده می‌شود تا جا کمتری بگیرد */
  .sync-status { display: none; } /* روی موبایل کوچک برای صرفه‌جویی در فضا مخفی می‌شود */
  .user-menu-btn { padding: 5px; }
  .kpi-grid { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .content { padding: 14px 14px 50px; }
  .card-body { padding: 14px; }
  .card-head { padding: 14px; }
  .auth-card { padding: 22px 18px; max-width: 100%; }
  .modal { max-width: 100% !important; }
  .modal-body { padding: 16px; }
  .table-toolbar { padding: 12px 14px; }
  .btn-sm { padding: 7px 10px; font-size: 11.5px; }
}

/* ---------- Auth / License full-screen cards (setup, login, activation) ---------- */
.auth-screen {
  position: fixed; inset: 0; z-index: 2000; background: var(--paper);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  overflow-y: auto;
}
.auth-card {
  background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 420px; padding: 30px 26px; margin: auto;
}
.auth-brand { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; margin-bottom: 22px; }
.auth-brand-mark { width: 56px; height: 56px; border-radius: 50%; overflow: hidden; background: var(--white); box-shadow: 0 0 0 2px var(--gray-200); }
.auth-brand-mark img { width: 100%; height: 100%; object-fit: contain; }
.auth-brand-text .t1 { font-weight: 800; font-size: 15px; color: var(--ink); }
.auth-brand-text .t2 { font-size: 11.5px; color: var(--gray-500); margin-top: 2px; }
.auth-title { margin: 0 0 6px; font-size: 16px; font-weight: 800; color: var(--ink); text-align: center; }
.auth-sub { margin: 0 0 18px; font-size: 12.5px; color: var(--gray-500); text-align: center; line-height: 1.9; }
.auth-card .field { margin-bottom: 14px; }
.auth-card .field input { width: 100%; }
.auth-remember { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--gray-700); margin: 4px 0 14px; cursor: pointer; }
.auth-error {
  background: #FBEAEA; color: var(--neg); border-radius: var(--radius-sm); padding: 9px 12px;
  font-size: 12.5px; margin-bottom: 14px; line-height: 1.8;
}

/* ---------- Trial banner ---------- */
.trial-banner {
  position: sticky; top: 0; z-index: 30; background: var(--warn-bg); color: var(--warn-fg);
  padding: 9px 20px; font-size: 12.5px; font-weight: 600; display: flex; align-items: center;
  justify-content: center; gap: 14px; text-align: center; border-bottom: 1px solid #E5B27A;
}
.trial-banner button {
  border: none; background: transparent; color: inherit; font-size: 13px; cursor: pointer;
  opacity: .7; line-height: 1; padding: 2px 4px;
}
.trial-banner button:hover { opacity: 1; }

/* ---------- User menu (topbar) ---------- */
.user-menu { position: relative; }
.user-menu-btn {
  display: flex; align-items: center; gap: 8px; border: 1px solid var(--gray-200); background: var(--white);
  border-radius: 999px; padding: 5px 10px 5px 6px; cursor: pointer; color: var(--gray-900);
}
.user-menu-btn:hover { border-color: var(--royal-red); }
.user-avatar {
  width: 26px; height: 26px; border-radius: 50%; background: var(--royal-red); color: var(--white);
  display: grid; place-items: center; font-size: 12px; font-weight: 800; flex: none;
}
.user-menu-name { font-size: 12.5px; font-weight: 700; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu-drop {
  position: absolute; inset-inline-end: 0; top: calc(100% + 8px); background: var(--white);
  border: 1px solid var(--gray-200); border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
  min-width: 200px; padding: 8px; display: none; z-index: 40;
}
.user-menu.open .user-menu-drop { display: block; }
.user-menu-role { font-size: 11px; color: var(--gray-500); padding: 6px 10px 10px; border-bottom: 1px solid var(--gray-100); margin-bottom: 6px; }
.user-menu-item {
  display: block; width: 100%; text-align: right; border: none; background: transparent;
  padding: 9px 10px; border-radius: 8px; font-size: 12.8px; font-weight: 600; color: var(--gray-900);
}
.user-menu-item:hover { background: var(--gray-100); }
.user-menu-item.danger { color: var(--neg); }
.user-menu-item.danger:hover { background: #FBEAEA; }

/* ---------- Sync status (server save indicator) ---------- */
.sync-status { font-size: 11px; font-weight: 700; white-space: nowrap; }
.sync-status:empty { display: none; }
.sync-status.ok { color: var(--pos); }
.sync-status.saving { color: var(--gray-500); }
.sync-status.error { color: var(--neg); }

/* ---------- Password show/hide toggle ---------- */
.pw-wrap { position: relative; }
.pw-wrap input { width: 100%; padding-inline-end: 40px; box-sizing: border-box; }
.pw-toggle {
  position: absolute; inset-inline-end: 4px; top: 50%; transform: translateY(-50%);
  border: none; background: transparent; color: var(--gray-500); cursor: pointer;
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; border-radius: 6px;
}
.pw-toggle:hover { color: var(--royal-red); background: var(--gray-100); }

/* ---------- Link-style button (e.g. "forgot password") ---------- */
.link-btn {
  border: none; background: transparent; color: var(--royal-red); font-size: 12.5px; font-weight: 700;
  cursor: pointer; padding: 4px 0; text-decoration: underline; text-underline-offset: 3px;
}
.link-btn:hover { color: var(--royal-red-dim); }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 20px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Loading ---------- */
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; animation: spin .7s linear infinite; }
.spinner-dark { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--gray-200); border-top-color: var(--royal-red); animation: spin .7s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Custom charts: gauges ---------- */
.gauge-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-around; }
.gauge-wrap { flex: 1 1 140px; max-width: 220px; text-align: center; }
.gauge-svg { width: 100%; height: auto; display: block; }
.gauge-label { font-size: 12px; font-weight: 700; color: var(--gray-700); margin-top: 2px; }

/* ---------- Custom charts: horizontal bars ---------- */
.hbar-group { display: flex; flex-direction: column; gap: 18px; }
.hbar-row-label { font-size: 12.5px; font-weight: 800; color: var(--ink); margin-bottom: 8px; }
.hbar-row-bars { display: flex; flex-direction: column; gap: 6px; }
.hbar-single { display: flex; flex-direction: column; gap: 10px; }
.hbar-line { display: grid; grid-template-columns: 84px 1fr 110px; align-items: center; gap: 8px; }
.hbar-name { font-size: 11.5px; color: var(--gray-700); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { background: var(--gray-100); border-radius: 999px; height: 12px; overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 999px; transition: width .4s ease; }
.hbar-val { font-size: 11.5px; font-weight: 800; color: var(--ink); text-align: left; }

/* ---------- Custom charts: composition bar ---------- */
.comp-bar { display: flex; width: 100%; height: 26px; border-radius: 8px; overflow: hidden; margin-bottom: 16px; box-shadow: inset 0 0 0 1px var(--gray-200); }
.comp-seg { height: 100%; transition: width .4s ease; }
.comp-legend { display: flex; flex-direction: column; gap: 10px; }
.comp-legend-item { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.comp-legend-item .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.comp-legend-item .name { color: var(--gray-700); font-weight: 600; flex: 1; }
.comp-legend-item .pct { font-weight: 800; color: var(--ink); width: 52px; text-align: left; }
.comp-legend-item .amt { color: var(--gray-500); width: 110px; text-align: left; }
