/* =====================================================================
   Components — shell, sidebar, cards, tables, forms, modals, etc.
   ===================================================================== */

/* ============ APP SHELL ============ */
.app { min-height: 100vh; }

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ============ SIDEBAR ============ */
.sidebar {
  background:
    radial-gradient(500px 300px at 120% 0%, rgba(18, 196, 138, 0.12), transparent 60%),
    linear-gradient(185deg, var(--ink-850), var(--ink-900) 70%);
  color: #c4d6ce;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-inline-end: 1px solid rgba(255, 255, 255, 0.06);
}
.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 6px 6px 20px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.brand__mark {
  width: 48px; height: 48px;
  border-radius: 15px;
  display: grid; place-content: center;
  color: var(--ink-900);
  background: linear-gradient(145deg, var(--mint-bright), var(--mint));
  box-shadow: 0 8px 20px var(--mint-glow), inset 0 1px 0 rgba(255,255,255,0.4);
  flex-shrink: 0;
}
.brand__mark svg { width: 27px; height: 27px; stroke-width: 2; stroke: var(--ink-900); }
.brand__txt b { color: #fff; font-size: 1rem; display: block; line-height: 1.3; font-weight: 800; letter-spacing: -0.01em; }
.brand__txt span { font-size: var(--fs-xs); color: #7fb8a4; font-weight: 500; }

.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.nav__item {
  position: relative;
  display: flex; align-items: center; gap: 13px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  color: #b3c9c0;
  font-weight: 600;
  transition: background var(--t-fast), color var(--t-fast);
  border: none; background: none; width: 100%; text-align: start;
}
.nav__item svg { width: 21px; height: 21px; flex-shrink: 0; opacity: 0.85; transition: opacity var(--t-fast); }
.nav__item:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.nav__item:hover svg { opacity: 1; }
.nav__item.active {
  background: linear-gradient(100deg, rgba(18,196,138,0.20), rgba(18,196,138,0.06));
  color: #fff;
  font-weight: 800;
}
.nav__item.active::before {
  content: ""; position: absolute; inset-inline-start: 0; top: 22%; bottom: 22%;
  width: 3.5px; border-radius: 999px;
  background: var(--mint-bright);
  box-shadow: 0 0 14px var(--mint-glow);
}
.nav__item.active svg { opacity: 1; color: var(--mint-bright); }
.nav__sep { font-size: var(--fs-xs); color: #6a9788; padding: 14px 13px 5px; letter-spacing: .5px; }

.sidebar__foot { margin-top: auto; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.08); }
.userchip { display: flex; align-items: center; gap: 11px; padding: 8px; border-radius: var(--r-md); background: rgba(255,255,255,0.03); }
.userchip__av {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(145deg, rgba(18,196,138,0.28), rgba(18,196,138,0.12));
  color: var(--mint-bright); border: 1px solid rgba(18,196,138,0.25);
  display: grid; place-content: center; font-weight: 800; flex-shrink: 0; font-size: var(--fs-sm);
}
.userchip__txt b { color: #fff; font-size: var(--fs-sm); display: block; font-weight: 700; }
.userchip__txt span { font-size: var(--fs-xs); color: #7fb8a4; }

/* ============ TOPBAR / MAIN ============ */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: var(--topbar-h);
  background: rgba(242, 246, 244, 0.80);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 50;
}
.topbar h1 { font-size: var(--fs-xl); font-weight: 800; }
.topbar__sub { font-size: var(--fs-xs); color: var(--ink-faint); margin-top: 1px; font-weight: 500; }
.burger { display: none; background: none; border: none; padding: 8px; border-radius: 10px; transition: background var(--t-fast); }
.burger:hover { background: var(--cream-2); }
.burger svg { width: 26px; height: 26px; color: var(--green); }

.content { padding: 24px; max-width: var(--maxw); width: 100%; margin: 0 auto; }
.page-head { margin-bottom: 20px; }
.page-head h2 { font-size: var(--fs-2xl); font-weight: 800; }
.page-head p { color: var(--ink-soft); font-size: var(--fs-sm); }

/* ============ CARDS ============ */
.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
  padding: 20px;
}
.card--pad-lg { padding: 26px; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.card__head h3 { font-size: var(--fs-lg); font-weight: 800; letter-spacing: -0.01em; }

.grid { display: grid; gap: 18px; }
/* Allow grid children to shrink below content width so inner overflow-x
   (e.g. wide tables/charts) scrolls instead of stretching the page. */
.grid > * { min-width: 0; }
canvas { max-width: 100%; }
.grid--kpi { grid-template-columns: repeat(4, 1fr); }
.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--cards { grid-template-columns: repeat(auto-fill, minmax(265px, 1fr)); }
@media (max-width: 1000px) { .grid--kpi { grid-template-columns: repeat(2, 1fr); } .grid--3 { grid-template-columns: 1fr; } }
@media (max-width: 900px)  { .grid--2 { grid-template-columns: 1fr; } }
@media (max-width: 560px)  { .grid--kpi { grid-template-columns: 1fr; } }

/* ============ BENTO DASHBOARD ============ */
/* Asymmetric metric grid: a hero tile (stock value) leads, the rest cluster.
   Driven by CSS only — the view just tags the hero with .kpi--hero. */
.grid--bento {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(4, 1fr);
}
.grid--bento .kpi--hero { grid-column: span 2; grid-row: span 2; }
@media (max-width: 1000px) {
  .grid--bento { grid-template-columns: repeat(2, 1fr); }
  .grid--bento .kpi--hero { grid-column: span 2; grid-row: span 1; }
}
@media (max-width: 520px) {
  .grid--bento { grid-template-columns: 1fr 1fr; }
  .grid--bento .kpi--hero { grid-column: span 2; }
}

/* ============ KPI ============ */
.kpi {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--sh-sm);
  position: relative;
  overflow: hidden;
  transition: transform var(--t-fast), box-shadow var(--t-fast), border-color var(--t-fast);
}
.kpi:hover { transform: translateY(-3px); box-shadow: var(--sh-md); border-color: var(--green-soft); }
/* Top accent rule — intentional, not the side-tab AI tell. */
.kpi::before {
  content: ""; position: absolute; inset-inline: 0; top: 0; height: 4px;
  background: var(--green); opacity: 0.9;
}
.kpi--gold::before { background: var(--gold); }
.kpi--late::before { background: var(--late); }
.kpi--warn::before { background: var(--warn); }
.kpi--ok::before   { background: var(--ok); }
.kpi__icon {
  width: 44px; height: 44px; border-radius: 13px;
  display: grid; place-content: center; margin-bottom: 14px;
  background: var(--green-soft); color: var(--green);
}
.kpi--gold .kpi__icon { background: var(--gold-soft); color: var(--gold-600); }
.kpi--late .kpi__icon { background: var(--late-bg); color: var(--late); }
.kpi--warn .kpi__icon { background: var(--warn-bg); color: var(--warn); }
.kpi--ok .kpi__icon { background: var(--ok-bg); color: var(--ok); }
.kpi__icon svg { width: 23px; height: 23px; }
.kpi__val {
  font-size: var(--fs-3xl);
  font-weight: var(--display-weight);
  line-height: 0.95;
  letter-spacing: var(--display-tracking);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.kpi__label { font-size: var(--fs-sm); color: var(--ink-soft); margin-top: 8px; font-weight: 600; }
.kpi__sub { font-size: var(--fs-xs); color: var(--ink-faint); margin-top: 4px; }

/* Hero KPI — the command tile. Dark ink surface, huge mint-lit number. */
.kpi--hero {
  background:
    radial-gradient(420px 300px at 115% -20%, rgba(18,196,138,0.20), transparent 60%),
    linear-gradient(160deg, var(--ink-850), var(--ink-900));
  border-color: transparent;
  box-shadow: var(--sh-hero);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 28px;
  min-height: 200px;
}
/* Icon floats top; the big number anchors to the bottom for a premium read. */
.kpi--hero .kpi__val { margin-top: auto; }
.kpi--hero::before { background: linear-gradient(90deg, var(--mint-bright), var(--mint)); opacity: 1; height: 5px; }
.kpi--hero .kpi__icon {
  background: rgba(18,196,138,0.16); color: var(--mint-bright);
  border: 1px solid rgba(18,196,138,0.24);
  width: 50px; height: 50px;
}
.kpi--hero .kpi__icon svg { width: 26px; height: 26px; }
.kpi--hero .kpi__val { font-size: var(--fs-4xl); color: #fff; }
.kpi--hero .kpi__label { color: #a7ccbe; font-size: var(--fs-md); margin-top: 10px; }
.kpi--hero .kpi__sub { color: #6fa593; }

/* ============ ALERT ITEM (dashboard triage list) ============ */
/* A scannable alert row: severity-tinted icon chip · item name · status badge.
   Left edge is tinted by severity so the eye triages the list top-to-bottom. */
.alert-item {
  display: flex; align-items: center; gap: 13px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--white);
  transition: box-shadow var(--t-fast), transform var(--t-fast), border-color var(--t-fast);
}
.alert-item + .alert-item { margin-top: 10px; }
.alert-item:hover { box-shadow: var(--sh-sm); transform: translateX(-2px); }
html[dir="rtl"] .alert-item:hover { transform: translateX(2px); }
.alert-item__ic {
  width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
  display: grid; place-content: center;
  background: var(--warn-bg); color: var(--warn);
}
.alert-item__ic svg { width: 21px; height: 21px; }
.alert-item__body { min-width: 0; flex: 1; }
.alert-item__name { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.alert-item__name b { font-weight: 800; font-size: var(--fs-md); color: var(--ink); }
.alert-item__cat { font-size: var(--fs-xs); color: var(--ink-faint); font-weight: 600; }
.alert-item__detail { font-size: var(--fs-sm); color: var(--ink-soft); margin-top: 2px; }
.alert-item__detail b { color: var(--ink); font-variant-numeric: tabular-nums; }
/* Severity accents */
.alert-item--late   { border-color: rgba(220,42,37,0.30);  background: linear-gradient(90deg, var(--late-bg), var(--white) 26%); }
.alert-item--late   .alert-item__ic { background: var(--late-bg); color: var(--late); }
.alert-item--soon   .alert-item__ic { background: var(--warn-bg); color: var(--warn); }
.alert-item--gold   .alert-item__ic { background: var(--gold-soft); color: var(--gold-600); }
.alert-item--neutral .alert-item__ic { background: var(--green-soft); color: var(--green); }

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-weight: 800; font-size: var(--fs-sm);
  transition: background var(--t-fast), transform 90ms var(--ease), box-shadow var(--t-fast), border-color var(--t-fast), color var(--t-fast);
  white-space: nowrap;
}
.btn svg { width: 18px; height: 18px; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--primary { background: var(--green); color: #fff; box-shadow: 0 2px 8px rgba(11,110,79,0.22); }
.btn--primary:hover { background: var(--green-600); box-shadow: var(--sh-green); }
.btn--gold { background: var(--gold); color: #2a2206; box-shadow: 0 2px 8px rgba(217,154,11,0.24); }
.btn--gold:hover { background: var(--gold-600); color:#fff; box-shadow: 0 8px 22px rgba(217,154,11,0.32); }
.btn--ghost { background: var(--white); color: var(--green-700); border-color: var(--line); }
.btn--ghost:hover { background: var(--green-tint); border-color: var(--green-soft); color: var(--green); }
.btn--tg { background: var(--tg); color: #fff; }
.btn--tg:hover { background: var(--tg-600); }
.btn--danger { background: var(--late-bg); color: var(--late); }
.btn--danger:hover { background: #f5d0cd; }
.btn--sm { padding: 8px 12px; font-size: var(--fs-xs); border-radius: var(--r-sm); }
.btn--icon { padding: 9px; border-radius: var(--r-sm); }
.btn--block { width: 100%; }

/* ============ BADGES / PILLS ============ */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: 800;
  border: 1px solid transparent;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.badge--ok   { background: var(--ok-bg);   color: var(--ok);   border-color: rgba(14,159,110,0.22); }
.badge--soon { background: var(--warn-bg); color: var(--warn); border-color: rgba(224,134,6,0.22); }
.badge--late { background: var(--late-bg); color: var(--late); border-color: rgba(220,42,37,0.22); }
.badge--done { background: var(--ok-bg);   color: var(--ok);   border-color: rgba(14,159,110,0.22); }
.badge--neutral { background: var(--cream-2); color: var(--ink-soft); border-color: var(--line); }
.badge--gold { background: var(--gold-soft); color: var(--gold-600); border-color: rgba(181,125,6,0.22); }
/* Offline / not-yet-synced row marker */
.badge--pending { background: var(--gold-tint); color: var(--gold-600); }
.badge--pending::before { display: none; }
.badge--pending svg { width: 13px; height: 13px; }

/* Topbar "unsynced changes" badge (offline write outbox) */
.sync-badge {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px; border-radius: var(--r-pill);
  background: var(--gold-tint); color: var(--gold-600);
  border: 1px solid var(--gold-soft);
  font-size: var(--fs-xs); font-weight: 700; white-space: nowrap;
  flex-shrink: 0; cursor: pointer;
  transition: background var(--t-fast), box-shadow var(--t-fast);
}
.sync-badge:hover { background: var(--gold-soft); box-shadow: var(--sh-sm); }
.sync-badge svg { width: 15px; height: 15px; }
.sync-badge__failed { color: var(--late); font-weight: 800; margin-inline-start: 4px; }
@media (max-width: 600px) {
  .sync-badge { padding: 6px 10px; }
  .sync-badge #sync-badge-txt { display: none; } /* icon-only on narrow phones */
}
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: var(--r-pill);
  background: var(--green-tint); color: var(--green-700);
  font-size: var(--fs-xs); font-weight: 700; border: 1px solid var(--green-soft);
}
.chip svg { width: 14px; height: 14px; }

/* ============ TABLES ============ */
.table-wrap { overflow-x: auto; border-radius: var(--r-lg); border: 1px solid var(--line); background:var(--white); box-shadow: var(--sh-sm); }
table.tbl { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); min-width: 640px; }
table.tbl thead th {
  background: var(--green-tint);
  color: var(--green-700);
  font-weight: 800;
  text-align: start;
  padding: 14px 16px;
  white-space: nowrap;
  border-bottom: 2px solid var(--green-soft);
  letter-spacing: -0.01em;
  position: sticky; top: 0; z-index: 1;
}
table.tbl tbody td { padding: 14px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl tbody tr { transition: background var(--t-fast); }
table.tbl tbody tr:hover { background: var(--green-tint); }
table.tbl tbody tr[data-item]:hover,
table.tbl tbody tr[style*="cursor"]:hover { background: var(--mint-glow); background: rgba(18,196,138,0.08); }
table.tbl .td-actions { display: flex; gap: 6px; }
table.tbl tbody b { font-weight: 800; font-variant-numeric: tabular-nums; }
.tag-mono { font-weight: 800; color: var(--green-700); }

/* ============ FORMS ============ */
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.field label { font-size: var(--fs-sm); font-weight: 700; color: var(--ink-soft); }
.field .hint { font-size: var(--fs-xs); color: var(--ink-faint); line-height: 1.5; }
.input, .select, .textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  background: var(--white);
  font-weight: 500;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input::placeholder, .textarea::placeholder { color: var(--ink-faint); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--green-soft); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--green-600);
  box-shadow: 0 0 0 3.5px var(--mint-glow);
}
.select { cursor: pointer; }
.textarea { resize: vertical; min-height: 88px; line-height: 1.6; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }
.form-row-actions { display: flex; gap: 10px; justify-content: flex-start; margin-top: 6px; }

/* Filter bar */
.toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-bottom: 18px;
}
.toolbar .select, .toolbar .input { width: auto; min-width: 150px; }
.toolbar .grow-input { flex: 1; min-width: 180px; }
.segment { display: inline-flex; background: var(--cream-2); border-radius: var(--r-md); padding: 3px; gap: 2px; }
.segment button {
  border: none; background: none; padding: 8px 14px; border-radius: var(--r-sm);
  font-size: var(--fs-sm); font-weight: 700; color: var(--ink-soft);
  transition: all var(--t-fast);
}
.segment button.on { background: var(--white); color: var(--green); box-shadow: var(--sh-sm); }

/* ============ MODAL ============ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(12, 47, 43, 0.42);
  backdrop-filter: blur(3px);
  display: grid; place-items: center;
  padding: 16px;
  animation: fade var(--t-fast);
}
.modal {
  background: var(--white);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-lg);
  width: min(560px, 100%);
  max-height: 90vh; overflow-y: auto;
  animation: pop var(--t-mid);
}
.modal--wide { width: min(780px, 100%); }
.modal__head {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 20px 24px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--white); z-index: 1;
}
.modal__head h3 { font-size: var(--fs-lg); font-weight: 800; letter-spacing: -0.01em; }
.modal__body { padding: 24px; }
.modal__foot { padding: 18px 24px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-start; background: var(--cream); border-radius: 0 0 var(--r-xl) var(--r-xl); }
.x-btn { background: none; border: none; padding: 7px; border-radius: 9px; color: var(--ink-soft); transition: background var(--t-fast), color var(--t-fast); }
.x-btn:hover { background: var(--late-bg); color: var(--late); }
.x-btn svg { width: 22px; height: 22px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(16px) scale(.97); } }

/* ============ TOAST ============ */
.toast-root {
  position: fixed; inset-block-start: 18px; inset-inline-end: 18px; z-index: 500;
  display: flex; flex-direction: column; gap: 10px; max-width: 360px;
}
.toast {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--white); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 13px 15px; box-shadow: var(--sh-lg);
  animation: slidein var(--t-mid);
}
/* Status carried by a coloured icon chip, not a side stripe — cohesive with
   the KPI / alert-item icon language and avoids the side-tab tell. */
.toast svg {
  width: 34px; height: 34px; flex-shrink: 0; padding: 7px;
  border-radius: 10px; box-sizing: border-box;
  background: var(--green-soft); color: var(--green);
}
.toast--ok svg  { background: var(--ok-bg);   color: var(--ok); }
.toast--err svg { background: var(--late-bg); color: var(--late); }
.toast--tg svg  { background: var(--tg-bg);   color: var(--tg); }
.toast b { display: block; font-size: var(--fs-sm); font-weight: 800; }
.toast span { font-size: var(--fs-xs); color: var(--ink-soft); }
.toast > div { padding-top: 2px; }
@keyframes slidein { from { opacity: 0; transform: translateX(-16px); } }

/* ============ TIMELINE ============ */
.timeline { position: relative; padding-inline-start: 26px; }
.timeline::before {
  content: ""; position: absolute; inset-inline-start: 7px; top: 6px; bottom: 6px;
  width: 2px; background: var(--line);
}
.tl-item { position: relative; padding-bottom: 18px; }
.tl-item::before {
  content: ""; position: absolute; inset-inline-start: -23px; top: 4px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--white); border: 3px solid var(--green);
}
.tl-item--done::before { border-color: var(--ok); background: var(--ok); }
.tl-item--late::before { border-color: var(--late); background: var(--late); }
.tl-item--soon::before { border-color: var(--warn); background: var(--warn); }
.tl-item--move::before { border-color: var(--gold); background: var(--gold); }
.tl-date { font-size: var(--fs-xs); color: var(--ink-faint); }
.tl-title { font-weight: 700; }
.tl-note { font-size: var(--fs-sm); color: var(--ink-soft); }

/* ============ EMPTY / LOADING ============ */
.empty { text-align: center; padding: 52px 24px; color: var(--ink-faint); }
.empty svg {
  width: 64px; height: 64px; margin: 0 auto 16px; padding: 15px;
  box-sizing: border-box; border-radius: 20px;
  background: var(--green-tint); color: var(--green); opacity: 1; stroke-width: 1.6;
}
.empty b { display: block; color: var(--ink-soft); font-size: var(--fs-lg); font-weight: 800; margin-bottom: 4px; }
.empty > div { font-size: var(--fs-sm); }
.skeleton {
  background: linear-gradient(90deg, var(--cream-2) 25%, #f0f4f2 37%, var(--cream-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.spin-sm { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; vertical-align: -2px; }

/* ============ CALF CARD ============ */
.calf-card {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--sh-sm); overflow: hidden; transition: transform var(--t-fast), box-shadow var(--t-fast);
  cursor: pointer; display: flex; flex-direction: column;
}
.calf-card:hover { transform: translateY(-3px); box-shadow: var(--sh-md); }
.calf-card__top {
  background: linear-gradient(135deg, var(--green-tint), var(--cream));
  padding: 14px 16px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line-soft);
}
.calf-card__tag { font-weight: 900; color: var(--green-700); font-size: var(--fs-lg); }
.calf-card__body { padding: 14px 16px; display: flex; flex-direction: column; gap: 9px; }
.calf-meta { display: flex; align-items: center; gap: 7px; font-size: var(--fs-sm); color: var(--ink-soft); }
.calf-meta svg { width: 16px; height: 16px; color: var(--gold-600); flex-shrink: 0; }
.calf-card__foot { margin-top: auto; padding: 12px 16px; border-top: 1px solid var(--line-soft); display: flex; justify-content: space-between; align-items: center; }

/* ============ STAT / MISC ============ */
.donut-legend { display: flex; flex-direction: column; gap: 10px; }
.donut-legend li { display: flex; align-items: center; gap: 9px; font-size: var(--fs-sm); }
.dot { width: 12px; height: 12px; border-radius: 4px; flex-shrink: 0; }
.alert-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
}
.alert-row:last-child { border-bottom: none; }
.alert-row__icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-content: center; flex-shrink: 0; }

/* Dashboard: upcoming vaccinations grouped by station → barn */
.st-alerts { display: flex; flex-direction: column; gap: 10px; }
.st-alert { border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: var(--white); }
.st-alert__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 13px; background: var(--green-tint); flex-wrap: wrap; }
.st-alert__title { display: flex; align-items: center; gap: 8px; color: var(--green-700); font-weight: 700; min-width: 0; }
.st-alert__title svg { width: 19px; height: 19px; flex-shrink: 0; }
.st-alert__farm { font-size: var(--fs-xs); font-weight: 600; color: var(--ink-faint); background: var(--cream-2); padding: 2px 9px; border-radius: var(--r-pill); }
.st-alert__barn { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 13px; border-top: 1px solid var(--line-soft); }
.st-alert__barnname { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.st-alert__barnname svg { width: 16px; height: 16px; color: var(--ink-faint); flex-shrink: 0; }
.st-alert__barnname .muted { font-size: var(--fs-xs); }
.st-alert__types { font-size: 0.76rem; margin-top: 3px; color: var(--ink-faint); line-height: 1.5; }
/* Mobile: stack the station/barn rows so names + types + badges each get the
   full width instead of being squeezed by space-between (which wraps text
   character-by-character on narrow screens). */
@media (max-width: 560px) {
  .st-alert__head { gap: 6px 8px; }
  .st-alert__head .sc-pills { flex: 1 1 100%; margin-inline-start: 0; }
  .st-alert__barn { flex-wrap: wrap; gap: 7px; }
  .st-alert__barn > .grow { flex: 1 1 100%; min-width: 0; }
  .st-alert__barn .sc-pills { flex: 1 1 100%; margin-inline-start: 0; }
  .st-alert__barnname b { white-space: nowrap; }
}

.def-list { display: grid; grid-template-columns: auto 1fr; gap: 10px 18px; font-size: var(--fs-sm); }
.def-list dt { color: var(--ink-faint); }
.def-list dd { font-weight: 600; }

/* ============ CALENDAR ============ */
.cal-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.cal-legend { display: flex; gap: 12px; }
.cal-legend li { display: flex; align-items: center; gap: 5px; font-size: var(--fs-xs); color: var(--ink-soft); }
.cal-scroll { overflow-x: auto; }
.cal-scroll-inner { min-width: 560px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.cal-mini { display: none; flex-wrap: wrap; gap: 3px; }
.cal-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.cal-dot--late { background: var(--late); }
.cal-dot--soon { background: var(--warn); }
.cal-dot--done { background: var(--ok); }
.cal-more-n { font-size: .6rem; font-weight: 800; color: var(--ink-faint); }
.cal-dow { font-size: var(--fs-xs); color: var(--ink-faint); text-align: center; font-weight: 700; padding: 4px 0; }
.cal-cell { min-height: 86px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--white); padding: 7px; display: flex; flex-direction: column; gap: 5px; transition: box-shadow var(--t-fast), transform var(--t-fast); }
.cal-cell.out { background: var(--cream-2); opacity: .45; }
.cal-cell.today { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold-soft); }
.cal-cell.has { cursor: pointer; }
.cal-cell.has:hover { box-shadow: var(--sh-md); transform: translateY(-1px); }
.cal-day { font-size: var(--fs-sm); font-weight: 700; color: var(--ink-soft); }
.cal-dots { display: flex; flex-direction: column; gap: 3px; margin-top: auto; }
.cal-pill { font-size: .64rem; padding: 2px 6px; border-radius: 5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-pill--late { background: var(--late-bg); color: var(--late); }
.cal-pill--soon { background: var(--warn-bg); color: var(--warn); }
.cal-pill--done { background: var(--ok-bg); color: var(--ok); }
.cal-pill--more { background: var(--cream-2); color: var(--ink-soft); }

/* ============ ATTACHMENTS ============ */
.attach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 12px; }
.attach { border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: var(--white); transition: box-shadow var(--t-fast); }
.attach:hover { box-shadow: var(--sh-md); }
.attach__thumb { display: block; height: 98px; background: var(--green-tint); }
.attach__thumb img { width: 100%; height: 100%; object-fit: cover; }
.attach__file { height: 100%; display: grid; place-content: center; color: var(--gold-600); }
.attach__file svg { width: 34px; height: 34px; }
.attach__meta { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-top: 1px solid var(--line-soft); }
.attach__name { font-size: .74rem; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach__del { border: none; background: none; color: var(--late); padding: 3px; border-radius: 6px; }
.attach__del:hover { background: var(--late-bg); }
.attach__del svg { width: 16px; height: 16px; }

/* ============ MOVEMENT LOG (elder-friendly, phone-first) ============ */
/* Big readable cards instead of a horizontal table. Each card reads as a
   short sentence: which calf, when, from → to, why, who recorded it. */
.mv-bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 6px; }
.mv-add { font-size: var(--fs-md); padding: 14px 22px; }
.mv-add svg { width: 21px; height: 21px; }
.mv-filter {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--white); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 5px 14px;
}
.mv-filter__lbl { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--ink-soft); white-space: nowrap; }
.mv-filter__lbl svg { width: 18px; height: 18px; color: var(--gold-600); }
.mv-filter__sel { border: none; background: none; font-size: var(--fs-md); font-weight: 700; color: var(--green-700); padding: 9px 4px; min-width: 130px; }
.mv-filter__sel:focus { box-shadow: none; outline: none; }
.mv-count { color: var(--ink-faint); font-size: var(--fs-sm); font-weight: 600; margin: 8px 2px 14px; }

.mv-list { display: flex; flex-direction: column; gap: 14px; }
.mv-card { background: var(--white); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-sm); padding: 16px 16px 14px; }
.mv-card__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.mv-card__calf { display: flex; align-items: center; gap: 12px; color: var(--ink); min-width: 0; }
.mv-card__calf:hover { color: var(--green-700); }
.mv-card__calf-ic { width: 46px; height: 46px; border-radius: 13px; background: var(--green-soft); color: var(--green); display: grid; place-content: center; flex-shrink: 0; }
.mv-card__calf-ic svg { width: 26px; height: 26px; }
.mv-card__calf-tag { display: block; font-size: var(--fs-lg); font-weight: 900; color: var(--green-700); }
.mv-card__date { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--ink-faint); margin-top: 2px; }
.mv-card__date svg { width: 15px; height: 15px; }
.mv-card__del { background: var(--late-bg); color: var(--late); border: none; border-radius: var(--r-md); width: 46px; height: 46px; display: grid; place-content: center; flex-shrink: 0; transition: transform var(--t-fast); }
.mv-card__del svg { width: 22px; height: 22px; }
.mv-card__del:active { transform: scale(.93); }

.mv-route { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; }
.mv-loc { background: var(--cream); border: 1px solid var(--line-soft); border-radius: var(--r-md); padding: 12px 12px; text-align: center; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.mv-loc--to { background: var(--gold-tint); border-color: var(--gold-soft); }
.mv-loc__label { font-size: var(--fs-xs); font-weight: 700; color: var(--ink-faint); }
.mv-loc--to .mv-loc__label { color: var(--gold-600); }
.mv-loc__place { font-size: var(--fs-lg); font-weight: 800; color: var(--ink); line-height: 1.25; }
.mv-loc__sub { font-size: var(--fs-sm); color: var(--ink-soft); }
.mv-route__arrow { width: 40px; height: 40px; border-radius: 50%; background: var(--gold); color: #2a2206; display: grid; place-content: center; box-shadow: var(--sh-sm); }
.mv-route__arrow svg { width: 22px; height: 22px; stroke-width: 2.4; }

.mv-card__foot { display: flex; flex-wrap: wrap; gap: 10px 26px; margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
.mv-fact { display: flex; flex-direction: column; gap: 1px; }
.mv-fact__k { font-size: var(--fs-xs); color: var(--ink-faint); font-weight: 600; }
.mv-fact__v { font-size: var(--fs-md); font-weight: 700; color: var(--ink); }

/* Big controls (also reused by the simplified movement form) */
.select--lg, .input.select--lg { padding: 14px 14px; font-size: var(--fs-md); }
.btn--lg { padding: 14px 22px; font-size: var(--fs-md); }
.btn--lg svg { width: 21px; height: 21px; }

/* Simplified movement form */
.mv-form .mv-lbl { display: block; font-size: var(--fs-md); font-weight: 800; color: var(--green-700); margin: 4px 0 9px; }
.mv-now { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--green-tint); border: 1px solid var(--green-soft); border-radius: var(--r-md); padding: 12px 14px; margin-bottom: 18px; }
.mv-now__lbl { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); font-weight: 700; color: var(--green); }
.mv-now__lbl svg { width: 18px; height: 18px; }
.mv-now__val { font-size: var(--fs-lg); font-weight: 800; color: var(--green-800); }
.reason-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.reason-chip { background: var(--white); border: 1.5px solid var(--line); border-radius: var(--r-pill); padding: 11px 17px; font-size: var(--fs-sm); font-weight: 700; color: var(--ink-soft); transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast); }
.reason-chip:hover { border-color: var(--green-soft); background: var(--green-tint); }
.reason-chip.on { background: var(--green); border-color: var(--green); color: #fff; }

@media (max-width: 600px) {
  .mv-add { width: 100%; justify-content: center; }
  .mv-filter { width: 100%; }
  .mv-filter__sel { flex: 1; }
  .mv-loc { padding: 11px 8px; }
  .mv-loc__place { font-size: var(--fs-md); }
  .mv-route { gap: 6px; }
  .mv-route__arrow { width: 34px; height: 34px; }
  .mv-route__arrow svg { width: 18px; height: 18px; }
  .modal__foot { flex-direction: column; }
  .modal__foot .btn { width: 100%; }
}

/* ============ VACCINE CATALOG (inline interval edit) ============ */
.vx-cat { display: flex; flex-direction: column; gap: 10px; }
.vx-item { border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; background: var(--white); }
.vx-item__name { font-weight: 700; color: var(--ink); margin-bottom: 10px; }
.vx-item__ctrl { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; }
.vx-item__field { display: flex; flex-direction: column; gap: 4px; }
.vx-item__field span { font-size: var(--fs-xs); color: var(--ink-faint); font-weight: 600; }
.vx-days { width: 96px; text-align: center; font-weight: 800; font-size: var(--fs-md); }

/* ============ HERD GROUP-BY-BARN ============ */
.herd-group { margin-bottom: 22px; }
.herd-group__head {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  padding: 10px 14px; margin-bottom: 12px;
  background: var(--green-tint); border: 1px solid var(--green-soft);
  border-radius: var(--r-md);
}
.herd-group__head svg { width: 20px; height: 20px; color: var(--green); }
.herd-group__head b { font-size: var(--fs-lg); color: var(--green-700); }
.herd-group__head .muted { font-size: var(--fs-sm); }
.herd-group__head .chip { margin-inline-start: auto; }

/* ============ HELP / USER GUIDE ============ */
.help-intro {
  background: linear-gradient(135deg, var(--green-tint), var(--cream));
  border: 1px solid var(--green-soft); border-radius: var(--r-lg);
  padding: 20px 22px; margin-bottom: 22px;
}
.help-intro h2 { font-size: var(--fs-2xl); color: var(--green-700); margin-bottom: 6px; }
.help-intro p { color: var(--ink-soft); font-size: var(--fs-md); }
.help-step {
  display: flex; gap: 16px; align-items: flex-start;
  background: var(--white); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--sh-sm); padding: 18px; margin-bottom: 16px;
}
.help-step__num {
  flex-shrink: 0; width: 44px; height: 44px; border-radius: 50%;
  background: var(--gold); color: #2a2206;
  display: grid; place-content: center; font-weight: 900; font-size: 1.25rem;
}
.help-step__body { flex: 1; min-width: 0; }
.help-step__body h3 { font-size: var(--fs-lg); margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.help-step__body h3 svg { width: 22px; height: 22px; color: var(--green); }
.help-step__body p { color: var(--ink-soft); font-size: var(--fs-md); line-height: 1.8; }
.help-step__shot { margin-top: 12px; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: var(--cream-2); }
.help-step__shot img { width: 100%; display: block; }
.help-step__shot figcaption { font-size: var(--fs-sm); color: var(--ink-faint); padding: 7px 12px; text-align: center; background: var(--white); border-top: 1px solid var(--line-soft); }
.help-tip { display: flex; gap: 10px; align-items: flex-start; background: var(--gold-tint); border: 1px solid var(--gold-soft); border-radius: var(--r-md); padding: 12px 14px; margin: 8px 0 0; font-size: var(--fs-sm); color: var(--ink-soft); }
.help-tip svg { width: 19px; height: 19px; color: var(--gold-600); flex-shrink: 0; margin-top: 1px; }

/* About box */
.about-card { text-align: center; }
.about-logo { width: 72px; height: 72px; border-radius: 18px; margin: 0 auto 14px; display: grid; place-content: center; background: linear-gradient(145deg, #e7c75a, var(--gold)); color: #0c2f2b; }
.about-logo svg { width: 40px; height: 40px; }
.about-row { display: flex; align-items: center; gap: 10px; justify-content: center; padding: 9px 0; border-top: 1px solid var(--line-soft); font-size: var(--fs-md); }
.about-row:first-of-type { border-top: none; }
.about-row svg { width: 18px; height: 18px; color: var(--gold-600); }
.about-row a { font-weight: 700; }

@media (max-width: 600px) {
  .help-step { padding: 14px; gap: 12px; }
  .help-step__num { width: 38px; height: 38px; font-size: 1.1rem; }
}

/* ============ REPORT PREVIEW (modal) ============ */
.report-doc__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding-bottom: 12px; border-bottom: 2px solid var(--gold); margin-bottom: 16px; }
.report-doc__head h2 { font-size: var(--fs-xl); color: var(--green-700); }
.report-doc__kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 20px; }
.report-kpi { background: var(--green-tint); border: 1px solid var(--green-soft); border-radius: var(--r-md); padding: 12px 8px; text-align: center; }
.report-kpi b { display: block; font-size: 1.5rem; font-weight: 900; color: var(--green-700); }
.report-kpi span { font-size: var(--fs-xs); color: var(--ink-soft); }
.report-doc__h3 { font-size: var(--fs-lg); margin: 18px 0 10px; color: var(--green-700); }
.report-doc table.tbl { min-width: 0; margin-bottom: 6px; }
@media (max-width: 600px) {
  .report-doc__kpis { grid-template-columns: repeat(2, 1fr); }
}

/* ============ OFFLINE BANNER ============ */
.net-banner {
  position: fixed; inset-block-start: 0; inset-inline: 0; z-index: 600;
  display: flex; align-items: center; justify-content: center; gap: 9px;
  background: var(--warn); color: #fff;
  padding: 8px 14px; font-size: var(--fs-sm); font-weight: 600;
  box-shadow: var(--sh-md);
}
.net-banner svg { flex-shrink: 0; }

/* ============ SCHEDULE DRILL-DOWN (hierarchical) ============ */
.crumb { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; margin-bottom: 16px; font-size: var(--fs-sm); }
.crumb a { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; color: var(--green); cursor: pointer; padding: 4px 6px; border-radius: var(--r-sm); }
.crumb a:hover { background: var(--green-tint); }
.crumb span:not(.crumb__sep) { font-weight: 700; color: var(--ink); padding: 4px 6px; }
.crumb a svg, .crumb span svg { width: 15px; height: 15px; }
.crumb__sep { color: var(--ink-faint); display: inline-flex; }
.crumb__sep svg { width: 14px; height: 14px; transform: scaleX(-1); }

.sc-summary__head { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.sc-summary__head svg { width: 40px; height: 40px; color: var(--green); }
.sc-summary__head h2 { font-size: var(--fs-2xl); color: var(--green-700); }

.sc-list { display: flex; flex-direction: column; gap: 10px; }
.sc-card {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: start;
  background: var(--white); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--sh-sm); padding: 14px 16px; transition: transform var(--t-fast), box-shadow var(--t-fast);
}
.sc-card:hover { transform: translateY(-1px); box-shadow: var(--sh-md); border-color: var(--green-soft); }
.sc-card__main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.sc-card__main svg { width: 30px; height: 30px; color: var(--gold-600); flex-shrink: 0; }
.sc-card__main b { display: block; font-size: var(--fs-lg); color: var(--green-700); }
.sc-card__main .muted { font-size: var(--fs-sm); }
.sc-pills { display: flex; gap: 6px; flex-wrap: wrap; margin-inline-start: auto; }
.sc-card__go { color: var(--ink-faint); display: inline-flex; flex-shrink: 0; }
.sc-card__go svg { width: 20px; height: 20px; transform: scaleX(-1); }

@media (max-width: 600px) {
  .sc-card { flex-wrap: wrap; }
  .sc-pills { width: 100%; margin-inline-start: 0; order: 3; }
  .sc-card__go { position: absolute; }
}

/* role-hidden helper */
[data-role-hidden] { display: none !important; }

/* ============ LOGIN ============ */
.login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
}
.login__art {
  position: relative; overflow: hidden;
  background:
    radial-gradient(700px 460px at 82% 8%, rgba(18,196,138,0.22), transparent 58%),
    radial-gradient(600px 500px at 0% 100%, rgba(11,110,79,0.28), transparent 60%),
    linear-gradient(160deg, var(--ink-850), var(--ink-900) 60%, var(--ink-800));
  color: var(--cream);
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 56px 52px;
}
.login__art .brand__mark { width: 54px; height: 54px; border-radius: 16px; }
.login__art .brand__txt b { font-size: 1.05rem; }
.login__art h2 { color: #fff; font-size: clamp(1.9rem, 4vw, 2.6rem); line-height: 1.25; max-width: 15ch; font-weight: 900; letter-spacing: -0.02em; }
.login__art h2 .accent { color: var(--mint-bright); }
.login__art p { color: #a7ccbe; margin-top: 18px; max-width: 40ch; font-size: var(--fs-md); line-height: 1.9; }
.login__pattern { position: absolute; inset: 0; opacity: .06;
  background-image: radial-gradient(currentColor 1.4px, transparent 1.4px);
  background-size: 28px 28px; color: var(--mint-bright); pointer-events: none; }
.login__panel { display: grid; place-items: center; padding: 32px; background: transparent; }
.login__box { width: min(400px, 100%); }
.login__box h1 { font-size: var(--fs-2xl); margin-bottom: 4px; font-weight: 900; letter-spacing: -0.02em; }
.login__box .sub { color: var(--ink-soft); margin-bottom: 28px; font-size: var(--fs-md); }
.demo-creds {
  margin-top: 20px; padding: 15px 17px; border: 1.5px dashed var(--green-soft);
  border-radius: var(--r-md); background: var(--green-tint); font-size: var(--fs-xs); color: var(--ink-soft);
}
.demo-creds b { color: var(--green-700); }
.demo-creds button { background:none;border:none;color:var(--tg);font-weight:800;text-decoration:underline; padding:0; font-size: var(--fs-xs); cursor: pointer; }

@media (max-width: 860px) {
  .login { grid-template-columns: 1fr; }
  .login__art { display: none; }
  .login__panel { padding: 24px; align-content: center; }
}

/* ============ RESPONSIVE SHELL ============ */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 300;
    width: 280px; transform: translateX(110%);
    transition: transform var(--t-mid); box-shadow: var(--sh-lg);
  }
  html[dir="rtl"] .sidebar { transform: translateX(110%); }
  .sidebar.open { transform: translateX(0) !important; }
  .burger { display: inline-flex; }
  .scrim { position: fixed; inset: 0; background: rgba(12,47,43,.4); z-index: 250; }
}

/* ============ MOBILE POLISH (phone-first — primary target) ============ */
@media (max-width: 600px) {
  .content { padding: 14px; }
  .topbar { padding: 0 14px; }
  .topbar h1 { font-size: var(--fs-lg); }
  .page-head h2 { font-size: var(--fs-xl); }
  .card, .card--pad-lg { padding: 15px; }
  .kpi__val { font-size: 2rem; }
  /* Calendar → compact dot mode (fits 7 columns, no horizontal scroll) */
  .cal-scroll-inner { min-width: 0; }
  .cal-grid { gap: 5px; }
  .cal-cell { min-height: 52px; padding: 5px 4px; }
  .cal-pill { display: none; }
  .cal-mini { display: flex; }
  .cal-dow { font-size: .62rem; }
  /* Comfortable touch targets */
  .btn--sm { padding: 8px 11px; }
  .btn--icon { padding: 9px; }
  table.tbl tbody td, table.tbl thead th { padding: 12px 12px; }
  .modal__body { padding: 18px; }
  .toast-root { inset-inline: 12px; max-width: none; }
}

/* ============ PRINT (PDF reports) ============ */
@media print {
  .sidebar, .topbar, .toolbar, .btn, .no-print { display: none !important; }
  .layout { grid-template-columns: 1fr; }
  body { background: #fff; }
  .content { max-width: 100%; padding: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  .print-only { display: block !important; }
}
.print-only { display: none; }

/* ===================== جدول الذهبية ٣ ===================== */
.dh3-banner { text-align: center; padding: 4px 0 12px; }
.dh3-banner__unit {
  display: inline-block; background: var(--green); color: #fff;
  font-weight: 800; font-size: var(--fs-lg); padding: 4px 22px;
  border-radius: var(--r-pill); margin-bottom: 8px;
}
.dh3-banner h2 { color: var(--green-700); margin: 2px 0; }
.dh3-banner__sub { color: var(--ink-soft); font-weight: 700; }
.dh3-legend {
  display: flex; gap: 22px; justify-content: center; flex-wrap: wrap;
  margin-top: 6px; color: var(--ink-soft); font-size: var(--fs-sm); font-weight: 600;
}
.dh3-legend span { display: inline-flex; align-items: center; gap: 7px; }
.dh3-dot { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.dh3-dot--done { background: var(--late); }
.dh3-dot--soon { background: var(--ok); }
.dh3-dot--past { background: #e8c62e; }
.dh3-dot--upcoming { background: #6bbf59; }

.dh3-tbl th, .dh3-tbl td { text-align: center; white-space: nowrap; }
.dh3-tbl td.tag-mono { font-weight: 800; }
.dh3-cell { font-weight: 700; }
.dh3-cell--done { background: var(--late-bg); color: var(--late); }
.dh3-cell--soon { background: var(--ok-bg);   color: var(--ok); }
.dh3-cell--empty { color: var(--ink-faint); }
.dh3-note { white-space: normal; min-width: 180px; color: var(--ink-soft); font-size: var(--fs-sm); text-align: start; }

/* ===== تابات بروتوكولات المحطات (تحت جدول التحصينات) ===== */
.proto-section { margin-top: 40px; }
.proto-section__title {
  display: flex; align-items: center; gap: 8px;
  color: var(--green-700); margin: 0 0 14px;
}
.proto-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.proto-tab {
  border: 1.5px solid var(--green); background: transparent; color: var(--green-700);
  font-weight: 800; font-size: var(--fs-sm); padding: 8px 22px;
  border-radius: var(--r-pill); cursor: pointer;
  transition: background .15s, color .15s;
}
.proto-tab:hover { background: var(--green-tint); }
.proto-tab.on { background: var(--green); color: #fff; }
.proto-toolbar { margin-bottom: 10px; }

/* ألوان صفوف الجدول: أصفر = عدّى تاريخه · أخضر = تاريخه قادم */
.proto-tbl thead th { background: var(--green-tint); color: var(--green-800); }
.proto-tbl tbody tr.proto-row--past td     { background: #fdf3b0; }
.proto-tbl tbody tr.proto-row--upcoming td { background: #d4ecc6; }
.proto-vax__note { display: none; }  /* على الشاشات الكبيرة الملاحظة في عمودها */

/* التحصينات الحية (جدول تحصينات العجل الواحد + الجدول الزمني في ملف العجل):
   نفس منطق الألوان أعلاه — أصفر = منفّذ أو عدّى موعده · أخضر = قادم ولسه. */
table.tbl tbody tr.vax-row--past td     { background: #fdf3b0; }
table.tbl tbody tr.vax-row--upcoming td { background: #d4ecc6; }
.tl-item.vax-row--past,
.tl-item.vax-row--upcoming { border-radius: var(--r-md); padding: 6px 10px 22px; }
.tl-item.vax-row--past     { background: #fdf3b0; }
.tl-item.vax-row--upcoming { background: #d4ecc6; }

/* موبايل: الجدول يـfit من غير scroll — الملاحظة تنزل تحت اسم التحصين */
@media (max-width: 600px) {
  table.dh3-tbl.proto-tbl { min-width: 0; table-layout: fixed; }
  .proto-tbl thead th.proto-note-col,
  .proto-tbl tbody td.dh3-note { display: none; }
  .proto-tbl th, .proto-tbl td { padding-inline: 6px; }
  .proto-tbl th:first-child, .proto-tbl td:first-child { width: 26px; padding-inline: 3px; }
  .proto-tbl thead th:nth-child(3), .proto-tbl .dh3-cell { width: 92px; white-space: normal; }
  .proto-tbl .proto-vax { white-space: normal; text-align: start; }  /* ياخد باقي العرض */
  .proto-vax__note {
    display: block; margin-top: 4px; font-size: 11px; font-weight: 500;
    line-height: 1.5; color: var(--ink-soft); white-space: normal;
  }
  .proto-tab { padding: 7px 15px; font-size: var(--fs-sm); }

  /* الحياة ١ (عمودان تاريخ): scroll أفقي بسيط بدل حشر العمودين في عرض الموبايل */
  table.dh3-tbl.proto-tbl.proto-tbl--multi { min-width: 520px; table-layout: auto; }
  .proto-tbl--multi .proto-vax { white-space: nowrap; }
}
