@font-face { font-family: "Noto Sans Arabic"; src: url(fonts/NotoSansArabic-Regular.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Noto Sans Arabic"; src: url(fonts/NotoSansArabic-Bold.woff2) format("woff2"); font-weight: 700; font-display: swap; }

:root {
  /* palette taken from the Global Brilliance logo: maroon red, silver, charcoal */
  --bg: #f4f4f5; --card: #ffffff; --line: #e4e4e7; --text: #1c1c1e; --muted: #6b6b70;
  --primary: #7a1a16; --primary-2: #5c110e; --primary-soft: #f7e9e8;
  --silver: #b9b9bc; --silver-2: #8f8f94; --charcoal: #1c1c1f; --charcoal-2: #0f0f11;
  --danger: #c2410c; --danger-soft: #fdebe3; --ok: #15803d; --ok-soft: #e4f5ea; --warn: #b45309; --warn-soft: #fdf1dc;
  --radius: 12px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.1);
  --side: 240px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body { font-family: "Noto Sans Arabic", "Segoe UI", Tahoma, Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.55; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
a { color: var(--primary); text-decoration: none; }
h1, h2, h3 { margin: 0 0 12px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }

/* layout */
.app { min-height: 100vh; }
.topbar { position: fixed; top: 0; right: 0; left: 0; height: 58px; background: var(--card); border-bottom: 1px solid var(--line); border-top: 3px solid var(--primary); display: flex; align-items: center; gap: 12px; padding: 0 16px 0 16px; z-index: 20; padding-right: calc(var(--side) + 16px); }
.top-mark { display: none; height: 30px; }
.topbar-title { font-weight: 700; font-size: 18px; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn { display: none; background: none; border: 1px solid var(--line); border-radius: 8px; font-size: 20px; width: 40px; height: 40px; cursor: pointer; }
.sidebar { position: fixed; top: 0; right: 0; bottom: 0; width: var(--side); background: linear-gradient(180deg, #232326 0%, #121214 100%); color: #d4d4d8; padding: 14px 10px; display: flex; flex-direction: column; gap: 4px; z-index: 30; border-left: 1px solid #2a2a2e; }
.sidebar::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 200px; background: url(img/mark.png) center bottom / 180px auto no-repeat; opacity: .07; pointer-events: none; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 16px; font-weight: 700; color: #fff; border-bottom: 1px solid #2f2f33; margin-bottom: 10px; }
.side-brand img { width: 74px; height: auto; flex: none; }
.side-brand .side-sub { font-size: 10px; letter-spacing: 1px; color: var(--silver); font-weight: 600; font-family: "Segoe UI", Arial, sans-serif; }
.sidebar a { color: #cfcfd4; padding: 10px 12px; border-radius: 10px; display: flex; align-items: center; gap: 10px; font-size: 15px; position: relative; z-index: 1; }
.sidebar a .ico { width: 22px; text-align: center; }
.sidebar a:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar a.active { background: linear-gradient(90deg, var(--primary), #9a2521); color: #fff; box-shadow: 0 4px 12px rgba(122,26,22,.35); }
.side-export { margin-top: auto; padding: 10px 2px 4px; position: relative; z-index: 1; text-align: center; }
.side-export .export-btn { width: 100%; background: #2b2b30; border-color: #3a3a40; color: #fff; justify-content: center; }
.side-export .export-btn:hover { background: var(--primary); border-color: var(--primary); }
.side-hint { font-size: 11px; color: var(--silver-2); margin-top: 4px; }
.content { padding: 78px 20px 30px; margin-right: var(--side); position: relative; z-index: 1; }
.content::before { content: ""; position: fixed; top: 58px; bottom: 0; left: 0; right: var(--side); background: url(img/mark.png) center 45% / min(60vw, 720px) auto no-repeat; opacity: .045; pointer-events: none; z-index: -1; }
.backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 25; }

/* cards & grid */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; }
.grid { display: grid; gap: 14px; }
.grid.kpi { grid-template-columns: repeat(3, 1fr); }
.kpi-card { background: var(--card); border: 1px solid var(--line); border-right: 4px solid var(--silver); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi-card.accent { border-right-color: var(--primary); }
.kpi-card .label { color: var(--muted); font-size: 13px; }
.kpi-card .value { font-size: 24px; font-weight: 700; margin-top: 4px; }
.kpi-card .sub { font-size: 12px; color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }

/* forms */
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
label > input, label > select, label > textarea { margin-top: 4px; }
input, select, textarea { width: 100%; font: inherit; padding: 9px 11px; border: 1px solid #cfd6dd; border-radius: 9px; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
input[type=number] { direction: ltr; text-align: right; }
input[type=date], input[type=datetime-local] { direction: ltr; text-align: right; }
textarea { min-height: 70px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text); }
.check input { width: auto; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 9px; border: 1px solid var(--line); background: #fff; color: var(--text); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f7f9fb; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-2); }
.btn.danger { background: var(--danger-soft); border-color: #f2c4b0; color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: right; vertical-align: middle; }
th { background: #f7f9fb; color: var(--muted); font-weight: 600; font-size: 13px; white-space: nowrap; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: #f4fbfa; }
td.num, th.num { text-align: left; direction: ltr; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.actions { white-space: nowrap; }
tfoot td { font-weight: 700; background: #f7f9fb; }
.empty { padding: 30px; text-align: center; color: var(--muted); }

/* badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.muted { background: #eef1f4; color: var(--muted); }
.pos { color: var(--danger); font-weight: 600; }
.neg { color: var(--ok); font-weight: 600; }

/* tabs & filters */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { background: none; border: none; padding: 10px 14px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 12px; }
.filters label { margin: 0; min-width: 150px; flex: 1; max-width: 260px; }
.filters .search { flex: 2; max-width: 360px; }

/* invoice editor */
.inv-lines td input { padding: 6px 8px; }
.inv-lines td.qty { width: 110px; }
.inv-lines td.price { width: 140px; }
.inv-lines td.tot { width: 130px; }
.inv-lines td.del { width: 40px; }
.totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.totals .box { background: #f7f9fb; border-radius: 10px; padding: 10px 12px; }
.totals .box .l { color: var(--muted); font-size: 12px; }
.totals .box .v { font-size: 20px; font-weight: 700; }
.totals .box.big { background: var(--primary-soft); }
.autocomplete { position: relative; }
.ac-list { position: absolute; top: 100%; right: 0; left: 0; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.12); z-index: 15; max-height: 320px; overflow: auto; margin-top: 4px; }
.ac-item { padding: 9px 12px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px solid #f0f2f4; }
.ac-item:hover, .ac-item.active { background: var(--primary-soft); }
.ac-item .meta { color: var(--muted); font-size: 12px; white-space: nowrap; }
.ac-item.new { color: var(--primary); font-weight: 600; }

/* modal & toast */
.modal { position: fixed; inset: 0; background: rgba(10,20,30,.45); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 40px 12px; overflow: auto; }
.modal-card { background: #fff; border-radius: 14px; padding: 20px; width: 100%; max-width: 640px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-card.wide { max-width: 900px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #1b2430; color: #fff; padding: 11px 18px; border-radius: 10px; z-index: 60; box-shadow: var(--shadow); max-width: 90vw; }
.toast.error { background: var(--danger); }
.err { color: var(--danger); font-size: 13px; min-height: 18px; margin: 6px 0; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(1200px 600px at 50% -10%, #3a3a3f 0%, #141416 55%, #0b0b0c 100%); padding: 20px; position: relative; }
.login::before { content: ""; position: absolute; inset: 0; background: url(img/mark.png) center 60% / min(90vw, 900px) auto no-repeat; opacity: .08; pointer-events: none; }
.login-card { position: relative; background: #fff; border-radius: 16px; padding: 24px 28px 28px; width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,.5); border-top: 4px solid var(--primary); }
.login-card label { margin-bottom: 12px; }
.brand-logo { text-align: center; padding: 6px 0 2px; }
.brand-logo img { width: 240px; max-width: 100%; height: auto; }
.center { text-align: center; }

.stat-line { display: flex; gap: 20px; flex-wrap: wrap; }
.stat-line div b { display: block; font-size: 18px; }
.item-img { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: #eef1f4; }
.pill-group { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.pill-group button { border: none; background: #fff; padding: 8px 14px; font: inherit; cursor: pointer; }
.pill-group button.active { background: var(--primary); color: #fff; }
.note { background: var(--warn-soft); color: var(--warn); padding: 10px 12px; border-radius: 10px; font-size: 13px; }
.info { background: var(--primary-soft); color: var(--primary-2); padding: 10px 12px; border-radius: 10px; font-size: 13px; }
kbd { background: #eef1f4; border-radius: 4px; padding: 1px 6px; font-size: 12px; }

@media (max-width: 900px) {
  .topbar { padding-right: 16px; }
  .icon-btn { display: inline-flex; align-items: center; justify-content: center; }
  .sidebar { transform: translateX(100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .backdrop.show { display: block; }
  .content { margin-right: 0; padding: 72px 12px 24px; }
  .topbar-actions .user { display: none; }
  .top-mark { display: block; }
  .topbar-title { font-size: 15px; }
  .content::before { right: 0; }
  .topbar-actions .btn.primary { padding: 7px 10px; font-size: 13px; }
  .grid.kpi { grid-template-columns: repeat(2, 1fr); }
  .filters label { min-width: 120px; }
  th, td { padding: 8px 6px; }
  .kpi-card .value { font-size: 20px; }
}
@media print { .sidebar, .topbar, .btn, .filters, .tabs { display: none !important; } .content { margin: 0; padding: 0; } }

/* users & permissions */
.perm-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 6px 14px; margin: 10px 0; }
.perm-grid .perm { background: #f7f9fb; border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; margin: 0; cursor: pointer; }
.perm-grid .perm:has(input:checked) { background: var(--primary-soft); border-color: #e3b9b6; }
.btn.small.hidden { display: none !important; }
/* barcode labels dialog */
.label-preview { background: #fff; border: 1px dashed var(--line); border-radius: 10px; padding: 10px; display: inline-block; direction: ltr; text-align: center; }
.scan-btn { flex: none; }
