/* Design system shared with AttendEd (salam.noura.center, noura/internal-tools/attended):
   Noura brand book colors, Parastoo, navy sidebar, sky accents. Keep the two in step. */
@font-face { font-family: Parastoo; src: url(/static/fonts/Parastoo.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: Parastoo; src: url(/static/fonts/Parastoo-Bold.woff2) format("woff2"); font-weight: 600 800; font-display: swap; }

:root {
  --navy: #2E3192;
  --navy-light: #e8e9f7;
  --navy-dim: rgba(46,49,146,0.12);
  --sky: #00AEEF;
  --sky-light: #e0f5fd;
  --sky-dim: rgba(0,174,239,0.12);
  --teal: #007F6E;
  --teal-light: #e0f2ef;
  --lime: #8DC63F;
  --silver: #A7A9AC;
  --silver-light: #f2f2f3;
  --bg: #f5f6f8;
  --bg-card: #ffffff;
  --bg-input: #f8f9fa;
  --bg-hover: #f0f1f8;
  --border: rgba(46,49,146,0.1);
  --border-mid: rgba(46,49,146,0.2);
  --grid: #eef0f6;
  --text-1: #1a1a2e;
  --text-2: #4a4a6a;
  --text-3: #9090a8;
  --red: #dc2626;
  --red-light: #fef2f2;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --font: Parastoo, Tahoma, "Segoe UI", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; scroll-behavior: smooth; }
body { font-family: var(--font); background: var(--bg); color: var(--text-1); direction: rtl; min-height: 100vh; line-height: 1.7; }
a { color: inherit; text-decoration: none; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }

/* LAYOUT */
.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.main { min-width: 0; background: var(--bg); }
.content { padding: 28px; }

/* SIDEBAR */
.sidebar { background: var(--navy); padding: 0 0 24px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar::before { content: ""; display: block; height: 4px; background: linear-gradient(90deg, var(--sky) 0%, var(--teal) 40%, var(--lime) 70%, var(--sky) 100%); }
.sidebar-logo { padding: 20px 20px 18px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.sidebar-logo-img { width: 130px; height: auto; display: block; }
.sidebar-section { padding: 18px 12px 6px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-section-label { font-size: 10px; color: rgba(255,255,255,0.35); padding: 0 10px; margin-bottom: 4px; letter-spacing: 0.8px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius); color: rgba(255,255,255,0.6); font-size: 13px; transition: background .15s, color .15s; }
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active { background: var(--sky); color: #fff; }
.nav-icon { font-size: 13px; width: 16px; text-align: center; }
.sidebar-footer { margin-top: auto; padding: 16px 12px 0; border-top: 1px solid rgba(255,255,255,0.1); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius); background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.12); }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--sky); display: flex; align-items: center; justify-content: center; font-size: 12px; color: #fff; font-weight: 700; flex-shrink: 0; }
.user-name { font-size: 12px; color: #fff; font-weight: 600; }
.user-role { font-size: 10px; color: rgba(255,255,255,0.4); }
.logout-form { margin-right: auto; }
.logout-btn { background: none; border: 0; cursor: pointer; color: rgba(255,255,255,0.4); font-size: 16px; transition: color .15s; }
.logout-btn:hover { color: #fff; }

/* TOPBAR */
.topbar { padding: 16px 28px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; background: #fff; flex-wrap: wrap; position: sticky; top: 0; z-index: 5; }
.topbar-title { font-size: 16px; font-weight: 700; color: var(--text-1); }
.topbar-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.topbar-spacer { flex: 1; }

/* BUTTONS */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 9px 18px; border-radius: var(--radius); font-size: 13px; font-weight: 600; font-family: var(--font); cursor: pointer; border: none; transition: opacity .15s, background .15s; }
.btn:active { transform: scale(0.98); }
.btn-navy { background: var(--navy); color: #fff; }
.btn-navy:hover { opacity: .9; }
.btn-ghost { background: transparent; color: var(--text-2); border: 1px solid var(--border-mid); }
.btn-ghost:hover { background: var(--bg-hover); }
.btn-full { width: 100%; justify-content: center; }
.btn-lg { padding: 13px 24px; font-size: 14px; border-radius: var(--radius-lg); }
.btn:disabled { opacity: .5; cursor: wait; }
.btn-mini { padding: 4px 12px; border-radius: 8px; font-size: 11px; border: 1px solid var(--border-mid); background: #fff; color: var(--text-2); cursor: pointer; font-family: var(--font); font-weight: 600; }
.btn-mini:hover { background: var(--bg-hover); }

.seg { display: inline-flex; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius); padding: 3px; }
.seg button { font-family: var(--font); font-size: 12px; border: 0; background: transparent; color: var(--text-3); padding: 4px 12px; border-radius: 7px; cursor: pointer; }
.seg button.on { background: var(--navy); color: #fff; font-weight: 700; }

/* MISC */
.brand-stripe { height: 4px; background: linear-gradient(90deg, var(--navy) 0%, var(--sky) 35%, var(--teal) 65%, var(--lime) 100%); border-radius: 2px; margin-bottom: 20px; }
.note-inline { font-size: 11px; color: var(--text-3); background: var(--bg-card); border: 1px solid var(--border); border-right: 3px solid var(--sky); border-radius: var(--radius); padding: 8px 12px; margin-top: 14px; }
.note-error { font-size: 12px; color: var(--red); background: var(--red-light); border: 1px solid #fecaca; border-radius: var(--radius); padding: 10px 14px; margin-bottom: 20px; }

/* STATS */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; scroll-margin-top: 90px; }
.stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px 20px 18px; position: relative; overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.stat-card::after { content: ""; position: absolute; bottom: 0; right: 0; left: 0; height: 3px; }
.stat-card.navy::after { background: var(--navy); }
.stat-card.sky::after { background: var(--sky); }
.stat-card.teal::after { background: var(--teal); }
.stat-card.lime::after { background: var(--lime); }
.stat-label { font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 10px; }
.stat-num { display: flex; flex-direction: column; gap: 2px; }
.kpi-num { font-size: 30px; font-weight: 800; line-height: 1.5; color: var(--text-1); font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi-unit { font-size: 12px; font-weight: 600; color: var(--text-3); line-height: 1.6; }
.stat-card.navy .kpi-num { color: var(--navy); }
.stat-sub { font-size: 11.5px; color: var(--text-3); margin-top: auto; padding-top: 10px; border-top: 1px dashed var(--border); line-height: 1.9; }
.stat-sub b { color: var(--text-1); font-weight: 700; }
.progress { height: 6px; background: var(--grid); border-radius: 3px; overflow: hidden; margin: 8px 0 10px; }
.progress span { display: block; height: 100%; background: var(--sky); border-radius: 3px; width: 0; }

/* CARDS */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px 22px; margin-bottom: 20px; min-width: 0; scroll-margin-top: 90px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-title { font-size: 13px; font-weight: 700; color: var(--text-2); display: flex; align-items: center; gap: 8px; }
.card-title::before { content: ""; width: 3px; height: 14px; background: var(--sky); border-radius: 2px; display: inline-block; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; scroll-margin-top: 90px; }

/* product bars */
.prod { display: grid; grid-template-columns: 100px 1fr auto; align-items: center; gap: 12px; padding: 7px 0; }
.prod-name { font-size: 13px; font-weight: 600; color: var(--text-2); }
.prod-track { position: relative; height: 12px; background: var(--grid); border-radius: 4px; }
.prod-fill { position: absolute; inset-block: 0; inset-inline-start: 0; background: var(--navy); border-radius: 4px; }
.prod-fore { position: absolute; inset-block: 0; inset-inline-start: 0; border-radius: 4px; border: 1.5px dashed var(--navy); opacity: .45; }
.prod-val { text-align: left; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.prod-val .muted { display: block; font-size: 11px; font-weight: 400; line-height: 1.4; }
.prod-legend { display: flex; gap: 16px; margin-top: 12px; font-size: 11px; color: var(--text-3); }
.prod-legend i { display: inline-block; width: 14px; height: 8px; border-radius: 2px; margin-inline-end: 6px; vertical-align: middle; }

/* charts */
.chart { width: 100%; height: 220px; position: relative; }
.chart-tall { height: 300px; }
/* LTR coordinates so text-anchor is predictable; y labels sit inside the right margin */
.chart svg { width: 100%; height: 100%; display: block; overflow: hidden; direction: ltr; }
.chart text { font-family: var(--font); fill: var(--text-3); font-size: 11px; direction: rtl; unicode-bidi: embed; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .axis-line { stroke: var(--border-mid); stroke-width: 1; }
.chart .bar { transition: opacity .1s; }
.chart .hit { fill: transparent; }
.chart.hovering .bar { opacity: .35; }
.chart .bar.hl { opacity: 1; }
.empty { display: grid; place-items: center; height: 100%; color: var(--text-3); font-size: 12px; text-align: center; line-height: 2; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: -4px 0 10px; font-size: 12px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 6px; vertical-align: -1px; }

.tooltip { position: fixed; z-index: 20; pointer-events: none; background: var(--navy); color: #fff; border-radius: var(--radius); padding: 8px 12px; font-size: 12px; line-height: 1.8; min-width: 170px; box-shadow: 0 8px 24px rgba(46,49,146,.25); }
.tooltip .t-title { font-weight: 700; margin-bottom: 2px; }
.tooltip .t-row { display: flex; justify-content: space-between; gap: 14px; }
.tooltip .t-row i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-inline-end: 6px; }
.tooltip .t-total { border-top: 1px solid rgba(255,255,255,.2); margin-top: 4px; padding-top: 4px; font-weight: 700; }

/* tables */
.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.search { font-family: var(--font); font-size: 13px; padding: 7px 14px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius); min-width: 200px; color: var(--text-1); outline: none; }
.search:focus { border-color: var(--sky); box-shadow: 0 0 0 3px var(--sky-dim); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { text-align: right; color: var(--text-3); font-weight: 600; font-size: 11px; padding: 9px 10px; background: var(--bg-input); border-bottom: 1px solid var(--border); white-space: nowrap; }
th:first-child { border-radius: 0 8px 0 0; }
th:last-child { border-radius: 8px 0 0 0; }
td { padding: 10px; border-bottom: 1px solid var(--border); white-space: nowrap; color: var(--text-1); }
tbody tr:hover { background: var(--bg-hover); }
tfoot td { border-bottom: 0; background: var(--navy-light); color: var(--navy); }
td.n, th.n { text-align: left; font-variant-numeric: tabular-nums; }
td.ltr { direction: ltr; text-align: right; font-family: ui-monospace, Menlo, monospace; font-size: 11px; color: var(--text-2); }
.badge { display: inline-flex; align-items: center; gap: 6px; border-radius: 20px; padding: 2px 10px; font-size: 11px; font-weight: 600; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.on { color: var(--teal); background: var(--teal-light); }
.badge.off { color: #6b6d70; background: var(--silver-light); }
.badge.bad { color: var(--red); background: var(--red-light); }
.pos { color: var(--teal); font-weight: 600; }
.neg { color: var(--red); font-weight: 600; }

/* LOGIN (same strips as AttendEd) */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 32px 16px; position: relative; overflow: hidden; background: linear-gradient(150deg, #eef2ff 0%, #f8faff 50%, #f0faf8 100%); }
.login-bg-strip { position: absolute; border-radius: 999px; opacity: 0.22; pointer-events: none; }
.strip-1 { width: 600px; height: 32px; background: var(--sky); transform: rotate(-35deg); top: 15%; left: -150px; }
.strip-2 { width: 480px; height: 24px; background: var(--teal); transform: rotate(-35deg); top: 32%; left: -80px; }
.strip-3 { width: 360px; height: 20px; background: var(--lime); transform: rotate(-35deg); top: 46%; left: -30px; }
.strip-4 { width: 600px; height: 32px; background: var(--navy); transform: rotate(-35deg); bottom: 15%; right: -150px; }
.strip-5 { width: 480px; height: 24px; background: var(--sky); transform: rotate(-35deg); bottom: 30%; right: -80px; }
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: var(--radius-xl); box-shadow: 0 8px 48px rgba(46,49,146,0.10), 0 2px 8px rgba(46,49,146,0.06); border: 1px solid rgba(46,49,146,0.07); padding: 40px 36px; position: relative; z-index: 1; }
.login-header { text-align: center; margin-bottom: 28px; }
.login-logo-img { width: 160px; height: auto; display: block; margin: 0 auto 16px; }
.login-logo-word { font-size: 15px; font-weight: 600; color: var(--text-2); }
.login-divider { height: 1px; background: var(--border); margin: 20px 0 24px; }
.login-title { font-size: 18px; font-weight: 800; color: var(--navy); margin-bottom: 4px; }
.login-sub { font-size: 12px; color: var(--text-3); }
.login-label { display: block; font-size: 11px; color: var(--text-2); margin-bottom: 6px; font-weight: 600; }
.login-input { width: 100%; padding: 11px 14px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text-1); font-size: 13px; font-family: var(--font); outline: none; margin-bottom: 14px; transition: border-color .15s; }
.login-input:focus { border-color: var(--sky); box-shadow: 0 0 0 3px var(--sky-dim); }
.login-footer { text-align: center; margin-top: 18px; font-size: 11px; color: var(--text-3); }
.login-error { color: var(--red); background: var(--red-light); border: 1px solid #fecaca; border-radius: var(--radius); padding: 10px 14px; font-size: 12px; margin-bottom: 14px; display: none; }
.login-error.show { display: block; }

/* RESPONSIVE: sidebar becomes a top bar, like AttendEd on small screens */
@media (max-width: 1100px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 0; }
  .sidebar::before { width: 100%; }
  .sidebar-logo { border: 0; padding: 12px 16px; }
  .sidebar-logo-img { width: 96px; }
  .sidebar-section { display: none; }
  .sidebar-footer { margin: 0 auto 0 0; border: 0; padding: 8px 12px; }
  .user-chip { padding: 6px 10px; }
  .topbar { padding: 12px 16px; position: static; }
  .content { padding: 16px; }
  .grid-2 { grid-template-columns: 1fr; gap: 0; }
}
@media (max-width: 520px) { .stats-grid { grid-template-columns: 1fr; } .search { min-width: 0; width: 100%; } }

/* MOBILE: each table row becomes a card (label from data-label), actions wrap, bigger tap targets */
@media (max-width: 640px) {
  .topbar { gap: 8px; }
  .topbar > div:first-child { width: 100%; }
  .topbar-spacer { display: none; }
  .topbar .btn { padding: 8px 12px; flex: 1; justify-content: center; }
  .topbar .seg { flex: 1; }
  .topbar .seg button { flex: 1; padding: 6px 8px; }
  .card { padding: 16px 14px; }
  .card-head { align-items: stretch; }
  .filters { width: 100%; }
  .filters .seg { width: 100%; }
  .filters .seg button { flex: 1; padding: 6px; }
  .kpi-num { font-size: 28px; }
  .prod { grid-template-columns: 72px 1fr auto; gap: 8px; }
  .chart-tall { height: 260px; }
  .rtable thead { display: none; }
  .rtable, .rtable tbody, .rtable tfoot, .rtable tr, .rtable td { display: block; width: 100%; }
  .rtable tr { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 10px; padding: 6px 12px; background: #fff; }
  .rtable tbody tr:hover { background: #fff; }
  .rtable td { border: 0; padding: 5px 0; display: flex; justify-content: space-between; gap: 12px; white-space: normal; text-align: left; }
  .rtable td::before { content: attr(data-label); color: var(--text-3); font-size: 11px; font-weight: 600; flex-shrink: 0; }
  .rtable td[data-label=""]::before { content: none; }
  .rtable td:first-child { font-size: 13px; border-bottom: 1px solid var(--border); padding-bottom: 8px; margin-bottom: 4px; }
  .rtable td.ltr { direction: ltr; justify-content: space-between; flex-direction: row-reverse; }
  .rtable tfoot tr { background: var(--navy-light); border-color: transparent; }
  .rtable tfoot td:first-child { border: 0; margin: 0; }
}
