/* =====================================================================
   VLMS design system
   ---------------------------------------------------------------------
   EVERY colour, size and radius used by the application is a custom
   property declared in :root below.  To restyle the whole product,
   change values here — nothing else needs editing.

   The three branding colours (primary, accent, sidebar) are overridden
   at runtime from Administration → Branding, so they are read from
   --brand-* first and fall back to the values here.
   ===================================================================== */

:root {
  /* ---- brand (overridable from the admin screen) ------------------ */
  --brand-primary: #12385A;
  --brand-accent:  #1C6E8C;
  --brand-sidebar: #0E2438;

  /* ---- ink -------------------------------------------------------- */
  --ink:        #0F1A24;
  --ink-2:      #4C5A66;
  --muted:      #7C8A96;
  --on-brand:   #FFFFFF;

  /* ---- surfaces --------------------------------------------------- */
  --surface:    #FFFFFF;
  --plane:      #F4F7F9;
  --raised:     #FAFCFD;
  --line:       #E4E9EE;
  --line-soft:  #EEF2F5;
  --sidebar-2:  #16334C;
  --sidebar-tx: #A9C0D2;
  --sidebar-mt: #5F7F97;

  /* ---- status (icon + label always accompany these) --------------- */
  --good:     #0CA30C;
  --warn:     #FAB219;
  --serious:  #EC835A;
  --critical: #D03B3B;
  --good-bg:     #E7F6E7; --good-fg:     #0A6B0A;
  --warn-bg:     #FEF4E0; --warn-fg:     #7A5406;
  --serious-bg:  #FDEDE6; --serious-fg:  #8A3F1B;
  --critical-bg: #FBE9E9; --critical-fg: #8E2020;
  --neutral-bg:  #EEF2F5; --neutral-fg:  #4C5A66;
  --brand-bg:    #E8F2F6;

  /* ---- data marks (validated for colour-vision deficiency) -------- */
  --data-1: #2a78d6;
  --ord-1: #86b6ef; --ord-2: #5598e7; --ord-3: #2a78d6; --ord-4: #184f95;

  /* ---- geometry --------------------------------------------------- */
  --radius:    8px;
  --radius-sm: 6px;
  --radius-pill: 20px;
  --sidebar-w: 216px;
  --gap:  14px;
  --pad:  16px;

  /* ---- type ------------------------------------------------------- */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
          "Noto Sans", "Noto Sans Arabic", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --fs-base: 14px;

  --shadow-1: 0 1px 2px rgba(15,26,36,.06);
  --shadow-2: 0 4px 16px rgba(15,26,36,.10);
  --shadow-3: 0 12px 40px rgba(15,26,36,.18);
}

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--plane);
  color: var(--ink);
  font: var(--fs-base)/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
p { margin: 0 0 10px; }
a { color: var(--brand-accent); }
img { max-width: 100%; }
[hidden] { display: none !important; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
:focus-visible { outline: 2px solid var(--brand-accent); outline-offset: 2px; border-radius: 4px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ================================================================ login */
.login-wrap {
  min-height: 100%; display: flex; align-items: center; justify-content: center;
  padding: 24px; background:
    radial-gradient(1100px 520px at 50% -10%, rgba(28,110,140,.16), transparent 65%),
    var(--plane);
}
.login-card {
  width: 100%; max-width: 400px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow-2); padding: 30px 28px;
}
.login-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 6px; }
.login-brand img { max-height: 40px; max-width: 170px; object-fit: contain; }
.login-card h1 { font-size: 20px; margin-bottom: 3px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.login-hint {
  margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line-soft);
  font-size: 12px; color: var(--muted); line-height: 1.6;
}

/* ================================================================ shell */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  background: var(--brand-sidebar); color: #fff;
  padding: 14px 0 26px; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 16px 16px; min-height: 46px;
}
.sidebar .brand img { max-height: 32px; max-width: 150px; object-fit: contain; }
.logo-mark {
  width: 28px; height: 28px; border-radius: 7px; background: var(--brand-accent);
  display: grid; place-items: center; font-size: 13px; font-weight: 800; color: #fff; flex: none;
}
.brand-name { font-size: 14px; font-weight: 700; letter-spacing: .2px; }

.nav-group {
  padding: 13px 16px 5px; font-size: 9.5px; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--sidebar-mt); font-weight: 700;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 16px; font-size: 13px; color: var(--sidebar-tx);
  border-left: 3px solid transparent; text-align: left; text-decoration: none;
}
.nav-item:hover { background: var(--sidebar-2); color: #fff; }
.nav-item.active { background: var(--sidebar-2); color: #fff; border-left-color: var(--brand-accent); font-weight: 600; }
.nav-item .ic { width: 16px; text-align: center; font-size: 12px; opacity: .9; flex: none; }
.nav-item .count {
  margin-left: auto; background: var(--critical); color: #fff;
  font-size: 10px; font-weight: 700; border-radius: 9px; padding: 1px 6px; min-width: 18px; text-align: center;
}
.sidebar-foot { margin-top: auto; padding: 14px 16px 0; font-size: 11px; color: var(--sidebar-mt); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding: 10px 22px; display: flex; align-items: center; gap: 12px;
  position: sticky; top: 0; z-index: 20;
}
.crumb { font-size: 12px; color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumb b { color: var(--ink); font-weight: 600; }
.spacer { flex: 1; }
.hamburger { display: none; font-size: 19px; padding: 4px 8px; border-radius: 6px; }
.hamburger:hover { background: var(--plane); }

.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--brand-bg);
  color: var(--brand-primary); display: grid; place-items: center;
  font-size: 11.5px; font-weight: 700; flex: none;
}
.usermenu { position: relative; }
.usermenu-pop {
  position: absolute; right: 0; top: 38px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-2); min-width: 210px; padding: 6px; z-index: 40;
}
.usermenu-pop .who { padding: 9px 11px; border-bottom: 1px solid var(--line-soft); margin-bottom: 5px; }
.usermenu-pop .who b { display: block; font-size: 13px; }
.usermenu-pop .who span { font-size: 11.5px; color: var(--muted); }
.usermenu-pop button {
  display: block; width: 100%; text-align: left; padding: 8px 11px;
  border-radius: var(--radius-sm); font-size: 13px;
}
.usermenu-pop button:hover { background: var(--plane); }

.canvas { padding: 20px 22px 48px; flex: 1; }
.page-head { margin-bottom: 18px; }
.page-head h2 { font-size: 20px; margin-bottom: 3px; }
.page-head p { color: var(--ink-2); font-size: 13px; max-width: 780px; margin: 0; }
.page-head .row { display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap; }

/* ============================================================= controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: var(--radius-sm); padding: 7px 14px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  white-space: nowrap; transition: filter .12s, background .12s;
}
.btn:hover:not(:disabled) { background: var(--raised); }
.btn.primary { background: var(--brand-primary); color: #fff; border-color: var(--brand-primary); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.15); background: var(--brand-primary); }
.btn.good { background: var(--good); color: #fff; border-color: var(--good); }
.btn.good:hover:not(:disabled) { filter: brightness(1.08); background: var(--good); }
.btn.danger { color: var(--critical-fg); border-color: #EFC8C8; background: var(--surface); }
.btn.danger:hover:not(:disabled) { background: var(--critical-bg); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover:not(:disabled) { background: var(--plane); }
.btn.sm { padding: 4.5px 10px; font-size: 12px; }
.btn:disabled { background: #EDF1F4; color: #A3AFB9; border-color: var(--line); cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.field { margin-bottom: 14px; }
.field > label {
  display: block; font-size: 11px; font-weight: 700; letter-spacing: .4px;
  text-transform: uppercase; color: var(--muted); margin-bottom: 5px;
}
.field .req { color: var(--critical); }
.input, select.input, textarea.input {
  width: 100%; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 8px 11px; font-size: 13px; background: var(--surface); color: var(--ink);
  -webkit-appearance: none; appearance: none;
}
select.input {
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%237C8A96' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px;
}
textarea.input { min-height: 84px; resize: vertical; line-height: 1.5; }
.input:focus { border-color: var(--brand-accent); box-shadow: 0 0 0 3px var(--brand-bg); outline: none; }
.input.invalid { border-color: var(--critical); }
.field .help { font-size: 11.5px; color: var(--muted); margin-top: 5px; }

.check { display: flex; align-items: flex-start; gap: 9px; font-size: 13px; cursor: pointer; }
.check input { margin: 3px 0 0; width: 15px; height: 15px; accent-color: var(--brand-accent); flex: none; }

.filters {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px;
}
.filters .input { width: auto; min-width: 150px; }
.filters .grow { flex: 1; min-width: 190px; }

/* ================================================================ cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card + .card { margin-top: var(--gap); }
.card-head {
  padding: 12px 16px; border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.card-head h3 { font-size: 14px; }
.card-head .sub { font-size: 11.5px; color: var(--muted); font-weight: 400; }
.card-head .right { margin-left: auto; display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
.card-body { padding: 15px 16px; }
.card-body.tight { padding: 0; }

.grid { display: grid; gap: var(--gap); }
.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)); }
.g-main { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }

.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .label {
  font-size: 10.5px; letter-spacing: .9px; text-transform: uppercase;
  color: var(--muted); font-weight: 700; margin-bottom: 6px;
}
.stat .value { font-size: 30px; font-weight: 700; letter-spacing: -.02em; line-height: 1.05; }
.stat .value .unit { font-size: 15px; color: var(--muted); font-weight: 600; margin-left: 2px; }
.stat .foot {
  margin-top: 9px; padding-top: 9px; border-top: 1px solid var(--line-soft);
  font-size: 11.5px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}

/* =============================================================== status */
.pill {
  display: inline-flex; align-items: center; gap: 5px; border-radius: var(--radius-pill);
  padding: 2.5px 9px; font-size: 11px; font-weight: 650; white-space: nowrap;
  background: var(--neutral-bg); color: var(--neutral-fg);
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.pill.good     { background: var(--good-bg);     color: var(--good-fg); }
.pill.warn     { background: var(--warn-bg);     color: var(--warn-fg); }
.pill.serious  { background: var(--serious-bg);  color: var(--serious-fg); }
.pill.critical { background: var(--critical-bg); color: var(--critical-fg); }
.pill.brand    { background: var(--brand-bg);    color: var(--brand-primary); }
.pill.lg { padding: 5px 12px; font-size: 12px; }

.days {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 54px; padding: 5px 7px; border-radius: 7px; line-height: 1.1;
  background: var(--neutral-bg); color: var(--neutral-fg);
}
.days b { font-size: 16px; font-weight: 750; }
.days span { font-size: 8.5px; letter-spacing: .5px; text-transform: uppercase; opacity: .85; margin-top: 1px; }
.days.good     { background: var(--good-bg);     color: var(--good-fg); }
.days.warn     { background: var(--warn-bg);     color: var(--warn-fg); }
.days.serious  { background: var(--serious-bg);  color: var(--serious-fg); }
.days.critical { background: var(--critical-bg); color: var(--critical-fg); }

.banner {
  border-radius: 7px; padding: 11px 14px; font-size: 13px;
  display: flex; gap: 10px; align-items: flex-start; margin-bottom: var(--gap);
}
.banner .bi { flex: none; font-weight: 800; line-height: 1.4; }
.banner.info     { background: var(--brand-bg);    border: 1px solid #C4DBE5; color: #113F53; }
.banner.good     { background: var(--good-bg);     border: 1px solid #B6E2B6; color: #0A5A0A; }
.banner.warn     { background: var(--warn-bg);     border: 1px solid #F0D391; color: #6B4A08; }
.banner.critical { background: var(--critical-bg); border: 1px solid #EFC2C2; color: #7E1F1F; }
.banner p:last-child { margin: 0; }

/* =============================================================== tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 10.5px; letter-spacing: .8px; text-transform: uppercase;
  color: var(--muted); font-weight: 700; padding: 9px 12px;
  border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface);
}
td { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); font-size: 12.5px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--raised); }
tbody tr.flag-row { background: #FDF4F4; }
.mono { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-2); }
.strong { font-weight: 650; }
.small { font-size: 11px; color: var(--muted); }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.empty { padding: 42px 20px; text-align: center; color: var(--muted); font-size: 13px; }
.empty .big { font-size: 26px; margin-bottom: 8px; opacity: .5; }

/* ========================================================= action rows */
.action-row {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); margin-bottom: 8px;
}
.action-row .body { flex: 1; min-width: 0; }
.action-row .t { font-size: 13.5px; font-weight: 650; line-height: 1.35; }
.action-row .m { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* ======================================================= approval chain */
.chain { display: flex; flex-direction: column; }
.step { display: flex; gap: 13px; }
.rail { display: flex; flex-direction: column; align-items: center; flex: 0 0 28px; }
.node {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; border: 2px solid var(--line);
  background: var(--surface); color: var(--muted); flex: none;
}
.node.done   { background: var(--good); border-color: var(--good); color: #fff; }
.node.active { border-color: var(--brand-accent); color: var(--brand-accent); box-shadow: 0 0 0 4px var(--brand-bg); }
.node.reject { background: var(--critical); border-color: var(--critical); color: #fff; }
.node.skip   { background: var(--plane); }
.node.info   { background: var(--warn); border-color: var(--warn); color: #fff; }
.rail .line { width: 2px; flex: 1; background: var(--line); min-height: 18px; }
.rail .line.done { background: var(--good); }
.step-body { flex: 1; min-width: 0; padding-bottom: 16px; }
.step-body .st { font-size: 13px; font-weight: 650; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.step-body .sm { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.step-body .note {
  margin-top: 7px; background: var(--plane); border-left: 2px solid var(--line);
  padding: 7px 10px; border-radius: 0 5px 5px 0; font-size: 11.5px; color: var(--ink-2);
}
.parallel { border: 1px dashed var(--line); border-radius: 7px; padding: 9px 11px; background: var(--raised); }
.parallel .ph {
  font-size: 9.5px; letter-spacing: 1px; text-transform: uppercase;
  color: var(--muted); font-weight: 700; margin-bottom: 8px;
}

/* ================================================================ chart */
.bars { display: flex; flex-direction: column; gap: 8px; }
.brow { display: grid; grid-template-columns: minmax(90px, 150px) 1fr 62px; align-items: center; gap: 10px; }
.brow .bl { font-size: 12px; color: var(--ink-2); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btrack { background: var(--line-soft); border-radius: 3px; height: 18px; overflow: hidden; }
.bfill { height: 100%; border-radius: 0 4px 4px 0; background: var(--data-1); min-width: 2px; }
.brow .bv { font-size: 12px; font-weight: 650; text-align: right; font-variant-numeric: tabular-nums; }
.stack { display: flex; height: 26px; border-radius: 5px; overflow: hidden; gap: 2px; background: var(--surface); }
.stack > div { height: 100%; min-width: 3px; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 11px; }
.legend .lg { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--ink-2); }
.legend .lg i { width: 11px; height: 11px; border-radius: 3px; display: block; flex: none; }

/* ================================================================ modal */
.modal-back {
  position: fixed; inset: 0; background: rgba(15,26,36,.45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 28px 16px; z-index: 100; overflow-y: auto;
}
.modal {
  background: var(--surface); border-radius: 11px; box-shadow: var(--shadow-3);
  width: 100%; max-width: 620px; margin: auto;
}
.modal.wide { max-width: 860px; }
.modal-head {
  padding: 15px 20px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
}
.modal-head h3 { font-size: 16px; }
.modal-head .x { margin-left: auto; font-size: 20px; color: var(--muted); line-height: 1; padding: 2px 6px; border-radius: 5px; }
.modal-head .x:hover { background: var(--plane); }
.modal-body { padding: 18px 20px; }
.modal-foot {
  padding: 13px 20px; border-top: 1px solid var(--line);
  display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap;
}

/* ================================================================ toast */
/* Toasts sit top-right and never intercept clicks, so they can never
   cover a modal's action buttons or block a control underneath. */
.toasts {
  position: fixed; right: 16px; top: 64px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--ink); color: #fff; border-radius: var(--radius-sm);
  padding: 11px 15px; font-size: 13px; box-shadow: var(--shadow-2);
  max-width: 380px; animation: toast-in .16s ease-out;
}
.toast.error { background: var(--critical); }
.toast.ok { background: var(--good); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

.spinner {
  width: 20px; height: 20px; border: 2px solid var(--line);
  border-top-color: var(--brand-accent); border-radius: 50%;
  animation: spin .7s linear infinite; margin: 32px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* =========================================================== responsive */
.scrim { display: none; }

@media (max-width: 1080px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-main { grid-template-columns: 1fr; }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 780px) {
  :root { --fs-base: 15px; --pad: 13px; }
  .hamburger { display: inline-flex; }

  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 60;
    transform: translateX(-100%); transition: transform .18s ease-out;
    box-shadow: var(--shadow-3);
  }
  .app.nav-open .sidebar { transform: none; }
  .app.nav-open .scrim {
    display: block; position: fixed; inset: 0; background: rgba(15,26,36,.45); z-index: 50;
  }

  .canvas { padding: 15px 13px 60px; }
  .topbar { padding: 9px 13px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }

  .action-row { flex-wrap: wrap; }
  .action-row .body { flex: 1 1 100%; order: 2; }
  .action-row .days { order: 1; }
  .action-row .pill { order: 1; }
  .action-row .btn { order: 3; margin-left: auto; }

  .modal-back { padding: 12px; align-items: stretch; }
  .modal { max-width: 100%; }
  .modal-foot { position: sticky; bottom: 0; background: var(--surface); }
  .modal-foot .btn { flex: 1; }

  .brow { grid-template-columns: minmax(70px, 110px) 1fr 52px; }
  .filters .input { width: 100%; min-width: 0; }
  .filters .grow { flex: 1 1 100%; }
  .toasts { left: 12px; right: 12px; top: 58px; }
  .toast { max-width: none; }

  /* Wide tables scroll horizontally rather than squashing. */
  .table-wrap table { min-width: 620px; }
}

@media (max-width: 420px) {
  .stat .value { font-size: 26px; }
  .page-head h2 { font-size: 18px; }
}

@media print {
  .sidebar, .topbar, .btn, .filters { display: none !important; }
  .canvas { padding: 0; }
  .card { break-inside: avoid; border-color: #ccc; }
}

/* Stack page headers and their action buttons on small screens. */
@media (max-width: 780px) {
  .page-head .row { flex-direction: column; align-items: stretch; gap: 10px; }
  .page-head .row .btn-row { justify-content: flex-start; }
  .page-head .row .days { align-self: flex-start; }
}

/* ============================================================== RTL ===
   `dir="rtl"` on <html> already mirrors every flex/grid layout on its
   own (that's the main axis, controlled by `direction`) — the rules
   below are only for the properties that never auto-mirror: physical
   left/right borders, margins, absolute positioning and text-align. */
[dir="rtl"] { direction: rtl; }

[dir="rtl"] .nav-item {
  border-left: none; border-right: 3px solid transparent; text-align: right;
}
[dir="rtl"] .nav-item.active { border-right-color: var(--brand-accent); }
[dir="rtl"] .nav-item .count { margin-left: 0; margin-right: auto; }

[dir="rtl"] .usermenu-pop { right: auto; left: 0; }
[dir="rtl"] .usermenu-pop button { text-align: right; }

[dir="rtl"] .card-head .right { margin-left: 0; margin-right: auto; }
[dir="rtl"] .stat .value .unit { margin-left: 0; margin-right: 2px; }
[dir="rtl"] .modal-head .x { margin-left: 0; margin-right: auto; }

[dir="rtl"] select.input {
  background-position: left 10px center; padding-right: 11px; padding-left: 30px;
}

[dir="rtl"] .step-body .note {
  border-left: none; border-right: 2px solid var(--line);
  border-radius: 5px 0 0 5px;
}

[dir="rtl"] th { text-align: right; }
[dir="rtl"] .num { text-align: left; }
[dir="rtl"] .brow .bl { text-align: left; }
[dir="rtl"] .bfill { border-radius: 0 4px 4px 0; }

/* Reference codes, dates and quantities read left-to-right even inside
   an Arabic page — flipping digit order would make them wrong, not
   just unfamiliar. */
[dir="rtl"] .mono { direction: ltr; unicode-bidi: embed; text-align: right; }

@media (max-width: 780px) {
  [dir="rtl"] .sidebar {
    left: auto; right: 0; transform: translateX(100%);
  }
  [dir="rtl"] .action-row .btn { margin-left: 0; margin-right: auto; }
}
