:root {
  --brand: #0f766e;
  --brand-2: #115e59;
  --brand-soft: #ccfbf1;
  --bg: #f1f5f9;
  --card: #fff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --danger: #dc2626;
  --warn: #d97706;
  --ok: #16a34a;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
  font-family: "Segoe UI", Tahoma, "Noto Sans Arabic", "Geeza Pro", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-size: 15px; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
h1, h2, h3 { margin: 0 0 12px; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
.num, .ltr { direction: ltr; unicode-bidi: isolate; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.danger { color: var(--danger); }
.ok { color: var(--ok); }
.warn { color: var(--warn); }
.hidden { display: none !important; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.grid { display: grid; gap: 12px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) { .grid.c3, .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* layout */
.layout { display: flex; height: 100vh; }
.sidebar {
  width: 210px; background: #0f172a; color: #cbd5e1; display: flex; flex-direction: column; flex-shrink: 0;
}
.sidebar .brand { padding: 16px; font-weight: 700; color: #fff; font-size: 17px; border-bottom: 1px solid #1e293b; }
.sidebar nav { flex: 1; overflow: auto; padding: 8px; }
.sidebar nav a {
  display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 8px; color: #cbd5e1; text-decoration: none; margin-bottom: 2px;
}
.sidebar nav a:hover { background: #1e293b; color: #fff; }
.sidebar nav a.active { background: var(--brand); color: #fff; }
.sidebar .me { padding: 12px 16px; border-top: 1px solid #1e293b; font-size: 13px; }
.sidebar .me button { background: none; border: 0; color: #94a3b8; cursor: pointer; padding: 0; text-decoration: underline; }
.main { flex: 1; overflow: auto; padding: 20px; min-width: 0; }
.layout.pos-mode .main { padding: 0; overflow: hidden; }
@media (max-width: 800px) {
  .sidebar { width: 58px; }
  .sidebar .brand, .sidebar nav a span, .sidebar .me .who { display: none; }
}

/* cards & tables */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 24px; font-weight: 700; margin-top: 4px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; vertical-align: middle; }
th { background: #f8fafc; font-weight: 600; font-size: 13px; color: #475569; position: sticky; top: 0; z-index: 1; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #f8fafc; }
.table-wrap { overflow: auto; max-height: calc(100vh - 220px); border: 1px solid var(--line); border-radius: 8px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; background: #e2e8f0; }
.badge.ok { background: #dcfce7; color: #166534; }
.badge.danger { background: #fee2e2; color: #991b1b; }
.badge.warn { background: #fef3c7; color: #92400e; }

/* forms */
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: #334155; }
input, select, textarea {
  border: 1px solid #cbd5e1; border-radius: 8px; padding: 8px 10px; background: #fff; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }
input[type=checkbox] { width: 18px; height: 18px; }
.btn {
  border: 1px solid #cbd5e1; background: #fff; padding: 8px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
}
.btn:hover { background: #f8fafc; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn.lg { padding: 14px 20px; font-size: 18px; font-weight: 600; }

/* modal */
.modal-bg {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: flex; align-items: flex-start; justify-content: center;
  z-index: 50; padding: 5vh 12px; overflow: auto;
}
.modal { background: #fff; border-radius: 12px; width: min(560px, 100%); box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.modal.wide { width: min(900px, 100%); }
.modal header { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal header h2 { margin: 0; }
.modal .body { padding: 18px; }
.modal footer { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-start; }

/* toasts */
#toasts { position: fixed; bottom: 16px; left: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow); max-width: 380px; }
.toast.error { background: var(--danger); }
.toast.ok { background: var(--ok); }

/* login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #0f766e, #0f172a); }
.login .card { width: min(360px, 92vw); padding: 28px; }

/* POS */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 360px; height: 100vh; }
.pos .left { display: flex; flex-direction: column; min-width: 0; padding: 12px; gap: 10px; }
.pos .scan { display: flex; gap: 8px; }
.pos .scan input { flex: 1; font-size: 22px; padding: 12px 14px; direction: ltr; text-align: right; }
.pos .cart { flex: 1; overflow: auto; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); }
.pos .cart td { padding: 10px; }
.pos .cart tr.sel td { background: var(--brand-soft); }
.pos .cart .qty { display: inline-flex; align-items: center; gap: 4px; }
.pos .cart .qty button { width: 30px; height: 30px; border-radius: 6px; border: 1px solid #cbd5e1; background: #fff; cursor: pointer; font-size: 17px; }
.pos .cart .qty input { width: 70px; text-align: center; padding: 5px; }
.pos .empty { text-align: center; color: var(--muted); padding: 60px 20px; font-size: 18px; }
.pos .right { background: #fff; border-inline-start: 1px solid var(--line); display: flex; flex-direction: column; padding: 14px; gap: 10px; }
.pos .totals { background: #0f172a; color: #fff; border-radius: 10px; padding: 14px; }
.pos .totals .line { display: flex; justify-content: space-between; padding: 3px 0; color: #cbd5e1; }
.pos .totals .grand { font-size: 36px; font-weight: 800; color: #5eead4; text-align: center; margin-top: 6px; }
.pos .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pos .actions .btn { white-space: normal; min-width: 0; padding: 8px 6px; font-size: 13px; }
.pos .keys { font-size: 12px; color: var(--muted); line-height: 1.8; }
.pos .keys kbd { background: #f1f5f9; border: 1px solid #cbd5e1; border-radius: 4px; padding: 0 5px; font-family: inherit; }
.pos .topbar { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }
@media (max-width: 900px) { .pos { grid-template-columns: 1fr; height: auto; } .layout.pos-mode .main { overflow: auto; } }

.pay-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pay-total { font-size: 34px; font-weight: 800; text-align: center; color: var(--brand); margin-bottom: 10px; }
.pay-change { font-size: 26px; text-align: center; font-weight: 700; }
.search-results { max-height: 50vh; overflow: auto; }

.bars { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-top: 10px; }
label.row { flex-wrap: nowrap; }
label.row input[type=checkbox] { flex-shrink: 0; }
.bars .bar { flex: 1; max-width: 70px; background: var(--brand); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.bars .bar span { position: absolute; bottom: -20px; left: 0; right: 0; text-align: center; font-size: 11px; color: var(--muted); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { background: none; border: 0; padding: 10px 14px; cursor: pointer; border-bottom: 2px solid transparent; }
.tabs button.active { border-color: var(--brand); color: var(--brand); font-weight: 600; }
