/* BK Site Operations - mobile first. Logical properties (inline-start /
   inline-end) make every layout mirror correctly between RTL and LTR. */
:root {
  --brand: #78b838;          /* BK green, from the Company Profile */
  --brand-ink: #4f8a1f;      /* darker green for text on white (contrast) */
  --navy: #203040;           /* BK navy */
  --bg: #f4f6f8;
  --surface: #ffffff;
  --ink: #191919;
  --ink-2: #555f6b;
  --line: #dde2e7;
  --focus: #257de0;
  --good: #0aac23; --good-bg: #e5f4e4;
  --warn: #b77900; --warn-bg: #fdf1d8;
  --crit: #c0302f; --crit-bg: #fbe9e9;
  --na: #8a929b;  --na-bg: #eef0f2;
  --series-1: #257de0;
  --radius: 10px;
  --tap: 48px;
  font-family: "Segoe UI", "Noto Sans Arabic", "Noto Sans", Tahoma, "Geeza Pro", "DejaVu Sans", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; font-size: 16px; line-height: 1.5; }
h1 { font-size: 1.35rem; margin: 0 0 12px; }
h2 { font-size: 1.15rem; margin: 0 0 10px; }
h3 { font-size: 1rem; margin: 0 0 8px; }
p { margin: 0 0 10px; }
a { color: var(--focus); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- top bar and navigation ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--navy); color: #fff;
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); }
.topbar .logo { height: 34px; background: #fff; border-radius: 6px; padding: 2px 4px; }
.topbar .title { font-weight: 600; font-size: .95rem; line-height: 1.2; flex: 1; min-width: 0; }
.topbar .title small { display: block; font-weight: 400; opacity: .8; font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.env-badge { background: #fbb315; color: #191919; font-weight: 700; font-size: .72rem; padding: 2px 8px; border-radius: 999px; }
.lang-btn { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.6); border-radius: 8px;
  min-height: 40px; padding: 0 12px; font: inherit; font-weight: 600; cursor: pointer; }
.nav { display: flex; gap: 4px; overflow-x: auto; background: var(--surface); border-bottom: 1px solid var(--line);
  padding: 0 8px; position: sticky; top: 50px; z-index: 19; scrollbar-width: none; }
.nav a { flex: none; display: flex; align-items: center; min-height: var(--tap); padding: 0 12px; text-decoration: none;
  color: var(--ink-2); font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; }
.nav a[aria-current="page"] { color: var(--navy); border-bottom-color: var(--brand); }
main { max-width: 1180px; margin: 0 auto; padding: 14px 12px 96px; }

/* ---------- cards, forms, buttons ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.card.tight { padding: 10px 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 160px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-weight: 600; margin-bottom: 4px; font-size: .92rem; }
.hint { color: var(--ink-2); font-size: .85rem; margin-top: 4px; }
input, select, textarea { width: 100%; min-height: var(--tap); font: inherit; color: var(--ink); background: #fff;
  border: 1px solid #b9c1ca; border-radius: 8px; padding: 8px 12px; }
textarea { min-height: 88px; resize: vertical; }
input[type="checkbox"] { width: 22px; min-height: 22px; height: 22px; accent-color: var(--brand-ink); }
input.qty { font-size: 1.35rem; font-weight: 700; text-align: center; direction: ltr; }
.check { display: flex; align-items: center; gap: 8px; min-height: 40px; }
.btn { min-height: var(--tap); padding: 0 18px; border-radius: 8px; border: 1px solid #b9c1ca; background: #fff;
  color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center;
  justify-content: center; gap: 6px; text-decoration: none; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.go { background: var(--brand-ink); border-color: var(--brand-ink); color: #fff; }
.btn.danger { color: var(--crit); border-color: var(--crit); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: .88rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.block { width: 100%; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.sticky-actions { position: fixed; inset-inline: 0; bottom: 0; z-index: 15; background: var(--surface);
  border-top: 1px solid var(--line); padding: 10px 12px; padding-bottom: max(10px, env(safe-area-inset-bottom));
  display: flex; gap: 10px; }
.sticky-actions .btn { flex: 1; }
.error-text { color: var(--crit); font-weight: 600; font-size: .9rem; margin-top: 6px; }
.notice { border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; font-weight: 600; }
.notice.warn { background: var(--warn-bg); color: #6b4700; border: 1px solid #f0c96a; }
.notice.info { background: #e7f1fb; color: #123e73; border: 1px solid #b6d5f8; }
.notice.crit { background: var(--crit-bg); color: #7d1f1e; border: 1px solid #efb4b4; }
.notice.good { background: var(--good-bg); color: #075e14; border: 1px solid #a9dca5; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .78rem; font-weight: 700; background: var(--na-bg); color: var(--ink-2); }
.badge.good { background: var(--good-bg); color: #075e14; }
.badge.warn { background: var(--warn-bg); color: #6b4700; }
.badge.crit { background: var(--crit-bg); color: #7d1f1e; }
.muted { color: var(--ink-2); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- segmented choices ---------- */
.segmented { display: flex; gap: 6px; flex-wrap: wrap; }
.seg { flex: 1 1 auto; min-height: var(--tap); padding: 0 10px; border: 1px solid #b9c1ca; background: #fff;
  border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; color: var(--ink); }
.seg[aria-checked="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }
.seg.s-working[aria-checked="true"] { background: var(--good); border-color: var(--good); }
.seg.s-stopped[aria-checked="true"] { background: var(--crit); border-color: var(--crit); }
.seg.s-partial[aria-checked="true"] { background: #f2a600; border-color: #f2a600; color: #191919; }
.seg.s-not_applicable[aria-checked="true"] { background: var(--na); border-color: var(--na); }

/* ---------- stepper ---------- */
.steps { display: flex; gap: 6px; margin-bottom: 12px; }
.steps span { flex: 1; text-align: center; font-size: .8rem; font-weight: 700; padding: 6px 2px; border-radius: 6px;
  background: var(--na-bg); color: var(--ink-2); }
.steps span.on { background: var(--navy); color: #fff; }
.steps span.done { background: var(--good-bg); color: #075e14; }

/* ---------- production cards and hour rows ---------- */
.scope-card { border-inline-start: 5px solid var(--brand); }
.scope-card.locked { border-inline-start-color: var(--na); background: #fafbfc; }
.scope-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.scope-head h3 { margin: 0; }
.unit { font-weight: 700; color: var(--ink-2); }
.hour-row { border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin-bottom: 8px; background: #fff; }
.hour-row .time { font-weight: 700; direction: ltr; unicode-bidi: isolate; display: inline-block; margin-bottom: 6px; }
.hour-row .seg { min-height: 42px; font-size: .9rem; padding: 0 6px; }
.hour-row .extra { margin-top: 8px; display: grid; gap: 8px; }
.hour-row.st-stopped { border-color: #efb4b4; background: #fff8f8; }
.hour-row.st-partial { border-color: #f0c96a; background: #fffbf1; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { padding: 8px 8px; border-bottom: 1px solid var(--line); text-align: start; vertical-align: top; }
th { font-size: .8rem; color: var(--ink-2); font-weight: 700; background: #f8f9fa; }
td.n, th.n { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.total td { font-weight: 700; border-top: 2px solid var(--ink-2); }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #f3f7fc; }

/* ---------- dashboard ---------- */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.kpi .label { font-size: .82rem; color: var(--ink-2); font-weight: 600; }
.kpi .value { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .value small { font-size: .85rem; color: var(--ink-2); font-weight: 600; }
.kpi.alert .value { color: var(--crit); }
.grid2 { display: grid; gap: 12px; }
.scope-tiles { display: grid; grid-template-columns: 1fr; gap: 10px; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { font-family: inherit; fill: var(--ink-2); font-size: 11px; }
.chart .grid line { stroke: #e6e9ed; }
.chart .bar { fill: var(--series-1); }
.chart .bar:hover, .chart .seg-rect:hover { opacity: .8; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .82rem; color: var(--ink-2); margin: 4px 0 8px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-inline-end: 6px; vertical-align: -1px; }
.tooltip { position: fixed; z-index: 50; pointer-events: none; background: #191919; color: #fff; font-size: .82rem;
  padding: 6px 9px; border-radius: 6px; max-width: 240px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 12px; }
.filters .field { margin: 0; flex: 1 1 150px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs button { min-height: 40px; }
.tabs button[aria-selected="true"] { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(180deg, #203040 0 220px, var(--bg) 220px); }
.login-card { width: 100%; max-width: 400px; }
.login-card .logo { display: block; width: 180px; margin: 0 auto 12px; }
.lang-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.lang-choice .btn { min-height: 56px; font-size: 1.1rem; }

/* ---------- dialogs and toasts ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 40; display: grid; place-items: center; padding: 12px; }
.dialog { background: #fff; border-radius: 12px; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; padding: 16px; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; flex-wrap: wrap; }
.toasts { position: fixed; inset-inline: 12px; bottom: 84px; z-index: 60; display: grid; gap: 8px; justify-items: center; }
.toast { background: #191919; color: #fff; padding: 10px 14px; border-radius: 8px; max-width: 520px; font-weight: 600; }
.toast.error { background: var(--crit); }
.toast.good { background: #075e14; }

/* ---------- printable report (PDF) ---------- */
.doc { background: #fff; color: #191919; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); }
.doc header { display: flex; justify-content: space-between; align-items: center; gap: 12px; border-bottom: 3px solid var(--brand);
  padding-bottom: 8px; margin-bottom: 12px; }
.doc header img { height: 54px; }
.doc h2 { margin-top: 14px; color: var(--navy); }
.doc .meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 4px 16px; margin-bottom: 8px; }
.strip { display: grid; grid-template-columns: repeat(10, 1fr); gap: 2px; }
.strip div { font-size: .7rem; text-align: center; padding: 4px 1px; border-radius: 3px; }
.st-working { background: var(--good-bg); } .st-stopped { background: var(--crit-bg); }
.st-partial { background: var(--warn-bg); } .st-not_applicable { background: var(--na-bg); }
.doc .report-block { break-inside: avoid; border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }

@media (min-width: 720px) {
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .scope-tiles { grid-template-columns: repeat(2, 1fr); }
  .grid2 { grid-template-columns: 1fr 1fr; }
  .sticky-actions { position: static; border: 0; padding: 0; background: none; margin-top: 12px; }
  .sticky-actions .btn { flex: 0 0 auto; }
  main { padding-bottom: 40px; }
  .hour-row { display: grid; grid-template-columns: 120px 1fr; gap: 10px; align-items: start; }
  .hour-row .time { margin: 10px 0 0; }
  .hour-row .extra { grid-column: 2; }
}
@media print {
  body { background: #fff; }
  body * { visibility: hidden; }
  .doc, .doc * { visibility: visible; }
  .doc { position: absolute; inset-inline-start: 0; top: 0; width: 100%; border: 0; padding: 0; }
  .no-print { display: none !important; }
  @page { size: A4; margin: 14mm; }
  .st-working, .st-stopped, .st-partial, .st-not_applicable, th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
