:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --text: #1d2433;
  --text-2: #475467;
  --muted: #6b7385;
  --ink: #15191f;
  --ink-2: #1f252e;
  --ink-line: #2a313b;
  --ink-text: #b8c0cc;
  --accent: #c2410c;
  --accent-hover: #a3360a;
  --accent-soft: #fff3ec;
  --accent-line: #fbd5c0;
  --blue: #1d5bd6;
  --blue-soft: #edf3ff;
  --green: #08744a;
  --green-soft: #e8f7ef;
  --amber: #a85b05;
  --amber-soft: #fff6e0;
  --red: #b42318;
  --red-soft: #fdeeec;
  --gray-soft: #f0f2f5;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .04);
  --shadow-lg: 0 20px 40px -12px rgba(16, 24, 40, .22);
  --font: "Noto Sans Arabic", -apple-system, "Segoe UI", Roboto, Tahoma, sans-serif;
  --side-w: 252px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; line-height: 1.35; font-weight: 700; }
p { margin: 0; }
img { max-width: 100%; }
table { border-collapse: collapse; width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--accent-line); }

.i { width: 18px; height: 18px; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.nowrap { white-space: nowrap; }
.right { text-align: left; }
.hidden, [hidden] { display: none !important; }
.m { unicode-bidi: isolate; white-space: nowrap; font-variant-numeric: tabular-nums; }
.m.neg { color: var(--red); }
.num { font-variant-numeric: tabular-nums; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.strong { font-weight: 700; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.gap-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- shell ---------- */
.app { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset-block: 0;
  right: 0;
  width: var(--side-w);
  background: var(--ink);
  color: var(--ink-text);
  display: flex;
  flex-direction: column;
  z-index: 50;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--ink-line);
}
.brand-mark {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 15px;
  flex: none;
}
.brand-mark .i { width: 22px; height: 22px; }
.doc-brand .brand-mark .i { width: 28px; height: 28px; }
.brand-logo { width: 40px; height: 40px; border-radius: 10px; object-fit: contain; background: #fff; flex: none; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { color: #fff; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text small { font-size: 11.5px; color: #8590a0; }

.nav { flex: 1; overflow-y: auto; padding: 10px 12px 16px; }
.nav-sec { font-size: 11px; color: #6f7a8a; padding: 16px 10px 6px; letter-spacing: .2px; }
.nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 11px;
  border-radius: 8px;
  color: var(--ink-text);
  margin-bottom: 2px;
  font-weight: 500;
  transition: background .12s, color .12s;
}
.nav a .i { width: 18px; height: 18px; opacity: .85; }
.nav a:hover { background: rgba(255, 255, 255, .05); color: #fff; }
.nav a.active { background: var(--ink-2); color: #fff; box-shadow: inset -3px 0 0 var(--accent); }
.nav a.active .i { color: #fb8a4f; opacity: 1; }
.nav a span { flex: 1; }
.nav-badge {
  font-style: normal;
  font-size: 11px;
  min-width: 22px;
  padding: 0 6px;
  height: 20px;
  border-radius: 10px;
  background: #2b333e;
  color: #dfe5ee;
  display: grid;
  place-items: center;
  font-weight: 600;
}
.nav-badge.warn { background: #7a2e0b; color: #ffd9c4; }

.side-foot {
  border-top: 1px solid var(--ink-line);
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.me { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; padding: 4px; border-radius: 8px; }
.me:hover { background: rgba(255, 255, 255, .05); }
.me span:last-child { display: flex; flex-direction: column; min-width: 0; }
.me strong { color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me small { font-size: 11.5px; color: #8590a0; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: #2b333e; color: #fff;
  display: grid; place-items: center;
  font-weight: 700; flex: none;
}
.side-foot .icon-btn { color: var(--ink-text); }
.side-foot .icon-btn:hover { background: rgba(255, 255, 255, .07); color: #fff; }

.main { margin-right: var(--side-w); min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: 62px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 28px;
  background: rgba(243, 244, 246, .88);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.top-search { position: relative; flex: 1; max-width: 480px; }
.top-search .i { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 17px; height: 17px; }
.top-search input {
  width: 100%;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  padding: 0 38px 0 12px;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.top-search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(194, 65, 12, .12); }
.top-end { display: flex; align-items: center; gap: 14px; margin-right: auto; }
.today { display: flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 13px; }
.today .i { width: 16px; height: 16px; color: var(--muted); }

.content { padding: 24px 28px 48px; max-width: 1440px; }
.scrim { display: none; }

/* ---------- page head ---------- */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-head h1 { font-size: 22px; letter-spacing: -.2px; }
.page-head .sub { color: var(--muted); margin-top: 3px; font-size: 13.5px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumb { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.crumb:hover { color: var(--accent); }
.crumb .i { width: 15px; height: 15px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 14px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s;
}
.btn .i { width: 17px; height: 17px; }
.btn:hover { background: var(--surface-2); border-color: #b9c0cc; }
.btn:focus-visible, .icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-dark:hover { background: #2a313b; border-color: #2a313b; }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
.btn-success:hover { background: #065f3c; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: #95190f; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--gray-soft); border-color: transparent; }
.btn-soft { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.btn-soft:hover { background: #ffe8db; border-color: #f8bf9f; }
.btn-sm { height: 32px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn-lg { height: 46px; padding: 0 22px; font-size: 15px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; pointer-events: none; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 0;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
}
.icon-btn:hover { background: var(--gray-soft); color: var(--text); }
.icon-btn.danger:hover { background: var(--red-soft); color: var(--red); }
.icon-btn .i { width: 17px; height: 17px; }
form.inline { display: inline; }

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
}
.card + .card { margin-top: 16px; }
.card-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  min-height: 56px;
  flex-wrap: wrap;
}
.card-h h2, .card-h h3 { font-size: 15px; display: flex; align-items: center; gap: 8px; }
.card-h h2 .i, .card-h h3 .i { color: var(--muted); }
.card-h .muted { font-size: 12.5px; }
.card-b { padding: 18px; }
.card-b.tight { padding: 0; }
.card-f { padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }

.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.split-wide { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.stack > * + * { margin-top: 16px; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: relative;
  min-width: 0;
}
.stat .lbl { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.stat .lbl .i { width: 16px; height: 16px; }
.stat .val { font-size: 23px; font-weight: 700; letter-spacing: -.3px; line-height: 1.45; }
.stat .hint { font-size: 12px; color: var(--muted); }
.stat.accent { border-color: var(--accent-line); background: linear-gradient(180deg, #fff 0%, var(--accent-soft) 160%); }
.stat.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.stat.dark .lbl, .stat.dark .hint { color: #9aa4b2; }
a.stat:hover { border-color: var(--border-strong); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
.table th, .table td { padding: 11px 14px; text-align: right; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-2);
  white-space: nowrap;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fbfbfc; }
.table tr.row-link { cursor: pointer; }
.table td.num, .table th.num { text-align: left; }
.table td.act { width: 1%; white-space: nowrap; text-align: left; }
.table tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--border); border-bottom: 0; }
.table .sub { display: block; font-size: 12px; color: var(--muted); }
.table.compact th, .table.compact td { padding: 8px 12px; }
.t-title { font-weight: 600; }
.t-title:hover { color: var(--accent); }

/* ---------- badges / chips ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.b-gray { background: var(--gray-soft); color: #4a5262; }
.b-blue { background: var(--blue-soft); color: var(--blue); }
.b-green { background: var(--green-soft); color: var(--green); }
.b-amber { background: var(--amber-soft); color: var(--amber); }
.b-red { background: var(--red-soft); color: var(--red); }
.b-accent { background: var(--accent-soft); color: var(--accent); }
.b-dark { background: var(--ink); color: #fff; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  border-radius: 6px;
  background: var(--gray-soft);
  font-size: 12px;
  color: var(--text-2);
  margin: 1px 0 1px 3px;
  white-space: nowrap;
}
.plate {
  display: inline-block;
  direction: ltr;
  unicode-bidi: isolate;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .4px;
  padding: 0 7px;
  border: 1.5px solid #2b333e;
  border-radius: 5px;
  background: #fff;
  color: #1d2433;
  line-height: 20px;
  white-space: nowrap;
}

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .lbl-row { font-size: 13px; font-weight: 600; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.field .req { color: var(--accent); }
.field small, .help { font-size: 12px; color: var(--muted); }
.form-grid { display: grid; gap: 14px 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 8px; justify-content: flex-start; margin-top: 18px; flex-wrap: wrap; }

:where(input[type=text], input[type=search], input[type=password], input[type=number], input[type=date],
input[type=datetime-local], input[type=month], input[type=tel], input[type=email], select, textarea) {
  width: 100%;
  height: 40px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  padding: 0 12px;
  background: var(--surface);
  outline: none;
  transition: border-color .12s, box-shadow .12s;
  min-width: 0;
}
:where(textarea) { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; line-height: 1.6; }
select { padding-left: 30px; appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7385' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: left 11px center; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(194, 65, 12, .12); }
input[readonly] { background: var(--surface-2); color: var(--text-2); }
:where(input.num, input[type=number], input[type=date], input[type=datetime-local], input[type=month], input[type=tel], input.ltr) {
  direction: ltr;
  text-align: right;
}
input::placeholder, textarea::placeholder { color: #a3aab6; }
.input-sm { height: 34px !important; font-size: 13px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; user-select: none; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); margin: 0; }
.checks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; }

.money-in { display: flex; align-items: stretch; position: relative; }
.money-in input { border-radius: 0 9px 9px 0; }
.money-in .cur, .money-in .cur-sel {
  flex: none;
  width: auto;
  min-width: 52px;
  height: 40px;
  border: 1px solid var(--border-strong);
  border-right: 0;
  border-radius: 9px 0 0 9px;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  color: var(--text-2);
  font-weight: 600;
  font-size: 13px;
  padding: 0 10px;
}
.money-in .cur-sel { padding: 0 26px 0 10px; background-position: left 8px center; cursor: pointer; }
.conv { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.conv .rate-in { width: 90px; height: 30px; padding: 0 8px; font-size: 12.5px; border: 1px solid var(--border-strong); border-radius: 7px; }
.conv b { color: var(--blue); font-weight: 600; margin-right: auto; }

.seg { display: inline-flex; background: var(--gray-soft); border-radius: 9px; padding: 3px; gap: 2px; }
.seg a, .seg button, .seg label {
  border: 0;
  background: transparent;
  padding: 5px 12px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
}
.seg a.on, .seg button.on, .seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(16, 24, 40, .12); }
.seg label { padding: 0; }
.seg label span { display: block; padding: 5px 12px; border-radius: 7px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }

/* ---------- toolbar / filters ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.toolbar input, .toolbar select { height: 36px; width: auto; min-width: 150px; }
.toolbar input[type=search] { min-width: 240px; flex: 1; max-width: 360px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); padding: 0 12px; overflow-x: auto; }
.tabs a {
  padding: 12px 12px 11px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
}
.tabs a:hover { color: var(--text); }
.tabs a.on { color: var(--accent); border-bottom-color: var(--accent); }
.tabs a em { font-style: normal; font-size: 11px; background: var(--gray-soft); color: var(--text-2); padding: 0 7px; border-radius: 10px; }
.tabs a.on em { background: var(--accent-soft); color: var(--accent); }
.page-tabs { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; box-shadow: var(--shadow); }
.page-tabs .tabs { border-bottom: 0; }

/* ---------- flash ---------- */
.flash {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-weight: 500;
  border: 1px solid;
  animation: drop .25s ease;
}
.flash-ok { background: var(--green-soft); border-color: #b5e4cb; color: #075e3d; }
.flash-error { background: var(--red-soft); border-color: #f6c9c4; color: #8f1d14; }
.flash-warn { background: var(--amber-soft); border-color: #f5dc9e; color: #7f4504; }
.flash span { flex: 1; }
.flash-x { border: 0; background: none; cursor: pointer; color: inherit; opacity: .6; padding: 2px; display: grid; }
.flash-x:hover { opacity: 1; }
@keyframes drop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--blue-soft);
  color: #18408f;
  font-size: 13px;
}
.notice.warn { background: var(--amber-soft); color: #7f4504; }
.notice.danger { background: var(--red-soft); color: #8f1d14; }
.notice .i { margin-top: 2px; }

/* ---------- empty ---------- */
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .i { width: 38px; height: 38px; color: #c4cad4; stroke-width: 1.4; margin-bottom: 8px; }
.empty h3 { font-size: 15px; color: var(--text); margin-bottom: 4px; }
.empty .btn { margin-top: 14px; }
.empty.big { padding: 90px 20px; }

/* ---------- lists ---------- */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 9px 16px; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; font-weight: 600; text-align: left; }
.sum-list > div { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; gap: 12px; }
.sum-list > div + div { border-top: 1px dashed var(--border); }
.sum-list .total { font-size: 17px; font-weight: 700; border-top: 1px solid var(--border-strong) !important; padding-top: 12px; margin-top: 4px; }
.mini-list > a, .mini-list > div { display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-bottom: 1px solid var(--border); }
.mini-list > *:last-child { border-bottom: 0; }
.mini-list > a:hover { background: var(--surface-2); }
.mini-list .grow { flex: 1; min-width: 0; }
.mini-list .grow strong { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-list .grow small { color: var(--muted); font-size: 12px; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--border-strong); }
.dot.blue { background: var(--blue); } .dot.green { background: var(--green); } .dot.amber { background: #e59a0b; } .dot.red { background: var(--red); }

.meter { height: 6px; background: var(--gray-soft); border-radius: 4px; overflow: hidden; min-width: 60px; }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.meter.green i { background: var(--green); }
.meter.red i { background: var(--red); }

/* ---------- bars chart ---------- */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 190px; padding: 6px 2px 0; direction: ltr; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; min-width: 0; }
.bar i { display: block; width: 100%; max-width: 34px; background: #e9ecf1; border-radius: 5px 5px 2px 2px; transition: background .15s; }
.bar:hover i { background: var(--accent); }
.bar:last-child i { background: var(--accent); }
.bar span { font-size: 10.5px; color: var(--muted); white-space: nowrap; }

/* ---------- job form ---------- */
.lookup { position: relative; }
.lookup-list {
  position: absolute;
  top: calc(100% + 4px);
  inset-inline: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  z-index: 30;
  max-height: 320px;
  overflow-y: auto;
}
.lookup-list button {
  display: flex;
  width: 100%;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  border: 0;
  background: none;
  cursor: pointer;
  text-align: right;
  border-bottom: 1px solid var(--border);
}
.lookup-list button:last-child { border-bottom: 0; }
.lookup-list button:hover, .lookup-list button.on { background: var(--accent-soft); }
.lookup-list .grow { flex: 1; min-width: 0; }
.lookup-list strong { display: block; }
.lookup-list small { color: var(--muted); }
.picked {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--accent-line);
  background: var(--accent-soft);
  border-radius: 10px;
}
.picked .grow { flex: 1; }
.picked strong { display: block; }

.svc-picks { display: flex; flex-wrap: wrap; gap: 6px; }
.svc-pick {
  border: 1px dashed var(--border-strong);
  background: var(--surface);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-2);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.svc-pick .i { width: 15px; height: 15px; }
.svc-pick:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); border-style: solid; }

.lines { width: 100%; }
.lines th { font-size: 12px; color: var(--muted); font-weight: 600; text-align: right; padding: 0 6px 8px; white-space: nowrap; }
.lines td { padding: 5px 6px; vertical-align: top; }
.lines td:first-child { padding-right: 0; }
.lines input, .lines select { height: 38px; }
.lines .c-pct { width: 92px; }
.lines .c-price, .lines .c-comm { width: 128px; }
.lines .c-master { width: 170px; }
.lines .c-x { width: 40px; }
.svc-sub { display: flex; gap: 6px; margin-top: 5px; }
.svc-sub .f-title { flex: 1; }
.svc-sub .wr { display: flex; align-items: center; gap: 4px; flex: none; font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.svc-sub .wr input { width: 46px; padding: 0 6px; text-align: center; }
.comm-box { position: relative; }
.comm-box input { padding-left: 34px; }
.comm-mode {
  position: absolute;
  left: 4px;
  top: 4px;
  width: 30px; height: 30px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.comm-mode .i { width: 15px; height: 15px; }
.comm-mode:hover { background: var(--gray-soft); }
.comm-mode.manual { color: var(--accent); }
.line-locked td { opacity: .75; }
.mode-tag { font-size: 11px; color: var(--muted); display: inline-flex; align-items: center; gap: 3px; }
.mode-tag .i { width: 13px; height: 13px; }
.sticky-side { position: sticky; top: 78px; }

.job-head { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.job-no { font-size: 13px; color: var(--muted); }
.job-car { display: flex; align-items: center; gap: 14px; }
.car-ico { width: 52px; height: 52px; border-radius: 12px; background: var(--ink); color: #fff; display: grid; place-items: center; flex: none; }
.car-ico .i { width: 28px; height: 28px; }
.steps { display: flex; gap: 0; align-items: center; flex-wrap: wrap; }
.steps form { display: contents; }
.step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px 7px 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  margin-left: -1px;
}
.step:first-child { border-radius: 0 9px 9px 0; }
.step:last-of-type { border-radius: 9px 0 0 9px; }
.step b { width: 20px; height: 20px; border-radius: 50%; background: var(--gray-soft); display: grid; place-items: center; font-size: 11px; }
.step.done { color: var(--green); }
.step.done b { background: var(--green); color: #fff; }
.step.cur { color: var(--text); background: var(--surface-2); }
.step.cur b { background: var(--accent); color: #fff; }
.step:hover:not(.cur) { background: var(--surface-2); color: var(--text); }

.balance-box { border-radius: 10px; padding: 14px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.balance-box.due { background: var(--red-soft); color: #8f1d14; }
.balance-box.clear { background: var(--green-soft); color: #075e3d; }
.balance-box strong { font-size: 19px; }

/* ---------- dialogs ---------- */
.dlg {
  border: 0;
  border-radius: 14px;
  padding: 0;
  width: min(520px, calc(100vw - 32px));
  box-shadow: var(--shadow-lg);
  color: var(--text);
}
.dlg::backdrop { background: rgba(15, 20, 28, .45); backdrop-filter: blur(2px); }
.dlg[open] { animation: pop .18s ease; }
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(6px); } to { opacity: 1; transform: none; } }
.dlg-h { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.dlg-h h3 { font-size: 16px; }
.dlg-b { padding: 20px; }
.dlg-f { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; background: var(--surface-2); }
.dlg-confirm form { padding: 26px 24px 20px; text-align: center; }
.dlg-confirm .dlg-icon { width: 48px; height: 48px; margin: 0 auto 12px; border-radius: 50%; background: var(--red-soft); color: var(--red); display: grid; place-items: center; }
.dlg-confirm h3 { font-size: 16px; margin-bottom: 6px; }
.dlg-confirm p { color: var(--muted); margin-bottom: 20px; }
.dlg-actions { display: flex; gap: 8px; justify-content: center; }
.dlg-actions .btn { min-width: 100px; }
.dlg.wide { width: min(760px, calc(100vw - 32px)); }

/* ---------- pager ---------- */
.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-top: 1px solid var(--border); gap: 10px; }
.pager > div { display: flex; align-items: center; gap: 8px; }
.pager-n { color: var(--muted); font-size: 13px; min-width: 60px; text-align: center; }

/* ---------- auth ---------- */
body.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr minmax(0, 1.1fr); background: var(--surface); }
.auth-side {
  background: var(--ink);
  color: #fff;
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.auth-side::after {
  content: "";
  position: absolute;
  width: 520px; height: 520px;
  left: -180px; bottom: -220px;
  border-radius: 50%;
  border: 70px solid rgba(194, 65, 12, .14);
}
.auth-side h2 { font-size: 28px; line-height: 1.5; max-width: 420px; position: relative; z-index: 1; }
.auth-side p { color: #9aa4b2; max-width: 420px; margin-top: 12px; position: relative; z-index: 1; }
.auth-feat { display: grid; gap: 12px; position: relative; z-index: 1; }
.auth-feat div { display: flex; gap: 10px; align-items: center; color: #c7ced8; }
.auth-feat .i { color: #fb8a4f; }
.auth-main { display: grid; place-items: center; padding: 40px 24px; }
.auth-box { width: 100%; max-width: 380px; }
.auth-box h1 { font-size: 24px; margin: 18px 0 6px; }
.auth-box .field { margin-bottom: 14px; }
.auth-box input { height: 46px; }

/* ---------- invoice / print ---------- */
.doc { background: #fff; max-width: 820px; margin: 24px auto; padding: 40px 44px; border: 1px solid var(--border); border-radius: 12px; }
.doc-head { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; padding-bottom: 20px; border-bottom: 2px solid var(--ink); }
.doc-brand { display: flex; gap: 14px; align-items: center; }
.doc-brand img { width: 64px; height: 64px; object-fit: contain; }
.doc-brand .brand-mark { width: 56px; height: 56px; font-size: 18px; }
.doc-brand h2 { font-size: 20px; }
.doc-brand p { color: var(--muted); font-size: 12.5px; }
.doc-title { text-align: left; }
.doc-title h1 { font-size: 22px; letter-spacing: .5px; }
.doc-title p { color: var(--muted); font-size: 13px; }
.doc-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 20px 0; }
.doc-meta > div { background: var(--surface-2); border-radius: 10px; padding: 12px 14px; }
.doc-meta h4 { font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.doc table th { background: var(--ink); color: #fff; font-weight: 600; font-size: 12.5px; padding: 9px 12px; text-align: right; }
.doc table td { padding: 9px 12px; border-bottom: 1px solid var(--border); }
.doc-totals { display: flex; justify-content: flex-end; margin-top: 16px; }
.doc-totals .sum-list { width: 300px; }
.doc-foot { margin-top: 32px; padding-top: 14px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; gap: 20px; color: var(--muted); font-size: 12.5px; }
.sign { margin-top: 44px; display: flex; justify-content: space-between; color: var(--muted); font-size: 12.5px; }
.sign span { border-top: 1px solid var(--border-strong); padding-top: 6px; min-width: 160px; text-align: center; }
.print-bar { display: flex; gap: 8px; justify-content: center; padding: 16px; flex-wrap: wrap; }
body.print-page { background: #e9ebef; }

.receipt { width: 80mm; margin: 20px auto; background: #fff; padding: 14px 12px; font-size: 12px; line-height: 1.55; color: #000; }
.receipt .c { text-align: center; }
.receipt h2 { font-size: 15px; }
.receipt hr { border: 0; border-top: 1px dashed #000; margin: 8px 0; }
.receipt table td { padding: 2px 0; }
.receipt .row { display: flex; justify-content: space-between; gap: 8px; }
.receipt .big { font-size: 14px; font-weight: 700; }

/* ---------- logo ---------- */
.logo-box { display: flex; gap: 18px; align-items: flex-start; padding: 14px; border: 1px dashed var(--border-strong); border-radius: 12px; background: var(--surface-2); }
.logo-preview { width: 96px; height: 96px; border-radius: 14px; background: #fff; border: 1px solid var(--border); display: grid; place-items: center; overflow: hidden; flex: none; }
.logo-preview img { max-width: 88px; max-height: 88px; object-fit: contain; }
.logo-preview .brand-mark { width: 64px; height: 64px; }
.code { direction: ltr; unicode-bidi: isolate; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; background: var(--gray-soft); padding: 8px 10px; border-radius: 8px; word-break: break-all; display: block; text-align: left; }
.steps-list { margin: 0; padding-right: 18px; line-height: 2; }

/* ---------- menus ---------- */
.menu { position: relative; display: inline-block; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary .i:last-child { width: 14px; height: 14px; opacity: .8; }
.menu-list {
  position: absolute;
  top: calc(100% + 6px);
  inset-inline-end: 0;
  min-width: 210px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 35;
}
.menu-list a { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 7px; font-weight: 500; }
.menu-list a:hover { background: var(--surface-2); color: var(--accent); }
.btn-wa { background: #1f9d55; border-color: #1f9d55; color: #fff; }
.btn-wa:hover { background: #17834a; border-color: #17834a; }

/* ---------- photos ---------- */
.photo-stages { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
.photo { padding: 0; border: 0; border-radius: 9px; overflow: hidden; aspect-ratio: 1; cursor: zoom-in; background: var(--gray-soft); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s; }
.photo:hover img { transform: scale(1.05); }
.photo-empty { grid-column: 1 / -1; border: 1.5px dashed var(--border-strong); border-radius: 10px; padding: 22px 12px; text-align: center; color: var(--muted); font-size: 12.5px; }
.upload-btn { cursor: pointer; }
.upload-status { grid-column: 1 / -1; color: var(--blue); font-weight: 600; }
.dlg-photo { width: min(1040px, calc(100vw - 24px)); background: #0f1217; color: #e6e9ee; }
.dlg-photo .dlg-h { border-color: #262b33; padding: 10px 14px; }
.dlg-photo .icon-btn { color: #c9d0da; }
.dlg-photo .icon-btn:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.photo-view { position: relative; display: flex; align-items: center; justify-content: center; min-height: 280px; }
.photo-view img { max-width: 100%; max-height: calc(100vh - 130px); display: block; }
.photo-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 42px; height: 42px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .5); color: #fff; cursor: pointer; display: grid; place-items: center; }
.photo-nav[data-dir="-1"] { right: 10px; }
.photo-nav[data-dir="1"] { left: 10px; }
.print-photos { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; }
.print-photos img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }

/* ---------- responsive ---------- */
.only-mobile { display: none; }
@media (max-width: 1280px) {
  .split { grid-template-columns: minmax(0, 1fr) 320px; }
}
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1080px) {
  .split, .split-wide { grid-template-columns: minmax(0, 1fr); }
  .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sticky-side { position: static; }
}
@media (max-width: 920px) {
  .only-mobile { display: inline-grid; }
  .only-desktop { display: none !important; }
  .sidebar { transform: translateX(100%); transition: transform .22s ease; box-shadow: var(--shadow-lg); }
  .nav-open .sidebar { transform: none; }
  .nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(15, 20, 28, .4); z-index: 45; }
  .main { margin-right: 0; }
  .topbar { padding: 0 16px; }
  .content { padding: 18px 16px 40px; }
  body.auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
}
@media (max-width: 640px) {
  .photo-stages { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 12px 14px; }
  .stat .val { font-size: 19px; }
  .g2, .g3, .g4, .form-grid, .form-grid.c3, .form-grid.c4, .checks { grid-template-columns: minmax(0, 1fr); }
  .page-head h1 { font-size: 19px; }
  .toolbar input[type=search] { min-width: 0; max-width: none; width: 100%; }
  .toolbar select, .toolbar input { flex: 1; min-width: 0; }
  .toolbar input[type=date], .toolbar input[type=month] { min-width: 140px; }
  .lines thead { display: none; }
  .lines tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--border); }
  .lines td { padding: 0; width: auto !important; }
  .lines td.c-svc, .lines td.c-x { grid-column: 1 / -1; }
  .lines td[data-label]::before { content: attr(data-label); display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 3px; }
  .lines td.c-x { text-align: left; }
  .doc { padding: 20px; margin: 0; border: 0; border-radius: 0; }
  .doc-meta { grid-template-columns: 1fr; }
  .table th, .table td { padding: 10px 12px; }
}

@media print {
  @page { size: A4; margin: 12mm; }
  body, body.print-page { background: #fff; font-size: 12px; }
  .sidebar, .topbar, .page-actions, .print-bar, .no-print, .toolbar, .tabs, .flash, .pager, .scrim { display: none !important; }
  .main { margin: 0; }
  .content { padding: 0; max-width: none; }
  .card, .stat { box-shadow: none; break-inside: avoid; }
  .doc { border: 0; margin: 0; padding: 0; max-width: none; }
  .doc table th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .receipt { margin: 0; width: auto; padding: 0; }
  body.receipt-page { width: 80mm; }
  a { text-decoration: none; }
}
