/* WELYNX design system — shared by the admin and company panels.
   Colours from the Welynx logo: orange-red brand, navy ink and sidebar, warm yellow accent, leaf green. */
:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --surface-3: #eff1f7;
  --border: #e3e6ef;
  --border-strong: #cfd5e3;
  --text: #1e2a4a;
  --text-2: #3a4668;
  --muted: #6b7591;
  --brand: #ff5a3c;
  --brand-600: #e8452a;
  --brand-soft: #ffede7;
  --brand-ink: #c23a1f;
  --accent: #ffb020;
  --accent-soft: #fff4dc;
  --success: #2e9e47;
  --success-soft: #e4f6e8;
  --warning: #c27100;
  --warning-soft: #fff3df;
  --danger: #d63a2f;
  --danger-soft: #fdeceb;
  --info: #1f78d6;
  --info-soft: #e6f1fd;
  --sidebar-bg: #1e2a4a;
  --sidebar-text: #c2cae0;
  --sidebar-active: #ffffff;
  --sidebar-hover: rgba(255,255,255,.07);
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(30,42,74,.06);
  --shadow: 0 1px 2px rgba(30,42,74,.05), 0 8px 24px -12px rgba(30,42,74,.14);
  --shadow-lg: 0 24px 60px -20px rgba(30,42,74,.35);
  --glow: 0 0 0 1px rgba(255,90,60,.18), 0 10px 26px -12px rgba(255,90,60,.38);
  --ease: cubic-bezier(.2,.8,.2,1);
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --sidebar-w: 256px;
  --topbar-h: 64px;
  color-scheme: light;
}
.admin-theme { --brand: #f7941d; --brand-600: #e07f0a; --brand-soft: #fff1df; --brand-ink: #a85a00; --accent: #ff5a3c; }

/* Dark mode "Ember": warm charcoal and cocoa with an orange glow (no navy). Other dark looks are themes. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15100d; --surface: #1f1712; --surface-2: #271d17; --surface-3: #2f231b;
    --border: #3a2a20; --border-strong: #4c382a; --text: #f7ede6; --text-2: #e3d3c7; --muted: #b8a597;
    --brand-soft: #3d1d12; --brand-ink: #ffb49c; --accent-soft: #3a2a10;
    --success-soft: #15301c; --warning-soft: #3b2a10; --danger-soft: #3f1a16; --info-soft: #142a40;
    --sidebar-bg: #110c0a; --sidebar-text: #c9b5a6;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.35); --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 28px -12px rgba(0,0,0,.6); --shadow-lg: 0 24px 60px -20px rgba(0,0,0,.75);
    --glow: 0 0 0 1px rgba(255,107,61,.35), 0 10px 30px -12px rgba(255,107,61,.45);
    color-scheme: dark;
  }
  :root:not([data-theme="light"]) .admin-theme { --brand-soft: #3a2a12; --brand-ink: #ffcf91; }
}
:root[data-theme="dark"] {
  --bg: #15100d; --surface: #1f1712; --surface-2: #271d17; --surface-3: #2f231b;
  --border: #3a2a20; --border-strong: #4c382a; --text: #f7ede6; --text-2: #e3d3c7; --muted: #b8a597;
  --brand-soft: #3d1d12; --brand-ink: #ffb49c; --accent-soft: #3a2a10;
  --success-soft: #15301c; --warning-soft: #3b2a10; --danger-soft: #3f1a16; --info-soft: #142a40;
  --sidebar-bg: #110c0a; --sidebar-text: #c9b5a6;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.35); --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 28px -12px rgba(0,0,0,.6); --shadow-lg: 0 24px 60px -20px rgba(0,0,0,.75);
  --glow: 0 0 0 1px rgba(255,107,61,.35), 0 10px 30px -12px rgba(255,107,61,.45);
  color-scheme: dark;
}
:root[data-theme="dark"] .admin-theme { --brand-soft: #3a2a12; --brand-ink: #ffcf91; }
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: var(--font-size, 14px); line-height: 1.5; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; }
p { margin: 0 0 1em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
code, .mono { font-family: var(--mono); font-size: .92em; }
.icon { width: 18px; height: 18px; flex: none; display: inline-block; vertical-align: middle; }
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 22px; height: 22px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.flex { display: flex; align-items: center; gap: 10px; }
.flex-wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 16px; }
.mt-0 { margin-top: 0 !important; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0 !important; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 960px) { .grid[style*="grid-template-columns"] { grid-template-columns: minmax(0, 1fr) !important; } }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--sidebar-bg); color: var(--sidebar-text); display: flex; flex-direction: column; padding: 18px 12px; scrollbar-width: thin; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: var(--sidebar-strong, #fff); text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; font-size: 13px; color: #fff; background: linear-gradient(135deg, var(--brand), var(--accent)); box-shadow: 0 6px 18px -6px color-mix(in srgb, var(--accent) 70%, transparent); }
.brand-name { font-weight: 800; letter-spacing: -.01em; font-size: 16px; line-height: 1.1; }
.brand-sub { display: block; font-size: 11px; font-weight: 500; color: var(--sidebar-text); }
.tenant-chip { margin: 0 4px 14px; padding: 10px 12px; border-radius: 12px; background: var(--sidebar-hover); border: 1px solid var(--sidebar-hover); font-size: 12.5px; }
.tenant-chip strong { display: block; color: var(--sidebar-strong, #fff); font-size: 13px; }
.nav-group { margin-top: 10px; }
.nav-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: color-mix(in srgb, var(--sidebar-text) 60%, transparent); padding: 8px 12px 6px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 8.5px 12px; border-radius: 10px; color: var(--sidebar-text); font-weight: 500; text-decoration: none; transition: background .15s, color .15s; }
.nav a:hover { background: var(--sidebar-hover); color: var(--sidebar-strong, #fff); }
.nav a.active { background: var(--sidebar-active-bg, linear-gradient(90deg, rgba(255,107,61,.32), rgba(255,107,61,.06))); color: var(--sidebar-active); box-shadow: inset 2px 0 0 var(--brand); }
.admin-theme .nav a.active { background: linear-gradient(90deg, rgba(255,92,157,.32), rgba(255,92,157,.06)); }
.nav a .icon { opacity: .85; }
.nav .badge { margin-left: auto; }
.sidebar-foot { margin-top: auto; padding-top: 16px; font-size: 11.5px; color: color-mix(in srgb, var(--sidebar-text) 65%, transparent); padding-left: 12px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; height: var(--topbar-h); display: flex; align-items: center; gap: 14px; padding: 0 28px; background: color-mix(in srgb, var(--topbar-bg, var(--bg)) 88%, transparent); backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--border); }
.topbar .search { flex: 1; max-width: 460px; position: relative; }
.topbar .search input { padding-left: 38px; background: var(--surface); }
.topbar .search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.menu-btn { display: none; }
.content { padding: 28px; max-width: 1400px; width: 100%; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { margin-bottom: 2px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.crumbs a { color: var(--muted); }

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 60; left: 0; top: 0; width: 280px; transform: translateX(-100%); transition: transform .25s ease; box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(10,8,20,.45); z-index: 50; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 0 16px; }
  .content { padding: 20px 16px; }
  .hide-mobile { display: none !important; }
}

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-body { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-head h2, .card-head h3 { margin: 0; }
.card-foot { padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }

.kpi { padding: 18px 20px; position: relative; overflow: hidden; }
.kpi .label { color: var(--muted); font-size: 12.5px; font-weight: 600; display: flex; align-items: center; gap: 8px; padding-right: 44px; }
.kpi .value { font-size: clamp(18px, 1.9vw, 26px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.main { overflow-x: clip; }
.kpi .value { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin-top: 6px; }
.kpi .delta { font-size: 12px; font-weight: 600; margin-top: 2px; }
.kpi .kpi-icon { position: absolute; right: 16px; top: 16px; width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-ink); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 15px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none; transition: background .15s, border-color .15s, transform .05s, box-shadow .15s; }
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand, #fff); box-shadow: 0 6px 16px -8px var(--brand); }
.btn-primary:hover { background: var(--brand-600); border-color: var(--brand-600); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.95); background: var(--danger); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(.95); background: var(--success); }
.btn-whatsapp { background: #1fa855; border-color: #1fa855; color: #fff; }
.btn-whatsapp:hover { background: #178a45; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-3); }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 9px; }
.btn-xs { height: 26px; padding: 0 8px; font-size: 12px; border-radius: 7px; }
.btn-icon { width: 38px; padding: 0; }
.btn-block { width: 100%; }
.btn[disabled], .btn.disabled { opacity: .55; pointer-events: none; }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; color: var(--text-2); }
.req::after { content: " *"; color: var(--danger); }
input:not([type]), input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=tel], input[type=url], input[type=search], input[type=month], input[type=time], select, textarea {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit; transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23706a8a' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent); }
input[readonly], textarea[readonly], select[disabled], input[disabled] { background: var(--surface-2); color: var(--text-2); }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; accent-color: var(--brand); vertical-align: middle; }
.field { margin-bottom: 16px; min-width: 0; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.field .error, .field-error { font-size: 12px; color: var(--danger); margin-top: 5px; font-weight: 600; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } }
.check { display: flex; align-items: center; gap: 9px; font-weight: 500; cursor: pointer; margin: 0; }
.input-group { display: flex; align-items: stretch; }
.input-group > input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group > .addon { display: flex; align-items: center; padding: 0 12px; border: 1px solid var(--border-strong); border-left: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; background: var(--surface-2); color: var(--muted); white-space: nowrap; font-size: 13px; }
.form-section { margin-bottom: 8px; padding-bottom: 4px; }
.form-section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; font-weight: 700; color: var(--muted); margin: 4px 0 14px; }

/* Toggle switch */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; margin: 0; font-weight: 500; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 40px; height: 23px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background .2s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch input:checked + .track { background: var(--success); }
.switch input:checked + .track::after { transform: translateX(17px); }
.switch input:focus-visible + .track { outline: 2px solid var(--brand); outline-offset: 2px; }
.switch input:disabled + .track { opacity: .45; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding: 11px 16px; background: var(--table-head, var(--surface-2)); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table a.row-link { color: var(--text); font-weight: 600; }
.table td:first-child a.row-link { white-space: nowrap; }
.table td .badge { white-space: nowrap; }
.table tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--border); }
.table-compact td, .table-compact th { padding: 8px 12px; }

/* Editable child table */
.child-table td { padding: 6px 6px; }
.child-table input, .child-table select { height: 34px; padding: 0 8px; font-size: 13px; }
.child-table .row-num { width: 34px; color: var(--muted); text-align: center; }
.child-table .row-del { width: 40px; text-align: center; }

/* Link field (autocomplete) */
.link-field { position: relative; }
.link-menu { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 45; max-height: 280px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 4px; display: none; min-width: 220px; }
.link-menu.open { display: block; }
.link-opt { display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; background: none; border-radius: 8px; font: inherit; color: var(--text); cursor: pointer; }
.link-opt small { display: block; color: var(--muted); font-size: 12px; }
.link-opt.active, .link-opt:hover { background: var(--brand-soft); }
.link-empty { padding: 10px; color: var(--muted); font-size: 13px; }
.link-ro { display: flex; align-items: center; height: 40px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); font-weight: 600; }
.num-input { text-align: right; font-variant-numeric: tabular-nums; }
.child-table .num-input { min-width: 90px; }
.child-table .link-field { min-width: 180px; }
/* Column chooser */
.col-menu { width: 300px; max-width: calc(100vw - 32px); max-height: min(70vh, 560px); overflow: hidden; }
.dropdown.open .dropdown-menu.col-menu { display: flex; flex-direction: column; }
.col-menu .dropdown-head { flex: none; }
.col-list { flex: 1; min-height: 0; overflow-y: auto; }
.col-list { list-style: none; margin: 0; padding: 0 4px; }
.col-list li { display: flex; align-items: center; gap: 4px; padding: 2px 4px 2px 8px; border-radius: 8px; }
.col-list li:hover { background: var(--surface-3); }
.col-list li .check { flex: 1; min-width: 0; padding: 7px 0; font-size: 13.5px; line-height: 1.3; }
.col-list li .check input { flex: none; }
.dropdown-menu .col-list li button { flex: none; width: 28px; height: 28px; padding: 0; justify-content: center; border-radius: 7px; color: var(--muted); font-size: 14px; }
.dropdown-menu .col-list li button:hover { background: var(--brand-soft); color: var(--brand-ink); }
.dropdown-menu .col-list li button:disabled { opacity: .3; cursor: default; background: none; }

/* Form editor */
.fe-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 960px) { .fe-grid { grid-template-columns: 1fr; } }
.fe-props { position: sticky; top: calc(var(--topbar-h) + 12px); }
.fe-list { list-style: none; margin: 0; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.fe-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer; }
.fe-item:hover { border-color: var(--border-strong); }
.fe-item.selected { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.fe-item.is-hidden { opacity: .55; }
.fe-item.dragging { opacity: .4; }
.fe-section { background: var(--surface-3); margin-top: 8px; }
.fe-section strong { text-transform: none; }
.fe-handle { cursor: grab; color: var(--muted); letter-spacing: -2px; user-select: none; }
.fe-chips { display: inline-flex; gap: 4px; margin-left: 6px; flex-wrap: wrap; vertical-align: middle; }
.fe-move { display: flex; gap: 2px; }
.fe-choices { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.fe-choices li { display: flex; gap: 4px; align-items: center; }
.fe-choices input { height: 34px; }

/* Totals summary card */
.summary-card { max-width: 440px; margin-left: auto; }
.summary-card .card-body { padding: 8px 20px 14px; }
.sum-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.sum-row:last-child { border-bottom: 0; }
.sum-row label { margin: 0; font-weight: 600; color: var(--muted); font-size: 13.5px; }
.sum-row input { width: 170px; text-align: right; font-variant-numeric: tabular-nums; }
.sum-row input[readonly] { border-color: transparent; background: transparent; font-weight: 700; color: var(--text); padding-right: 0; height: 30px; }
.sum-grand { border-top: 2px solid var(--text); border-bottom: 0; margin-top: 4px; padding-top: 12px; }
.sum-grand label { color: var(--text); font-size: 15px; }
.sum-grand input[readonly] { font-size: 20px; font-weight: 800; }
@media (max-width: 720px) { .summary-card { max-width: none; } }
.save-bar { position: sticky; bottom: 12px; z-index: 20; box-shadow: var(--shadow-lg); }
.doc-form .card-body.form-grid { padding-bottom: 4px; }

/* ---------- Badges / pills ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.plain::before { display: none; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-brand { background: var(--brand-soft); color: var(--brand-ink); }

/* Subscription countdown pill */
.sub-pill { display: inline-flex; align-items: center; gap: 9px; padding: 6px 12px 6px 8px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-size: 12.5px; font-weight: 600; white-space: nowrap; text-decoration: none; color: var(--text); }
.sub-pill:hover { text-decoration: none; border-color: var(--border-strong); }
.sub-pill .plan { padding: 2px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-ink); font-size: 11.5px; }
.sub-pill .timer { font-variant-numeric: tabular-nums; }
.sub-pill.expiring { border-color: #f5c46b; background: var(--warning-soft); }
.sub-pill.expiring .timer { color: var(--warning); }
.sub-pill.grace, .sub-pill.locked { border-color: #f1a19b; background: var(--danger-soft); }
.sub-pill.grace .timer { color: var(--danger); }

.countdown { display: flex; gap: 6px; }
.countdown .unit { flex: 1 1 0; min-width: 0; max-width: 80px; padding: 10px 4px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); text-align: center; }
.countdown .unit b { display: block; font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.countdown .unit span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }

/* ---------- Alerts / banners ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: 12px; border: 1px solid transparent; margin-bottom: 16px; font-weight: 500; }
.alert .icon { margin-top: 1px; }
.alert-success { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 25%, transparent); }
.alert-error, .alert-danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.alert-warning { background: var(--warning-soft); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 25%, transparent); }
.alert-info { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 25%, transparent); }
.alert a { color: inherit; text-decoration: underline; font-weight: 700; }
.banner { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 9px 16px; font-size: 13px; font-weight: 600; text-align: center; flex-wrap: wrap; }
.banner-warning { background: var(--warning-soft); color: var(--warning); border-bottom: 1px solid color-mix(in srgb, var(--warning) 25%, transparent); }
.banner-danger { background: var(--danger); color: #fff; }
.banner a { color: inherit; text-decoration: underline; }

.toast-stack { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: flex; flex-direction: column; gap: 10px; max-width: min(380px, calc(100vw - 40px)); }
.toast { box-shadow: var(--shadow-lg); animation: toast-in .25s ease; margin: 0; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tabs a, .tabs button { padding: 10px 14px; border: 0; background: none; font: inherit; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; white-space: nowrap; text-decoration: none; }
.tabs a.active, .tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab-panel:not(.active) { display: none; }

/* ---------- Dropdown ---------- */
.dropdown { position: relative; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 40; display: none; }
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu.dropdown-fixed { position: fixed; right: auto; z-index: 60; }

/* Scan box above item lines, camera reader and price check */
.scan-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.scan-bar > .icon { color: var(--brand); flex: none; }
.scan-bar input[data-scan-input] { flex: 1 1 260px; min-width: 0; height: 36px; }
.scan-bar .scan-msg { flex-basis: 100%; min-height: 1em; }
.scan-bar .scan-msg:empty { display: none; }
tr.scan-hit td { background: var(--brand-soft) !important; transition: background .3s; }
.text-success { color: var(--success); }
.scan-cam { max-width: 520px; }
.scan-cam-view { position: relative; width: 100%; aspect-ratio: 4 / 3; background: #000; border-radius: 12px; overflow: hidden; }
.scan-cam-view video { width: 100%; height: 100%; object-fit: cover; }
.scan-cam-view::after { content: ""; position: absolute; inset: 22% 12%; border: 2px solid rgba(255,255,255,.85); border-radius: 10px; box-shadow: 0 0 0 9999px rgba(0,0,0,.25); pointer-events: none; }
#we-cam-view > div, #we-cam-view video { border-radius: 12px; }
.pc-item { padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.pc-name { font-size: 1.1rem; font-weight: 800; }
.pc-prices { display: flex; gap: 24px; margin-top: 10px; flex-wrap: wrap; }
.pc-prices > div { display: flex; flex-direction: column; }
.pc-prices strong { font-size: 1.35rem; }

/* Help guide (on-screen tour) */
.tour-hole { position: fixed; z-index: 9998; border-radius: 10px; box-shadow: 0 0 0 9999px rgba(8, 6, 18, .55); outline: 2px solid var(--brand); transition: all .25s var(--ease, ease); pointer-events: none; }
.tour-pop { position: fixed; z-index: 9999; width: min(340px, calc(100vw - 32px)); background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 16px; }
.tour-pop h4 { margin: 0 0 6px; font-size: 1rem; }
.tour-pop p { margin: 0 0 12px; color: var(--muted); font-size: .93rem; line-height: 1.45; }
.tour-pop .tour-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tour-pop .tour-step { font-size: .8rem; color: var(--muted); }
.help-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; white-space: nowrap; }
.help-toggle .switch { margin: 0; }
.dropdown-menu a, .dropdown-menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: 8px; color: var(--text); background: none; border: 0; font: inherit; text-align: left; cursor: pointer; text-decoration: none; }
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--surface-3); text-decoration: none; }
.dropdown-menu .sep { height: 1px; background: var(--border); margin: 6px 0; }
.dropdown-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }

.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 12.5px; color: #fff; background: linear-gradient(135deg, var(--brand), var(--accent)); flex: none; }
.avatar-lg { width: 48px; height: 48px; font-size: 16px; }
.user-btn { display: flex; align-items: center; gap: 10px; background: none; border: 0; cursor: pointer; padding: 4px; border-radius: 999px; font: inherit; color: var(--text); }
.user-btn:hover { background: var(--surface-3); }

/* ---------- Misc ---------- */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .icon { width: 40px; height: 40px; color: var(--border-strong); margin-bottom: 10px; }
.empty h3 { color: var(--text); }
.dl { display: grid; grid-template-columns: 160px 1fr; gap: 10px 16px; margin: 0; }
.dl dt { color: var(--muted); font-weight: 600; font-size: 13px; }
.dl dd { margin: 0; font-weight: 500; }
@media (max-width: 600px) { .dl { grid-template-columns: 1fr; gap: 2px; } .dl dd { margin-bottom: 10px; } }
.progress { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--brand), var(--accent)); }
.list-plain { list-style: none; padding: 0; margin: 0; }
.list-plain li { padding: 10px 0; border-bottom: 1px solid var(--border); }
.list-plain li:last-child { border-bottom: 0; }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 12px; }
.feature-tile { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.feature-tile .t { font-weight: 700; }
.feature-tile .d { font-size: 12.5px; color: var(--muted); }
.feature-tile.on { border-color: color-mix(in srgb, var(--success) 40%, var(--border)); background: color-mix(in srgb, var(--success-soft) 45%, var(--surface)); }
.pagination { display: flex; gap: 6px; align-items: center; justify-content: flex-end; padding: 14px 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--muted); }
.status-dot.on { background: var(--success); }
.doc-status { font-size: 12px; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(10,8,20,.5); z-index: 80; display: none; align-items: center; justify-content: center; padding: 16px; }
.modal-backdrop.open { display: flex; }
.modal { width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); }
.chart-box { position: relative; height: 280px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.filters .field { margin: 0; min-width: 150px; }
.filters label { font-size: 11.5px; }
.filters input, .filters select { height: 36px; }

/* ---------- Auth pages ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 46fr) minmax(0, 54fr); background: var(--bg); }
.auth-art { position: relative; overflow: hidden; isolation: isolate; background: radial-gradient(120% 80% at 50% 110%, #ff3d2e 0%, transparent 60%), linear-gradient(170deg, #ff7a3d 0%, #ff5a3c 45%, #f2412f 100%); color: #fff; padding: 40px 44px; display: flex; flex-direction: column; justify-content: space-between; height: 100vh; align-self: start; position: sticky; top: 0; }
.auth-warp { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; }
.auth-art > :not(.auth-warp) { position: relative; }
.auth-art a.wl { color: #fff; }
.auth-hero { display: grid; justify-items: start; gap: 18px; }
.auth-mascot { width: 132px; height: auto; filter: drop-shadow(0 26px 30px rgba(120, 20, 0, .35)); animation: auth-bob 5.5s ease-in-out infinite; transform-origin: 50% 80%; }
@keyframes auth-bob { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-12px) rotate(2deg); } }
.auth-art h2 { font: 900 clamp(30px, 3.2vw, 44px)/1.05 'Outfit', var(--font); max-width: 470px; letter-spacing: -.025em; margin: 0; }
.auth-art p { color: rgba(255,255,255,.86); max-width: 420px; margin: 0; font-size: 15px; }
.auth-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.auth-chip { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.3); backdrop-filter: blur(8px); }
.auth-chip i { width: 7px; height: 7px; border-radius: 50%; background: #ffcf3a; box-shadow: 0 0 0 3px rgba(255,207,58,.3); }
.auth-foot { font-size: 12.5px; color: rgba(255,255,255,.78); }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 72px 24px 40px; }
.auth-card { width: 100%; max-width: 420px; animation: auth-in .45s var(--ease) both; }
@keyframes auth-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.auth-card h1 { font: 800 28px/1.15 var(--font); letter-spacing: -.02em; margin-bottom: 6px; }
.auth-card .lede { color: var(--muted); margin-bottom: 22px; }
.auth-top-link { position: absolute; top: 22px; right: 26px; font-size: 13.5px; color: var(--muted); }
.auth-top-link a { font-weight: 700; }
.auth-form { position: relative; }
.sso-list { display: grid; gap: 10px; }
.sso-btn { display: flex; align-items: center; justify-content: center; gap: 10px; height: 46px; border-radius: 12px; border: 1px solid var(--border-strong); background: var(--sso-bg, var(--surface)); color: var(--sso-fg, var(--text)); font-weight: 650; font-size: 14.5px; text-decoration: none; transition: transform .18s var(--ease), box-shadow .18s var(--ease), border-color .18s; }
.sso-btn:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--brand) 40%, var(--border-strong)); }
.sso-btn svg { width: 20px; height: 20px; flex: none; }
.sso-btn .sso-letter { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; font-size: 12px; font-weight: 800; background: var(--brand); color: #fff; }
.or-line { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12.5px; margin: 18px 0; }
.or-line::before, .or-line::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.signup-steps { display: flex; gap: 8px; margin: 0 0 22px; }
.signup-steps span { flex: 1; height: 5px; border-radius: 5px; background: var(--surface-3); position: relative; overflow: hidden; }
.signup-steps span.done::after, .signup-steps span.now::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, var(--brand), var(--accent)); }
.signup-steps span.now::after { animation: step-fill .6s var(--ease) both; }
@keyframes step-fill { from { transform: translateX(-100%); } to { transform: none; } }
.step-label { font-size: 12px; font-weight: 700; color: var(--brand); letter-spacing: .02em; margin-bottom: 6px; }
.code-input { font: 800 26px/1 var(--mono); letter-spacing: .5em; text-align: center; height: 58px !important; }
.addr-preview { font-size: 12.5px; color: var(--muted); margin-top: 6px; min-height: 18px; }
.addr-preview b { color: var(--text); }
.choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.choice { position: relative; display: flex; gap: 10px; align-items: flex-start; padding: 12px 12px; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; background: var(--surface); transition: border-color .18s, box-shadow .18s, transform .18s var(--ease); }
.choice:hover { transform: translateY(-1px); border-color: var(--border-strong); }
.choice input { margin-top: 2px; accent-color: var(--brand); }
.choice:has(input:checked) { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 15%, transparent); background: color-mix(in srgb, var(--brand) 5%, var(--surface)); }
.choice strong { display: block; font-size: 13.5px; }
.choice small { color: var(--muted); font-size: 12px; line-height: 1.35; display: block; }
.launch { text-align: center; padding: 30px 0; }
.launch .auth-mascot { width: 120px; animation: launch-fly 2.4s cubic-bezier(.5,0,.2,1) both; }
@keyframes launch-fly { 0% { transform: translateY(40px) scale(.6); opacity: 0; } 40% { transform: translateY(-6px) scale(1.05); opacity: 1; } 70% { transform: translateY(0) scale(1); } 100% { transform: translateY(-260px) scale(.4); opacity: 0; } }
.launch-bar { height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; margin: 22px auto 0; max-width: 260px; }
.launch-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--accent)); animation: launch-load 2.4s var(--ease) both; }
@keyframes launch-load { from { width: 0; } to { width: 100%; } }
@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-art { height: auto; position: relative; padding: 22px 20px 26px; }
  .auth-hero { grid-template-columns: auto 1fr; align-items: center; gap: 14px; margin-top: 16px; }
  .auth-mascot { width: 64px; }
  .auth-art h2 { font-size: 24px; }
  .auth-art p, .auth-chips, .auth-foot { display: none; }
  .auth-form { flex-direction: column; align-items: stretch; justify-content: flex-start; padding: 24px 20px 40px; }
  .auth-card { margin: 0 auto; }
  .auth-top-link { position: static; text-align: right; margin: 0 auto 16px; width: 100%; max-width: 420px; }
  .choice-grid { grid-template-columns: 1fr; }
}
@media (max-height: 760px) and (min-width: 901px) {
  .auth-art { padding-top: 28px; padding-bottom: 24px; }
  .auth-mascot { width: 86px; }
  .auth-hero { gap: 12px; }
  .auth-art h2 { font-size: clamp(26px, 2.6vw, 34px); }
  .auth-chips { display: none; }
}
@media (prefers-reduced-motion: reduce) { .auth-mascot, .launch .auth-mascot { animation: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Print ---------- */
@media print {
  .sidebar, .topbar, .page-head .actions, .no-print, .banner, .toast-stack { display: none !important; }
  .shell { display: block; }
  .content { padding: 0; }
  body { background: #fff; }
  .card { border: 0; box-shadow: none; }
}

/* ---------- Appearance / theme builder ---------- */
.brand-logo { max-height: 40px; max-width: 190px; object-fit: contain; display: block; }
.theme-presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.theme-swatch { border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius-sm); padding: 8px; cursor: pointer; text-align: left; font: inherit; color: var(--text); }
.theme-swatch:hover, .theme-swatch.active { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.theme-swatch:disabled { cursor: default; opacity: .8; }
.theme-swatch .sw { display: flex; height: 64px; border-radius: 8px; overflow: hidden; gap: 6px; padding-right: 6px; }
.theme-swatch .sw-side { width: 26%; }
.theme-swatch .sw-card { flex: 1; margin: 8px 0; border: 1px solid; border-radius: 6px; display: flex; align-items: flex-end; gap: 4px; padding: 6px; }
.theme-swatch .sw-card span { width: 18px; height: 8px; border-radius: 4px; }
.theme-swatch .sw-name { display: block; font-weight: 600; font-size: 13px; margin-top: 8px; }
.theme-layout { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 20px; align-items: start; }
.theme-side { position: sticky; top: calc(var(--topbar-h) + 12px); display: flex; flex-direction: column; gap: 16px; }
.theme-group + .theme-group { margin-top: 16px; }
.color-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.color-field { display: flex; gap: 10px; align-items: center; margin: 0; font-weight: 500; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.color-field input[type=color] { width: 40px; height: 40px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: none; cursor: pointer; flex: none; }
.color-field .input { height: 30px; padding: 0 8px; font-size: 12.5px; margin-top: 3px; width: 100%; }
.logo-box { width: 200px; height: 72px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); display: grid; place-items: center; padding: 8px; background: var(--surface-2); }
.logo-box img { max-width: 100%; max-height: 100%; object-fit: contain; }
.dot-swatch { width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--border); display: inline-block; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.seg button { border: 0; background: none; padding: 5px 10px; font: inherit; font-size: 12.5px; cursor: pointer; color: var(--muted); }
.seg button.active { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }
/* Mini preview: its colours come from variables set by appearance.js on #theme-preview */
.tp { display: flex; height: 280px; border-radius: 12px; overflow: hidden; border: 1px solid var(--p-border); background: var(--p-bg); color: var(--p-text); font-size: 11px; }
.tp-side { width: 92px; background: var(--p-sidebar_bg); color: var(--p-sidebar_text); padding: 10px 6px; flex: none; }
.tp-logo span { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: linear-gradient(135deg, var(--p-brand), var(--p-accent)); color: #fff; font-weight: 800; font-size: 9px; margin: 0 0 10px 4px; }
.tp-nav { padding: 5px 6px; border-radius: 6px; margin-bottom: 2px; }
.tp-nav.active { background: var(--p-sidebar_active); color: var(--p-sidebar-active-text); box-shadow: inset 2px 0 0 var(--p-brand); }
.tp-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tp-top { height: 30px; background: var(--p-topbar_bg); border-bottom: 1px solid var(--p-border); display: flex; align-items: center; padding: 0 10px; }
.tp-search { background: var(--p-surface); border: 1px solid var(--p-border); border-radius: 6px; padding: 2px 8px; color: var(--p-muted); width: 60%; }
.tp-body { padding: 10px; display: flex; flex-direction: column; gap: 8px; overflow: hidden; }
.tp-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tp-card { background: var(--p-surface); border: 1px solid var(--p-border); border-radius: var(--p-radius, 8px); padding: 8px; }
.tp-muted { color: var(--p-muted); }
.tp-big { font-size: 17px; font-weight: 800; margin: 2px 0 4px; }
.tp-pill { display: inline-block; border-radius: 99px; padding: 1px 7px; font-weight: 700; font-size: 10px; }
.tp-pill.ok { color: var(--p-success); background: color-mix(in srgb, var(--p-success) 14%, transparent); }
.tp-pill.warn { color: var(--p-warning); background: color-mix(in srgb, var(--p-warning) 14%, transparent); }
.tp-pill.bad { color: var(--p-danger); background: color-mix(in srgb, var(--p-danger) 14%, transparent); }
.tp-th, .tp-tr { display: grid; grid-template-columns: 1fr 1fr 70px; gap: 6px; padding: 5px 6px; align-items: center; }
.tp-th { background: var(--p-table_head); color: var(--p-muted); font-weight: 700; border-radius: 4px; }
.tp-tr + .tp-tr, .tp-th + .tp-tr { border-top: 1px solid var(--p-border); }
.tp-link { color: var(--p-brand); font-weight: 600; }
.tp-actions { display: flex; gap: 6px; margin-top: 8px; }
.tp-btn { background: var(--p-brand); color: var(--p-brand-text); border-radius: 6px; padding: 4px 9px; font-weight: 700; }
.tp-accent { background: var(--p-accent); color: var(--p-accent-text); border-radius: 6px; padding: 4px 9px; font-weight: 700; }
.contrast-row { display: flex; gap: 8px; align-items: center; font-size: 12.5px; padding: 3px 0; }
.contrast-row.bad { color: var(--danger); font-weight: 600; }
.contrast-row.ok { color: var(--success); }
@media (max-width: 1100px) { .theme-layout { grid-template-columns: 1fr; } .theme-side { position: static; } }.auth-logo { display: block; max-height: 56px; max-width: 220px; object-fit: contain; margin: 0 0 18px; }
.print-logo { max-height: 60px; max-width: 220px; object-fit: contain; display: block; margin-bottom: 6px; }

/* ---------- Import ---------- */
.import-steps { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.step-no { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-ink); font-size: 12.5px; font-weight: 800; margin-right: 6px; }
.table-compact td, .table-compact th { padding: 7px 12px; }
details summary { cursor: pointer; color: var(--brand); font-weight: 600; }
@media (max-width: 900px) { .import-steps { grid-template-columns: 1fr; } }.text-danger { color: var(--danger); }
[hidden] { display: none !important; }

/* Real buttons inside dropdown menus (e.g. Apply / Reset in the column chooser) */
.dropdown-menu button.btn { display: inline-flex; justify-content: center; width: auto; padding: 0 14px; border: 1px solid var(--border-strong); background: var(--surface); }
.dropdown-menu button.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand, #fff); }
.dropdown-menu button.btn-primary:hover { background: var(--brand-600); }
/* ---------- Record pickers: floating menu ---------- */
.link-menu.floating { position: fixed; left: 0; right: auto; top: 0; z-index: 90; min-width: 0; max-height: 380px; padding: 6px; }
.link-menu.wide .lo-head, .link-menu.wide .lo-grid { display: grid; grid-template-columns: minmax(0, 1fr) 110px 150px; gap: 12px; align-items: center; }
.lo-head { padding: 4px 10px 6px; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.lo-head span:nth-child(2) { text-align: right; }
.link-opt { display: flex; align-items: center; gap: 10px; }
.link-opt .lo-main { flex: 1; min-width: 0; }
.lo-label { display: block; font-weight: 600; white-space: normal; line-height: 1.3; }
.lo-label mark { background: var(--warning-soft); color: inherit; border-radius: 3px; padding: 0 1px; }
.lo-price { text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; color: var(--text-2); }
.lo-badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 11.5px; font-weight: 700; white-space: nowrap; justify-self: start; }
.tone-ok { background: var(--success-soft); color: var(--success); }
.tone-low { background: var(--warning-soft); color: var(--warning); }
.tone-out { background: var(--danger-soft); color: var(--danger); }
.tone-muted { background: var(--surface-3); color: var(--muted); }
.link-empty { display: flex; flex-direction: column; gap: 6px; }
.link-create { font-weight: 700; }
.link-field { display: flex; flex-direction: column; }
.link-field .link-input { padding-right: 30px; }
.link-open { position: absolute; right: 6px; top: 8px; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 6px; color: var(--muted); }
.child-table .link-open { top: 6px; }
.link-open:hover { background: var(--brand-soft); color: var(--brand-ink); }
.link-sub { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); margin-top: 3px; min-height: 0; }
.link-sub:empty { display: none; }
.link-sub .lo-badge { height: 18px; font-size: 10.5px; padding: 0 6px; }
label .link-to { font-weight: 500; font-size: 11.5px; color: var(--muted); margin-left: 4px; }

/* ---------- Item lines ---------- */
.child-head { flex-wrap: wrap; gap: 8px; }
.child-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.child-table th[data-col="item_id"] { min-width: 240px; }
.child-table .link-field { min-width: 220px; }
.child-table td { vertical-align: top; }
.child-table td.num { text-align: right; }
.child-table input.num-plain { border-color: transparent; background: transparent; box-shadow: none; padding-right: 2px; color: var(--text-2); }
.child-table [data-col="net_amount"] input.num-plain { font-weight: 700; color: var(--text); }
.child-table input.over { border-color: var(--danger); background: var(--danger-soft); }
.col-off { display: none; }
.row-num { white-space: nowrap; }
.row-toggle { border: 0; background: none; padding: 2px; margin-right: 2px; cursor: pointer; color: var(--muted); border-radius: 6px; vertical-align: middle; display: inline-grid; place-items: center; }
.row-toggle .icon { transition: transform .15s; }
tr.expanded .row-toggle .icon { transform: rotate(90deg); }
.row-toggle:hover { background: var(--brand-soft); color: var(--brand-ink); }
.child-table .row-num { width: 54px; }
tr.row-detail > td { background: var(--surface-2); padding: 12px 16px 16px 54px; }
.rd-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px 22px; }
.rd-item { grid-column: span 2; }
.rd-stock { grid-column: 1 / -1; }
.rd-label { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 3px; }
.rd-val { font-weight: 600; }
.rd-strong { font-size: 16px; }
.rd-stores { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px; }
.rd-stores li { display: flex; justify-content: space-between; gap: 10px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.rd-stores li.out strong { color: var(--danger); }
.child-collapse { display: none; }
.child-wrap.expanded { position: fixed; inset: 16px; z-index: 70; margin: 0; display: flex; flex-direction: column; box-shadow: 0 0 0 100vmax rgba(10, 8, 25, .55), var(--shadow-lg); }
.child-wrap.expanded .child-scroll { flex: 1; overflow: auto; }
.child-wrap.expanded .child-collapse { display: inline-flex; }
.child-wrap.expanded .child-table input, .child-wrap.expanded .child-table select { height: 38px; font-size: 14px; }
body.child-expanded { overflow: hidden; }

/* Phones: each line becomes a card */
@media (max-width: 760px) {
  .child-table thead { display: none; }
  .child-table, .child-table tbody, .child-table tr, .child-table td { display: block; width: 100%; }
  .child-table tr[data-row] { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; padding: 12px; border-bottom: 1px solid var(--border); position: relative; }
  .child-table tr[data-row] > td { padding: 0; border: 0; }
  .child-table tr[data-row] > td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; font-weight: 700; color: var(--muted); margin-bottom: 3px; }
  .child-table tr[data-row] > td[data-col="item_id"] { grid-column: 1 / -1; }
  .child-table tr[data-row] > td.row-num { grid-column: 1 / -1; display: flex; align-items: center; }
  .child-table tr[data-row] > td.row-del { position: absolute; top: 8px; right: 8px; width: auto; }
  .child-table .link-field, .child-table th[data-col="item_id"] { min-width: 0; }
  .child-table td.col-off { display: none; }
  tr.row-detail > td { padding: 12px; }
  .rd-item { grid-column: 1 / -1; }
  .child-wrap.expanded { inset: 0; border-radius: 0; }
}

/* ---------- POS payment card ---------- */
.pos-body { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(240px, 1fr); gap: 24px; }
.pos-row { display: grid; grid-template-columns: minmax(0, 1fr) 140px 160px; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.pos-row:last-child { border-bottom: 0; }
.pos-mode { display: flex; flex-direction: column; min-width: 0; }
.pos-mode small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pos-ref { min-width: 0; }
.pos-side .sum-row strong { font-variant-numeric: tabular-nums; }
.pos-owing strong { color: var(--danger); }
@media (max-width: 760px) {
  .pos-body { grid-template-columns: 1fr; }
  .pos-row { grid-template-columns: 1fr 1fr; }
  .pos-mode { grid-column: 1 / -1; }
}

/* ---------- Saved messages with buttons ---------- */
.toast { padding-right: 36px; position: relative; }
.toast-x { position: absolute; right: 8px; top: 8px; border: 0; background: none; color: inherit; opacity: .6; cursor: pointer; padding: 2px; border-radius: 6px; }
.toast-x:hover { opacity: 1; }
.toast-links { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.toast-links a { display: inline-flex; align-items: center; height: 28px; padding: 0 12px; border-radius: 8px; background: var(--surface); color: var(--text); text-decoration: none; font-weight: 600; font-size: 13px; border: 1px solid var(--border); }
.toast-links a:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
/* ---------- Choice cards, send page, print designer, channels ---------- */
.choice-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.choice-card { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; margin: 0; font-weight: 500; }
.choice-card:has(input:checked) { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.choice-card small { display: block; color: var(--muted); font-weight: 400; }
.pd-thumb { display: block; width: 100%; height: 54px; border: 1px solid var(--border); border-radius: 6px; margin-bottom: 6px; padding: 6px; background: #fff; }
.pd-thumb i { display: block; height: 10px; border-radius: 2px; background: var(--brand); margin-bottom: 5px; }
.pd-thumb b { display: block; height: 4px; background: var(--border); margin-bottom: 4px; border-radius: 2px; }
.pd-classic i { height: 3px; } .pd-minimal i { height: 2px; background: var(--text); }
.pd-layout, .send-layout { display: grid; grid-template-columns: minmax(0, 1fr) 460px; gap: 20px; align-items: start; }
.send-layout { grid-template-columns: minmax(0, 1fr) 320px; }
.pd-side, .send-side { position: sticky; top: calc(var(--topbar-h) + 12px); display: flex; flex-direction: column; gap: 16px; }
.pd-frame-wrap { height: 70vh; background: #efedf6; border-radius: 0 0 var(--radius) var(--radius); overflow: hidden; }
.pd-frame { width: 100%; height: 100%; border: 0; background: #fff; }
.switch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px 16px; }
.channel-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.channel-tile { display: flex; gap: 10px; align-items: center; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; margin: 0; font-weight: 500; }
.channel-tile:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.channel-tile.off { opacity: .55; cursor: not-allowed; }
.channel-tile small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }
.ct-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-3); flex: none; }
.send-result { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 10px; }
.send-result.ok { background: var(--success-soft); } .send-result.bad { background: var(--danger-soft); }
.sent-list { list-style: none; margin: 0; padding: 0 16px 12px; }
.sent-list li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.doc-channels { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px; }
.doc-channels summary { display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline; color: inherit; }
.smtp-log { max-height: 220px; overflow: auto; font-size: 12px; background: var(--surface-2); padding: 10px; border-radius: 8px; white-space: pre-wrap; }
.btn-lg { height: 46px; font-size: 15px; }
@media (max-width: 1100px) { .pd-layout, .send-layout { grid-template-columns: 1fr; } .pd-side, .send-side { position: static; } }.save-bar .flex { flex-wrap: wrap; justify-content: flex-end; }


/* ---------- Payment: POS / Standard ---------- */
.settle-choice { display: grid; grid-template-columns: repeat(2, minmax(0, 220px)); gap: 10px; }
.settle-option { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border: 2px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; margin: 0; }
.settle-option input { position: absolute; opacity: 0; pointer-events: none; }
.settle-option:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.settle-option:has(input:focus-visible) { outline: 2px solid var(--brand); outline-offset: 2px; }
.settle-option strong { font-size: 15px; }
.so-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-3); flex: none; }
.settle-option:has(input:checked) .so-icon { background: var(--brand); color: var(--on-brand, #fff); }
.settle-panel { margin-top: 16px; }
.settle-mode { display: grid; grid-template-columns: minmax(0, 1fr) 170px 170px; gap: 12px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--border); }
.settle-mode:last-child { border-bottom: 0; }
.sm-name { display: flex; flex-direction: column; min-width: 0; }
.sm-amount { height: 42px; font-size: 16px; font-weight: 700; }
.settle-totals { margin: 12px 0 0 auto; max-width: 360px; }
.settle-figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.settle-figures > div { display: flex; flex-direction: column; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.settle-figures strong { font-size: 17px; font-variant-numeric: tabular-nums; }
.settle-figures .total { background: var(--warning-soft); border-color: transparent; }
@media (max-width: 760px) {
  .settle-choice { grid-template-columns: 1fr 1fr; }
  .settle-mode { grid-template-columns: 1fr 1fr; }
  .settle-mode .sm-name { grid-column: 1 / -1; }
}
/* ---------- Confirm box ---------- */
.confirm-backdrop { z-index: 200; padding: 16px; }
.confirm-box { max-width: 420px; padding: 0; animation: toast-in .18s ease; }
.confirm-box .modal-body { padding: 22px 22px 6px; }
.confirm-msg { margin: 0; font-size: 15px; line-height: 1.5; font-weight: 500; }
.confirm-box .modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px 20px; flex-wrap: wrap; }.settle-mode { grid-template-columns: 74px minmax(0, 1fr) 170px 170px; }
.sm-main { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 12.5px; font-weight: 600; color: var(--muted); cursor: pointer; }
.sm-main:has(input:checked) { color: var(--brand); }
.settle-mode:has(.sm-main input:checked) { background: var(--brand-soft); border-radius: var(--radius-sm); padding-left: 8px; padding-right: 8px; }
@media (max-width: 760px) { .settle-mode { grid-template-columns: auto 1fr; } .settle-mode .sm-amount, .settle-mode .sm-ref { grid-column: 1 / -1; } }.confirm-backdrop { background: rgba(8, 6, 18, .62); backdrop-filter: blur(2px); }

/* Small phones: the top bar keeps search, price check, help guide switch, dark mode and account;
   the plan pill (also on the dashboard) and the "explain this page" button make room */
@media (max-width: 480px) {
  .topbar .sub-pill, .topbar [data-tour-replay] { display: none; }
  .topbar { gap: 4px; }
}

/* ---------- Phones ---------- */
@media (max-width: 640px) {
  /* Top bar: search shrinks, subscription pill shows only the plan, nothing pushed off-screen */
  .topbar { gap: 8px; padding: 0 10px; }
  .topbar .search { min-width: 0; }
  .topbar .search input { padding-right: 8px; font-size: 14px; }
  .topbar .search input::placeholder { color: transparent; }
  .sub-pill { padding: 5px 8px; gap: 6px; }
  .sub-pill .timer, .sub-pill .icon { display: none; }
  .topbar .btn-icon { width: 34px; height: 34px; }
  .user-btn .avatar { width: 32px; height: 32px; }
  .topbar .search { min-width: 40px; }

  /* Dropdown menus open as a sheet from the bottom of the screen */
  .dropdown.open::before { content: ""; position: fixed; inset: 0; background: rgba(8, 6, 18, .5); z-index: 94; }
  .dropdown-menu, .dropdown-menu.col-menu {
    position: fixed; left: 8px; right: 8px; bottom: 8px; top: auto; width: auto; min-width: 0; max-width: none;
    max-height: 75vh; overflow-y: auto; border-radius: 16px; z-index: 95; padding: 8px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }
  .dropdown.open .dropdown-menu.col-menu { display: flex; }
  .dropdown-menu a, .dropdown-menu > button, .dropdown-menu form > button { padding: 12px; font-size: 15px; }

  /* Page heading buttons wrap neatly; long rows of actions scroll sideways instead of overlapping */
  .page-head { gap: 10px; }
  .page-head .actions { width: 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .page-head .actions::-webkit-scrollbar { display: none; }
  .page-head .actions > * { flex: none; }

  /* Tab bars scroll sideways (no stuck or squashed buttons) */
  .tabs, [data-tabs] { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .tabs::-webkit-scrollbar, [data-tabs]::-webkit-scrollbar { display: none; }
  .tabs a, .tabs button, [data-tabs] > * { flex: none; white-space: nowrap; }

  /* Save bar: buttons share the width */
  .save-bar .card-body { padding: 10px; }
  .save-bar .card-body > span { display: none; }
  .save-bar .flex { width: 100%; }
  .save-bar .flex > .btn { flex: 1 1 auto; }

  .card-head { flex-wrap: wrap; }
  .toast-stack { left: 10px; right: 10px; bottom: 10px; max-width: none; }
}input[type=file] { max-width: 100%; min-width: 0; }
@media (max-width: 640px) { .card-body.flex.wrap > form { width: 100%; } .card-body.flex.wrap > form input[type=file] { flex: 1 1 100%; } }
@media (max-width: 640px) { .tabs { -webkit-mask-image: linear-gradient(to right, #000 85%, transparent); mask-image: linear-gradient(to right, #000 85%, transparent); padding-right: 24px; } }
.banner-demo { background: linear-gradient(90deg, var(--brand), var(--accent)); color: #fff; } .banner-demo a { color: #fff; font-weight: 700; text-decoration: underline; }
.currency-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px 14px; } .currency-pick { padding: 6px 8px; border-radius: 8px; } .currency-pick:has(input:checked) { background: var(--brand-soft); }

/* ---------- Languages ---------- */
.lang-meter { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-bottom: 4px; max-width: 220px; }
.lang-meter span { display: block; height: 100%; background: var(--brand); border-radius: inherit; }
.lang-table textarea { width: 100%; min-height: 38px; resize: vertical; field-sizing: content; }
.lang-src { white-space: pre-wrap; }

/* Right-to-left languages (Arabic and any added RTL language) */
[dir=rtl] body { text-align: right; }
[dir=rtl] .right, [dir=rtl] .table .num, [dir=rtl] .table th.num, [dir=rtl] .num-input, [dir=rtl] .sum-row input, [dir=rtl] .child-table td.num, [dir=rtl] .lo-price, [dir=rtl] .lo-head span:nth-child(2) { text-align: left; }
[dir=rtl] .table th, [dir=rtl] .link-opt, [dir=rtl] .dropdown-menu a, [dir=rtl] .dropdown-menu button, [dir=rtl] .theme-swatch { text-align: right; }
[dir=rtl] .nav .badge { margin-left: 0; margin-right: auto; }
[dir=rtl] .sidebar-foot { padding-left: 0; padding-right: 12px; }
[dir=rtl] .topbar .search input { padding-left: 12px; padding-right: 38px; }
[dir=rtl] .topbar .search .icon { left: auto; right: 12px; }
[dir=rtl] .kpi .label { padding-right: 0; padding-left: 44px; }
[dir=rtl] .kpi .kpi-icon { right: auto; left: 16px; }
[dir=rtl] select { background-position: left 12px center; padding-right: 12px; padding-left: 32px; }
[dir=rtl] .input-group > .addon { border-left: 1px solid var(--border-strong); border-right: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
[dir=rtl] .switch .track::after { left: auto; right: 3px; }
[dir=rtl] .switch input:checked + .track::after { transform: translateX(-17px); }
[dir=rtl] .dropdown-menu { right: auto; left: 0; }
[dir=rtl] .summary-card { margin-left: 0; margin-right: auto; }
[dir=rtl] .fe-chips, [dir=rtl] label .link-to { margin-left: 0; margin-right: 6px; }
[dir=rtl] .step-no, [dir=rtl] .row-toggle { margin-right: 0; margin-left: 6px; }
[dir=rtl] .link-field .link-input { padding-right: 12px; padding-left: 30px; }
[dir=rtl] .link-open { right: auto; left: 6px; }
[dir=rtl] .toast-stack { right: auto; left: 20px; }
[dir=rtl] .toast { padding-right: 16px; padding-left: 36px; }
[dir=rtl] .toast-x { right: auto; left: 8px; }
[dir=rtl] .icon-dir { transform: scaleX(-1); }
[dir=rtl] input[type=number], [dir=rtl] input[type=tel], [dir=rtl] input[type=email], [dir=rtl] .mono { direction: ltr; text-align: right; }
@media (max-width: 960px) {
  [dir=rtl] .sidebar { left: auto; right: 0; transform: translateX(100%); }
  [dir=rtl] .nav-open .sidebar { transform: none; }
}
@media (max-width: 640px) {
  [dir=rtl] .tabs { -webkit-mask-image: linear-gradient(to left, #000 85%, transparent); mask-image: linear-gradient(to left, #000 85%, transparent); padding-right: 0; padding-left: 24px; }
  [dir=rtl] .child-table tr[data-row] > td.row-del { right: auto; left: 8px; }
}
:lang(ar) body, :lang(fa) body, :lang(ur) body { font-family: "Noto Sans Arabic", var(--font, system-ui), sans-serif; }
:lang(zh) body { font-family: var(--font, system-ui), "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif; }
:lang(hi) body { font-family: var(--font, system-ui), "Noto Sans Devanagari", sans-serif; }/* Mixed text (dates, numbers, codes) keeps its own reading order inside right-to-left screens */
[dir=rtl] .table td, [dir=rtl] .table th, [dir=rtl] .kpi .value, [dir=rtl] .sum-row strong { unicode-bidi: plaintext; }
[dir=rtl] .topbar .search input { text-align: right; }
/* ---------- Module builder ---------- */
.mb-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.mb-side { position: sticky; top: 76px; }
.mb-sub { margin: 18px 0 8px; font-size: 13px; color: var(--muted); font-weight: 700; }
.mb-fields td { vertical-align: top; }
.mb-fields input:not([type=checkbox]), .mb-fields select, .mb-fields textarea { width: 100%; min-width: 110px; }
.mb-fields td:first-child input { min-width: 150px; }
.mb-detail { min-width: 200px; }
.mb-detail > * + * { margin-top: 6px; }
.mb-detail .mb-hint { font-size: 12.5px; }
.mb-problems ul { margin: 0; padding-inline-start: 34px; display: grid; gap: 6px; font-size: 13px; }
.mb-companies { display: grid; gap: 6px; max-height: 320px; overflow-y: auto; }
.mb-record { border-inline-start: 3px solid var(--brand); }
@media (max-width: 1280px) { .mb-layout { grid-template-columns: 1fr; } .mb-side { position: static; display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; } .mb-side > .card { margin: 0; } }
/* Language switch in the account menu */
.menu-lang { padding: 6px 10px 8px; display: grid; gap: 6px; }
.menu-lang label { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.menu-lang select { height: 34px; font-size: 13px; }
/* Control Room: show a user's password */
.pw-reveal { display: inline-flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.pw-reveal-box { display: inline-flex; gap: 6px; }
.pw-reveal-out { background: var(--surface-2); padding: 4px 8px; border-radius: 6px; user-select: all; }
/* ---------- Report tables ---------- */
.rep-tools { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.rep-filter th { padding: 4px 8px; background: var(--surface); }
.rep-filter input { height: 30px; font-size: 12.5px; padding: 4px 8px; min-width: 70px; width: 100%; }
.rep-link { cursor: pointer; }
.rep-link:hover td { background: var(--brand-soft); }
.rep-bold td { font-weight: 700; }
.rep-flag-reversal td, .rep-flag-reversed td, .rep-flag-cancelled td { color: var(--muted); }
.rep-flag-reversed td:not(.num), .rep-flag-cancelled td:not([data-col=flag]):not([data-col=status]) { text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--danger) 60%, transparent); }
@media print { .rep-filter, .rep-tools { display: none; } }

/* ---------- Transaction breakdown ---------- */
.txn-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px 20px; }
.txn-grid .k { font-size: 12px; color: var(--muted); }
.txn-grid .v { font-weight: 600; }
.qty-warn { display: block; color: var(--danger); font-size: 11.5px; font-weight: 600; margin-top: 2px; white-space: nowrap; }

/* A line whose tax differs from the document's Tax */
.child-table input.differs { box-shadow: inset 3px 0 0 var(--warning); }

/* Back arrow in page titles; removed fields in the form editor */
.back-btn { margin-inline-end: 6px; vertical-align: middle; width: 34px; height: 34px; flex: none; }
h1 > .back-btn:first-child { margin-inline-start: -8px; }
.fe-removed-head { padding: 10px 6px 4px; list-style: none; }
.fe-removed s { text-decoration-color: var(--danger); }
/* ---------- Motion & hover feel ---------- */
.btn { transition: background .18s var(--ease), border-color .18s var(--ease), transform .18s var(--ease), box-shadow .18s var(--ease), color .18s; }
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0) scale(.98); box-shadow: none; }
.btn-primary:hover { box-shadow: 0 10px 24px -10px var(--brand), 0 0 0 3px color-mix(in srgb, var(--brand) 16%, transparent); }
.btn-ghost:hover, .btn-xs:hover { box-shadow: none; }
.btn .icon { transition: transform .2s var(--ease); }
.btn:hover .icon { transform: translateX(1px) scale(1.06); }
.btn-icon:hover .icon { transform: rotate(-8deg) scale(1.08); }

.card { transition: box-shadow .22s var(--ease), border-color .22s var(--ease), transform .22s var(--ease); }
.kpi, .card.hoverable, .grid > a.card { --mx: 50%; --my: 50%; }
.kpi:hover, .card.hoverable:hover, .grid > a.card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--brand) 35%, var(--border)); box-shadow: var(--glow); }
.kpi::after, .card.hoverable::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity .25s var(--ease);
  background: radial-gradient(260px circle at var(--mx) var(--my), color-mix(in srgb, var(--brand) 14%, transparent), transparent 70%); }
.card.hoverable { position: relative; }
.kpi:hover::after, .card.hoverable:hover::after { opacity: 1; }
.kpi .kpi-icon { transition: transform .25s var(--ease), background .25s; }
.kpi:hover .kpi-icon { transform: rotate(-6deg) scale(1.08); background: var(--brand); color: #fff; }

.nav a { position: relative; transition: background .18s var(--ease), color .18s, padding-left .18s var(--ease); }
.nav a:hover { padding-left: 15px; }
.nav a::before { content: ""; position: absolute; left: 0; top: 22%; bottom: 22%; width: 3px; border-radius: 3px; background: var(--brand); transform: scaleY(0); transition: transform .2s var(--ease); }
.nav a:hover::before { transform: scaleY(.6); }
.nav a.active::before { transform: scaleY(1); }
.nav a .icon { transition: transform .2s var(--ease), opacity .2s; }
.nav a:hover .icon { transform: scale(1.1); opacity: 1; }

.table tbody tr td { transition: background .15s var(--ease); }
.table tbody tr:hover td { background: color-mix(in srgb, var(--brand) 6%, var(--surface)); }
.table tbody tr:hover td:first-child { box-shadow: inset 3px 0 0 var(--brand); }
.table tbody tr[data-href], .table tbody tr.rep-link { cursor: pointer; }

input:not([type=checkbox]):not([type=radio]), select, textarea { transition: border-color .18s var(--ease), box-shadow .18s var(--ease), background .18s; }
input:not([type=checkbox]):not([type=radio]):hover, select:hover, textarea:hover { border-color: var(--border-strong); }
input:not([type=checkbox]):not([type=radio]):focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 16%, transparent); outline: none; }

.dropdown.open .dropdown-menu { animation: we-pop .16s var(--ease); transform-origin: top right; }
@keyframes we-pop { from { opacity: 0; transform: translateY(-4px) scale(.97); } to { opacity: 1; transform: none; } }
.dropdown-menu a, .dropdown-menu button { transition: background .14s, padding-left .16s var(--ease); }
.dropdown-menu a:hover, .dropdown-menu button:hover { padding-left: 13px; }
.badge { transition: transform .18s var(--ease); }
tr:hover .badge { transform: scale(1.04); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
  .btn:hover, .kpi:hover, .card.hoverable:hover, .grid > a.card:hover { transform: none; }
}

/* ---------- Getting started checklist ---------- */
.onboard { padding: 18px 20px; position: relative; overflow: hidden; background: linear-gradient(120deg, color-mix(in srgb, var(--brand) 9%, var(--surface)), var(--surface) 55%); }
.onboard-head { display: flex; gap: 14px; align-items: center; }
.onboard-mascot { width: 44px; height: auto; animation: auth-bob 5s ease-in-out infinite; }
.onboard-bar { height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; margin-top: 8px; max-width: 360px; }
.onboard-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--accent)); border-radius: 6px; transition: width .6s var(--ease); }
.onboard-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 16px; }
.onboard-step { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-weight: 600; font-size: 13.5px; text-decoration: none; transition: transform .18s var(--ease), border-color .18s, box-shadow .18s; }
.onboard-step:hover { text-decoration: none; transform: translateY(-2px); border-color: color-mix(in srgb, var(--brand) 40%, var(--border)); box-shadow: var(--glow); }
.onboard-tick { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-ink); flex: none; }
.onboard-step.done { color: var(--muted); }
.onboard-step.done span:last-child { text-decoration: line-through; }
.onboard-step.done .onboard-tick { background: var(--success-soft); color: var(--success); }
@media (max-width: 900px) { .onboard-steps { grid-template-columns: 1fr; } }

/* ---------- Control Room: quick sign-in ---------- */
.sso-card > summary::-webkit-details-marker { display: none; }
.sso-card[open] > summary { border-bottom: 1px solid var(--border); }
.sso-card > summary { border-bottom: 0; }
.sso-logo { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; border: 1px solid var(--border); flex: none; }
