/* =====================================================================
   zain-contract — dark, application-grade design system.

   Architecture mirrors the Checkup reference (token-driven dark app
   shell, sticky compact topbar, segmented language switch, modern cards,
   application-style tables, status triplets, dropzone upload, progress
   bars, RTL/LTR via CSS logical properties).

   Brand: Zain purple is preserved. The Checkup green tokens are
   substituted by Zain's purple as --primary / --primary-hover /
   --primary-soft / --accent / --accent-soft. No CDN, no icon fonts.
   ===================================================================== */

:root {
  /* --- Brand (Zain purple — substituted for Checkup's green) --------- */
  --primary:        #6a1b9a;                      /* Zain brand purple   */
  --primary-hover:  #7d29b3;                      /* hover (lighter on dark) */
  --primary-soft:   rgba(138, 63, 196, .16);      /* tints / focus ring  */
  --accent:         #a45fd0;                       /* lighter purple, on dark */
  --accent-soft:    rgba(164, 95, 208, .14);

  /* --- Dark surfaces ------------------------------------------------- */
  --bg:             #0f1117;
  --surface:        #171a23;
  --surface-2:      #1d212c;                       /* table head / raised */
  --surface-hover:  #222736;
  --ink:            #e8eaf0;
  --text-2:         #c2c7d2;
  --muted:          #8b91a1;
  --line:           #282d3a;
  --line-strong:    #39414f;

  /* --- Status triplets (bg / text / border) — dark tuned ------------- */
  --ok-bg:    rgba(46, 160, 91, .16);   --ok-fg:    #5fd38a;   --ok-bd:    rgba(46,160,91,.34);
  --warn-bg:  rgba(214, 158, 46, .16);  --warn-fg:  #f0c061;   --warn-bd:  rgba(214,158,46,.34);
  --info-bg:  rgba(70, 130, 220, .16);  --info-fg:  #79aefc;   --info-bd:  rgba(70,130,220,.34);
  --err-bg:   rgba(214, 69, 69, .16);   --err-fg:   #f08a8a;   --err-bd:   rgba(214,69,69,.34);
  --neutral-bg: rgba(255,255,255,.06);  --neutral-fg: #b1b7c4; --neutral-bd: rgba(255,255,255,.12);
  --brand-bg: var(--accent-soft);       --brand-fg: #c79ae6;   --brand-bd: rgba(164,95,208,.30);

  --radius:    14px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --shadow:    0 1px 2px rgba(0,0,0,.4), 0 12px 32px rgba(0,0,0,.32);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  --ring:      0 0 0 3px var(--primary-soft);
}

* { box-sizing: border-box; }

html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, "Noto Sans Arabic", system-ui, sans-serif;
  background:
    radial-gradient(1100px 520px at 100% -10%, var(--accent-soft) 0%, rgba(0,0,0,0) 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; transition: color .15s ease; }
a:hover { color: #c79ae6; }

h1 { font-size: 1.5rem; margin: 0 0 6px; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 0 0 14px; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.err { color: var(--err-fg); }

/* =====================================================================
   Topbar — sticky, compact, brand + nav + right user cluster
   ===================================================================== */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(20, 23, 32, .82);
  backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  display: flex;
  align-items: center;
  gap: 8px 22px;
  width: 100%;
  max-width: 1180px;
  margin-inline: auto;
  padding-inline: 24px;
  min-height: 56px;
}
.brand {
  display: inline-flex; align-items: center; gap: 9px;
  font-weight: 800; font-size: 1.08rem; color: var(--ink);
  letter-spacing: -.01em;
}
.brand:hover { color: var(--ink); }
.brand::before {
  content: "";
  width: 22px; height: 22px; border-radius: 7px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 2px 8px var(--primary-soft);
}

.topnav { display: flex; align-items: center; gap: 6px; }
.topnav a {
  position: relative;
  display: inline-flex; align-items: center;
  padding: 7px 10px;
  border-radius: var(--radius-xs);
  color: var(--text-2);
  font-weight: 500; font-size: .92rem;
  transition: color .15s ease, background-color .15s ease;
}
.topnav a:hover { color: var(--ink); background: var(--surface-hover); }
.topnav a.active { color: var(--ink); font-weight: 700; }
.topnav a.active::after {
  content: "";
  position: absolute;
  inset-inline: 10px;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

/* Right cluster: language + user + logout sits at the inline-end */
.topbar-right {
  margin-inline-start: auto;
  display: flex; align-items: center; gap: 14px;
}
.topbar-user { display: flex; align-items: center; gap: 10px; }
.user-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-2);
  font-size: .82rem; font-weight: 600;
  white-space: nowrap;
}
.topbar-logout {
  color: var(--muted); font-weight: 500; font-size: .88rem;
  white-space: nowrap;
}
.topbar-logout:hover { color: var(--err-fg); }

/* =====================================================================
   Segmented language switch — fixed-width segments so the toggle never
   jumps when the active label changes between Arabic and English.
   ===================================================================== */
.lang-switch {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 3px; border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.lang-btn {
  cursor: pointer;
  border: 0; background: transparent;
  color: var(--muted);
  font: inherit; font-size: .8rem; font-weight: 600;
  padding: 5px 0;
  width: 64px;                 /* stable width => toggle stays put */
  text-align: center;
  border-radius: 999px;
  transition: background-color .15s ease, color .15s ease;
}
.lang-btn:hover { color: var(--ink); }
.lang-btn.active {
  background: var(--primary);
  color: #fff; font-weight: 700;
  box-shadow: 0 1px 6px var(--primary-soft);
}
/* Login page (no header): pin the switch to the top inline-end corner. */
.lang-switch-floating {
  position: fixed; top: 18px; inset-inline-end: 18px; z-index: 40;
  background: rgba(20, 23, 32, .9);
  backdrop-filter: blur(8px);
}

/* =====================================================================
   Layout — centered content column; wider only for table-heavy pages
   ===================================================================== */
.container {
  width: 100%; max-width: 760px;
  margin-inline: auto; margin-block: 34px;
  padding-inline: 24px; padding-block-end: 32px;
}
.container.wide { max-width: 1180px; }     /* operations / admin tables  */

.page-head { margin-block-end: 20px; }
.page-head .muted { margin: 0; }

/* =====================================================================
   Cards
   ===================================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  margin-block: 16px;
}
.card-pad-lg { padding: 28px 30px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  margin-block-end: 16px;
}
.card-head h2 { margin: 0; }

/* Key/value rows (job-detail) */
.row {
  display: flex; gap: 1rem; justify-content: space-between; align-items: center;
  border-bottom: 1px solid var(--line); padding-block: .6rem;
}
.row:last-child { border-bottom: 0; }
.row .k { color: var(--muted); min-width: 9rem; font-size: .9rem; }
.row .v { text-align: end; }

/* =====================================================================
   Forms / inputs / selects
   ===================================================================== */
label { font-weight: 600; color: var(--text-2); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { color: var(--text-2); font-size: .85rem; font-weight: 600; }

input[type=file], input[type=text], input[type=password],
input[type=search], input[type=number], select, textarea {
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs);
  padding: 10px 13px;
  color: var(--ink);
  font: inherit;
  width: 100%;
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
input::placeholder { color: var(--muted); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
  background: var(--surface);
}
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%238b91a1' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  padding-inline-start: 13px; padding-inline-end: 34px;
}
html[dir="ltr"] select { background-position: right 12px center; }

/* =====================================================================
   Buttons
   ===================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  cursor: pointer;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--ink);
  padding: 10px 18px;
  border-radius: var(--radius-xs);
  font-size: .92rem; font-weight: 600;
  white-space: nowrap;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, transform .05s ease;
}
.btn:hover { border-color: var(--accent); color: #fff; background: var(--surface-hover); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--primary); border-color: var(--primary); color: #fff;
  box-shadow: 0 2px 10px var(--primary-soft);
}
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--surface-hover); }
.btn.small { padding: 7px 13px; font-size: .85rem; }
.btn.danger { background: transparent; border-color: var(--err-bd); color: var(--err-fg); }
.btn.danger:hover { background: var(--err-bg); border-color: var(--err-fg); color: var(--err-fg); }
.btn.is-disabled { opacity: .45; pointer-events: none; cursor: not-allowed; }
.btn:disabled, .btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }
.actions { display: flex; gap: .6rem; align-items: center; margin-block: 18px; flex-wrap: wrap; }

/* =====================================================================
   Dropzone upload — styled wrapper around the real file input
   ===================================================================== */
.upload-form { display: flex; flex-direction: column; gap: 18px; }
.dropzone {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; text-align: center;
  padding: 40px 24px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text-2);
  cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease;
}
.dropzone:hover, .dropzone.is-dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dropzone input[type=file] {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  opacity: 0; cursor: pointer;
}
/* Pure-CSS upload glyph (no icon font / image) */
.dropzone-icon {
  width: 46px; height: 46px; border-radius: 14px;
  background: var(--primary-soft); position: relative;
}
.dropzone-icon::before {
  content: ""; position: absolute; inset-inline-start: 50%; top: 13px;
  width: 3px; height: 20px; margin-inline-start: -1.5px;
  background: var(--accent); border-radius: 2px;
}
.dropzone-icon::after {
  content: ""; position: absolute; inset-inline-start: 50%; top: 13px;
  width: 11px; height: 11px; margin-inline-start: -5.5px;
  border-top: 3px solid var(--accent); border-inline-start: 3px solid var(--accent);
  border-radius: 2px; transform: rotate(45deg); transform-origin: center;
}
.dropzone-title { font-weight: 700; color: var(--ink); font-size: 1rem; }
.dropzone-hint { font-size: .85rem; color: var(--muted); }
.dropzone-file {
  display: none;
  align-items: center; gap: 8px;
  padding: 7px 14px; border-radius: 999px;
  background: var(--primary-soft); color: var(--brand-fg);
  font-size: .88rem; font-weight: 600;
}
.dropzone.has-file .dropzone-file { display: inline-flex; }

/* =====================================================================
   Tables — application style, with responsive scroll container
   ===================================================================== */
.table-wrap {
  width: 100%; overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  -webkit-overflow-scrolling: touch;
}
.grid {
  width: 100%; border-collapse: collapse;
  min-width: 560px;
}
.grid th, .grid td {
  padding: 13px 16px; text-align: start;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.grid th {
  background: var(--surface-2); color: var(--muted);
  font-weight: 700; font-size: .76rem; letter-spacing: .03em;
  text-transform: uppercase;
  position: sticky; top: 0;
}
.grid tbody tr { transition: background-color .12s ease; }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid tbody tr:hover { background: var(--surface-hover); }
.grid td.num { font-variant-numeric: tabular-nums; color: var(--text-2); }
.cell-id { color: var(--muted); font-variant-numeric: tabular-nums; }
.cell-link { font-weight: 600; }

/* =====================================================================
   Status badges / pills — color triplets, raw status kept in class
   ===================================================================== */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: .22rem .65rem; border-radius: 999px;
  font-size: .78rem; font-weight: 700; line-height: 1.4;
  background: var(--neutral-bg); color: var(--neutral-fg);
  border: 1px solid var(--neutral-bd);
  white-space: nowrap;
}
.badge::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
}
.badge.done,
.badge.noamountfound { background: var(--ok-bg);   color: var(--ok-fg);   border-color: var(--ok-bd); }
.badge.running       { background: var(--info-bg); color: var(--info-fg); border-color: var(--info-bd); }
.badge.pending       { background: var(--neutral-bg); color: var(--neutral-fg); border-color: var(--neutral-bd); }
.badge.failed        { background: var(--err-bg);  color: var(--err-fg);  border-color: var(--err-bd); }
.badge.timeout,
.badge.invalidinput  { background: var(--warn-bg); color: var(--warn-fg); border-color: var(--warn-bd); }
.badge.stopped       { background: var(--brand-bg); color: var(--brand-fg); border-color: var(--brand-bd); }
.badge.role-admin    { background: var(--brand-bg); color: var(--brand-fg); border-color: var(--brand-bd); }
.badge.role-user     { background: var(--neutral-bg); color: var(--neutral-fg); border-color: var(--neutral-bd); }
.badge.active-yes    { background: var(--ok-bg); color: var(--ok-fg); border-color: var(--ok-bd); }
.badge.active-no     { background: var(--err-bg); color: var(--err-fg); border-color: var(--err-bd); }

/* =====================================================================
   Progress bar
   ===================================================================== */
.progress {
  display: flex; align-items: center; gap: 10px;
  min-width: 130px;
}
.progress-track {
  flex: 1; height: 7px; border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  overflow: hidden;
}
.progress-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width .3s ease;
}
.progress-label {
  font-size: .78rem; color: var(--muted);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}

/* =====================================================================
   Toolbar (search + filters)
   ===================================================================== */
.toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-block-end: 16px;
}
.toolbar .search { position: relative; flex: 1 1 220px; min-width: 180px; }
.toolbar .search input { padding-inline-start: 36px; }
.toolbar .search::before {
  content: "🔍"; position: absolute;
  inset-inline-start: 11px; top: 50%; transform: translateY(-50%);
  font-size: .85rem; opacity: .6; pointer-events: none;
}
.toolbar select { width: auto; min-width: 150px; }
.toolbar-spacer { margin-inline-start: auto; }

/* =====================================================================
   Alerts / messages — consistent severities
   ===================================================================== */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 13px 16px; border-radius: var(--radius-sm);
  margin-block: 14px;
  border: 1px solid var(--line); background: var(--surface-2);
  font-size: .92rem; color: var(--text-2);
}
.alert::before { font-size: 1rem; line-height: 1.4; }
.alert.info    { border-color: var(--info-bd); background: var(--info-bg); color: var(--info-fg); }
.alert.info::before { content: "ℹ️"; }
.alert.success { border-color: var(--ok-bd); background: var(--ok-bg); color: var(--ok-fg); }
.alert.success::before { content: "✅"; }
.alert.warning { border-color: var(--warn-bd); background: var(--warn-bg); color: var(--warn-fg); }
.alert.warning::before { content: "⚠️"; }
.alert.error   { border-color: var(--err-bd); background: var(--err-bg); color: var(--err-fg); }
.alert.error::before { content: "⛔"; }

/* =====================================================================
   Empty state — intentional, not blank
   ===================================================================== */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; text-align: center;
  padding: 56px 24px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
}
.empty-icon {
  width: 56px; height: 56px; border-radius: 16px;
  display: grid; place-items: center;
  background: var(--primary-soft); color: var(--accent);
  font-size: 1.6rem; margin-block-end: 4px;
}
.empty-title { font-weight: 700; color: var(--ink); font-size: 1.05rem; }
.empty-text { font-size: .92rem; }

/* =====================================================================
   Log block
   ===================================================================== */
.log {
  background: #0a0c12; color: #c8d4f5;
  padding: 1rem 1.1rem; border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  overflow: auto; direction: ltr; text-align: left;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: .82rem; white-space: pre-wrap; line-height: 1.55;
  max-height: 420px;
}

/* =====================================================================
   Login
   ===================================================================== */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 32px 20px;
}
.login-card { width: 100%; max-width: 400px; padding: 34px 32px; margin: 0; }
.login-card h1 { text-align: center; font-size: 1.3rem; margin: 0 0 22px; }
.login-card .upload-form { gap: 16px; }
.login-card .btn { width: 100%; margin-block-start: 4px; }

/* =====================================================================
   Admin inline forms
   ===================================================================== */
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-form input[type=text], .inline-form input[type=password] { min-width: 130px; flex: 1 1 130px; width: auto; }
.inline-form select { width: auto; min-width: 130px; }

/* =====================================================================
   Upload hero — single centered focus (Checkup composition)
   ===================================================================== */
.upload-hero {
  min-height: calc(100vh - 200px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 20px; text-align: center;
  max-width: 600px; margin-inline: auto;
}
.upload-heading { font-size: 1.75rem; margin: 0; letter-spacing: -.02em; }
.upload-hero .muted { margin: 0; max-width: 48ch; }
.upload-hero .alert { width: 100%; text-align: start; }
.upload-hero .upload-form { width: 100%; gap: 16px; }
.upload-hero .dropzone { min-height: 230px; }
.upload-hero .btn.primary { align-self: center; min-width: 190px; }

/* =====================================================================
   Operation-detail page (Checkup .op-* composition)
   A single focused, centered operation-tracking dashboard.
   ===================================================================== */
.op-page { max-width: 640px; margin-inline: auto; }

/* 1 — top navigation row: back link (start) + tracking eyebrow (end) */
.op-topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-block-end: 14px;
}
.op-back {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--text-2); font-weight: 600; font-size: .9rem;
}
.op-back:hover { color: var(--ink); }
/* Chevron drawn from logical borders, so it mirrors automatically in RTL/LTR */
.op-back-arrow {
  width: 8px; height: 8px;
  border-inline-start: 2px solid currentColor;
  border-block-end: 2px solid currentColor;
  transform: rotate(45deg);
}
.op-eyebrow {
  font-size: .74rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); font-weight: 700;
}

/* 2 — main operation card */
.op-card { padding: 24px 26px; }
.op-card-top {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 14px; flex-wrap: wrap;
}
.op-id { font-size: .8rem; color: var(--muted); font-weight: 700; }
.op-title {
  font-size: 1.4rem; margin: 4px 0 0; letter-spacing: -.01em;
  word-break: break-word; line-height: 1.3;
}
.op-status { display: inline-flex; align-items: center; gap: 12px; flex-shrink: 0; }

/* Read-only worker / pacing info (job detail only) — small neutral chips that
   reuse the .badge shape but drop the status dot. */
.op-workers { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.op-workers .worker-badge { font-weight: 600; }
.op-workers .worker-badge::before { display: none; }
.op-workers .worker-badge .num { font-weight: 700; font-variant-numeric: tabular-nums; }

/* Live indicator (running) */
.live {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: .8rem; color: var(--info-fg); font-weight: 700;
}
.live-dot {
  width: 8px; height: 8px; border-radius: 50%; background: currentColor;
  animation: live-pulse 1.6s ease-out infinite;
}
@keyframes live-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(121,174,252,.5); }
  70%  { box-shadow: 0 0 0 8px rgba(121,174,252,0); }
  100% { box-shadow: 0 0 0 0 rgba(121,174,252,0); }
}

/* Progress block inside the main card */
.op-progress { margin-block-start: 20px; }
.op-progress-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin-block-end: 8px;
}
.op-progress-head .activity { color: var(--text-2); font-size: .92rem; margin: 0; }
.op-pct { font-size: 1.05rem; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; }
.op-progress .progress-track { height: 10px; }

/* In-card live meta grid (processed / last update / started / …) */
.op-meta {
  display: grid; gap: 14px 18px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-block-start: 22px;
  padding-block-start: 18px;
  border-block-start: 1px solid var(--line);
}
.op-meta-item { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.op-meta-label {
  font-size: .72rem; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted); font-weight: 700;
}
.op-meta-val { color: var(--ink); font-size: .92rem; word-break: break-word; }
.op-meta-val .num { font-weight: 700; font-variant-numeric: tabular-nums; }
.op-card .alert { margin-block: 18px 0; }

/* 3 — stat / metric cards (balanced grid, lives inside the main card) */
.op-stats {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  margin-block: 16px;
}
.op-card .op-stats {
  margin-block: 22px 0;
  padding-block-start: 22px;
  border-block-start: 1px solid var(--line);
}
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.stat .num {
  font-size: 1.6rem; font-weight: 800; line-height: 1.1;
  font-variant-numeric: tabular-nums; color: var(--ink);
}
.stat .stat-label { font-size: .76rem; color: var(--muted); margin-block-start: 5px; }
.stat.ok   .num { color: var(--ok-fg); }
.stat.warn .num { color: var(--warn-fg); }
.stat.bad  .num { color: var(--err-fg); }
.stat.info .num { color: var(--info-fg); }

/* 4 — actions row (grouped inside the main card) */
.op-actions {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-block: 18px;
}
.op-card .op-actions {
  margin-block: 22px 0;
  padding-block-start: 22px;
  border-block-start: 1px solid var(--line);
}
.op-actions form { display: inline-flex; margin: 0; }
.is-hidden { display: none !important; }

/* Advanced / technical panel (collapsible) */
.advanced {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); margin-block: 16px; overflow: hidden;
}
.advanced > summary {
  cursor: pointer; padding: 13px 16px; font-weight: 600; color: var(--text-2);
  list-style: none; display: flex; align-items: center; justify-content: space-between;
}
.advanced > summary::-webkit-details-marker { display: none; }
.advanced > summary::after { content: "▾"; color: var(--muted); transition: transform .15s ease; }
.advanced[open] > summary::after { transform: rotate(180deg); }
.advanced > summary:hover { color: var(--ink); }
.advanced-body { padding: 0 16px 16px; }
.advanced-body .log { margin: 0; }

/* Advanced options nested inside the operation card (contained panel) */
.op-card .op-advanced {
  margin-block: 22px 0;
  background: var(--surface-2);
}
.adv-option {
  display: flex; align-items: flex-start; gap: 12px; cursor: pointer;
}
.adv-option input[type="checkbox"] {
  width: 18px; height: 18px; margin: 2px 0 0; flex-shrink: 0;
  accent-color: var(--primary); cursor: pointer;
}
.adv-option-text { display: flex; flex-direction: column; gap: 3px; }
.adv-option-title { font-weight: 600; color: var(--ink); }
.adv-option-hint { font-size: .85rem; color: var(--muted); }

/* =====================================================================
   Table inside a card (operations dashboard)
   ===================================================================== */
.card.card-table { padding: 14px 16px; }
.card-table .toolbar { margin-block-end: 12px; }
.table-wrap.flush {
  border: 0; box-shadow: none; border-radius: 0; background: transparent;
}

/* =====================================================================
   Responsive — stack tables on small screens, avoid horizontal page scroll
   ===================================================================== */
@media (max-width: 760px) {
  .topbar-inner { flex-wrap: wrap; min-height: 0; padding-block: 10px; gap: 8px 14px; }
  .topnav { order: 3; width: 100%; overflow-x: auto; }
  .topbar-right { margin-inline-start: auto; }
  .container, .container.wide { padding-inline: 16px; margin-block: 22px; }

  /* Card-style stacked rows: each <tr> becomes a card, each <td> a line. */
  .table-wrap { border: 0; background: transparent; box-shadow: none; overflow: visible; }
  .grid { min-width: 0; }
  .grid thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .grid, .grid tbody, .grid tr, .grid td { display: block; width: 100%; }
  .grid tr {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-block-end: 12px;
    padding: 6px 4px;
  }
  .grid td {
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    border-bottom: 1px solid var(--line);
    padding: 10px 14px; text-align: end;
  }
  .grid tr td:last-child { border-bottom: 0; }
  .grid td::before {
    content: attr(data-label);
    color: var(--muted); font-size: .78rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .03em;
    text-align: start;
  }
  .grid td:empty { display: none; }
  .progress { min-width: 0; flex: 1; }
  .inline-form { width: 100%; }
  .inline-form select, .inline-form input { flex: 1 1 100%; width: 100%; min-width: 0; }

  /* Operation-detail page on small screens */
  .op-card { padding: 20px 18px; }
  .op-stats { grid-template-columns: repeat(2, 1fr); }
  .op-actions .btn, .op-actions form { width: 100%; }
  .op-actions form .btn { width: 100%; }
}
