/* ============================================================
   HK Electronics — App Design System
   Clean business dashboard · responsive · print-ready
   ============================================================ */

:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-soft: #eef2ff;
    --sidebar-bg: #0f172a;
    --sidebar-hover: #1e293b;
    --sidebar-active: #312e81;
    --bg: #f1f5f9;
    --card: #ffffff;
    --border: #e2e8f0;
    --text: #0f172a;
    --text-soft: #475569;
    --text-muted: #94a3b8;
    --green: #059669; --green-soft: #d1fae5;
    --red: #dc2626;   --red-soft: #fee2e2;
    --amber: #d97706; --amber-soft: #fef3c7;
    --blue: #2563eb;  --blue-soft: #dbeafe;
    --purple: #7c3aed; --purple-soft: #ede9fe;
    --sidebar-text: #cbd5e1;         /* v5.17.0 — menu text, Theme Studio controlled */
    --input-bg: #ffffff;             /* v5.17.0 — inputs / buttons surface */
    --tbl-head-bg: #f8fafc;          /* v5.17.0 — table header band */
    --radius: 10px;
    --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
    --shadow-lg: 0 10px 30px rgba(15, 23, 42, .12);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    /* v7.7.3 — Bangla-capable fallbacks appended (the owner's rule 4): systems
       that ship a Bengali face (Noto Sans Bengali on Android, Vrinda /
       Nirmala on Windows, SolaimanLipi where installed) now render বাংলা
       uniformly instead of falling back per-glyph. Latin-first order keeps
       the English look byte-identical. */
    font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans Bengali', 'SolaimanLipi', 'Vrinda', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14.5px;
    line-height: 1.55;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 12px; font-weight: 700; }
img { max-width: 100%; }

/* ---------------- Sidebar ---------------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
    width: 250px; flex-shrink: 0;
    background: var(--sidebar-bg); color: #cbd5e1;
    position: fixed; inset: 0 auto 0 0; z-index: 60;
    display: flex; flex-direction: column;
    transition: transform .25s ease;
    overflow-y: auto;
}
.sidebar .brand {
    display: flex; align-items: center; gap: 10px;
    padding: 18px 18px 14px; color: #fff; text-decoration: none;
}
.sidebar .brand:hover { text-decoration: none; }
.brand-logo {
    width: 38px; height: 38px; border-radius: 9px; flex-shrink: 0;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 800; font-size: 15px;
}
.brand-name { font-weight: 700; font-size: 16px; line-height: 1.2; }
.brand-sub { font-size: 11px; color: #64748b; }

.nav-groups { padding: 6px 10px 30px; flex: 1; }
.nav-group-title {
    font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em;
    color: #64748b; padding: 14px 10px 5px; font-weight: 700;
}
.nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 8.5px 12px; border-radius: 8px; margin: 1px 0;
    color: #cbd5e1; text-decoration: none; font-size: 13.8px;
}
.nav-link:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.nav-link .ico { width: 19px; text-align: center; opacity: .85; flex-shrink: 0; }
.nav-link .cnt {
    margin-left: auto; background: var(--red); color: #fff; border-radius: 99px;
    font-size: 10.5px; padding: 1px 7px; font-weight: 700;
}

/* ---- v2.7 — collapsible menu groups (menu > sub-menu) ---- */
.nav-sec { margin: 1px 0; }
.nav-sec-head {
    display: flex; align-items: center; gap: 9px; width: 100%;
    padding: 8px 12px; border-radius: 8px; margin: 2px 0 1px;
    background: none; border: 0; cursor: pointer; text-align: left;
    color: var(--text-muted); font-size: 11.5px; font-weight: 700;
    letter-spacing: .07em; text-transform: uppercase;
}
.nav-sec-head:hover { background: var(--sidebar-hover); color: var(--sidebar-text); }
.nav-sec-head .ico { width: 19px; text-align: center; flex-shrink: 0; font-size: 13px; opacity: .9; }
.nav-sec-head .chev { margin-left: auto; font-size: 10px; opacity: .65; transition: transform .15s; }
.nav-sec-head .cnt { margin-left: auto; }
.nav-sec-head .cnt + .chev { margin-left: 6px; }
.nav-sec.open .nav-sec-head .chev { transform: rotate(90deg); }
.nav-sec-body { display: none; }
.nav-sec.open .nav-sec-body { display: block; }
.nav-sec-body .nav-link { padding-left: 38px; font-size: 13.2px; }
/* v5.10.0 — Menu Builder custom node types */
.nav-sec-body .nav-divider { height: 1px; margin: 5px 14px 5px 30px; background: rgba(203,213,225,.18); }
.nav-sec-body .nav-subhead {
    padding: 7px 14px 2px 38px; font-size: 10.5px; font-weight: 700; letter-spacing: .08em;
    text-transform: uppercase; opacity: .6; display: flex; gap: 6px; align-items: center;
}
.nav-sec-body .nav-subhead .ico { width: 16px; text-align: center; }
.nav-sec-body .nav-link .cnt { margin-left: auto; }

/* v6.2.0 — SUB-MENU ITEMS (Menu Builder nesting): an item with children
   becomes a collapsible group — the parent link stays clickable, the ▸
   chevron toggles the children. Levels: 2 = sub-items, 3 = sub-sub items. */
.nav-sub { margin: 1px 0; }
.nav-sub-row { display: flex; align-items: center; gap: 0; }
.nav-sub-row .nav-link { flex: 1; min-width: 0; }
.nav-sub-chev { border: 0; background: transparent; color: var(--sidebar-text); opacity: .6; cursor: pointer;
    font-size: 9px; padding: 6px 10px 6px 0; transition: transform .15s; }
.nav-sub-chev:hover { opacity: 1; }
.nav-sub.open > .nav-sub-row .nav-sub-chev { transform: rotate(90deg); }
.nav-sub-body { display: none; }
.nav-sub.open > .nav-sub-body { display: block; }
.nav-sub[data-level="2"] .nav-sub-body .nav-link { padding-left: 52px; font-size: 12.6px; }
.nav-sub[data-level="3"] .nav-sub-body .nav-link { padding-left: 64px; font-size: 12.2px; }
/* a nested group inside another group indents a little more */
.nav-sub .nav-sub { margin-left: 10px; }
.nav-sub .nav-sub > .nav-sub-row .nav-link { padding-left: 50px !important; font-size: 12.6px; }
.nav-sub .nav-sub .nav-sub > .nav-sub-row .nav-link { padding-left: 62px !important; font-size: 12.2px; }

.sidebar-footer { padding: 12px 16px; border-top: 1px solid var(--sidebar-hover); font-size: 11.5px; color: var(--sidebar-text); opacity: .85; }

/* ---------------- Main area ---------------- */
.main { flex: 1; margin-left: 250px; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    position: sticky; top: 0; z-index: 50;
    background: var(--card); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 14px;
    padding: 10px 22px; min-height: 58px;
}
.hamburger {
    display: none; border: 1px solid var(--border); background: var(--input-bg); border-radius: 8px;
    padding: 7px 11px; cursor: pointer; font-size: 16px; line-height: 1;
}
.global-search { flex: 1; max-width: 460px; position: relative; }
.global-search input {
    width: 100%; padding: 9px 14px 9px 38px; border: 1px solid var(--border);
    border-radius: 9px; background: var(--bg); font-size: 13.5px; outline: none;
}
.global-search input:focus { border-color: var(--primary); background: var(--input-bg); }
.global-search .s-ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }

.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn {
    position: relative; border: 1px solid var(--border); background: var(--input-bg);
    width: 38px; height: 38px; border-radius: 9px; cursor: pointer; font-size: 16px;
    display: inline-flex; align-items: center; justify-content: center; color: var(--text-soft);
    text-decoration: none;
}
.icon-btn:hover { background: var(--bg); text-decoration: none; }
.icon-btn.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.icon-btn .dot {
    position: absolute; top: -5px; right: -5px; background: var(--red); color: #fff;
    font-size: 10px; font-weight: 700; min-width: 17px; height: 17px; border-radius: 99px;
    display: flex; align-items: center; justify-content: center; padding: 0 4px;
}
.user-chip {
    display: flex; align-items: center; gap: 10px; padding: 5px 6px 5px 12px;
    border: 1px solid var(--border); border-radius: 10px; background: var(--input-bg); position: relative;
}
.user-chip .u-name { font-size: 13px; font-weight: 600; line-height: 1.2; }
.user-chip .u-role { font-size: 11px; color: var(--text-muted); }
.avatar {
    width: 30px; height: 30px; border-radius: 99px; background: var(--primary-soft);
    color: var(--primary); font-weight: 700; font-size: 13px;
    display: flex; align-items: center; justify-content: center;
}
.dropdown { position: relative; }
.dropdown-menu {
    position: absolute; right: 0; top: calc(100% + 8px); min-width: 180px;
    background: var(--input-bg); border: 1px solid var(--border); border-radius: 10px;
    box-shadow: var(--shadow-lg); padding: 6px; display: none; z-index: 70;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a, .dropdown-menu button {
    display: block; width: 100%; text-align: left; padding: 8px 12px; border-radius: 7px;
    color: var(--text); font-size: 13.5px; background: none; border: 0; cursor: pointer;
}
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--bg); text-decoration: none; }

.content { padding: 22px; max-width: 1400px; width: 100%; margin: 0 auto; flex: 1; }

.breadcrumb { font-size: 12.5px; color: var(--text-muted); margin-bottom: 6px; }
.breadcrumb a { color: var(--text-soft); }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 21px; margin: 0; }
.page-head .spacer { flex: 1; }

/* ---------------- Cards ---------------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card { margin-top: 18px; }
.card-h {
    padding: 14px 18px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.card-h h2, .card-h h3 { margin: 0; font-size: 15.5px; }
.card-b { padding: 18px; }
.card-b.p0 { padding: 0; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--primary); opacity: .85; }
.stat.green::before { background: var(--green); }
.stat.red::before { background: var(--red); }
.stat.amber::before { background: var(--amber); }
.stat.blue::before { background: var(--blue); }
.stat.purple::before { background: var(--purple); }
.stat .s-label { font-size: 12.5px; color: var(--text-soft); font-weight: 600; }
.stat .s-value { font-size: 23px; font-weight: 800; margin-top: 3px; letter-spacing: -.02em; }
.stat .s-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }
/* v7.9.12 — .grid-4 was used by the warranty records + commission statement
   stat rows since their rounds but was never DEFINED (the cards silently
   stacked full-width on wide screens). Additive definition — every page
   using it (them + the new Sync Center) now gets the intended 4 columns. */
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }

/* ---------------- Tables ---------------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
/* v2.8 — wrap-friendly tables: always fit the available width and grow
   downwards instead of scrolling sideways (invoice items list etc.) */
.tbl.wrap td, .tbl.wrap th { white-space: normal; overflow-wrap: anywhere; }
.tbl.wrap td { padding: 8px 10px; }
.tbl.wrap code { white-space: normal; overflow-wrap: anywhere; }
.tbl.wrap .num { white-space: nowrap; }
.tbl th {
    text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em;
    color: var(--text-muted); font-weight: 700; padding: 10px 14px;
    border-bottom: 1px solid var(--border); background: var(--tbl-head-bg); white-space: nowrap;
}
.tbl td { padding: 10px 14px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.tbl tbody tr:hover { background: var(--tbl-head-bg); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .actions { white-space: nowrap; text-align: right; }
.tbl .actions a, .tbl .actions button { margin-left: 6px; }

/* ---------------- Badges ---------------- */
.badge {
    display: inline-block; padding: 3px 10px; border-radius: 99px;
    font-size: 11.5px; font-weight: 700; white-space: nowrap; line-height: 1.5;
}
.badge-green { background: var(--green-soft); color: #065f46; }
.badge-red { background: var(--red-soft); color: #991b1b; }
.badge-amber { background: var(--amber-soft); color: #92400e; }
.badge-blue { background: var(--blue-soft); color: #1e40af; }
.badge-purple { background: var(--purple-soft); color: #5b21b6; }
.badge-gray { background: #f1f5f9; color: #475569; }

/* ---------------- Buttons ---------------- */
.btn {
    display: inline-flex; align-items: center; gap: 7px;
    background: var(--primary); color: #fff; border: 1px solid var(--primary);
    padding: 9px 16px; border-radius: 8px; font-size: 13.5px; font-weight: 600;
    cursor: pointer; text-decoration: none; transition: background .15s;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; color: #fff; }
.btn-secondary { background: var(--input-bg); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); color: var(--text); }
.btn-danger { background: var(--red); border-color: var(--red); }
.btn-danger:hover { background: #b91c1c; }
.btn-success { background: var(--green); border-color: var(--green); }
.btn-success:hover { background: #047857; }
.btn-sm { padding: 5px 11px; font-size: 12.5px; border-radius: 7px; }
.btn-ghost-danger { background: var(--input-bg); color: var(--red); border: 1px solid #fecaca; }
.btn-ghost-danger:hover { background: var(--red-soft); color: var(--red); }

/* ---------------- Forms ---------------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid .cols-3 { grid-column: span 2; display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 18px; }
label.f { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-soft); margin-bottom: 5px; }
label.f .req { color: var(--red); }
.input, select.input, textarea.input {
    width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
    font-size: 13.5px; font-family: inherit; background: var(--input-bg); color: var(--text); outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, .12); }
textarea.input { resize: vertical; min-height: 80px; }
.input-hint { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13.5px; padding: 4px 0; }
.form-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

/* ---------------- Filters ---------------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.filters .f-group { min-width: 150px; }
.filters label.f { margin-bottom: 4px; font-size: 11.5px; }

/* ---------------- Alerts / toasts ---------------- */
.alerts { position: fixed; top: 14px; right: 14px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: 380px; }
.alert {
    padding: 12px 16px; border-radius: 9px; font-size: 13.5px; font-weight: 500;
    box-shadow: var(--shadow-lg); animation: slideIn .25s ease; display: flex; gap: 8px;
}
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.alert-success { background: #ecfdf5; border: 1px solid #6ee7b7; color: #065f46; }
.alert-error { background: #fef2f2; border: 1px solid #fca5a5; color: #991b1b; }
.alert-info { background: #eff6ff; border: 1px solid #93c5fd; color: #1e40af; }
.alert-warning { background: #fffbeb; border: 1px solid #fcd34d; color: #92400e; }
/* v4.13.1 — click-to-dismiss notifications: pointer cursor, subtle hover
   and the small × on the right tell the user ONE click closes the message */
.alert { cursor: pointer; }
.alert:hover { filter: brightness(.97); }
.alert .alert-x { margin-left: auto; font-size: 16px; font-weight: 700; line-height: 1; opacity: .45; }
.alert .alert-x:hover { opacity: 1; }

/* ---------------- Modal ---------------- */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(15, 23, 42, .55); z-index: 90;
    display: none; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto;
}
.modal-overlay.open { display: flex; }
.modal { background: var(--input-bg); border-radius: 14px; width: 100%; max-width: 560px; box-shadow: var(--shadow-lg); animation: pop .18s ease; }
.modal.lg { max-width: 800px; }
@keyframes pop { from { transform: scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-h { padding: 15px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; }
.modal-h h3 { margin: 0; font-size: 16px; flex: 1; }
.modal-x { border: 0; background: none; font-size: 20px; cursor: pointer; color: var(--text-muted); line-height: 1; }
.modal-b { padding: 20px; }
.modal-f { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ---------------- Tabs ---------------- */
.tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--border); flex-wrap: wrap; }
.tab {
    padding: 9px 16px; font-size: 13.5px; font-weight: 600; color: var(--text-soft);
    border: 0; background: none; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px;
}
.tab:hover { color: var(--primary); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-pane { display: none; padding-top: 18px; }
.tab-pane.active { display: block; }

/* ---------------- Timeline ---------------- */
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ''; position: absolute; left: 8px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding-bottom: 18px; }
.tl-item::before {
    content: ''; position: absolute; left: -24px; top: 4px; width: 12px; height: 12px;
    border-radius: 99px; background: var(--primary); border: 2.5px solid #fff; box-shadow: 0 0 0 1.5px var(--primary);
}
.tl-item.tl-gray::before { background: #94a3b8; box-shadow: 0 0 0 1.5px #94a3b8; }
.tl-item.tl-green::before { background: var(--green); box-shadow: 0 0 0 1.5px var(--green); }
.tl-item.tl-red::before { background: var(--red); box-shadow: 0 0 0 1.5px var(--red); }
.tl-time { font-size: 11.5px; color: var(--text-muted); }
.tl-title { font-weight: 600; font-size: 13.5px; }
.tl-detail { font-size: 13px; color: var(--text-soft); }

/* ---------------- Files / attachments ---------------- */
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.file-card { border: 1px solid var(--border); border-radius: 9px; overflow: hidden; background: var(--input-bg); }
.file-card img { width: 100%; height: 100px; object-fit: cover; display: block; }
.file-card .pdf-thumb {
    height: 100px; display: flex; align-items: center; justify-content: center;
    background: var(--red-soft); color: var(--red); font-size: 26px; font-weight: 800;
}
.file-card .f-name { font-size: 11.5px; padding: 7px 9px 2px; word-break: break-all; }
.file-card .f-meta { font-size: 10.5px; color: var(--text-muted); padding: 0 9px 8px; display: flex; justify-content: space-between; }

.dropzone {
    border: 2px dashed var(--border); border-radius: 10px; padding: 22px; text-align: center;
    color: var(--text-muted); cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }

/* ---------------- Kanban board ---------------- */
.board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 10px; align-items: flex-start; }
.board-col { background: #eef2f7; border-radius: 10px; padding: 10px; min-width: 250px; width: 250px; flex-shrink: 0; }
.board-col h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-soft); margin: 2px 4px 10px; }
.board-card { background: var(--input-bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; box-shadow: var(--shadow); }
.board-card .bc-title { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.board-card .bc-meta { font-size: 11.5px; color: var(--text-muted); display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------- Pagination ---------------- */
.pager { display: flex; gap: 6px; align-items: center; padding: 14px 18px; font-size: 13px; }
.pager a, .pager span.cur {
    padding: 6px 12px; border: 1px solid var(--border); border-radius: 7px; background: var(--input-bg); color: var(--text-soft);
}
.pager span.cur { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 700; }
.pager a:hover { background: var(--bg); text-decoration: none; }
.pager .p-info { margin-right: auto; color: var(--text-muted); }

/* ---------------- Auth pages ---------------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 55%, #312e81 100%); }
.auth-card { background: var(--input-bg); border-radius: 16px; padding: 34px; width: 100%; max-width: 420px; box-shadow: var(--shadow-lg); }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-brand .brand-logo { width: 46px; height: 46px; font-size: 18px; }
.auth-brand h1 { font-size: 20px; margin: 0; }
.auth-brand .sub { font-size: 12.5px; color: var(--text-muted); }
.auth-foot { text-align: center; font-size: 12.5px; color: var(--text-muted); margin-top: 18px; }
.demo-box { background: var(--tbl-head-bg); border: 1px dashed var(--border); border-radius: 9px; padding: 10px 14px; font-size: 12px; color: var(--text-soft); margin-top: 16px; }

/* ---------------- Empty state ---------------- */
.empty { text-align: center; padding: 46px 20px; color: var(--text-muted); }
.empty .e-ico { font-size: 34px; margin-bottom: 8px; }
.empty .e-title { font-weight: 700; color: var(--text-soft); font-size: 15px; }
.empty .e-sub { font-size: 13px; }

/* ---------------- Detail rows ---------------- */
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 7px 14px; font-size: 13.5px; }
.kv .k { color: var(--text-muted); font-weight: 600; font-size: 12.5px; }

/* ---------------- Invoice print ---------------- */
.print-area { background: var(--input-bg); padding: 34px; max-width: 860px; margin: 0 auto; border: 1px solid var(--border); border-radius: 8px; }
.print-head { display: flex; justify-content: space-between; gap: 20px; border-bottom: 3px solid var(--primary); padding-bottom: 16px; margin-bottom: 20px; }
.print-head .co-name { font-size: 22px; font-weight: 800; color: var(--primary); }
.print-head .co-meta { font-size: 12.5px; color: var(--text-soft); line-height: 1.6; }
.print-inv-no { font-size: 19px; font-weight: 800; }
.badge-print { border: 2px solid var(--green); color: var(--green); padding: 4px 14px; border-radius: 6px; font-weight: 800; text-transform: uppercase; font-size: 12px; letter-spacing: .06em; }
.print-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 30px; margin-bottom: 18px; font-size: 13px; }
.print-total-row td { font-weight: 800; font-size: 14px; background: var(--primary-soft); }
.print-sign { display: flex; justify-content: space-between; margin-top: 60px; font-size: 13px; }
.print-sign div { border-top: 1px solid var(--text); padding-top: 6px; width: 200px; text-align: center; }

/* ---------------- Responsive ---------------- */
@media (max-width: 1024px) {
    .grid-2, .grid-3, .grid-2-1, .grid-4 { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .cols-3 { grid-template-columns: 1fr; grid-column: auto; }
    .kv { grid-template-columns: 1fr; }
    .kv .k { margin-top: 4px; }
}
@media (max-width: 860px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
    .main { margin-left: 0; }
    .hamburger { display: inline-block; }
    .content { padding: 14px; }
    .global-search { max-width: none; }
    .user-chip .u-meta { display: none; }
    .print-head { flex-direction: column; }
    .print-grid { grid-template-columns: 1fr; }
}

/* v3.3 — phones: comfortable touch targets, stacked filters, no iOS zoom */
@media (max-width: 640px) {
    body { font-size: 14px; }
    .content { padding: 10px 10px 26px; }
    .page-head { gap: 8px; margin-bottom: 14px; }
    .page-head h1 { font-size: 18px; }
    .topbar { padding: 8px 10px; gap: 8px; }
    .global-search input { font-size: 13px; }
    .content { overflow-x: hidden; }
    .card-h, .card-b { padding-left: 12px; padding-right: 12px; }
    .filters { padding: 10px 12px; }
    .filters .f-group { flex: 1 1 100%; min-width: 0; }
    .filters .btn { flex: 1 1 auto; }
    .form-actions { flex-direction: column; align-items: stretch; }
    .form-actions .btn { width: 100%; }
    .btn { min-height: 40px; }
    .btn-sm { min-height: 34px; }
    .input, select.input, textarea.input { font-size: 16px; }   /* prevents iOS auto-zoom */
    .tbl { font-size: 12.5px; }
    .tbl th, .tbl td { padding: 8px 9px; }
    .stat-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)) !important; }
    .stat .s-value, .stat .stat-v { font-size: 16px; }
    .kv { grid-template-columns: 105px 1fr; gap: 5px 10px; }
    .modal { width: 94vw; }
    .modal.lg { width: 96vw; }
    .alert { font-size: 13px; }
    .dropdown-menu { min-width: 190px; }
    .hamburger { padding: 6px 10px; }
}

/* ---------------- Print ---------------- */
@page { size: A4 portrait; margin: 12mm 10mm; }

@media print {
    html, body { background: #ffffff !important; }
    body { padding: 0 !important; margin: 0 !important; }
    .sidebar, .topbar, .alerts, .no-print, .modal-overlay { display: none !important; }
    .main { margin: 0; }
    .content { padding: 0; }
    .print-area { border: 0; border-radius: 0; box-shadow: none !important; padding: 0; width: auto !important; max-width: 100% !important; }
    /* A4 print viewport is narrow (<860px) and would otherwise trigger the
       mobile stacked header — force the document header onto ONE row. */
    .print-head { flex-direction: row !important; justify-content: flex-start !important; align-items: center !important; gap: 14px !important; }
    .print-head .co-block { flex: 0 1 auto !important; }
    .print-grid { grid-template-columns: 1fr 1fr !important; }
    /* pagination hygiene: never split the header/banners/signature across pages */
    .brand-head, .print-sign, .quote-banner, .adj-banner, .quote-valid { break-inside: avoid; page-break-inside: avoid; }
    .tbl tr { break-inside: avoid; page-break-inside: avoid; }
    h4 { break-after: avoid; page-break-after: avoid; }
    .tbl th { background: #f1f5f9 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .badge-print, .print-total-row td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ============================================================
   v2 — Autocomplete / Progressive Disclosure / Serial picker
   ============================================================ */

/* ---- Autocomplete selector (customers, products, vendors) ---- */
.ac-wrap { position: relative; }
.ac-input { width: 100%; }
.ac-list {
    position: absolute; z-index: 60; top: calc(100% + 4px); left: 0; right: 0;
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-lg); max-height: 320px; overflow-y: auto; display: none;
}
.ac-list.open { display: block; }
/* v2.5 — fixed overlay variant: used when the input sits inside an
   overflow-clipping container (e.g. .table-wrap) so results are never
   cut off and never require scrolling to see. */
.ac-list.ac-overlay { position: fixed; left: 0; top: 0; z-index: 300; }
.ac-item { padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--border); }
.ac-item:last-child { border-bottom: 0; }
.ac-item:hover, .ac-item.active { background: var(--primary-soft); }
.ac-item .ac-title { font-weight: 600; font-size: 13.5px; color: var(--text); }
.ac-item .ac-sub { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.ac-item .ac-tag { font-size: 10.5px; background: var(--primary-soft); color: var(--primary); border-radius: 4px; padding: 1px 6px; margin-left: 6px; }
.ac-empty { padding: 12px; text-align: center; color: var(--text-muted); font-size: 12.5px; }
.ac-selected-card {
    display: flex; align-items: center; gap: 10px; padding: 9px 12px; margin-top: 6px;
    background: var(--primary-soft); border: 1px solid var(--primary); border-radius: var(--radius); font-size: 13px;
}
.ac-selected-card b { flex: 1; }
.ac-hidden-value { display: none; }

/* ---- Collapsible advanced sections (progressive disclosure) ---- */
details.adv { border: 1px solid var(--border); border-radius: var(--radius); margin-top: 14px; background: #fbfcfe; }
details.adv > summary {
    cursor: pointer; padding: 10px 14px; font-weight: 700; font-size: 13px; color: var(--text-soft);
    list-style: none; display: flex; align-items: center; gap: 8px; user-select: none;
}
details.adv > summary::-webkit-details-marker { display: none; }
details.adv > summary::before { content: '▸'; display: inline-block; transition: transform .15s; color: var(--text-muted); }
details.adv[open] > summary::before { transform: rotate(90deg); }
details.adv > summary .adv-hint { font-weight: 400; font-size: 11.5px; color: var(--text-muted); margin-left: auto; }
details.adv .adv-body { padding: 4px 14px 14px; }
details.adv + details.adv { margin-top: 10px; }

/* ---- Serial picker on invoice rows ---- */
.serial-picker { min-width: 150px; }
.serial-chip {
    display: inline-flex; align-items: center; gap: 5px; background: var(--primary-soft); color: var(--primary);
    border-radius: 12px; padding: 2px 8px; font-size: 11.5px; font-weight: 600; margin: 2px 3px 2px 0;
}
.serial-chip button { background: none; border: 0; color: var(--primary); cursor: pointer; font-weight: 800; padding: 0; }
.sp-available { font-size: 11px; color: var(--text-muted); }

/* ---- Document type pills on invoice/quotation form ---- */
.doc-type-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.doc-type-pills label.pill {
    border: 1.5px solid var(--border); border-radius: 20px; padding: 7px 16px; font-size: 13px;
    font-weight: 600; cursor: pointer; color: var(--text-soft); background: var(--card);
}
.doc-type-pills input { display: none; }
.doc-type-pills input:checked + span, .doc-type-pills label.pill.on { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }

/* ---- Payment option tiles ---- */
.pay-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.pay-opts label {
    border: 1.5px solid var(--border); border-radius: var(--radius); padding: 10px 12px; cursor: pointer;
    font-size: 13px; font-weight: 600; color: var(--text-soft); background: var(--card); text-align: center;
}
.pay-opts input { display: none; }
.pay-opts label.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.pay-opts label small { display: block; font-weight: 400; font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ---- Category-based conditional fields ---- */
.cat-fields[data-show="0"] { display: none; }
.cat-hint { font-size: 11.5px; color: var(--text-muted); background: var(--bg); border: 1px dashed var(--border); border-radius: 8px; padding: 7px 10px; margin-top: 10px; }

/* ---- Totals box ---- */
.totals-box { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; }
.totals-box .trow { display: flex; justify-content: space-between; padding: 3px 0; font-size: 13px; }
.totals-box .trow.grand { border-top: 2px solid var(--text); margin-top: 5px; padding-top: 7px; font-weight: 800; font-size: 15px; }

/* ---- Print: quotation banner / statement / receipt ---- */
.quote-banner {
    border: 2px solid #b45309; color: #b45309; border-radius: 8px; text-align: center;
    font-weight: 800; letter-spacing: 2px; font-size: 18px; padding: 8px; margin: 12px 0;
}
.quote-valid { font-size: 12.5px; color: #64748b; text-align: center; margin-bottom: 8px; }
.adj-banner { border: 2px solid #7c3aed; color: #7c3aed; border-radius: 8px; text-align: center; font-weight: 700; padding: 6px; margin: 10px 0; font-size: 14px; }
.stmt-run-b { font-weight: 700; }
.brand-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.brand-head .co-block { flex: 1; }

/* ---- Invoice/Quotation option cards (Payment, Discount & Quotation Options) ---- */
.opt-cards {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 10px; align-items: stretch;
}
.opt-card {
    position: relative; display: flex; flex-direction: column; gap: 4px;
    border: 1.5px solid var(--border); border-radius: var(--radius); padding: 12px 13px;
    background: var(--card); cursor: pointer; transition: border-color .15s, box-shadow .15s, background .15s;
}
.opt-card:hover { border-color: #c7d2fe; box-shadow: var(--shadow); }
/* v2.7 FIX — hide ONLY the card's radio control. The old rule (.opt-card input)
   also hid the real data inputs inside the expanded card body (Partial Payment
   amount, % discount, Force Adjustment amount, due dates…) — the fields were
   rendered at opacity:0 so users saw the card "on" but no input field. */
.opt-card > input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.opt-card .oc-head { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 13.5px; color: var(--text); }
.opt-card .oc-ico { font-size: 15px; line-height: 1; }
.opt-card .oc-title { flex: 1; }
.opt-card .oc-dot {
    width: 15px; height: 15px; border-radius: 50%; border: 2px solid var(--border);
    background: var(--input-bg); flex: 0 0 auto; transition: all .15s;
}
.opt-card .oc-hint { font-size: 11.5px; color: var(--text-muted); line-height: 1.45; }
.opt-card .oc-body { display: none; margin-top: 8px; flex-direction: column; gap: 6px; }
.opt-card.on { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 1px var(--primary) inset; }
.opt-card.on .oc-dot { border-color: var(--primary); background: var(--primary); box-shadow: inset 0 0 0 3px #fff; }
.opt-card.on .oc-body { display: flex; }
.opt-card.opt-card-adjust.on { border-color: var(--purple); background: var(--purple-soft); box-shadow: 0 0 0 1px var(--purple) inset; }
.opt-card.opt-card-adjust.on .oc-dot { border-color: var(--purple); background: var(--purple); }
.opt-card.opt-card-sm .oc-body { margin-top: 6px; }
.opt-card.dimmed { opacity: .45; }
.opt-card.dimmed:hover { opacity: .8; }
.opt-card .oc-flabel {
    font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
    color: var(--text-soft);
}
.opt-card .oc-body .input { font-size: 12.5px; padding: 6px 9px; background: var(--input-bg); }

/* ---- v2.7 bar-code scan feedback (invoice + purchase rows) ---- */
.i-barcode.bc-hit { border-color: #16a34a; background: #f0fdf4; }
.i-barcode.bc-miss { border-color: var(--red); background: #fef2f2; }
html[data-theme="dark"] .i-barcode.bc-hit { background: #052e16; }
html[data-theme="dark"] .i-barcode.bc-miss { background: #450a0a; }

/* ---- Tax % OR amount inline rows in the summary ---- */
.tax-line { align-items: center; flex-wrap: wrap; gap: 6px; }
.tax-line .tl-inputs { display: inline-flex; align-items: center; gap: 5px; }
.tax-line .tl-inputs .input {
    width: 74px; font-size: 12px; padding: 3px 7px; text-align: right;
    font-variant-numeric: tabular-nums; background: var(--input-bg);
}
.tax-line .tl-inputs b { font-size: 12px; color: var(--text-soft); }
.tax-line .tl-inputs i {
    font-style: normal; font-size: 10px; font-weight: 700; color: var(--text-muted);
    border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; background: var(--bg);
}

/* ---- Summary panel status colors ---- */
.sum-panel .trow.pos span:last-child, .sum-panel .trow.pos b { color: var(--green); }
.sum-panel .trow.neg span:last-child, .sum-panel .trow.neg b { color: var(--red); }
.sum-panel .trow.final {
    border-top: 2px solid var(--border); margin-top: 6px; padding-top: 8px;
    font-weight: 800; font-size: 15.5px; color: var(--green);
}
.sum-panel .trow.final span:last-child { color: var(--green); }
.ac-id {
    display: inline-block; font-size: 10.5px; font-weight: 700; color: var(--primary);
    background: var(--primary-soft); border-radius: 4px; padding: 1px 6px; margin-right: 4px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.ac-input.ac-error { border-color: var(--red); }

/* ============================================================
   Theme: DARK  (html[data-theme="dark"]) — Bright is the default
   ============================================================ */
html[data-theme="dark"] {
    --primary: #6366f1;
    --primary-dark: #818cf8;
    --primary-soft: rgba(99, 102, 241, .16);
    --sidebar-bg: #060b16;
    --sidebar-hover: #141d33;
    --sidebar-active: #1e1b4b;
    --bg: #0b1220;
    --card: #101a2d;
    --border: #233049;
    --text: #e2e8f0;
    --text-soft: #a8b6cc;
    --text-muted: #7c8aa5;
    --green: #34d399; --green-soft: rgba(52, 211, 153, .14);
    --red: #f87171;   --red-soft: rgba(248, 113, 113, .14);
    --amber: #fbbf24; --amber-soft: rgba(251, 191, 36, .14);
    --blue: #60a5fa;  --blue-soft: rgba(96, 165, 250, .14);
    --purple: #a78bfa; --purple-soft: rgba(167, 139, 250, .14);
    --shadow: 0 1px 3px rgba(0, 0, 0, .45), 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, .55);
    --sidebar-text: #a8b6cc; --input-bg: #101a2d; --tbl-head-bg: #0d1626;
    color-scheme: dark;
}
html[data-theme="dark"] body { background: var(--bg); color: var(--text); }
html[data-theme="dark"] .global-search input,
html[data-theme="dark"] .dropdown-menu,
html[data-theme="dark"] .user-chip,
html[data-theme="dark"] .input, html[data-theme="dark"] select.input, html[data-theme="dark"] textarea.input,
html[data-theme="dark"] .btn-secondary,
html[data-theme="dark"] .btn-ghost-danger,
html[data-theme="dark"] .modal,
html[data-theme="dark"] .file-card,
html[data-theme="dark"] .board-card,
html[data-theme="dark"] .pager span,
html[data-theme="dark"] .demo-box,
html[data-theme="dark"] .ac-list,
html[data-theme="dark"] .sp-available { background: #0d1729; color: var(--text); }
html[data-theme="dark"] .global-search input:focus { background: #0d1729; }
html[data-theme="dark"] .btn-secondary, html[data-theme="dark"] .btn-ghost-danger { color: var(--text); }
html[data-theme="dark"] .btn-ghost-danger { border-color: rgba(248, 113, 113, .35); color: var(--red); }
html[data-theme="dark"] .btn, html[data-theme="dark"] .btn:hover { color: #fff; }
html[data-theme="dark"] .tbl th { background: #16213a; color: var(--text-soft); }
html[data-theme="dark"] .tbl td { border-bottom-color: #1b2740; }
html[data-theme="dark"] .tbl tbody tr:hover { background: #152038; }
html[data-theme="dark"] .tbl tbody tr:hover .i-total, html[data-theme="dark"] .tbl tbody tr:hover td { color: var(--text); }
html[data-theme="dark"] .badge-green { color: #6ee7b7; }
html[data-theme="dark"] .badge-red { color: #fca5a5; }
html[data-theme="dark"] .badge-amber { color: #fcd34d; }
html[data-theme="dark"] .badge-blue { color: #93c5fd; }
html[data-theme="dark"] .badge-purple { color: #c4b5fd; }
html[data-theme="dark"] .badge-gray { background: #1a2540; color: var(--text-muted); }
html[data-theme="dark"] .alert-success { background: rgba(52, 211, 153, .1); border-color: rgba(52, 211, 153, .4); color: #6ee7b7; }
html[data-theme="dark"] .alert-error { background: rgba(248, 113, 113, .1); border-color: rgba(248, 113, 113, .4); color: #fca5a5; }
html[data-theme="dark"] .alert-warning { background: rgba(251, 191, 36, .1); border-color: rgba(251, 191, 36, .4); color: #fcd34d; }
html[data-theme="dark"] .alert-info { background: rgba(96, 165, 250, .1); border-color: rgba(96, 165, 250, .4); color: #93c5fd; }
html[data-theme="dark"] .auth-card { background: #101a2d; color: var(--text); }
html[data-theme="dark"] .auth-wrap { background: linear-gradient(135deg, #060b16 0%, #131233 55%, #1e1b4b 100%); }
html[data-theme="dark"] .tl-item::before { border-color: var(--bg); }
html[data-theme="dark"] .timeline::before { background: var(--border); }
html[data-theme="dark"] input[type="date"], html[data-theme="dark"] input[type="number"] { color-scheme: dark; }
/* the printable sheet mirrors the paper document — stays light in dark mode */
html[data-theme="dark"] .print-area { background: var(--input-bg); border-color: var(--border); }
html[data-theme="dark"] .print-area, html[data-theme="dark"] .print-area * { color: #0f172a; }
html[data-theme="dark"] .print-head .co-name { color: var(--primary); }

/* ---------------- Theme toggle button ---------------- */
#theme-toggle { cursor: pointer; font-size: 15px; line-height: 1; }

/* ---------------- Invoice form — show-on-invoice flag ---------------- */
.show-flag {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 11.5px; font-weight: 600; color: var(--text-muted);
    white-space: nowrap; margin-left: 4px; cursor: pointer;
}
.show-flag input { accent-color: var(--primary); cursor: pointer; }

/* ---------------- Billing reminder banner ---------------- */
.billing-banner {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 16px; border-radius: var(--radius); margin-bottom: 18px;
    font-weight: 600; font-size: 13.5px;
    border: 1px solid var(--amber); background: var(--amber-soft); color: #92400e;
}
.billing-banner .bb-ico { font-size: 17px; }
.billing-banner.billing-due, .billing-banner.billing-grace {
    border-color: var(--red); background: var(--red-soft); color: #991b1b;
}

/* ============================================================
   v3.5 — Sidebar hidden mode: full-width content, no horizontal
   scrolling. The ◧ top-bar button toggles it (remembered locally).
   ============================================================ */
body.nav-hidden .sidebar { display: none !important; }
body.nav-hidden .app { display: block !important; }
body.nav-hidden .main { margin-left: 0 !important; flex: 1 1 auto !important; width: auto !important; min-width: 0 !important; }
body.nav-hidden .content,
body.nav-hidden .topbar { max-width: 100%; }

/* language switcher dropdown uses the shared .dropdown styles */
.lang-switch .dropdown-menu a { display: block; padding: 8px 14px; white-space: nowrap; }

/* ============================================================
   v4.1.2 — Showroom / Company attention style (Root decides).
   On the new invoice / quotation (and every other screen that
   selects a Showroom / Company) the whole field can blink inside a
   neon box, or the "Showroom / Company *" label itself can blink in
   Red / Blue / Black — so nobody picks the wrong business.
   Settings → Invoices → "Showroom selection attention style".
   ============================================================ */
@keyframes hkeAttnBox {
    0%, 100% { box-shadow: 0 0 0 1px currentColor, 0 0 2px 0 currentColor; }
    50%      { box-shadow: 0 0 0 3px currentColor, 0 0 16px 3px currentColor; }
}
@keyframes hkeAttnText {
    0%, 100% { opacity: 1; }
    50%      { opacity: .2; }
}
.sr-attn-box {
    border: 2px solid currentColor !important;
    border-radius: 10px;
    padding: 10px 12px;
    animation: hkeAttnBox 1.2s ease-in-out infinite;
}
.sr-attn-box.c-blue  { color: #2563eb; }
.sr-attn-box.c-red   { color: #dc2626; }
.sr-attn-box.c-black { color: #111827; }
html[data-theme="dark"] .sr-attn-box.c-black { color: #e5e7eb; }
.sr-attn-label { animation: hkeAttnText 1s ease-in-out infinite; font-weight: 800 !important; }
.sr-attn-label.c-blue  { color: #2563eb; }
.sr-attn-label.c-red   { color: #dc2626; }
.sr-attn-label.c-black { color: #111827; }
html[data-theme="dark"] .sr-attn-label.c-black { color: #e5e7eb; }
@media (prefers-reduced-motion: reduce) {
    .sr-attn-box, .sr-attn-label { animation: none; }
}

/* v4.1.3 — floating Home button (Root decides visibility; hidden on Dashboard) */
.hke-float-home {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 60;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 21px;
    line-height: 1;
    text-decoration: none;
    background: var(--input-bg);
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 14px rgba(15, 23, 42, .18);
    transition: transform .12s ease, box-shadow .12s ease;
}
.hke-float-home:hover {
    transform: translateY(-2px) scale(1.04);
    box-shadow: 0 8px 20px rgba(15, 23, 42, .26);
}
.hke-float-home:active { transform: scale(.96); }
html[data-theme="dark"] .hke-float-home { background: #1e293b; border-color: #334155; }
@media (max-width: 640px) {
    .hke-float-home { right: 12px; bottom: 12px; width: 42px; height: 42px; font-size: 19px; }
}

/* v7.5.0 — MOBILE TOPBAR FIT (no horizontal scroll on phones). The topbar
   stays one row: the brand collapses to its logo, the search box becomes
   shrinkable, redundant helpers (language / shortcuts / expand-all) hide,
   icon buttons shrink to 32px, the avatar to 26px, and the user name / role
   — the old overflow culprits — tuck away behind the avatar (they stay in
   the dropdown). Desktop is completely untouched. */
@media (max-width: 640px) {
    .topbar { flex-wrap: nowrap; min-width: 0; gap: 6px !important; }
    .topbar > * { min-width: 0; flex-shrink: 1; }
    .topbar .brand { flex: 0 0 auto; max-width: 34vw; overflow: hidden; }
    .topbar .brand-name, .topbar .brand-sub { display: none; }
    .global-search { flex: 1 1 80px; min-width: 0; }
    .global-search input { min-width: 0; width: 100%; }
    .global-search .s-ico { flex: 0 0 auto; }
    #sys-search-btn span { display: none; }
    .top-actions { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; }
    .topbar .icon-btn, .hamburger, #sidebar-toggle { width: 32px; height: 32px; min-width: 32px; padding: 0; font-size: 15px; flex: 0 0 auto; }
    .lang-switch, #shortcut-help, #nav-expand-all, #theme-toggle { display: none; }
    .user-chip { max-width: 30px; flex: 0 0 auto; }
    .user-chip .u-meta { display: none; }
    .user-chip .avatar { width: 26px; height: 26px; min-width: 26px; font-size: 12px; }
    .user-chip .dot { transform: scale(.8); transform-origin: top right; }
}

/* ============================================================
   v7.7.0 — MOBILE OPTIONS IN THE USER-CHIP DROPDOWN (tasks 2 + 2.1)
   The topbar helpers that hide on phones (language / keyboard
   shortcuts / expand-all / theme) + the HORIZONTAL SCROLLING
   switch live inside the avatar dropdown. Hidden on desktop —
   the desktop topbar keeps doing exactly what it always did.
   ============================================================ */
.dd-mobile-sec { display: none; }
.dd-mobile-sec .dd-item-btn {
    display: block; width: 100%; text-align: left; background: none; border: 0;
    padding: 8px 14px; font: inherit; color: inherit; cursor: pointer;
}
.dd-mobile-sec .dd-item-btn:hover { background: var(--bg, #f1f5f9); }
.dd-mobile-sec .dd-lang-list a {
    display: block; padding: 7px 14px 7px 26px; color: inherit; text-decoration: none; font-size: 13.5px;
}
.dd-mobile-sec .dd-lang-list a:hover { background: var(--bg, #f1f5f9); }
.dd-mobile-sec .dd-mobile-hint {
    padding: 6px 14px 10px; font-size: 11.5px; color: #64748b; line-height: 1.45;
}
@media (max-width: 640px) {
    .dd-mobile-sec {
        display: block;
        border-bottom: 1px solid var(--border, #e2e8f0);
        margin-bottom: 4px; padding-bottom: 2px;
    }
    .user-chip .dropdown-menu { min-width: 230px; max-height: 76vh; overflow-y: auto; }
}

/* ============================================================
   v7.7.0 — HORIZONTAL SCROLLING MODE (task 2.1)
   OFF (default): phones cut a wide table at the screen edge, as before.
   ON (the dropdown switch): wide tables keep their natural width and the
   page scrolls sideways so EVERY column can be reached with a swipe.
   ============================================================ */
body.hscroll-on .content { overflow-x: auto; -webkit-overflow-scrolling: touch; }
body.hscroll-on .card-b { overflow-x: auto; }
body.hscroll-on table.tbl { min-width: max-content; }
body.hscroll-on .page-head { max-width: none; }
/* keep the sticky headline bar full-width even in scroll mode */
body.hscroll-on #hke-headlines { position: sticky; }
@media (prefers-reduced-motion: reduce) {
    .hke-float-home { transition: none; }
    .hke-float-home:hover { transform: none; }
}
/* v4.1.3 — HELD service badge (public intake kept unapproved by Root) */
:root { --badge-held: #7c3aed; }
.badge-held { background: var(--badge-held); color: #fff; }

/* ============================================================
   v4.1.4 — Clean Start (Root-only data reset)
   ============================================================ */
.clean-scope-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
}
.clean-scope {
    display: flex;
    gap: 10px;
    padding: 14px;
    border: 1.5px solid var(--border, #e2e8f0);
    border-radius: 12px;
    cursor: pointer;
    transition: border-color .12s ease, box-shadow .12s ease, background .12s ease;
    background: var(--surface, #fff);
}
.clean-scope:hover { border-color: color-mix(in srgb, var(--accent) 55%, transparent); }
.clean-scope.sel {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
    background: color-mix(in srgb, var(--accent) 5%, transparent);
}
.clean-scope input[type="radio"] { margin-top: 4px; accent-color: var(--accent); }
html[data-theme="dark"] .clean-scope { background: var(--surface); }
@media (prefers-reduced-motion: reduce) {
    .clean-scope { transition: none; }
}

/* v4.1.4 — password paste-policy hint (non-root cannot paste passwords) */
.hke-pw-tip {
    position: fixed;
    z-index: 9999;
    left: 50%;
    transform: translateX(-50%);
    bottom: 26px;
    max-width: 92vw;
    padding: 10px 16px;
    border-radius: 10px;
    background: #b91c1c;
    color: #fff;
    font-size: 13.5px;
    font-weight: 600;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .3);
    opacity: 0;
    transition: opacity .15s ease;
    pointer-events: none;
}
.hke-pw-tip.show { opacity: 1; }

/* ============================================================
   v5.6.4 — HINT ICONS (ⓘ) beside every setting & control.
   Hover (desktop) or tap/keyboard-focus (phone) shows a small
   dark bubble explaining what the control does and what happens
   if you change it. The text comes from the central registry
   (\App\Core\SettingHints) — one source of truth for the icons,
   the Ctrl+K search results and the System Options Directory.
   ============================================================ */
.hint-ico {
    display: inline-flex; align-items: center; justify-content: center;
    width: 15px; height: 15px; margin-left: 2px;
    border-radius: 50%; background: #e0e7ff; color: #3730a3;
    font-size: 10.5px; font-weight: 700; font-style: normal;
    cursor: help; user-select: none; vertical-align: middle;
    position: relative;
}
.hint-ico:hover, .hint-ico:focus-visible { background: #4f46e5; color: #fff; outline: none; }
.hint-ico::after {
    content: attr(data-tip);
    position: absolute; z-index: 90; left: 50%; bottom: calc(100% + 7px);
    transform: translateX(-50%);
    width: min(330px, 74vw); white-space: normal;
    background: #0f172a; color: #f1f5f9; border-radius: 9px;
    padding: 9px 11px; font-size: 12px; font-weight: 400; line-height: 1.45;
    text-align: left; box-shadow: 0 10px 26px rgba(0,0,0,.28);
    opacity: 0; pointer-events: none; transition: opacity .12s ease;
}
.hint-ico::before {
    content: ""; position: absolute; z-index: 91; left: 50%; bottom: calc(100% + 1px);
    transform: translateX(-50%); border: 6px solid transparent; border-top-color: #0f172a;
    opacity: 0; transition: opacity .12s ease;
}
.hint-ico:hover::after, .hint-ico:focus-visible::after,
.hint-ico:hover::before, .hint-ico:focus-visible::before { opacity: 1; }
/* keep bubbles inside the viewport on the right edge */
.hint-ico[data-tip]:hover { text-decoration: none; }

/* ============================================================
   v5.17.0 — user preference body classes (My Preferences)
   ============================================================ */
/* Compact tables: tighter rows, more records per screen */
body.dense-tables .tbl th, body.dense-tables .tbl td { padding: 4px 8px; font-size: 12.6px; }
body.dense-tables .tbl td { line-height: 1.35; }
body.dense-tables .card-b { padding: 10px 14px; }
body.dense-tables .nav-sec-body .nav-link { padding: 5px 12px 5px 38px; }
/* Bigger text inside long note / remarks boxes */
body.big-editor-text textarea.input { font-size: 15.5px; line-height: 1.7; }

/* ============================================================
   v5.18.0 — THEME STUDIO PRESET CARDS (real colour previews)
   The studio's "Pick a theme" cards carry a live mini-mockup of
   every palette (sidebar strip, accent rows, total bar) so the
   colours are SEEN before a theme is chosen — the v5.17 page
   shipped the markup without these styles, so the preview area
   rendered empty (the owner: "it's just lines of texts").
   ============================================================ */
.pd-themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 12px; }
.pd-theme { cursor: pointer; position: relative; }
.pd-theme input { position: absolute; opacity: 0; pointer-events: none; }
.pd-theme-card { display: block; border: 2px solid var(--border, #e2e8f0); border-radius: 12px; padding: 10px;
    background: var(--card, #fff); transition: border-color .15s, box-shadow .15s, transform .15s; }
.pd-theme:hover .pd-theme-card { border-color: #94a3b8; transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(15, 23, 42, .10); }
.pd-theme input:checked + .pd-theme-card { border-color: var(--primary, #4f46e5);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary, #4f46e5) 22%, transparent); }
.pd-theme input:focus-visible + .pd-theme-card { border-color: var(--primary, #4f46e5); }

/* the mini-mockup: a sidebar bar + three content rows + a total strip */
.pd-theme-prev { display: block; border-radius: 8px; overflow: hidden; border: 1px solid rgba(15,23,42,.08);
    background: var(--bg2, #fff); padding: 0; height: 92px; position: relative; }
.pd-theme-prev::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 26px;
    background: var(--sw2); }
.ptp-head { display: block; height: 15px; margin: 6px 8px 5px 32px; background: var(--sw1);
    border-radius: 3px; }
.ptp-row { display: block; height: 8px; margin: 4px 8px 4px 32px; background: var(--sw1); opacity: .8;
    border-radius: 2px; }
.ptp-row.alt { opacity: .45; background: var(--sw2); }
.ptp-total { display: block; height: 12px; margin: 6px 8px 8px 32px; background: var(--sw3);
    border: 1px solid var(--sw1); border-radius: 3px; }
.pd-theme-name { display: block; font-weight: 700; font-size: 13.5px; margin-top: 8px; }
.pd-theme-desc { display: block; font-size: 11.5px; color: var(--text-muted, #94a3b8); margin-top: 2px;
    line-height: 1.4; min-height: 30px; }
.pd-theme .sw-chips { display: flex; gap: 4px; margin-top: 7px; }
.pd-theme .sw-chip { width: 16px; height: 16px; border-radius: 4px; border: 1px solid rgba(15,23,42,.12); }

/* v5.18.0 — the NUMERIC CUSTOMER ID BOX (owner's item 13): bold, one size up */
.nid-box { display: inline-block; border: 1.5px solid var(--border, #cbd5e1); border-radius: 7px;
    padding: 2px 10px; background: var(--primary-soft, #eef2ff); color: var(--primary, #4f46e5);
    font-weight: 800; font-size: 1.15em; font-variant-numeric: tabular-nums; letter-spacing: .5px; }
.nid-box:hover { border-color: var(--primary, #4f46e5); }
