:root {
  --bg: #f3f6f9;
  --surface: #ffffff;
  --surface-2: #eef2f6;
  --border: #d9e0e8;
  --text: #17212b;
  --muted: #5d6b7a;
  --primary: #0f5e8c;
  --primary-ink: #ffffff;
  --nav: #0f3d5e;
  --nav-ink: #d8e6f0;
  --success: #1e7d4f;
  --danger: #b4232f;
  --warning: #9a6200;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 32, 48, .06), 0 4px 16px rgba(16, 32, 48, .05);
  font-family: Tahoma, "Segoe UI", "Noto Sans Arabic", "Noto Sans", Arial, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.35rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.center { text-align: center; display: block; }
.num, td.num, th.num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.neg { color: var(--danger); }
.pos { color: var(--success); }

/* Shell */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 240px; flex: 0 0 240px; background: var(--nav); color: var(--nav-ink); padding: 14px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; gap: 10px; align-items: center; color: #fff; padding: 4px 8px 14px; }
.brand:hover { text-decoration: none; }
.brand small { display: block; color: var(--nav-ink); opacity: .8; font-size: .78rem; }
.brand-mark { font-size: 1.6rem; }
.brand.big { color: var(--text); justify-content: center; padding-bottom: 6px; }
.brand.big small { color: var(--muted); }
.sidebar nav a { display: block; color: var(--nav-ink); padding: 7px 10px; border-radius: 7px; font-size: .92rem; }
.sidebar nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.sidebar nav a.active { background: rgba(255,255,255,.16); color: #fff; font-weight: 600; }
.nav-group { margin: 14px 10px 4px; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; opacity: .65; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 10px 18px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.topbar .spacer { flex: 1; }
.topbar .user { color: var(--muted); font-size: .85rem; }
.trip-picker select { min-width: 230px; }
.menu-btn { display: none; }
.content { padding: 18px; max-width: 1500px; width: 100%; }
.net-status { background: var(--warning); color: #fff; border-radius: 999px; padding: 2px 10px; font-size: .8rem; }

/* Page header */
.page-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head .spacer { flex: 1; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* Cards / grid */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.card.tight { padding: 0; overflow: hidden; }
.card.tight > h2, .card.tight > .card-head { padding: 14px 16px 0; }
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: .8rem; }
.stat .value { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .sub { color: var(--muted); font-size: .78rem; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--border); text-align: start; vertical-align: middle; }
th { background: var(--surface-2); font-weight: 600; font-size: .82rem; color: #33414f; position: sticky; top: 0; }
tbody tr:hover { background: #f8fafc; }
tfoot td, tr.total td { font-weight: 700; background: var(--surface-2); }
tr.voided td { color: var(--muted); text-decoration: line-through; }
table.compact th, table.compact td { padding: 4px 7px; }
td input, td select { width: 100%; min-width: 70px; }

/* Forms */
label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: 10px; }
label.check { display: flex; gap: 6px; align-items: center; font-weight: 400; }
input, select, textarea { display: block; width: 100%; margin-top: 4px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font: inherit; background: #fff; color: var(--text); }
input[type=checkbox], input[type=radio] { width: auto; display: inline-block; margin: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--primary) 40%, transparent); border-color: var(--primary); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0 12px; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form label { margin-bottom: 0; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 12px; }
.filters label { margin: 0; min-width: 150px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { text-decoration: none; border-color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 9px; font-size: .82rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn { border: 0; background: transparent; font-size: 1.2rem; cursor: pointer; }
.chip { display: inline-block; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border); font-size: .82rem; color: var(--text); background: var(--surface); }
.chip.active, .chip:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }

/* Badges / alerts */
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.badge.open, .badge.draft { background: #e6f3ec; color: var(--success); }
.badge.closed, .badge.received, .badge.checked_out { background: #e9eef4; color: #42566b; }
.badge.sent { background: #fff3dc; color: var(--warning); }
.badge.error { background: #fde8ea; color: var(--danger); }
.badge.warning { background: #fff3dc; color: var(--warning); }
.badge.info { background: #e5f1fa; color: var(--primary); }
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; border: 1px solid; }
.alert ul { margin: 0; padding-inline-start: 18px; }
.alert.success { background: #e9f6ef; border-color: #b8e0c8; color: #14532d; }
.alert.error { background: #fdecee; border-color: #f3c1c7; color: #7f1d1d; }
.alert.info { background: #e8f2fa; border-color: #bfd8ec; color: #0c3c5c; }
.alert.warning { background: #fff6e2; border-color: #f0d9a4; color: #6b4500; }

/* Folio sheet */
.sheet th:first-child, .sheet td:first-child { position: sticky; inset-inline-start: 0; background: var(--surface); }
.sheet thead th:first-child { background: var(--surface-2); }
.balance-box { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; text-align: center; }
.balance-box div { background: var(--surface-2); border-radius: 8px; padding: 10px; }
.balance-box strong { display: block; font-size: 1.25rem; }

/* Fast entry */
.fast { display: grid; grid-template-columns: 1.3fr 1fr; gap: 14px; }
.suite-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); gap: 6px; }
.suite-btn { padding: 10px 4px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); font-weight: 700; cursor: pointer; font-size: .95rem; }
.suite-btn small { display: block; font-weight: 400; color: var(--muted); font-size: .7rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suite-btn.selected { background: var(--primary); color: #fff; border-color: var(--primary); }
.suite-btn.selected small { color: #dbeaf5; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; }
.cat-btn { padding: 10px 6px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 600; }
.cat-btn.selected { background: #e5f1fa; border-color: var(--primary); color: var(--primary); }
.amount-input { font-size: 1.5rem; font-weight: 700; text-align: center; }
.pending { background: #fff6e2; border: 1px solid #f0d9a4; border-radius: 8px; padding: 8px 12px; margin-bottom: 10px; }

/* Line items */
.lines td .item-pick { min-width: 220px; }
.lines .remove-line { color: var(--danger); }

/* Login */
.guest { display: grid; min-height: 100vh; place-items: center; background: linear-gradient(160deg, #0f3d5e, #155e86 55%, #e7eef4 55%); }
.login { width: min(380px, 100% - 32px); }
.login-card { padding: 24px; }

/* Print */
.print-only { display: none; }
@media print {
  .sidebar, .topbar, .no-print, .alert { display: none !important; }
  .print-only { display: block; }
  .content { padding: 0; }
  .card { box-shadow: none; border: 0; padding: 0; }
  body { background: #fff; }
}

@media (max-width: 960px) {
  .sidebar { position: fixed; inset-inline-start: 0; z-index: 20; transform: translateX(-100%); transition: transform .2s; }
  [dir=rtl] .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: none !important; }
  .menu-btn { display: inline-block; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4, .fast { grid-template-columns: 1fr; }
  .trip-picker select { min-width: 0; max-width: 60vw; }
  .topbar .user { display: none; }
  .content { padding: 12px; }
}

/* Page links */
.pagination { display: flex; gap: 4px; list-style: none; padding: 0; margin: 10px 0; flex-wrap: wrap; }
.pagination li > * { display: inline-block; min-width: 34px; padding: 5px 10px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); text-align: center; }
.pagination li.active > * { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination li.disabled > * { color: var(--muted); }
.inline-form > input, .inline-form > select { width: auto; min-width: 200px; margin-top: 0; }
