@font-face { font-family: "Cairo"; src: url("../fonts/Cairo-Regular.ttf") format("truetype"); font-display: swap; }

/* ===== Palette: identical to the app (Core/Theme.cs) ===== */
:root {
    --primary: #1F7A4D; --primary-dark: #155C39; --primary-soft: #E7F4EC;
    --accent: #F5B921; --accent-soft: #FEF6DC;
    --bg: #F5F6F8; --surface: #FFFFFF; --surface-alt: #F0F2F5; --line: #E4E7EC;
    --text: #15201A; --text-2: #5E6670; --muted: #98A1AB;
    --danger: #E5484D; --danger-soft: #FDECEC; --success: #2E9E5B; --warning: #E68A00; --warning-soft: #FFF3E0;
    --info: #2F6FED; --info-soft: #EAF1FE;
    --staff: #1E293B; --staff-soft: #E2E8F0;
    --s1: #2F6FED; --s2: #E68A00; --s3: #7C3AED; --s4: #0891B2; --s5: #2E9E5B; --s6: #E5484D;
    --radius: 16px; --shadow: 0 1px 2px rgba(16,24,40,.04);
}
html[data-theme="dark"] {
    --primary: #34B377; --primary-dark: #1F7A4D; --primary-soft: #173A2A;
    --accent-soft: #3A3121;
    --bg: #0E1311; --surface: #18201C; --surface-alt: #222B26; --line: #2C3631;
    --text: #EAF0EC; --text-2: #A7B1AC; --muted: #76817B;
    --danger: #FF6B70; --danger-soft: #3B1E20; --success: #4CC283; --warning: #FFB340; --warning-soft: #3A2D17;
    --info: #79A6FF; --info-soft: #1B2944;
    --staff: #3B4A63; --staff-soft: #263142;
    --s1: #79A6FF; --s2: #FFB340; --s3: #B794F6; --s4: #4FD1E8; --s5: #4CC283; --s6: #FF6B70;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: "Cairo", system-ui, sans-serif; font-size: 14px; background: var(--bg); color: var(--text); }
a { color: var(--primary); text-decoration: none; }
h1 { font-size: 24px; margin: 0; }
h2 { font-size: 18px; margin: 0; }
h3 { font-size: 15px; margin: 0; }
.muted { color: var(--muted); font-size: 12px; }
.body2 { color: var(--text-2); }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ===== boot ===== */
.boot { height: 100vh; display: grid; place-items: center; align-content: center; gap: 18px; }
.boot img { width: 120px; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
/* loading block (first load) + small spinner inside buttons (refresh) */
.card.loading { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 48px 16px; color: var(--muted); font-weight: 600; }
.spin { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-top-color: transparent; animation: spin .7s linear infinite; vertical-align: -2px; opacity: .8; }
.spin.light { border-color: #fff; border-top-color: transparent; }
.btn[disabled] { cursor: progress; }

/* ===== layout ===== */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--staff); color: #fff; padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.side .brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 18px; font-weight: 700; font-size: 16px; }
.side .brand img { width: 36px; height: 36px; background: #fff; border-radius: 10px; padding: 3px; }
.side a { display: flex; align-items: center; gap: 10px; color: rgba(255,255,255,.78); padding: 10px 12px; border-radius: 12px; font-weight: 600; }
.side a:hover { background: rgba(255,255,255,.08); color: #fff; }
.side a.active { background: rgba(255,255,255,.14); color: #fff; }
.side .spacer { flex: 1; }
.side .who { font-size: 12px; opacity: .75; padding: 8px 12px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 12px; padding: 14px 24px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top .title { flex: 1; }
.content { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.menu-btn { display: none; }

@media (max-width: 900px) {
    .shell { grid-template-columns: 1fr; }
    .side { position: fixed; inset-inline-start: 0; z-index: 20; width: 250px; transform: translateX(-110%); transition: transform .2s; }
    html[dir="rtl"] .side { transform: translateX(110%); }
    .shell.open .side { transform: none; }
    .menu-btn { display: inline-flex; }
    .content { padding: 14px; }
}

/* ===== surfaces ===== */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; }
.hero { background: linear-gradient(135deg, var(--staff), #334155); color: #fff; border-radius: var(--radius); padding: 22px; }
html[data-theme="dark"] .hero { background: linear-gradient(135deg, #0B1220, #1E293B); }
.grid { display: grid; gap: 14px; }
.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)); }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 6px; }
.grow { flex: 1; min-width: 0; }
.kpi .value { font-size: 22px; font-weight: 700; margin-top: 4px; }
.kpi .label { color: var(--muted); font-size: 12px; }

/* ===== controls ===== */
.btn { font: inherit; font-weight: 700; border: 0; border-radius: 12px; padding: 0 16px; height: 42px; cursor: pointer; background: var(--primary); color: #fff; display: inline-flex; align-items: center; gap: 8px; justify-content: center; white-space: nowrap; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.staff { background: var(--staff); }
.btn.soft { background: var(--primary-soft); color: var(--primary); }
.btn.ghost { background: transparent; color: var(--text-2); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.outline { background: transparent; color: var(--staff); border: 1.5px solid var(--staff); }
html[data-theme="dark"] .btn.outline { color: var(--text); border-color: var(--text-2); }
.btn.sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn.wa { background: #25D366; color: #fff; }
.input, select.input, textarea.input { font: inherit; width: 100%; height: 44px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }
textarea.input { height: auto; min-height: 80px; padding: 10px 14px; }
.input:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.input.big { height: 54px; font-size: 20px; font-weight: 700; text-align: center; letter-spacing: 1px; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 20px; padding: 6px 14px; cursor: pointer; font: inherit; font-size: 13px; }
.chip.on { background: var(--staff); border-color: var(--staff); color: #fff; }
.chip .n { opacity: .7; font-weight: 700; margin-inline-start: 4px; }
.seg { display: inline-flex; background: var(--staff-soft); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { font: inherit; font-weight: 700; border: 0; background: transparent; color: var(--text-2); padding: 6px 14px; border-radius: 9px; cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--text); }
.hero .seg { background: rgba(255,255,255,.14); }
.hero .seg button { color: #fff; }
.hero .seg button.on { background: #fff; color: var(--staff); }

/* ===== status / badges ===== */
.pill { display: inline-flex; align-items: center; gap: 4px; border-radius: 10px; padding: 2px 10px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.st1 { color: var(--s1); background: color-mix(in srgb, var(--s1) 14%, transparent); }
.st2 { color: var(--s2); background: color-mix(in srgb, var(--s2) 14%, transparent); }
.st3 { color: var(--s3); background: color-mix(in srgb, var(--s3) 14%, transparent); }
.st4 { color: var(--s4); background: color-mix(in srgb, var(--s4) 14%, transparent); }
.st5 { color: var(--s5); background: color-mix(in srgb, var(--s5) 14%, transparent); }
.st6 { color: var(--s6); background: color-mix(in srgb, var(--s6) 14%, transparent); }
.bar1 { background: var(--s1); } .bar2 { background: var(--s2); } .bar3 { background: var(--s3); }
.bar4 { background: var(--s4); } .bar5 { background: var(--s5); } .bar6 { background: var(--s6); }
.badge-w { color: var(--warning); background: var(--accent-soft); }
.badge-u { color: var(--text-2); background: var(--surface-alt); }
.badge-sub { color: var(--info); background: var(--info-soft); }
.badge-hidden { color: var(--danger); background: var(--danger-soft); }
.alert { border-radius: 12px; padding: 10px 14px; }
.alert.err { background: var(--danger-soft); color: var(--danger); }
.alert.ok { background: var(--primary-soft); color: var(--primary); }
.alert.info { background: var(--info-soft); color: var(--info); }

/* ===== lists / tables ===== */
.list { display: flex; flex-direction: column; gap: 10px; }
.item-row { display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.item-row.click { cursor: pointer; }
.item-row.click:hover { border-color: var(--primary); }
.item-row.dim { opacity: .45; }
.item-row.picked { background: var(--primary-soft); }
.item-row.missing { background: var(--danger-soft); opacity: .75; }
.thumb { width: 52px; height: 52px; flex: none; border-radius: 10px; border: 1px solid var(--line); background: #fff center/contain no-repeat; }
.thumb.lg { width: 72px; height: 72px; }
.accent-bar { width: 4px; align-self: stretch; border-radius: 2px; flex: none; }
table.t { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
table.t th, table.t td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: start; vertical-align: middle; }
table.t th { font-size: 12px; color: var(--muted); font-weight: 700; background: var(--surface-alt); }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: var(--surface-alt); }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty .ic { font-size: 34px; }

/* ===== charts ===== */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding-top: 18px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; min-width: 0; }
.bars .b .v { font-size: 10px; color: var(--text-2); }
.bars .b .fill { width: 100%; border-radius: 6px 6px 2px 2px; background: var(--primary); min-height: 3px; }
.bars .b .fill.zero { background: var(--line); }
.bars .b .l { font-size: 10px; color: var(--muted); white-space: nowrap; }
.hbar { height: 10px; border-radius: 5px; background: var(--surface-alt); overflow: hidden; }
.hbar > div { height: 100%; border-radius: 5px; }
.progress { height: 6px; border-radius: 3px; background: var(--surface-alt); overflow: hidden; }
.progress > div { height: 100%; background: var(--primary); }

/* ===== drawer / modal ===== */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 30; display: flex; justify-content: flex-end; }
.drawer { width: min(560px, 100%); height: 100%; background: var(--bg); overflow: auto; display: flex; flex-direction: column; }
.drawer .head { position: sticky; top: 0; background: var(--surface); padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; z-index: 2; }
.drawer .body { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; flex: 1; }
.drawer .foot { position: sticky; bottom: 0; background: var(--surface); padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; }
.overlay.center { justify-content: center; align-items: center; padding: 16px; }
.modal { width: min(520px, 100%); max-height: 90vh; overflow: auto; background: var(--surface); border-radius: 20px; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.toast { position: fixed; bottom: 20px; inset-inline-start: 50%; transform: translateX(-50%); background: #15201A; color: #fff; padding: 10px 18px; border-radius: 12px; z-index: 50; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
html[dir="rtl"] .toast { transform: translateX(50%); }

/* ===== login ===== */
.login { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.login .art { background: linear-gradient(135deg, var(--staff), #334155); color: #fff; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; padding: 48px; gap: 14px; }
.login .art img { width: 96px; background: #fff; border-radius: 22px; padding: 10px; }
.login .form { display: flex; align-items: center; justify-content: center; padding: 24px; }
.login .form .card { width: min(420px, 100%); display: flex; flex-direction: column; gap: 14px; padding: 28px; }
@media (max-width: 800px) { .login { grid-template-columns: 1fr; } .login .art { padding: 28px; } }

#blazor-error-ui { background: var(--danger-soft); color: var(--danger); bottom: 0; display: none; left: 0; padding: .6rem 1.25rem; position: fixed; width: 100%; z-index: 1000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }

@media print {
    .side, .top, .no-print, .drawer .foot { display: none !important; }
    .shell { display: block; }
    .overlay { position: static; background: none; }
    .drawer { width: 100%; }
}
