:root {
  --brand: #1f6fd1;
  --brand-dark: #1759ab;
  --brand-light: #e8f1fc;
  --accent: #22a45d;
  --accent-dark: #1b8a4d;
  --danger: #d9443a;
  --warn: #e0a106;
  --ink: #26303d;
  --muted: #7b8594;
  --line: #e4e8ee;
  --bg: #f2f4f7;
  --panel: #ffffff;
  --rail: 64px;
  --rail-open: 236px;
  --top: 60px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Lato", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 14px;
}
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); }
.text-muted { color: var(--muted) !important; }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- sidebar rail ---------- */
.rail {
  position: fixed; inset: 0 auto 0 0; width: var(--rail); background: var(--brand); z-index: 1040;
  display: flex; flex-direction: column; transition: width .18s ease;
}
.rail .logo { height: var(--top); display: flex; align-items: center; justify-content: center; color: #fff; gap: 10px; flex: none; }
.rail .logo .mark {
  width: 34px; height: 34px; border-radius: 9px; background: rgba(255,255,255,.16); display: grid; place-items: center;
  font-weight: 900; letter-spacing: -1px; font-size: 15px;
}
.rail .logo .word { display: none; font-weight: 800; font-size: 17px; white-space: nowrap; }
.rail nav { flex: 1; overflow-y: auto; overflow-x: visible; padding: 6px 0; scrollbar-width: none; }
.rail .grp { position: relative; }
.rail .grp > a {
  display: flex; align-items: center; gap: 14px; height: 46px; padding: 0 21px; color: rgba(255,255,255,.88);
  white-space: nowrap; position: relative;
}
.rail .grp > a i { font-size: 19px; width: 22px; text-align: center; flex: none; }
.rail .grp > a .lbl { display: none; font-weight: 700; }
.rail .grp > a .chev { display: none; margin-left: auto; font-size: 11px; transition: transform .15s; }
.rail .grp:hover > a, .rail .grp.active > a { background: rgba(0,0,0,.14); color: #fff; }
.rail .grp.active > a::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: #fff; }
.rail .sub {
  display: none; position: fixed; left: var(--rail); min-width: 210px; background: #fff; border-radius: 0 8px 8px 0;
  box-shadow: 4px 6px 24px rgba(20,40,80,.18); padding: 6px 0; z-index: 1050;
}
.rail .sub .sub-title { padding: 8px 16px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.rail .sub a { display: block; padding: 8px 16px; color: var(--ink); white-space: nowrap; }
.rail .sub a:hover { background: var(--brand-light); color: var(--brand); }
.rail .sub a.on { color: var(--brand); font-weight: 700; background: var(--brand-light); }

body.rail-open .rail { width: var(--rail-open); }
body.rail-open .rail .logo { justify-content: flex-start; padding-left: 15px; }
body.rail-open .rail .logo .word { display: inline; }
body.rail-open .rail .grp > a .lbl, body.rail-open .rail .grp > a .chev { display: inline; }
body.rail-open .rail .sub { position: static; box-shadow: none; border-radius: 0; background: rgba(0,0,0,.12); padding: 4px 0; min-width: 0; }
body.rail-open .rail .sub .sub-title { display: none; }
body.rail-open .rail .sub a { color: rgba(255,255,255,.85); padding: 7px 16px 7px 57px; }
body.rail-open .rail .sub a:hover, body.rail-open .rail .sub a.on { background: rgba(255,255,255,.12); color: #fff; }
body.rail-open .rail .grp.open > .sub { display: block; }
body.rail-open .rail .grp.open > a .chev { transform: rotate(90deg); }

/* ---------- top bar ---------- */
.topbar {
  position: fixed; top: 0; right: 0; left: var(--rail); height: var(--top); background: #fff; z-index: 1030;
  display: flex; align-items: center; gap: 14px; padding: 0 18px; border-bottom: 1px solid var(--line); transition: left .18s ease;
}
body.rail-open .topbar { left: var(--rail-open); }
.topbar .burger { border: 0; background: none; font-size: 24px; color: var(--ink); padding: 4px 6px; line-height: 1; }
.topbar .search { position: relative; width: min(360px, 40vw); }
.topbar .search input { width: 100%; height: 38px; border: 1px solid var(--line); border-radius: 6px; padding: 0 36px 0 12px; background: #fafbfc; }
.topbar .search input:focus { outline: none; border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px var(--brand-light); }
.topbar .search button { position: absolute; right: 4px; top: 4px; border: 0; background: none; color: var(--muted); height: 30px; width: 30px; }
.btn-plus { width: 38px; height: 34px; border-radius: 6px; background: var(--accent); color: #fff; border: 0; font-size: 20px; line-height: 1; display: grid; place-items: center; }
.btn-plus:hover { background: var(--accent-dark); color: #fff; }
.topbar .org { margin-left: auto; text-align: right; line-height: 1.15; cursor: pointer; }
.topbar .org .name { font-size: 18px; font-weight: 800; max-width: 34vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .org .state { font-size: 12px; color: var(--muted); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: #1b5e3b; color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 12px; border: 0; }

/* ---------- main ---------- */
.main { margin-left: var(--rail); padding: calc(var(--top) + 14px) 22px 40px; min-height: 100vh; transition: margin-left .18s ease; }
body.rail-open .main { margin-left: var(--rail-open); }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h1 { font-size: 21px; font-weight: 800; margin: 0; }
.page-head .crumb { color: var(--muted); font-weight: 400; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.tabs-app { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: -4px 0 14px; overflow-x: auto; }
.tabs-app a { padding: 9px 12px; color: var(--ink); font-weight: 700; font-size: 13px; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs-app a.on { border-bottom-color: var(--ink); }
.tabs-app a:hover { color: var(--brand); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.panel-head { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.panel-head h2, .panel-head h3 { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: #5d6676; margin: 0; }
.panel-body { padding: 16px; }
.panel + .panel { margin-top: 14px; }

.btn-green { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.btn-green:hover, .btn-green:focus { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.btn { font-size: 13.5px; }
.btn-light { background: #f0f2f5; border-color: #e3e6eb; }

/* ---------- tables ---------- */
.table-app { width: 100%; margin: 0; border-collapse: collapse; }
.table-app th { font-size: 12.5px; font-weight: 800; color: #3b4452; padding: 11px 12px; border-bottom: 1px solid var(--line); background: #fff; white-space: nowrap; }
.table-app th[data-sort] { cursor: pointer; user-select: none; }
.table-app th[data-sort]::after { content: " \2195"; color: #c3c9d2; font-size: 11px; }
.table-app td { padding: 10px 12px; border-bottom: 1px solid #eef1f4; vertical-align: middle; }
.table-app tbody tr:hover td { background: #f6f9fe; }
.table-app tr.row-link { cursor: pointer; }
.table-app tfoot td, .table-app tr.total td { font-weight: 800; background: #fafbfc; }
.table-app tr.subtotal td { font-weight: 700; background: #fcfcfd; }
.table-app tr.section td { font-weight: 800; text-transform: uppercase; font-size: 12px; letter-spacing: .04em; color: #5d6676; background: #f5f7fa; }
.table-app tr.danger td { background: #fff3f2; }
.table-app tr.warning td { background: #fff9e9; }
.table-app .actions-cell { text-align: right; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
.empty { text-align: center; color: var(--muted); padding: 38px 10px !important; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 4px; font-size: 12px; font-weight: 800; color: #fff; }
.pill-success { background: var(--accent); }
.pill-primary { background: var(--brand); }
.pill-warning { background: var(--warn); }
.pill-danger { background: var(--danger); }
.pill-secondary { background: #98a1ae; }
.pill-info { background: #2a9fb8; }
.pill-dark { background: #4a5260; }
.pill-overdue { background: #fff0ef; color: var(--danger); border: 1px solid #f6c8c4; }
.tag { display: inline-block; padding: 1px 6px; border-radius: 3px; font-size: 11px; background: #eef1f5; color: #5d6676; margin-left: 4px; }

/* ---------- summary strip ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0; text-align: center; }
.stats .stat { padding: 16px 10px; }
.stats .stat .v { font-size: 22px; font-weight: 800; }
.stats .stat .l1 { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stats .stat .l2 { font-size: 15px; font-weight: 700; }

/* ---------- dashboard ---------- */
.dash-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px; }
.span-12 { grid-column: span 12; } .span-8 { grid-column: span 8; } .span-7 { grid-column: span 7; } .span-6 { grid-column: span 6; }
.span-5 { grid-column: span 5; } .span-4 { grid-column: span 4; }
@media (max-width: 1100px) { .span-8, .span-7, .span-6, .span-5, .span-4 { grid-column: span 12; } }
.alert-strip { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; border-left: 3px solid var(--warn); }
.alert-strip .ttl { width: 100%; text-align: center; font-size: 12px; font-weight: 800; color: #7a6a3a; letter-spacing: .05em; }
.alert-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border: 1px solid var(--line); border-radius: 6px; font-size: 14px; }
.alert-chip b { font-size: 20px; }
.alert-chip.red { border-bottom: 3px solid var(--danger); } .alert-chip.red b { color: var(--danger); }
.alert-chip.amber { border-bottom: 3px solid var(--warn); } .alert-chip.amber b { color: var(--warn); }
.kpi { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 20px; align-items: center; padding: 18px 26px; }
.kpi .k { display: flex; align-items: center; gap: 8px; font-size: 20px; font-weight: 800; color: #555f6d; }
.kpi .k .dot { width: 12px; height: 12px; border-radius: 50%; }
.kpi .v { font-size: 24px; font-weight: 800; margin-bottom: 10px; }
.kpi .net { text-align: right; }
.kpi .net .v { color: var(--accent); }
.kpi .net .v.neg { color: var(--danger); }
.kpi.masked .v { filter: blur(7px); user-select: none; }
.chart-box { position: relative; height: 240px; }
.chart-box.tall { height: 290px; }
.mini-table td, .mini-table th { padding: 8px 12px; }
.seg { display: inline-flex; gap: 2px; }
.seg a { padding: 3px 9px; border-radius: 4px; font-size: 12px; font-weight: 700; color: var(--muted); }
.seg a.on { background: var(--brand-light); color: var(--brand); }

/* ---------- entry board ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.tile { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 20px 14px; text-align: center; color: var(--ink); transition: all .15s; position: relative; }
.tile:hover { border-color: var(--brand); box-shadow: 0 6px 18px rgba(31,111,209,.12); transform: translateY(-2px); color: var(--ink); }
.tile i { font-size: 30px; color: var(--brand); display: block; margin-bottom: 8px; }
.tile .t { font-weight: 800; }
.tile .s { font-size: 12px; color: var(--muted); }
.tile kbd { position: absolute; top: 8px; right: 8px; font-size: 10px; background: #eef1f5; color: var(--muted); }

/* ---------- forms ---------- */
.form-label { font-size: 12.5px; font-weight: 700; color: #4b5563; margin-bottom: 4px; }
.form-control, .form-select { font-size: 14px; border-color: #d9dee6; }
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-light); }
.req::after { content: " *"; color: var(--danger); }
.form-section { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 800; margin: 18px 0 10px; border-bottom: 1px dashed var(--line); padding-bottom: 6px; }
.sticky-actions { position: sticky; bottom: 0; background: rgba(255,255,255,.96); border-top: 1px solid var(--line); padding: 12px 16px; display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; z-index: 5; border-radius: 0 0 8px 8px; }
.party-box { background: #f7f9fc; border: 1px dashed #d4dbe6; border-radius: 6px; padding: 8px 12px; font-size: 13px; min-height: 38px; }

/* line editor */
.lines { width: 100%; border-collapse: collapse; }
.lines th { font-size: 12px; font-weight: 800; color: #4b5563; background: #f5f7fa; padding: 8px 6px; border: 1px solid var(--line); white-space: nowrap; }
.lines td { border: 1px solid var(--line); padding: 0; vertical-align: top; }
.lines td input, .lines td select { border: 0; width: 100%; padding: 8px 6px; background: transparent; font-size: 13.5px; outline: none; }
.lines td input:focus { background: #fffbe6; }
.lines td.amt { padding: 8px 6px; text-align: right; font-weight: 700; background: #fafbfc; white-space: nowrap; }
.lines td.idx { text-align: center; color: var(--muted); padding: 8px 4px; width: 32px; }
.lines td.del { width: 34px; text-align: center; }
.lines td.del button { border: 0; background: none; color: #c0c6cf; padding: 8px; }
.lines td.del button:hover { color: var(--danger); }
.lines .ts-wrapper { min-width: 220px; }
.lines .ts-control { border: 0 !important; box-shadow: none !important; padding: 8px 6px !important; background: transparent !important; }
.lines .meta { font-size: 11px; color: var(--muted); padding: 0 6px 6px; }
.lines input.desc { font-size: 12px; color: var(--muted); padding-top: 0; }
.totals { width: 100%; max-width: 380px; margin-left: auto; }
.totals td { padding: 6px 4px; }
.totals td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.totals tr.grand td { font-size: 18px; font-weight: 800; border-top: 2px solid var(--ink); padding-top: 10px; }

/* view / document preview */
.doc-sheet { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 28px 32px; }
.doc-sheet h2 { font-size: 22px; font-weight: 800; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 4px 10px; font-size: 13.5px; }
.kv dt { color: var(--muted); font-weight: 400; }
.kv dd { margin: 0; font-weight: 700; }
.ribbon { display: inline-block; padding: 4px 12px; border-radius: 4px; font-weight: 800; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }

/* toasts */
.flash { position: fixed; top: calc(var(--top) + 10px); right: 18px; z-index: 2000; min-width: 280px; max-width: 420px; box-shadow: 0 8px 24px rgba(0,0,0,.12); }

/* login */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { background: linear-gradient(140deg, #1f6fd1, #1b4f99); color: #fff; padding: 60px; display: flex; flex-direction: column; justify-content: center; }
.login-art h1 { font-weight: 900; font-size: 38px; }
.login-art li { margin: 8px 0; opacity: .92; }
.login-form { display: flex; align-items: center; justify-content: center; padding: 30px; background: #fff; }
.login-form form { width: 100%; max-width: 360px; }
@media (max-width: 860px) { .login-wrap { grid-template-columns: 1fr; } .login-art { display: none; } }

/* report */
.report-list a { display: block; padding: 9px 14px; border-bottom: 1px solid #f0f2f5; color: var(--ink); }
.report-list a:hover { background: var(--brand-light); color: var(--brand); }
.report-list a small { display: block; color: var(--muted); }
.indent-1 { padding-left: 30px !important; }

/* ---------- mobile ---------- */
@media (max-width: 768px) {
  .rail { transform: translateX(-100%); width: var(--rail-open); transition: transform .2s; }
  body.rail-open .rail { transform: none; }
  body.rail-open .rail .logo .word, body.rail-open .rail .grp > a .lbl { display: inline; }
  .topbar, body.rail-open .topbar { left: 0; padding: 0 10px; gap: 8px; }
  .main, body.rail-open .main { margin-left: 0; padding: calc(var(--top) + 10px) 12px 30px; }
  .topbar .search { width: auto; flex: 1; }
  .topbar .org .name { font-size: 14px; max-width: 30vw; }
  .topbar .org .state { display: none; }
  .rail .sub { position: static; box-shadow: none; background: rgba(0,0,0,.12); }
  .rail .sub a { color: rgba(255,255,255,.85); padding-left: 57px; }
  .doc-sheet { padding: 16px; }
  .sticky-actions { position: static; }
  .page-head h1 { font-size: 18px; }
  .kpi { padding: 14px; }
}

@media print {
  .rail, .topbar, .no-print, .flash, .sticky-actions { display: none !important; }
  .main { margin: 0 !important; padding: 0 !important; }
  body { background: #fff; }
  .panel { border: 0; }
  .table-app th { position: static; }
}

/* ---------- contact dialog (customer / supplier form) ---------- */
.pdlg-page { max-width: 1140px; margin: 0 auto; background: #fff; border-radius: 6px; box-shadow: 0 4px 24px rgba(0,0,0,.12); }
.pdlg-modal { max-width: 1060px; }
.pdlg-modal .modal-content { border: 0; border-radius: 4px; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.pdlg { display: flex; flex-direction: column; font-size: 13px; }
.pdlg-head { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid #e3e6ea; background: #fafafa; position: sticky; top: 0; z-index: 6; border-radius: 4px 4px 0 0; }
.pdlg-title { font-size: 19px; font-weight: 700; color: #222; text-decoration: none; }
.pdlg-title:hover { color: #222; }
.pdlg-title i { font-size: 11px; vertical-align: middle; }
.pdlg .btn-gray { background: #e0e1e2; color: #333; border: 0; font-weight: 600; padding-left: 18px; padding-right: 18px; }
.pdlg .btn-gray:hover { background: #cacbcd; }
.pdlg-head .btn-green { font-weight: 700; }
.pdlg-head .dropdown-toggle-split { border-left: 1px solid rgba(255,255,255,.35); }
.pdlg-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); flex: 1; }
.pdlg-left { padding: 18px 18px 8px; border-right: 1px solid #e3e6ea; }
.pdlg-right { padding: 18px 16px; }
.pdlg .fg { margin-bottom: 14px; }
.pdlg label { font-weight: 700; font-size: 12.5px; color: #222; margin-bottom: 4px; }
.pdlg .form-check-label { font-weight: 400; color: #555; }
.pdlg .req-red { color: #8b1a1a; }
.pdlg .req-red span { color: #db2828; }
.pdlg .form-control, .pdlg .form-select { border-radius: 4px; border-color: #dcdfe3; font-size: 13px; min-height: 36px; }
.pdlg .form-control::placeholder { color: #aab0b6; }
.pdlg .form-control:focus { background: #fffde6; border-color: #85b7d9; box-shadow: none; }
.pdlg .hint { color: #777; font-size: 11px; cursor: help; }
.pdlg-tabs { display: flex; flex-wrap: nowrap; list-style: none; padding: 0; margin: 0; border-bottom: 1px solid #d4d4d5; }
.pdlg-tabs li { margin-bottom: -1px; }
.pdlg-tabs button { background: none; border: 1px solid transparent; border-radius: 4px 4px 0 0; padding: 9px 16px; font-size: 13px; color: #333; white-space: nowrap; }
.pdlg-tabs button.active { background: #fff; border-color: #d4d4d5; border-bottom-color: #fff; font-weight: 700; }
.pdlg-tabbox { border: 1px solid #d4d4d5; border-top: 0; padding: 14px; border-radius: 0 0 4px 4px; }
.pdlg-tabbox h5 { font-size: 15px; font-weight: 700; margin-bottom: 14px; }
.pdlg-scroll { max-height: 400px; overflow-y: auto; padding-right: 6px; }
.pdlg .loc a[data-loc-toggle] { color: #555; font-size: 15px; }
.pdlg .loc-box { margin-top: 8px; }
.pdlg .ship-item { border: 1px solid #e3e6ea; border-radius: 4px; padding: 10px 12px; margin-bottom: 10px; }
.pdlg .ship-item .ship-edit:not(.d-none) { padding-top: 2px; }
.pdlg-foot { display: flex; align-items: center; padding: 14px 18px; border-top: 1px solid #e3e6ea; background: #fafafa; position: sticky; bottom: 0; border-radius: 0 0 4px 4px; }
.pdlg-foot .form-check-input:checked { background-color: #333; border-color: #333; }
.pdlg .attach { cursor: pointer; font-size: 18px; color: #333; margin: 0; }
.pdlg .attach-name { margin-left: 8px; }
.pdlg .ts-wrapper.multi .ts-control > div { background: #e8e8e8; border-radius: 3px; font-size: 12px; }
.pdlg .ts-control { min-height: 36px; border-color: #dcdfe3; }
.pdlg .dropdown-menu { font-size: 13px; }
@media (max-width: 767px) {
  .pdlg-body { grid-template-columns: minmax(0, 1fr); }
  .pdlg-left { border-right: 0; border-bottom: 1px solid #e3e6ea; }
  .pdlg-tabs { overflow-x: auto; }
  .pdlg-tabs button { padding: 8px 10px; }
  .pdlg-head { flex-wrap: wrap; gap: 8px; }
}
.pdlg-modal .pdlg { max-height: calc(100vh - 3.5rem); }
.pdlg-modal .pdlg-body { overflow-y: auto; }

/* ---------- document split view (list + printed document) ---------- */
.split { display: flex; margin: -14px -22px -40px; height: calc(100vh - var(--top)); background: #fff; }
.split-list { width: 360px; flex: 0 0 360px; display: flex; flex-direction: column; border-right: 1px solid #e3e6ea; background: #fff; }
.sl-head { padding: 18px 14px 10px 18px; }
.sl-title { font-size: 18px; font-weight: 700; color: #222; text-decoration: none; }
.sl-title:hover { color: #222; }
.sl-title i { font-size: 11px; vertical-align: middle; }
.sl-tools { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 8px; }
.btn-tool { background: #e0e1e2; border: 0; color: #444; padding: 6px 11px; border-radius: 4px; }
.btn-tool:hover, .btn-tool:focus { background: #cacbcd; color: #222; }
.btn-group > .btn-tool.dropdown-toggle-split { border-left: 1px solid #cfd0d1; padding: 6px 8px; }
.sl-more { color: #555; font-size: 18px; padding: 0 4px; }
.sl-keys kbd { background: #eef0f2; color: #333; font-size: 11px; padding: 1px 5px; margin-right: 4px; }
.sl-keys .small > div { padding: 2px 0; }
.sl-search { padding: 0 14px 8px 18px; }
.sl-items { flex: 1; overflow-y: auto; border-top: 1px solid #eef0f2; }
.sl-item { display: block; padding: 12px 16px 10px 18px; border-bottom: 1px solid #eef0f2; color: #333; text-decoration: none; font-size: 13px; }
.sl-item:hover { background: #f4f7fb; color: #333; }
.sl-item.on { background: #d6dcfa; }
.sl-item .r1, .sl-item .r2 { display: flex; align-items: center; gap: 10px; }
.sl-item .r1 { margin-bottom: 14px; }
.sl-item .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sl-item .amt { color: #1f6fd1; font-weight: 600; white-space: nowrap; }
.sl-item .r2 > span:first-child { width: 120px; }
.sl-item .no { flex: 1; }
.sl-item .st { font-size: 10.5px; color: #21ba45; }
.sl-item .st-OVERDUE, .sl-item .st-CANCELLED { color: #db2828; }
.sl-item .st-OPEN, .sl-item .st-PARTIAL { color: #f2711c; }
.sl-item .st-DRAFT, .sl-item .st-CLOSED { color: #888; }
.sl-item .st-CONVERTED { color: #1f6fd1; }
.split-doc { flex: 1; min-width: 0; display: flex; flex-direction: column; background: #fff; }
.sd-bar { display: flex; align-items: center; padding: 12px 18px 10px 26px; gap: 10px; min-height: 64px; }
.sd-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.sd-actions .btn-gray { background: #e0e1e2; border: 0; color: #333; font-weight: 600; padding: 7px 18px; }
.sd-actions .btn-gray:hover, .sd-actions .btn-gray.show { background: #cacbcd; }
.sd-actions .btn-gray.dropdown-toggle-split { padding: 7px 12px; border-left: 1px solid #cfd0d1; }
.sd-actions .btn-green { font-weight: 700; }
.sd-actions .btn-close-doc { padding: 7px 12px; }
.sd-actions .dropdown-menu { font-size: 13px; min-width: 190px; }
.sd-actions .dropdown-item { padding: 6px 14px; }
.print-menu .dropdown-item { cursor: pointer; }
.print-menu label.dropdown-item, .print-menu label { color: #555; }
.print-menu .stepper { display: inline-flex; align-items: center; border: 1px solid #ddd; border-radius: 3px; }
.print-menu .stepper button { border: 0; background: none; width: 20px; color: #888; padding: 0; line-height: 18px; }
.print-menu .stepper input { width: 24px; border: 0; border-left: 1px solid #ddd; border-right: 1px solid #ddd; text-align: center; font-size: 12px; padding: 0; }
.stamp { font-weight: 900; font-size: 20px; letter-spacing: 3px; padding: 2px 14px; border: 4px double currentColor; border-radius: 6px; transform: rotate(-8deg); opacity: .55; font-family: Arial, sans-serif; user-select: none; margin-left: 180px; }
.stamp-green { color: #21ba45; } .stamp-red { color: #db2828; } .stamp-orange { color: #f2711c; } .stamp-gray { color: #888; } .stamp-blue { color: #1f6fd1; }
.sd-info { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; padding: 0 26px 10px; font-size: 12.5px; color: #555; }
.sd-info .chip { background: #f1f3f5; border-radius: 12px; padding: 2px 10px; color: #333; text-decoration: none; font-size: 12px; }
.sd-info a.chip:hover { background: #e3e8ef; }
.sd-paper { flex: 1; min-height: 0; padding: 0 0 0 26px; border-top: 1px solid #eef0f2; }
.sd-paper iframe { width: 100%; height: 100%; border: 0; display: block; }
@media (max-width: 991px) {
  .split { flex-direction: column; height: auto; margin: -10px -12px -30px; }
  .split-list { width: auto; flex: none; border-right: 0; border-bottom: 1px solid #e3e6ea; }
  .sl-items { max-height: 220px; }
  .sd-bar { flex-wrap: wrap; padding: 10px 12px; }
  .stamp { margin-left: 4px; font-size: 15px; }
  .sd-actions { flex-wrap: wrap; }
  .sd-info { padding: 0 12px 10px; }
  .sd-paper { padding: 0; height: 80vh; flex: none; }
}

/* ---------- Settings > General ---------- */
.gs-head { margin: -14px -22px 0; padding: 14px 22px 0; background: #fff; border-bottom: 1px solid #e3e6ea; }
.gs-head h1 { font-size: 22px; font-weight: 700; margin: 6px 0 10px; }
.gs-head h1 a { color: var(--brand); text-decoration: none; font-weight: 600; }
.gs-head h1 .bi { font-size: 14px; color: #888; margin: 0 4px; }
.gs-tabs-row { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.gs-tabs { display: flex; gap: 4px; overflow-x: auto; }
.gs-tabs a { padding: 10px 18px; color: #444; text-decoration: none; border-bottom: 2px solid transparent; white-space: nowrap; font-size: 14px; }
.gs-tabs a .bi { margin-right: 6px; color: #555; }
.gs-tabs a:hover { color: var(--brand); }
.gs-tabs a.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.gs-tabs a.on .bi { color: var(--brand); }
.gs-actions { margin-left: auto; display: flex; gap: 8px; padding-bottom: 8px; }
.gs-body { background: #f7f8fa; margin: 0 -22px -40px; padding: 20px 22px 40px; min-height: calc(100vh - 160px); }
.gs-box { max-width: 1200px; padding: 10px 6px; }
.gs-box h2 { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.gs-sub { color: #555; font-size: 13px; margin-bottom: 18px; }
.gs-table { background: #fff; border: 1px solid #e6e8eb; border-radius: 8px; overflow-x: auto; }
.gs-table table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.gs-table th { font-weight: 700; color: #444; padding: 12px 12px; border-bottom: 1px solid #e6e8eb; font-size: 13px; vertical-align: middle; background: #fafbfc; }
.gs-table td { padding: 14px 12px; border-bottom: 1px solid #eef0f2; vertical-align: middle; }
.gs-table tr:last-child td { border-bottom: 0; }
.gs-table .c { text-align: center; } .gs-table .r { text-align: right; }
.gs-table .dash { display: inline-block; width: 12px; height: 3px; background: #ccc; border-radius: 2px; vertical-align: middle; }
.gs-table .empty { color: #888; text-align: center; padding: 30px; }
.gs-edit td { padding: 10px 8px; }
.gs-edit select[data-f=type] { min-width: 150px; }
.gs-edit [data-f=account] + .ts-wrapper, .gs-edit select[data-f=account] { min-width: 190px; }
.gs-edit [data-f=expenseAccount] + .ts-wrapper, .gs-edit [data-f=vendor] + .ts-wrapper { min-width: 200px; }
.gs-edit input[data-f=name] { min-width: 150px; }
.gs-edit input[data-f=defaultValue] { min-width: 90px; }
.gs-add { display: inline-block; margin-top: 14px; font-weight: 600; text-decoration: none; }
/* ON / OFF switch */
.sw { position: relative; display: inline-block; width: 48px; height: 24px; flex: 0 0 48px; margin: 0; cursor: pointer; }
.sw input[type=checkbox] { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.sw span { position: absolute; inset: 0; border-radius: 12px; background: #fff; border: 1px solid #d4d6d9; transition: .15s; }
.sw span::before { content: ""; position: absolute; left: 2px; top: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.35); transition: .15s; }
.sw span::after { content: "OFF"; position: absolute; right: 6px; top: 4px; font-size: 9.5px; font-weight: 700; color: #888; }
.sw input:checked + span { background: #2185d0; border-color: #2185d0; }
.sw input:checked + span::before { left: 26px; }
.sw input:checked + span::after { content: "ON"; left: 7px; right: auto; color: #fff; }
.sw input:focus-visible + span { box-shadow: 0 0 0 3px var(--brand-light); }
/* preference cards */
.pref-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; max-width: 1200px; align-items: start; }
.pref-card { background: #fff; border: 1px solid #e6e8eb; border-radius: 10px; padding: 18px 20px 8px; }
.pref-card h3 { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 12px; margin: 0 0 18px; }
.pref-card h3 .ic { width: 34px; height: 34px; border-radius: 8px; background: #eef2fd; color: #4a6cf7; display: inline-flex; align-items: center; justify-content: center; font-size: 16px; }
.pref-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 8px 0; font-size: 13.5px; color: #333; }
.pref-label { flex: 1; min-width: 0; }
.pref-label .hint { color: #777; font-size: 12px; margin-left: 4px; cursor: help; }
.pref-below { margin-top: 8px; }
.pref-inline { border: 0; background: none; color: #2185d0; font-weight: 600; font-size: 12.5px; padding: 0 2px; margin-left: 6px; cursor: pointer; max-width: 210px; }
.pref-text { max-width: 220px; flex: 0 0 210px; }
.pref-num { max-width: 90px; flex: 0 0 90px; }
.pref-card .ts-wrapper.multi .ts-control > div { background: #e8e8e8; border-radius: 3px; }
@media (max-width: 991px) {
  .pref-grid { grid-template-columns: minmax(0, 1fr); }
  .gs-head { margin: -10px -12px 0; padding: 10px 12px 0; }
  .gs-body { margin: 0 -12px -30px; padding: 14px 12px 30px; }
  .gs-actions { width: 100%; justify-content: flex-end; }
  .pref-text { flex-basis: 150px; max-width: 160px; }
}

/* ---------- Import Items dialog ---------- */
.imp .modal-header { background: #fafafa; }
.imp .btn-gray { background: #e0e1e2; color: #333; border: 0; font-weight: 600; }
.imp .btn-gray:hover { background: #cacbcd; }
.imp .btn-green { font-weight: 700; }
.imp-file { display: flex; align-items: center; border: 1px solid #e3e6ea; border-radius: 4px; max-width: 440px; overflow: hidden; }
.imp-choose { background: #00b5ad; color: #fff; font-weight: 700; padding: 9px 22px; margin: 0; cursor: pointer; white-space: nowrap; }
.imp-choose:hover { background: #009c95; }
.imp-file #impFileName { padding: 0 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.imp-map { border: 1px solid #e3e6ea; border-radius: 6px; padding: 0 12px 10px; max-width: 760px; }
.imp-table th { font-weight: 700; font-size: 13px; background: #fafbfc; }
.imp-table td { vertical-align: middle; font-size: 13px; }
.imp-preview { max-height: 46vh; border: 1px solid #e3e6ea; border-radius: 6px; }
.imp-preview th { position: sticky; top: 0; background: #fafbfc; font-size: 12.5px; white-space: nowrap; }
.imp-preview td { font-size: 13px; }

/* ---------- Settings tiles ---------- */
.set-title { font-size: 22px; font-weight: 700; margin: 4px 0 18px; }
.set-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 26px 10px; max-width: 1000px; }
.set-tile { display: flex; flex-direction: column; align-items: center; gap: 8px; text-decoration: none; color: #222; padding: 8px 4px; border-radius: 10px; text-align: center; }
.set-tile i { font-size: 52px; color: var(--brand); line-height: 1; }
.set-tile span { font-size: 15px; }
.set-tile:hover { background: var(--brand-light); color: #111; }
.set-more { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 34px; padding-top: 16px; border-top: 1px solid var(--line); max-width: 1000px; font-size: 13.5px; }
.set-more a { color: #555; text-decoration: none; }
.set-more a:hover { color: var(--brand); }
@media (max-width: 767px) { .set-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } .set-tile i { font-size: 38px; } .set-tile span { font-size: 13px; } }

/* ---------- Settings cards (Company Settings and others) ---------- */
.crumbs-h1 { font-size: 22px; font-weight: 700; margin: 4px 0 16px; }
.crumbs-h1 a { color: var(--brand); text-decoration: none; font-weight: 600; }
.crumbs-h1 .bi { font-size: 14px; color: #888; margin: 0 6px; }
.cs-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; max-width: 1250px; align-items: start; }
.cs-card { background: #fff; border: 1px solid #e6e8eb; border-radius: 10px; padding: 16px 20px; }
.cs-head { display: flex; align-items: flex-start; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid #eef0f2; margin-bottom: 14px; }
.cs-head .ic { width: 34px; height: 34px; border-radius: 8px; background: #eef2fd; color: #4a6cf7; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 34px; }
.cs-head h3 { font-size: 15px; font-weight: 700; margin: 0; }
.cs-head p { font-size: 12.5px; color: #666; margin: 0; }
.cs-head .btn { margin-left: auto; }
.cs-kv { font-size: 14px; line-height: 1.8; }
.cs-kv .muted { color: #777; }
.cs-logo { border: 1px solid #e6e8eb; border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.cs-logo .box { background: #f1f2f4; border-radius: 4px; height: 70px; display: flex; align-items: center; justify-content: center; margin-top: 6px; }
.cs-logo img { max-height: 64px; max-width: 100%; }
.theme-swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.theme-swatches label { width: 30px; height: 30px; border-radius: 6px; cursor: pointer; position: relative; margin: 0; }
.theme-swatches input { position: absolute; opacity: 0; }
.theme-swatches input:checked + span { position: absolute; inset: 0; border-radius: 6px; box-shadow: 0 0 0 3px #fff inset, 0 0 0 2px #333; }
@media (max-width: 991px) { .cs-grid { grid-template-columns: minmax(0, 1fr); } }
.rail .logo .mark-img { object-fit: contain; background: #fff; padding: 2px; }

/* ---------- print settings / default content / approvals / add-ons ---------- */
.pt-row { background: #fff; border: 1px solid #e6e8eb; border-radius: 10px; padding: 14px 16px; margin-bottom: 16px; scroll-margin-top: 80px; }
.pt-head { display: flex; align-items: center; margin-bottom: 10px; }
.pt-head h3 { font-size: 15px; font-weight: 700; margin: 0; }
.pt-head .btn { margin-left: auto; }
.pt-cards { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 4px; }
.pt-card { flex: 0 0 150px; border: 1px solid #e3e6ea; border-radius: 8px; padding: 10px; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; margin: 0; }
.pt-card.on { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-light); }
.pt-name { font-weight: 700; font-size: 13px; }
.pt-desc { font-size: 11px; color: #777; min-height: 30px; }
.pt-thumb { width: 92px; height: 118px; border: 1px solid #d5d8dc; background: #fff; position: relative; padding: 8px 7px; display: flex; flex-direction: column; gap: 5px; }
.pt-thumb span { display: block; background: #d9dde2; height: 5px; border-radius: 2px; }
.pt-thumb .l1 { width: 60%; height: 7px; } .pt-thumb .l2 { width: 85%; } .pt-thumb .l3 { width: 45%; }
.pt-thumb .tb { flex: 1; background: repeating-linear-gradient(#fff 0 7px, #e6e9ed 7px 8px); border: 1px solid #d9dde2; }
.pt-thumb.tpl-COMPANY_LETTERPAD .l1 { background: var(--brand); height: 10px; width: 100%; }
.pt-thumb.tpl-ELITE { border-top: 14px solid var(--brand); }
.pt-thumb.tpl-LETTERPAD { padding-top: 34px; }
.pt-thumb.tpl-THERMAL { width: 52px; }
.pt-thumb.tpl-DOTMATRIX span { background: repeating-linear-gradient(90deg, #aab 0 2px, transparent 2px 4px); }
.pt-thumb.tpl-SIMPLE .tb { border: 0; }
.pt-thumb.tpl-CLASSIC { border: 3px double #999; }
.pt-thumb.tpl-COMPACT .tb { background: repeating-linear-gradient(#fff 0 4px, #e6e9ed 4px 5px); }
.dc-row { border-bottom: 1px solid #eef0f2; padding: 12px 2px; scroll-margin-top: 80px; }
.dc-row:last-child { border-bottom: 0; }
.dc-sub { font-weight: 700; font-size: 13px; color: #444; margin-bottom: 6px; }
.sno-table th { font-size: 12.5px; background: #fafbfc; }
.sno-table td { font-size: 13.5px; }
.ap-wrap { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 16px; max-width: 1100px; }
.ap-grp { font-size: 11px; font-weight: 800; letter-spacing: .06em; color: #888; margin: 12px 0 4px; }
.ap-item { display: flex; justify-content: space-between; padding: 7px 8px; border-radius: 6px; color: #333; text-decoration: none; font-size: 13.5px; }
.ap-item.on, .ap-item:hover { background: var(--brand-light); color: var(--brand); }
.ap-state { font-size: 11.5px; color: #999; }
.ap-state.on { color: #21ba45; font-weight: 700; }
.addon-flag { color: #999; }
.addon-flag.on { color: #21ba45; }
@media (max-width: 767px) { .ap-wrap { grid-template-columns: minmax(0, 1fr); } }
.chq-pos input { width: 80px; display: inline-block; border: 1px solid #dcdfe3; border-radius: 4px; padding: 2px 6px; font-size: 13px; }
.chq-preview-wrap { overflow-x: auto; }
.chq-preview { position: relative; background: linear-gradient(135deg, #eef6ff, #f9fbff); border: 1px solid #b9c7d8; border-radius: 4px; }
.chq-preview span { position: absolute; white-space: nowrap; font-family: Arial, sans-serif; color: #102a54; }
.chq-preview .chq-sign { border-top: 1px solid #555; padding-top: 2px; }
.chq-preview .chq-cross { left: 8px; top: 8px; transform: rotate(-30deg); font-size: 12px; border-top: 1px solid #333; border-bottom: 1px solid #333; padding: 1px 6px; }

/* ---------- customer / supplier view (demo split layout) ---------- */
.pv .split-list { width: 300px; flex-basis: 300px; }
.pv .sl-head { padding-bottom: 6px; }
.pv .sl-head .btn-tool { text-decoration: none; }
.pv-item { display: block; padding: 10px 14px 10px 18px; color: #333; text-decoration: none; border-bottom: 1px solid #f2f4f6; }
.pv-item:hover { background: #f4f7fb; color: #333; }
.pv-item.on { background: #d6dcfa; }
.pv-item .nm { display: block; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv-item .amt { display: block; font-size: 12.5px; color: #1f6fd1; margin-top: 3px; }
.pv-main { overflow-y: auto; }
.pv-head { padding: 14px 22px 6px 26px; }
.pv-title { display: flex; align-items: center; gap: 14px; }
.pv-title h2 { font-size: 22px; font-weight: 700; margin: 0; color: #222; }
.pv-title > a { color: #333; font-size: 13px; text-decoration: none; }
.pv-title > a:hover { color: var(--brand, #1f6fd1); }
.pv-limit { font-size: 10.5px; color: #333; white-space: nowrap; }
.pv-limit i { font-size: 13px; margin-right: 1px; }
.pv-title .pv-close { font-size: 18px; color: #555; }
.pv-sub { font-size: 12px; color: #333; margin-top: 4px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.pv-tag { background: #21ba45; color: #fff; font-size: 9.5px; font-weight: 700; padding: 2px 9px 2px 14px; border-radius: 0 9px 9px 0; position: relative; }
.pv-tag::before { content: ""; position: absolute; left: 5px; top: 50%; width: 4px; height: 4px; margin-top: -2px; border-radius: 50%; background: #fff; }
.pv-contact { color: #667; }
.pv-kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 18px 10px 22px; text-align: center; }
.pv-kpi .v { font-size: 25px; font-weight: 700; color: #222; }
.pv-kpi .v.neg { color: #a5281f; }
.pv-kpi .l1 { font-size: 12px; color: #666; margin-top: 8px; }
.pv-kpi .l2 { font-size: 20px; font-weight: 700; color: #222; line-height: 1.1; }
.pv-bar { display: flex; align-items: center; padding: 6px 22px 8px 26px; border-bottom: 1px solid #eef0f2; }
.pv-tabs { display: flex; gap: 18px; list-style: none; margin: 0; padding: 0; }
.pv-tabs a { color: #666; text-decoration: none; font-weight: 600; padding: 6px 0; border-bottom: 2px solid transparent; }
.pv-tabs a.on { color: #222; border-bottom-color: var(--brand, #1f6fd1); }
.pv-bar .btn-tool { padding: 6px 12px; font-size: 15px; }
.pv-filters { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 26px; background: #f8f9fb; border-bottom: 1px solid #eef0f2; }
.pv-body { padding: 0 8px 20px 12px; }
.pv-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.pv-table th { font-weight: 700; color: #222; padding: 14px 10px; border-bottom: 1px solid #e6e8eb; white-space: nowrap; }
.pv-table td { padding: 14px 10px; border-bottom: 1px solid #eef0f2; vertical-align: middle; color: #333; }
.pv-table .num { text-align: right; white-space: nowrap; }
.pv-table .c { text-align: center; }
.pv-table td.dt { white-space: nowrap; }
.pv-table a { color: #1f6fd1; text-decoration: none; }
.pv-table tr.sub td { font-weight: 700; background: #f6f8fb; }
.pv-table .pv-empty td { text-align: center; color: #999; padding: 30px; }
.pv-st { font-size: 13px; color: #555; }
.pv-st.st-DRAFT, .pv-st.st-CONVERTED { color: #1f6fd1; }
.pv-st.st-OPEN { color: #666; }
.pv-st.st-PARTIAL { color: #f2711c; }
.pv-st.st-PAID, .pv-st.st-CLOSED { color: #21ba45; }
.pv-st.st-OVERDUE, .pv-st.st-CANCELLED { color: #db2828; }
.pv-st.st-PENDING_APPROVAL { color: #b45309; }
@media (max-width: 991px) {
  .pv .split-list { width: auto; flex-basis: auto; }
  .pv-kpis { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .pv-body { overflow-x: auto; }
}
@media print { .pv .split-list, .pv-bar, .pv-filters, .pv-title a { display: none !important; } }
.pv-table td:nth-child(3) { white-space: nowrap; }
