/* ==========================================================================
   نظام أفق — الهوية البصرية
   --------------------------------------------------------------------------
   الوضع الفاتح هو الافتراضي على :root ، والوضع الداكن يُعاد تعريفه بالكامل
   في :root[data-theme="dark"] بلوحة أفق الأصلية (قسم 19 من القواعد العامة).
   ⚠️ ممنوع أي لون صريح داخل مكوّن — كل لون جديد يُضاف كتوكن في الكتلتين،
      وإلا انكسر أحد الوضعين. المفتاح المحفوظ: localStorage['ofoq_theme'].
   ========================================================================== */
:root {
  color-scheme: light;

  /* ------------------------------ الأسطح ------------------------------- */
  --bg-0: #f5f3fa;
  --bg-1: #ffffff;
  --bg-2: #ece7f8;
  --bg-3: #e0d8f2;
  --panel: #ffffff;
  --panel-2: #f2effa;
  --surf-soft: #f5f2fc;
  --surf-faint: #faf8fe;
  --inset-bg: #f2effa;
  --input-bg: #ffffff;
  --option-bg: #ffffff;
  --pop-bg: #ffffff;
  --body-bg:
    radial-gradient(1100px 700px at 85% -10%, rgba(232, 181, 75, .16), transparent 60%),
    radial-gradient(900px 700px at 5% 100%, rgba(120, 70, 200, .10), transparent 60%),
    linear-gradient(160deg, #ffffff 0%, #f5f3fa 55%, #efe9f9 100%);
  --sidebar-bg: linear-gradient(190deg, #f6f3fd, #efeaf9);
  --topbar-bg: rgba(255, 255, 255, .82);
  --tabbar-bg: rgba(255, 255, 255, .96);
  --card-bg: linear-gradient(160deg, #ffffff, #fbfaff);
  --modal-bg: linear-gradient(165deg, #ffffff, #fbf9ff);
  --toast-bg: linear-gradient(150deg, #ffffff, #f6f2fd);
  --login-card-bg: linear-gradient(165deg, rgba(255, 255, 255, .96), rgba(250, 247, 255, .98));
  --hero-bg: linear-gradient(165deg, #ffffff, #f5f1fd);
  --sheet-doc-bg: linear-gradient(165deg, #ffffff, #f7f4fe);
  --doc-title-bg: linear-gradient(180deg, #f2ecfc, #e7defa);
  --sheet-meta-bg: #faf7ff;
  --thead-bg: linear-gradient(180deg, #efeafa, #e4dcf5);
  --row-hover: #f6f3fd;
  --track: #e7e1f4;
  --nav-active-bg: linear-gradient(90deg, var(--gold-soft), rgba(232, 181, 75, .05));
  --scrim: rgba(40, 24, 80, .42);
  --scroll-track: rgba(26, 16, 48, .06);
  --scroll-thumb: rgba(122, 83, 16, .32);
  --scroll-thumb-hover: rgba(122, 83, 16, .55);

  /* ------------------------------ الحدود ------------------------------- */
  --line-soft: #eee9f8;
  --line: #e3ddf0;
  --line-2: #ded7ee;
  --line-chip: #cfc6e6;
  --line-muted: #cfc6e6;
  --line-strong: #8f83b0;
  --topbar-line: #e3ddf0;

  /* ------------------------------ النصوص ------------------------------- */
  --txt: #1a1030;
  --txt-2: #4a4260;
  --txt-3: #6b6483;
  --on-gold: #24123f;
  --on-danger: #ffffff;
  --on-danger-strong: #ffffff;
  --thead-fg: #4a2f0a;
  --tfoot-fg: #2b1547;

  /* ------------------------------ الذهبي ------------------------------- */
  --gold: #e8b54b;
  --gold-hi: #f6d488;
  --gold-3: #b8842a;
  --gold-ink: #7a5310;
  --gold-2: var(--gold-ink);
  --gold-fg: #7a5310;
  --icon-fg: #7a5310;
  --gold-soft: rgba(232, 181, 75, .18);
  --gold-line: rgba(122, 83, 16, .3);
  --gold-ring: rgba(122, 83, 16, .2);
  --gold-glow: rgba(184, 132, 42, .3);
  --bar-grad: linear-gradient(90deg, #8a5f16, #b8842a);

  /* ------------------------------ الحالات ------------------------------ */
  --ok: #0f7a5a;
  --ok-ink: #0a5b43;
  --ok-ink-2: #0a5b43;
  --ok-soft: rgba(15, 122, 90, .12);
  --ok-line: rgba(15, 122, 90, .45);
  --ok-line-strong: rgba(15, 122, 90, .5);
  --warn: #8a5a06;
  --warn-ink: #6e4604;
  --warn-ink-2: #6e4604;
  --warn-soft: rgba(138, 90, 6, .12);
  --warn-soft-2: rgba(138, 90, 6, .08);
  --warn-line: rgba(138, 90, 6, .4);
  --warn-line-2: rgba(138, 90, 6, .32);
  --danger: #c02637;
  --danger-ink: #a01b2a;
  --danger-soft: rgba(192, 38, 55, .1);
  --danger-soft-2: rgba(192, 38, 55, .07);
  --danger-line: rgba(192, 38, 55, .4);
  --danger-line-strong: rgba(192, 38, 55, .5);
  --danger-grad: linear-gradient(135deg, #c9364a, #a8121f);
  --danger-glow: rgba(192, 38, 55, .22);
  --info: #1d5fa8;
  --info-ink: #154b86;
  --info-ink-2: #154b86;
  --info-soft: rgba(29, 95, 168, .12);
  --info-soft-2: rgba(29, 95, 168, .08);
  --info-line: rgba(29, 95, 168, .4);
  --info-line-2: rgba(29, 95, 168, .3);
  --muted-soft: rgba(26, 16, 48, .06);
  --muted-line: rgba(26, 16, 48, .14);

  /* ------------------------------ التركيز ------------------------------ */
  --focus-outline: #7a5310;
  --focus-ring: rgba(122, 83, 16, .18);

  /* ------------------------------ الرسوم ------------------------------- */
  --chart-1: #b8842a;
  --chart-2: #7a5310;
  --chart-ok: #0f7a5a;
  --chart-danger: #c02637;
  --chart-info: #1d5fa8;
  --chart-grid: rgba(26, 16, 48, .12);
  --chart-fg: #4a4260;
  --chart-track: #ebe6f7;

  /* ---- الخريطة: فوق بلاطات OSM الفاتحة في الوضعين — لا تتبع الثيم ---- */
  --map-bg: #1a1030;
  --map-line: rgba(232, 181, 75, .28);
  --map-ctl-bg: rgba(20, 10, 38, .88);
  --map-ctl-fg: #e8b54b;
  --map-hint-bg: rgba(20, 10, 38, .82);
  --map-hint-fg: rgba(255, 255, 255, .74);
  --map-attr-bg: rgba(0, 0, 0, .4);
  --map-attr-fg: rgba(255, 255, 255, .55);
  --map-me: #4aa8ff;
  --map-me-ring: #ffffff;
  --map-me-halo: rgba(74, 168, 255, .25);
  --marker-shadow: rgba(0, 0, 0, .6);

  /* ---- الكشف الرسمي: ورق مطبوع — فاتح في الوضعين، لا يتبع الثيم ---- */
  --sheet-paper: #f2f2f4;
  --sheet-paper-alt: #e8e8ee;
  --sheet-paper-hover: #ffeec9;
  --sheet-ink: #1c1030;
  --sheet-line: #d8d8e0;
  --sheet-link: #3c1f6e;

  /* ---- الشعار: صورة على خلفية داكنة — تُعرض على لوحة بلون الهوية ---- */
  --logo-plate: #1d1033;
  --logo-ring: rgba(26, 16, 48, .18);

  /* ------------------ الطباعة: فاتحة دائماً في الوضعين ------------------ */
  --print-bg: #ffffff;
  --print-fg: #000000;
  --print-line: #dddddd;
  --print-ink: #1c1030;
  --print-gold-line: #b8842a;
  --print-title-bg: #f6ecd8;
  --print-muted: #8a6520;
  --print-meta-bg: #faf7f0;
  --print-thead-bg: #f0e3c8;
  --print-thead-fg: #4a2f0a;
  --print-tfoot-bg: #e8c778;

  /* ------------------------------ الهندسة ------------------------------ */
  --r-lg: 20px;
  --r-md: 14px;
  --r-sm: 10px;
  --shadow: 0 12px 34px rgba(40, 24, 80, .12);
  --shadow-pop: 0 18px 40px rgba(40, 24, 80, .16);
  --shadow-drawer: -20px 0 50px rgba(40, 24, 80, .18);
  --shadow-mnav: 0 -8px 24px rgba(40, 24, 80, .12);
  --side-w: 264px;
  /* Height of the mobile bottom bar. Everything that sits above it reads this one value. */
  --mnav-h: 58px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: "Tajawal", "Cairo", "Segoe UI", "Noto Naskh Arabic", Tahoma, sans-serif;
}

/* ============================ الوضع الداكن ============================== */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg-0: #140a26;
  --bg-1: #1d1033;
  --bg-2: #2a1848;
  --bg-3: #34205a;
  --panel: rgba(255, 255, 255, .045);
  --panel-2: rgba(255, 255, 255, .07);
  --surf-soft: rgba(255, 255, 255, .05);
  --surf-faint: rgba(255, 255, 255, .03);
  --inset-bg: rgba(0, 0, 0, .25);
  --input-bg: rgba(0, 0, 0, .28);
  --option-bg: #241239;
  --pop-bg: #1c1132;
  --body-bg:
    radial-gradient(1100px 700px at 85% -10%, rgba(232, 181, 75, .10), transparent 60%),
    radial-gradient(900px 700px at 5% 100%, rgba(120, 70, 200, .22), transparent 60%),
    linear-gradient(160deg, var(--bg-1) 0%, var(--bg-0) 55%, #100820 100%);
  --sidebar-bg: linear-gradient(190deg, rgba(42, 24, 72, .92), rgba(20, 10, 38, .92));
  --topbar-bg: rgba(20, 10, 38, .72);
  --tabbar-bg: rgba(20, 10, 38, .96);
  --card-bg: linear-gradient(160deg, rgba(255, 255, 255, .06), rgba(255, 255, 255, .025));
  --modal-bg: linear-gradient(165deg, #2b1749, #1c1033);
  --toast-bg: linear-gradient(150deg, #33205a, #221340);
  --login-card-bg: linear-gradient(165deg, rgba(52, 32, 90, .92), rgba(24, 13, 44, .95));
  --hero-bg: linear-gradient(165deg, rgba(58, 34, 99, .9), rgba(26, 14, 48, .92));
  --sheet-doc-bg: linear-gradient(165deg, #2b1749, #1a0e30);
  --doc-title-bg: linear-gradient(180deg, #3a2263, #2a1848);
  --sheet-meta-bg: rgba(0, 0, 0, .22);
  --thead-bg: linear-gradient(180deg, #35205c, #281645);
  --row-hover: rgba(255, 255, 255, .04);
  --track: rgba(255, 255, 255, .1);
  --nav-active-bg: linear-gradient(90deg, var(--gold-soft), rgba(232, 181, 75, .04));
  --scrim: rgba(8, 3, 18, .72);
  --scroll-track: rgba(0, 0, 0, .2);
  --scroll-thumb: rgba(232, 181, 75, .3);
  --scroll-thumb-hover: rgba(232, 181, 75, .5);

  --line-soft: rgba(255, 255, 255, .06);
  --line: rgba(255, 255, 255, .08);
  --line-2: rgba(255, 255, 255, .09);
  --line-chip: rgba(255, 255, 255, .1);
  --line-muted: rgba(255, 255, 255, .14);
  --line-strong: rgba(255, 255, 255, .12);
  --topbar-line: rgba(255, 255, 255, .07);

  --txt: #ffffff;
  --txt-2: rgba(255, 255, 255, .74);
  --txt-3: rgba(255, 255, 255, .48);
  --thead-fg: #f6d488;

  --gold-ink: #f6d488;
  --gold-fg: #e8b54b;
  --icon-fg: #e8b54b;
  --gold-soft: rgba(232, 181, 75, .16);
  --gold-line: rgba(232, 181, 75, .28);
  --gold-ring: rgba(232, 181, 75, .2);
  --gold-glow: rgba(232, 181, 75, .22);
  --bar-grad: linear-gradient(90deg, var(--gold), var(--gold-hi));

  --ok: #4ad3a1;
  --ok-ink: #7fe8c4;
  --ok-ink-2: #9cf0d4;
  --ok-soft: rgba(74, 211, 161, .15);
  --ok-line: rgba(74, 211, 161, .4);
  --ok-line-strong: rgba(74, 211, 161, .5);
  --warn: #f5b942;
  --warn-ink: #ffd98a;
  --warn-ink-2: #ffe0a3;
  --warn-soft: rgba(245, 185, 66, .15);
  --warn-soft-2: rgba(245, 185, 66, .08);
  --warn-line: rgba(245, 185, 66, .35);
  --warn-line-2: rgba(245, 185, 66, .3);
  --danger: #ff6b7a;
  --danger-ink: #ffa8b2;
  --danger-soft: rgba(255, 107, 122, .15);
  --danger-soft-2: rgba(255, 107, 122, .1);
  --danger-line: rgba(255, 107, 122, .4);
  --danger-line-strong: rgba(255, 107, 122, .55);
  --danger-grad: linear-gradient(135deg, #ff9aa6, #ff6b7a);
  --danger-glow: rgba(255, 107, 122, .22);
  --on-danger-strong: #40101a;
  --info: #7ab8ff;
  --info-ink: #a9d2ff;
  --info-ink-2: #cfe4ff;
  --info-soft: rgba(122, 184, 255, .15);
  --info-soft-2: rgba(122, 184, 255, .08);
  --info-line: rgba(122, 184, 255, .35);
  --info-line-2: rgba(122, 184, 255, .25);
  --muted-soft: rgba(255, 255, 255, .08);
  --muted-line: rgba(255, 255, 255, .14);

  --focus-outline: #e8b54b;
  --focus-ring: rgba(232, 181, 75, .15);

  --chart-1: #e8b54b;
  --chart-2: #f6d488;
  --chart-ok: #4ad3a1;
  --chart-danger: #ff6b7a;
  --chart-info: #7ab8ff;
  --chart-grid: rgba(255, 255, 255, .1);
  --chart-fg: rgba(255, 255, 255, .62);
  --chart-track: rgba(255, 255, 255, .06);

  --logo-ring: transparent;

  --shadow: 0 18px 45px rgba(0, 0, 0, .45);
  --shadow-pop: 0 18px 40px rgba(0, 0, 0, .45);
  --shadow-drawer: -20px 0 50px rgba(0, 0, 0, .5);
  --shadow-mnav: 0 -8px 24px rgba(0, 0, 0, .45);
}

/* الطباعة فاتحة دائماً مهما كان الوضع المختار */
@media print { :root, :root[data-theme="dark"] { color-scheme: light; } }

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; min-height: 100%;
  background: var(--bg-0);
  color: var(--txt);
  font-family: var(--font);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
body {
  background: var(--body-bg);
  background-attachment: fixed;
}
/* انتقال لوني خفيف عند تبديل الوضع — يُعطَّل تحت prefers-reduced-motion */
html, body { transition: background-color .18s linear, color .18s linear; }
@media (prefers-reduced-motion: reduce) {
  html, body { transition: none; }
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--scroll-track); }
::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--scroll-thumb-hover); }

a { color: var(--gold-fg); text-decoration: none; }
input, select, textarea, button { font-family: inherit; font-size: 14px; }
h1, h2, h3, h4 { margin: 0; font-weight: 800; letter-spacing: -.2px; }
:focus-visible { outline: 3px solid var(--focus-outline); outline-offset: 2px; }

/* --------------------------------- logo ---------------------------------- */
.ofoq-logo {
  --lw: 132px;
  width: var(--lw);
  height: calc(var(--lw) / 2.33);
  background-color: var(--logo-plate);
  background-image: url('../assets/ofoq-logo.jpeg');
  background-repeat: no-repeat;
  background-size: calc(var(--lw) * 3.265) calc(var(--lw) * 1.2807);
  background-position: calc(var(--lw) * -1.1633) calc(var(--lw) * -0.4283);
  border-radius: 6px;
  box-shadow: 0 0 0 1px var(--logo-ring);
  flex: none;
}
.ofoq-logo.sm { --lw: 96px; }
.ofoq-logo.lg { --lw: 190px; }

/* ------------------------------ app shell -------------------------------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--side-w); flex: none; padding: 18px 14px 24px;
  background: var(--sidebar-bg);
  border-inline-start: 1px solid var(--gold-line);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 6px;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 16px; }
.sidebar .brand .t { font-size: 12px; color: var(--txt-3); line-height: 1.5; }
.nav-group { margin-top: 12px; font-size: 11px; color: var(--txt-3); padding: 0 12px 6px; letter-spacing: .5px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 11px 13px; border-radius: var(--r-md);
  color: var(--txt-2); cursor: pointer; transition: .16s; font-weight: 600; font-size: 14px;
  border: 1px solid transparent;
}
.nav-item:hover { background: var(--panel); color: var(--txt); }
.nav-item.active {
  background: var(--nav-active-bg);
  color: var(--txt); border-color: var(--gold-line);
}
.nav-item .ico { width: 20px; text-align: center; color: var(--icon-fg); font-size: 16px; }
.nav-item .badge-dot { margin-inline-start: auto; background: var(--danger); color: var(--on-danger); border-radius: 20px; padding: 1px 7px; font-size: 11px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 14px 22px;
  border-bottom: 1px solid var(--topbar-line);
  background: var(--topbar-bg); backdrop-filter: blur(14px);
  position: sticky; top: 0; z-index: 40;
}
.topbar h1 { font-size: 17px; }
.topbar .sub { font-size: 12px; color: var(--txt-3); }
.topbar .spacer { flex: 1; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
  background: var(--panel); border: 1px solid var(--line); color: var(--icon-fg);
  cursor: pointer; position: relative; font-size: 16px;
}
.icon-btn:hover { background: var(--panel-2); }
.icon-btn .dot {
  position: absolute; top: -5px; inset-inline-end: -5px; background: var(--danger); color: var(--on-danger);
  font-size: 10px; min-width: 17px; height: 17px; border-radius: 10px; display: grid; place-items: center; padding: 0 4px;
}
.user-chip { display: flex; align-items: center; gap: 9px; padding: 6px 12px; border-radius: 30px; background: var(--panel); border: 1px solid var(--gold-line); cursor: pointer; }
.user-chip .av { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(140deg, var(--gold), var(--gold-3)); color: var(--on-gold); display: grid; place-items: center; font-weight: 800; font-size: 13px; }
.user-chip .nm { font-size: 13px; font-weight: 700; }
.user-chip .rl { font-size: 11px; color: var(--txt-3); }

/* زر تبديل الوضع — نفس الموضع في كل الشاشات (قسم 19) */
.theme-toggle.fixed { position: fixed; top: 16px; inset-inline-end: 16px; z-index: 60; }

.content { padding: 22px; flex: 1; }
.page-head { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h2 { font-size: 22px; }
.page-head .desc { color: var(--txt-3); font-size: 13px; margin-top: 4px; }
.page-head .actions { margin-inline-start: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* -------------------------------- cards ---------------------------------- */
.card {
  background: var(--card-bg);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 18px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.card.gold { border-color: var(--gold-line); }
.card h3 { font-size: 15px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.card h3 .ico { color: var(--icon-fg); }
/* Counters pinned to the far end of a card heading (the supervisor boards). */
.card h3 .h3-stats { margin-inline-start: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-auto { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

.kpi { display: flex; flex-direction: column; gap: 8px; }
.kpi .label { color: var(--txt-3); font-size: 12.5px; display: flex; align-items: center; gap: 7px; }
.kpi .value { font-size: 30px; font-weight: 800; line-height: 1; }
.kpi .value small { font-size: 14px; color: var(--txt-3); font-weight: 600; }
.kpi .foot { font-size: 11.5px; color: var(--txt-3); }
.kpi.gold .value { color: var(--gold-2); }
.kpi::after {
  content: ''; position: absolute; inset-inline-end: -30px; top: -30px; width: 110px; height: 110px;
  border-radius: 50%; border: 1px solid var(--gold-line); opacity: .5;
}

/* ------------------------------- buttons --------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 10px 16px; border-radius: 12px;
  border: 1px solid var(--line-strong); background: var(--panel); color: var(--txt);
  cursor: pointer; font-weight: 700; font-size: 13.5px; transition: .16s; white-space: nowrap;
}
.btn:hover { background: var(--panel-2); transform: translateY(-1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.primary { background: linear-gradient(135deg, var(--gold-hi), var(--gold), var(--gold-3)); color: var(--on-gold); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; border-color: var(--gold-line); color: var(--gold-fg); }
.btn.danger { background: var(--danger-soft); border-color: var(--danger-line); color: var(--danger-ink); }
.btn.ok { background: var(--ok-soft); border-color: var(--ok-line); color: var(--ok-ink-2); }
.btn.sm { padding: 6px 11px; font-size: 12.5px; border-radius: 9px; }
.btn.block { width: 100%; justify-content: center; }
.btn.xl { padding: 20px; font-size: 18px; border-radius: 18px; }

/* -------------------------------- forms ---------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label { font-size: 12.5px; color: var(--txt-2); font-weight: 600; }
.field .hint { font-size: 11px; color: var(--txt-3); }
/* `input:not([type])` is deliberate: an attribute selector does not match a missing attribute,
   so a bare `<input value="…">` — the approval-stage name and every editable cell of the import
   preview — was getting none of this styling at all. */
input[type=text], input[type=password], input[type=number], input[type=date], input[type=time],
input[type=email], input[type=search], input[type=tel], input:not([type]), select, textarea {
  width: 100%; padding: 11px 13px; border-radius: 11px; color: var(--txt);
  background: var(--input-bg); border: 1px solid var(--line-strong); outline: none;
  transition: .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold-fg); box-shadow: 0 0 0 3px var(--focus-ring); }
select option { background: var(--option-bg); color: var(--txt); }
textarea { min-height: 86px; resize: vertical; }
input[type=checkbox] { accent-color: var(--gold-fg); width: 16px; height: 16px; }
.row { display: grid; gap: 12px; }
.row.c2 { grid-template-columns: 1fr 1fr; }
.row.c3 { grid-template-columns: repeat(3, 1fr); }
.row.c4 { grid-template-columns: repeat(4, 1fr); }
.check-line { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }

/* -------------------------------- tables --------------------------------- */
.table-wrap { overflow-x: auto; border-radius: var(--r-md); border: 1px solid var(--line-2); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 640px; }
thead th {
  background: var(--thead-bg); color: var(--thead-fg);
  padding: 12px 10px; text-align: center; font-weight: 700; font-size: 12.5px;
  border-bottom: 1px solid var(--gold-line); white-space: nowrap; position: sticky; top: 0;
}
tbody td { padding: 10px; text-align: center; border-bottom: 1px solid var(--line-soft); }
tbody tr:hover { background: var(--row-hover); }
tbody tr.clickable { cursor: pointer; }
tfoot td { background: linear-gradient(180deg, var(--gold-hi), var(--gold)); color: var(--tfoot-fg); font-weight: 800; padding: 12px 10px; text-align: center; }
.t-name { text-align: right !important; font-weight: 700; }
.t-muted { color: var(--txt-3); font-size: 12px; }

/* الكشف الرسمي — نسخة مطابقة للنموذج المطبوع */
.sheet-doc { background: var(--sheet-doc-bg); border: 1px solid var(--gold-line); border-radius: var(--r-lg); padding: 22px; }
.sheet-doc .doc-head { text-align: center; margin-bottom: 16px; }
.sheet-doc .doc-title {
  display: inline-block; background: var(--doc-title-bg); border: 1px solid var(--gold-line);
  border-radius: 0 0 18px 18px; padding: 14px 40px; font-size: 26px; font-weight: 800;
}
.sheet-doc .doc-sub { color: var(--gold-2); font-size: 14px; margin-top: 8px; letter-spacing: 3px; }
.sheet-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; border: 1px solid var(--gold-line); border-radius: 14px; overflow: hidden; margin: 16px 0; background: var(--sheet-meta-bg); }
.sheet-meta .cell { padding: 12px 16px; border-inline-start: 1px solid var(--gold-line); }
.sheet-meta .cell:first-child { border: 0; }
.sheet-meta .k { color: var(--gold-2); font-size: 11.5px; margin-bottom: 3px; }
.sheet-meta .v { font-weight: 700; font-size: 14px; }
table.sheet tbody td { background: var(--sheet-paper); color: var(--sheet-ink); border: 1px solid var(--sheet-line); }
table.sheet tbody tr:nth-child(even) td { background: var(--sheet-paper-alt); }
table.sheet tbody tr:hover td { background: var(--sheet-paper-hover); }
table.sheet tfoot td { border: 1px solid var(--gold-3); }
table.sheet thead th { border: 1px solid var(--gold-line); }
.sheet-notes { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; margin-top: 18px; }
.sheet-notes ul { margin: 0; padding-inline-start: 18px; color: var(--txt-2); font-size: 13px; line-height: 2; }
.sign-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; text-align: center; }
.sign-row .s { padding: 12px; }
.sign-row .s .lbl { color: var(--gold-2); font-size: 13px; margin-bottom: 26px; }
.sign-row .s .line { border-bottom: 1px dashed var(--gold-line); }

/* -------------------------------- badges --------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 700; border: 1px solid transparent; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok-ink); border-color: var(--ok-line); }
.badge.warn { background: var(--warn-soft); color: var(--warn-ink); border-color: var(--warn-line); }
.badge.danger { background: var(--danger-soft); color: var(--danger-ink); border-color: var(--danger-line); }
.badge.info { background: var(--info-soft); color: var(--info-ink); border-color: var(--info-line); }
.badge.muted { background: var(--muted-soft); color: var(--txt-2); border-color: var(--muted-line); }
.badge.gold { background: var(--gold-soft); color: var(--gold-2); border-color: var(--gold-line); }
table.sheet .badge { border-width: 1px; }

/* -------------------------------- modal ---------------------------------- */
.modal-back {
  position: fixed; inset: 0; background: var(--scrim); backdrop-filter: blur(6px);
  display: grid; place-items: center; z-index: 100; padding: 16px; overflow-y: auto;
}
.modal {
  width: min(920px, 100%); max-height: 92vh; overflow-y: auto;
  background: var(--modal-bg); border: 1px solid var(--gold-line);
  border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 20px;
}
.modal.sm { width: min(520px, 100%); }
.modal.lg { width: min(1180px, 100%); }
.modal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--gold-line); }
.modal-head h3 { font-size: 17px; }
.modal-head .x { margin-inline-start: auto; cursor: pointer; color: var(--txt-3); font-size: 22px; line-height: 1; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-start; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }

/* -------------------------------- toast ---------------------------------- */
#toasts { position: fixed; bottom: 20px; inset-inline-start: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  min-width: 260px; max-width: 380px; padding: 13px 16px; border-radius: 13px; font-size: 13.5px; font-weight: 600;
  background: var(--toast-bg); border: 1px solid var(--gold-line);
  box-shadow: var(--shadow); animation: slideIn .25s ease;
}
.toast.ok { border-color: var(--ok-line-strong); }
.toast.err { border-color: var(--danger-line-strong); }
@keyframes slideIn { from { transform: translateY(14px); opacity: 0; } }

/* -------------------------------- tabs ----------------------------------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tab { padding: 10px 16px; cursor: pointer; color: var(--txt-3); font-weight: 700; font-size: 13.5px; border-bottom: 2px solid transparent; }
.tab:hover { color: var(--txt); }
.tab.active { color: var(--gold-2); border-bottom-color: var(--gold-fg); }

/* -------------------------------- misc ----------------------------------- */
.toolbar { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input, .toolbar select { width: auto; min-width: 150px; }
.empty { text-align: center; padding: 46px 20px; color: var(--txt-3); }
.empty .big { font-size: 40px; margin-bottom: 10px; opacity: .6; }
.loading { display: grid; place-items: center; padding: 60px; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--gold-ring); border-top-color: var(--gold-fg); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.divider { height: 1px; background: var(--line); margin: 16px 0; }
.pill-list { display: flex; gap: 6px; flex-wrap: wrap; }
.stat-line { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.stat-line .k { color: var(--txt-3); }
.stat-line .v { font-weight: 700; }
.progress { height: 8px; border-radius: 8px; background: var(--track); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--bar-grad); }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; direction: ltr; display: inline-block; }
.note-box { background: var(--info-soft-2); border: 1px solid var(--info-line-2); border-radius: var(--r-md); padding: 12px 14px; font-size: 12.5px; color: var(--info-ink-2); line-height: 1.9; }
.note-box.warn { background: var(--warn-soft-2); border-color: var(--warn-line-2); color: var(--warn-ink-2); }

/* ------------------------------ login page -------------------------------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(430px, 100%); background: var(--login-card-bg); border: 1px solid var(--gold-line); border-radius: 26px; padding: 34px 30px; box-shadow: var(--shadow); text-align: center; }
.login-card .ofoq-logo { margin: 0 auto 18px; }
.login-card h2 { font-size: 19px; margin-bottom: 6px; }
.login-card .s { color: var(--txt-3); font-size: 12.5px; margin-bottom: 22px; }
.login-card .field { text-align: right; }
.demo-users { margin-top: 20px; padding-top: 16px; border-top: 1px dashed var(--gold-line); font-size: 12px; color: var(--txt-3); }
.demo-users .u { display: inline-block; margin: 3px; padding: 4px 9px; border-radius: 8px; background: var(--panel); border: 1px solid var(--line-chip); cursor: pointer; }
.demo-users .u:hover { border-color: var(--gold-fg); color: var(--gold-2); }

/* ------------------------------ member mobile ----------------------------- */
.m-app { max-width: 560px; margin: 0 auto; padding: 16px 16px 90px; }
.m-head { display: flex; align-items: center; gap: 12px; padding: 14px 4px 18px; }
.m-hero { background: var(--hero-bg); border: 1px solid var(--gold-line); border-radius: 24px; padding: 22px; text-align: center; margin-bottom: 16px; }
.m-hero .greet { font-size: 19px; font-weight: 800; }
.m-hero .ev { color: var(--gold-2); font-size: 13.5px; margin-top: 5px; }
.m-hero .date { color: var(--txt-3); font-size: 12.5px; margin-top: 8px; }
.m-status { margin: 18px 0; padding: 16px; border-radius: 18px; background: var(--inset-bg); border: 1px dashed var(--gold-line); }
.m-status .st { font-size: 17px; font-weight: 800; }
.m-times { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.m-times .t { background: var(--surf-soft); border-radius: 14px; padding: 12px; }
.m-times .t .k { font-size: 11px; color: var(--txt-3); }
.m-times .t .v { font-size: 19px; font-weight: 800; margin-top: 3px; }
.big-action { padding: 24px; font-size: 19px; font-weight: 800; border-radius: 22px; width: 100%; border: none; cursor: pointer; box-shadow: 0 14px 34px var(--gold-glow); }
.big-action.in { background: linear-gradient(135deg, var(--gold-hi), var(--gold), var(--gold-3)); color: var(--on-gold); }
.big-action.out { background: var(--danger-grad); color: var(--on-danger-strong); box-shadow: 0 14px 34px var(--danger-glow); }
.big-action:disabled { opacity: .5; }
.geo-line { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 12.5px; color: var(--txt-3); margin-top: 12px; }
/* ---------------------------------------------------------------------------
   Mobile bottom bar (global rule 25-ب) — the app-style quick bar every user
   gets under 768px. Built by renderShell() in public/js/app.js from the same
   permission checks the sidebar uses, so a link never appears for a user who
   cannot open it. It is hidden above the breakpoint, in print, and behind the
   modal scrim (z-index 80 < .modal-back 100), and it steps out of the way when
   the on-screen keyboard opens (`.is-hidden`, set on focusin).
   --------------------------------------------------------------------------- */
.ofoq-mnav { display: none; }
.ofoq-mnav__list { display: flex; margin: 0; padding: 0; list-style: none; height: var(--mnav-h); }
.ofoq-mnav__list > li { flex: 1 1 0; min-width: 0; }
.ofoq-mnav__link {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  width: 100%; height: 100%; min-width: 44px; padding: 6px 3px;
  background: none; border: 0; cursor: pointer;
  color: var(--txt-3); font-family: inherit; font-size: 11px; font-weight: 700;
  line-height: 1.2; text-align: center; text-decoration: none;
}
.ofoq-mnav__link .i { font-size: 19px; line-height: 1; }
.ofoq-mnav__link .t { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ofoq-mnav__link[aria-current="page"] { color: var(--gold-2); }
.ofoq-mnav__link[aria-current="page"] .i { filter: drop-shadow(0 0 6px var(--gold-glow)); }
.ofoq-mnav__link:focus-visible { outline: 3px solid var(--focus-outline); outline-offset: -3px; border-radius: 10px; }
.ofoq-mnav__badge {
  position: absolute; top: 4px; inset-inline-end: 50%; transform: translateX(50%) translateX(14px);
  min-width: 17px; height: 17px; padding: 0 4px; border-radius: 10px;
  background: var(--danger); color: var(--on-danger);
  font-size: 10px; font-weight: 700; line-height: 17px;
}
.ofoq-mnav__link { position: relative; }

/* Drawer backdrop: without it the sidebar could only be closed from its own links. */
.sidebar-scrim { display: none; position: fixed; inset: 0; z-index: 85; background: var(--scrim); backdrop-filter: blur(3px); }
.sidebar-scrim.on { display: block; }

/* --------------------------------- map ------------------------------------ */
.map { position: relative; width: 100%; height: 340px; border-radius: var(--r-md); overflow: hidden; border: 1px solid var(--gold-line); background: var(--map-bg); cursor: grab; touch-action: none; }
.map.dragging { cursor: grabbing; }
.map .tiles { position: absolute; inset: 0; }
.map .tiles img { position: absolute; width: 256px; height: 256px; user-select: none; -webkit-user-drag: none; }
.map .marker { position: absolute; width: 22px; height: 22px; margin: -22px 0 0 -11px; pointer-events: none; font-size: 20px; line-height: 1; filter: drop-shadow(0 2px 4px var(--marker-shadow)); }
.map .fence { position: absolute; border-radius: 50%; border: 2px solid var(--gold); background: var(--gold-soft); pointer-events: none; transform: translate(-50%, -50%); }
.map .me { position: absolute; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: var(--map-me); border: 2px solid var(--map-me-ring); box-shadow: 0 0 0 6px var(--map-me-halo); pointer-events: none; }
.map .zoom { position: absolute; top: 10px; inset-inline-start: 10px; display: flex; flex-direction: column; gap: 4px; z-index: 5; }
.map .zoom button { width: 32px; height: 32px; border-radius: 9px; background: var(--map-ctl-bg); border: 1px solid var(--map-line); color: var(--map-ctl-fg); font-size: 17px; cursor: pointer; }
.map .hint { position: absolute; bottom: 8px; inset-inline-start: 8px; font-size: 10.5px; color: var(--map-hint-fg); background: var(--map-hint-bg); padding: 4px 9px; border-radius: 8px; z-index: 5; }
.map .attr { position: absolute; bottom: 4px; inset-inline-end: 6px; font-size: 9.5px; color: var(--map-attr-fg); background: var(--map-attr-bg); padding: 2px 6px; border-radius: 6px; z-index: 5; }
.map.mini { height: 190px; }

/* place search + picked-location readout (event location picker) */
.geo-search { position: relative; margin-bottom: 10px; }
.geo-input { display: flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--gold-line); border-radius: var(--r-md); padding: 0 12px; }
.geo-input .ico { font-size: 14px; opacity: .8; }
.geo-input input { flex: 1; background: none; border: 0; outline: none; color: var(--txt); font: inherit; font-size: 13.5px; padding: 11px 0; }
.geo-input input::placeholder { color: var(--txt-3); }
.geo-input:focus-within { border-color: var(--gold-fg); box-shadow: 0 0 0 3px var(--gold-soft); }
.geo-clear { background: none; border: 0; color: var(--txt-3); font-size: 13px; cursor: pointer; padding: 4px; }
.geo-clear:hover { color: var(--gold-fg); }
.geo-results { position: absolute; inset-inline: 0; top: calc(100% + 6px); z-index: 30; max-height: 260px; overflow-y: auto; background: var(--pop-bg); border: 1px solid var(--gold-line); border-radius: var(--r-md); box-shadow: var(--shadow-pop); }
.geo-item { display: block; width: 100%; text-align: start; background: none; border: 0; border-bottom: 1px solid var(--line-soft); padding: 9px 13px; cursor: pointer; color: var(--txt); }
.geo-item:last-child { border-bottom: 0; }
.geo-item:hover, .geo-item.on { background: var(--gold-soft); }
.geo-item .ttl { display: block; font-size: 13px; font-weight: 600; }
.geo-item .sub { display: block; font-size: 11px; color: var(--txt-3); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.geo-msg { padding: 11px 13px; font-size: 12.5px; color: var(--txt-3); }
.geo-msg.err { color: var(--danger-ink); }
.geo-picked { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; padding: 9px 12px; background: var(--panel); border: 1px solid var(--gold-line); border-radius: var(--r-md); font-size: 12.5px; }
.geo-picked .addr { flex: 1; min-width: 180px; color: var(--txt-2); }
.geo-picked .coords { color: var(--gold-2); }
.sm-select { padding: 6px 11px; font-size: 12.5px; border-radius: 9px; width: auto; }
.btn.xs { padding: 4px 9px; font-size: 11.5px; border-radius: 8px; }

/* -------------------------------- charts ---------------------------------- */
.chart { width: 100%; overflow: hidden; }
.chart svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--txt-2); margin-top: 10px; justify-content: center; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-inline-end: 5px; }

/* ------------------------------ import table ------------------------------- */
.imp-table td { text-align: right; }
.imp-table input { padding: 6px 8px; font-size: 12.5px; border-radius: 7px; min-width: 90px; }
tr.row-error td { background: var(--danger-soft-2); }
tr.row-warn td { background: var(--warn-soft-2); }
.drop-zone { border: 2px dashed var(--gold-line); border-radius: var(--r-lg); padding: 44px 20px; text-align: center; cursor: pointer; transition: .18s; background: var(--surf-faint); }
.drop-zone:hover, .drop-zone.over { border-color: var(--gold-fg); background: var(--gold-soft); }
.drop-zone .big { font-size: 44px; margin-bottom: 10px; }

/* ------------------------------ permissions -------------------------------- */
.perm-grid { display: grid; gap: 14px; }
.perm-module { border: 1px solid var(--line-2); border-radius: var(--r-md); overflow: hidden; }
.perm-module > .h { background: var(--surf-soft); padding: 11px 14px; font-weight: 700; font-size: 13.5px; display: flex; align-items: center; gap: 8px; }
.perm-module > .h .c { margin-inline-start: auto; font-size: 11.5px; color: var(--txt-3); }
.perm-module .b { padding: 12px 14px; display: flex; gap: 8px; flex-wrap: wrap; }
.perm-chip { display: flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 10px; background: var(--inset-bg); border: 1px solid var(--line-chip); font-size: 12.5px; cursor: pointer; user-select: none; }
.perm-chip.on { background: var(--gold-soft); border-color: var(--gold-line); color: var(--gold-2); }
.perm-chip.disabled { opacity: .4; text-decoration: line-through; }

/* ------------------------------ responsive --------------------------------- */
.mobile-only { display: none; }

/* A two-column page layout whose first column is a fixed-width rail (reports list, role list).
   It is a class and not an inline style so that this file can collapse it on a phone — an
   inline `grid-template-columns:300px 1fr` cannot be overridden by a media query, and that is
   exactly what pushed the reports screen 589px wide inside a 360px viewport. */
.g-rail { grid-template-columns: var(--rail-w, 300px) minmax(0, 1fr); }

@media (max-width: 1100px) { .g-4 { grid-template-columns: repeat(2, 1fr); } .g-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 900px) {
  /*
   * The drawer slides in from the inline-start edge — the same side the sidebar occupies on a
   * wide screen, which in this RTL interface is the right. `inset-inline-end` put it on the
   * left, and because `transform` is physical (never mirrored by `dir`), the closed state
   * `translateX(100%)` moved it 264px to the RIGHT: straight into the viewport, on top of the
   * page, on every screen under 900px. Both directions are spelled out below so the document
   * stays correct if `ofoq_fullscreen_html_dir` ever flips it to ltr.
   */
  .sidebar {
    position: fixed; inset-inline-start: 0; top: 0; z-index: 90;
    height: 100vh; height: 100dvh; transition: transform .22s;
  }
  html[dir="rtl"] .sidebar { transform: translateX(100%); }
  html[dir="ltr"] .sidebar, html:not([dir]) .sidebar { transform: translateX(-100%); }
  html[dir="rtl"] .sidebar.open,
  html[dir="ltr"] .sidebar.open,
  html:not([dir]) .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-drawer); }
  @media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }

  .mobile-only { display: inline-flex; }
  .content { padding: 14px; }
  .g-2, .g-3, .g-4, .g-rail, .row.c2, .row.c3, .row.c4 { grid-template-columns: minmax(0, 1fr); }
  .sheet-meta { grid-template-columns: 1fr; }
  .sheet-meta .cell { border-inline-start: 0; border-top: 1px solid var(--gold-line); }
  .sheet-notes { grid-template-columns: 1fr; }
  .topbar h1 { font-size: 15px; }
  .sheet-doc { padding: 14px; }
  .sheet-doc .doc-title { font-size: 19px; padding: 10px 20px; }
}

/* ---- phone: the bottom bar, and everything that has to make room for it (rule 25) ---- */
@media (max-width: 767.98px) {
  .ofoq-mnav {
    display: block; position: fixed; inset-inline: 0; bottom: 0; z-index: 80;
    height: calc(var(--mnav-h) + var(--safe-b));
    padding-bottom: var(--safe-b);
    background: var(--tabbar-bg); border-top: 1px solid var(--gold-line);
    box-shadow: var(--shadow-mnav); backdrop-filter: blur(10px);
    transition: transform .2s ease;
  }
  /* The on-screen keyboard would otherwise sit on top of the field being typed into. */
  .ofoq-mnav.is-hidden { transform: translateY(100%); }
  @media (prefers-reduced-motion: reduce) { .ofoq-mnav { transition: none; } }

  /* Nothing may end up underneath the bar: page content, the member screen, the toasts. */
  .content, .m-app { padding-bottom: calc(var(--mnav-h) + var(--safe-b) + 18px); }
  #toasts { bottom: calc(var(--mnav-h) + var(--safe-b) + 12px); inset-inline-start: 12px; inset-inline-end: 12px; }
  .toast { min-width: 0; max-width: none; }

  /*
   * 16px is the threshold under which iOS Safari zooms the whole page the moment a field takes
   * focus — and the page never zooms back. Every control gets it, not only text inputs.
   */
  input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=range]):not([type=color]),
  select, textarea { font-size: 16px; }
  .sm-select, .imp-table input { padding: 9px 11px; }

  /* Touch targets: 44px is the minimum comfortable finger target (rule 25-أ). */
  .icon-btn { width: 44px; height: 44px; flex: none; }
  .btn { min-height: 44px; }
  /* The compact buttons live inside table rows, where they are the only thing a finger has to
     hit; they keep their small type but not their small box. */
  .btn.sm, .btn.xs { min-height: 44px; min-width: 44px; justify-content: center; }
  /* Four stacked tabs eat half a phone screen before the form starts, so the strip scrolls
     sideways instead — inside its own scroll container, so the page never moves with it. */
  .tabs { flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
  .tab { flex: none; min-height: 44px; display: flex; align-items: center; white-space: nowrap; }
  .nav-item { padding: 13px; }
  .user-chip { padding: 6px 10px; min-height: 44px; }
  .modal-head .x { min-width: 44px; min-height: 44px; display: grid; place-items: center; }

  /* A card heading carries a title and a row of counters; side by side they squeeze the title
     into a three-line column, so the counters drop to their own line instead. */
  .card h3 { flex-wrap: wrap; }
  .card h3 .h3-stats { margin-inline-start: 0; width: 100%; }

  .topbar { padding: 8px 12px; gap: 8px; }
  .topbar h1 { font-size: 14.5px; }
  .topbar .sub { display: none; }
  .page-head { margin-bottom: 14px; }
  .page-head .actions { width: 100%; }
  .page-head .actions .toolbar { width: 100%; }
  .toolbar input, .toolbar select { min-width: 0; flex: 1 1 140px; }
  .kpi .value { font-size: 24px; }
  .user-chip .nm, .user-chip .rl { display: none; }

  .modal-back { padding: 10px; align-items: flex-start; }
  .modal { max-height: calc(100vh - 20px); padding: 16px; }
  .modal.lg, .modal.sm { width: 100%; }

  /*
   * `touch-action: none` on the map swallowed the vertical swipe as well, so a finger landing
   * on a full-width map could not scroll the page past it. `pan-y` leaves the vertical gesture
   * to the browser and keeps the horizontal drag for panning; the pointercancel the browser
   * then fires is already handled by public/js/map.js.
   */
  .map { height: 260px; touch-action: pan-y; }
  .map.mini { height: 180px; }
  .map .zoom button { width: 44px; height: 44px; font-size: 20px; }

  .sign-row { grid-template-columns: 1fr; }
  .sheet-doc .doc-title { font-size: 17px; padding: 9px 16px; }
  /*
   * The table already scrolls inside its own box, so squeezing it to 640px only breaks every
   * Arabic name onto three lines. Give the columns room and let the box scroll: a wider table
   * on a phone reads better than a narrow one, as long as the page itself never moves.
   */
  .table-wrap { overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
  .table-wrap table { min-width: 760px; }
  .t-name { white-space: nowrap; }
  /*
   * A name inside a table cell is a 17px-tall line of text, which is a 17px-tall tap target.
   * Growing the element itself would grow the row; an absolutely positioned ::after grows only
   * the area a finger has to hit, to 45×44, and leaves the layout exactly where it was.
   */
  .table-wrap td a,
  .card h3 a { position: relative; }
  .table-wrap td a::after,
  .card h3 a::after { content: ''; position: absolute; top: -14px; bottom: -14px; left: -8px; right: -8px; }
  /* A call to action inside a notice is a button in everything but markup. */
  .note-box a { display: inline-flex; align-items: center; min-height: 44px; }
}

@media (max-width: 560px) {
  .m-times { gap: 8px; }
  .big-action { padding: 20px; font-size: 17px; }
}

/* -------------------------------- print ------------------------------------ */
@media print {
  body { background: var(--print-bg) !important; color: var(--print-fg); }
  .sidebar, .topbar, .no-print, .ofoq-mnav, .sidebar-scrim, #toasts, .theme-toggle { display: none !important; }
  .content, .m-app { padding-bottom: 0 !important; }
  .content { padding: 0; }
  .sheet-doc { background: var(--print-bg) !important; border-color: var(--print-gold-line); color: var(--print-ink); }
  .sheet-doc .doc-title { background: var(--print-title-bg) !important; color: var(--print-ink); }
  .sheet-doc .doc-sub, .sheet-meta .k { color: var(--print-muted); }
  .sheet-meta { background: var(--print-meta-bg); }
  .sheet-meta .v, .sheet-notes ul { color: var(--print-ink) !important; }
  thead th { background: var(--print-thead-bg) !important; color: var(--print-thead-fg) !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  tfoot td { background: var(--print-tfoot-bg) !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  table.sheet tbody td { background: var(--print-bg) !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .card { background: var(--print-bg) !important; border-color: var(--print-line); box-shadow: none; color: var(--print-fg); }
}
