/* ============================================================
   Reusable Swiss data components: cards, badges, gauges,
   timelines, sparklines, stat blocks, tables.
   ============================================================ */

/* ---- Data card ---- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  position: relative;
}
.card-pad { padding: var(--s5); }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--s4) var(--s5); border-block-end: 1px solid var(--border);
}
.card-title { font-family: var(--font-head); font-weight: 600; font-size: var(--fs-h3); }
.card-sub { font-size: var(--fs-xs); color: var(--text-muted); margin-block-start: 2px; }

/* ---- KPI / metric tiles ---- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s4); }
.kpi {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: var(--s5); position: relative; overflow: hidden;
}
.kpi::before {
  content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; width: 3px;
  background: var(--accent, var(--emerald));
}
.kpi .kpi-label { display: flex; align-items: center; gap: var(--s2); color: var(--text-muted); }
.kpi .kpi-label .ico { width: 15px; height: 15px; color: var(--accent, var(--emerald)); }
.kpi .kpi-val { font-family: var(--font-num); font-weight: 700; font-size: 32px; line-height: 1.05; margin-block: var(--s3) var(--s2); letter-spacing: -0.03em; }
.kpi .kpi-val small { font-size: 14px; color: var(--text-muted); font-weight: 600; margin-inline-start: 4px; }
.kpi .kpi-foot { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-xs); }
.trend { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; font-family: var(--font-num); }
.trend.up { color: var(--emerald); } .trend.down { color: var(--red); } .trend.flat { color: var(--text-muted); }

/* ---- Badges ---- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: var(--r-sm); font-size: var(--fs-xs); font-weight: 700;
  font-family: var(--font-head); letter-spacing: 0.02em; white-space: nowrap;
  border: 1px solid transparent;
}
.badge .ico { width: 12px; height: 12px; }
.badge.em  { color: var(--emerald); background: var(--emerald-soft); border-color: rgba(16,185,129,0.25); }
.badge.am  { color: var(--amber);   background: var(--amber-soft);   border-color: rgba(245,158,11,0.25); }
.badge.red { color: var(--red);     background: var(--red-soft);     border-color: rgba(239,68,68,0.25); }
.badge.blue{ color: var(--blue);    background: var(--blue-soft);    border-color: rgba(59,130,246,0.25); }
.badge.ghost { color: var(--text-body); background: var(--bg-inset); border-color: var(--border); }

/* Verification badge (national CR / trade license) */
.verif {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px;
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  background: var(--bg-inset); font-size: var(--fs-xs);
}
.verif .flag { width: 16px; height: 11px; border-radius: 2px; flex: none; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12); }
.verif .vmeta b { font-family: var(--font-head); font-weight: 600; display: block; font-size: var(--fs-xs); }
.verif .vmeta span { font-family: var(--font-num); font-size: var(--fs-micro); color: var(--text-muted); }
.verif .chk { width: 13px; height: 13px; color: var(--emerald); margin-inline-start: 2px; }

/* ---- Circular execution-score gauge ---- */
.gauge { position: relative; display: inline-grid; place-items: center; }
.gauge svg { transform: rotate(-90deg); }
.gauge .g-track { fill: none; stroke: var(--border); }
.gauge .g-fill  { fill: none; stroke-linecap: round; transition: stroke-dashoffset 700ms var(--ease); }
.gauge .g-center { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.gauge .g-num { font-family: var(--font-num); font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.gauge .g-cap { font-size: 8px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-muted); font-family: var(--font-head); font-weight: 700; margin-top: 2px; }

/* ---- Delivery timeline (dotted, no text reviews) ---- */
.timeline { display: flex; align-items: center; gap: 0; }
.tl-dot {
  position: relative; width: 11px; height: 11px; border-radius: 50%; flex: none;
  box-shadow: 0 0 0 3px var(--bg-card);
}
.tl-dot.em  { background: var(--emerald); }
.tl-dot.am  { background: var(--amber); }
.tl-dot.red { background: var(--red); }
.tl-dot.future { background: var(--border-strong); }
.tl-seg { height: 2px; flex: 1; background: var(--border); min-width: 6px; }
.tl-dot[data-tip]:hover::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 8px); inset-inline-start: 50%; transform: translateX(-50%);
  background: var(--bg-elevated); border: 1px solid var(--border-strong); color: var(--text-primary);
  padding: 6px 9px; border-radius: var(--r-sm); font-size: var(--fs-xs); white-space: nowrap; z-index: 30;
  box-shadow: var(--shadow-pop); font-family: var(--font-body);
}
[dir="rtl"] .tl-dot[data-tip]:hover::after { transform: translateX(50%); }

/* ---- Sparkline / micro bars ---- */
.spark { display: flex; align-items: flex-end; gap: 2px; height: 30px; }
.spark i { flex: 1; background: var(--border-strong); border-radius: 1px; min-height: 2px; transition: height var(--dur) var(--ease); }
.spark i.em { background: var(--emerald); } .spark i.am { background: var(--amber); }

/* ---- Deviation stat inline ---- */
.dev { display: flex; flex-direction: column; gap: 3px; }
.dev .dev-k { font-size: var(--fs-micro); letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); font-family: var(--font-head); font-weight: 600; }
.dev .dev-v { font-family: var(--font-num); font-weight: 700; font-size: var(--fs-h3); }

/* ---- Data grid / table ---- */
.grid-tbl { width: 100%; border-collapse: separate; border-spacing: 0; }
.grid-tbl thead th {
  text-align: start; font-family: var(--font-head); font-weight: 600; font-size: var(--fs-micro);
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted);
  padding: var(--s3) var(--s4); border-block-end: 1px solid var(--border); position: sticky; top: 0; background: var(--bg-card); z-index: 5;
}
.grid-tbl tbody td { padding: var(--s4); border-block-end: 1px solid var(--border-faint); vertical-align: middle; }
.grid-tbl tbody tr { transition: background var(--dur) var(--ease); cursor: pointer; }
.grid-tbl tbody tr:hover { background: var(--bg-card-hover); }
.grid-tbl tbody tr[aria-selected="true"] { background: var(--bg-card-hover); box-shadow: inset 3px 0 0 var(--emerald); }
[dir="rtl"] .grid-tbl tbody tr[aria-selected="true"] { box-shadow: inset -3px 0 0 var(--emerald); }

.co-cell { display: flex; align-items: center; gap: var(--s3); }
.co-logo {
  width: 38px; height: 38px; border-radius: 9px; flex: none; display: grid; place-items: center;
  font-family: var(--font-head); font-weight: 700; font-size: 14px; color: var(--text-strong);
  border: 1px solid var(--border-strong); position: relative;
}
.co-logo .vchk { position: absolute; inset-block-end: -3px; inset-inline-end: -3px; width: 14px; height: 14px; border-radius: 50%; background: var(--emerald); color: #04130D; display: grid; place-items: center; border: 2px solid var(--bg-card); }
.co-logo .vchk svg { width: 8px; height: 8px; }
.co-name b { font-family: var(--font-head); font-weight: 600; font-size: var(--fs-body); display: block; }
.co-name span { font-size: var(--fs-xs); color: var(--text-muted); font-family: var(--font-num); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  padding: 9px 15px; border-radius: var(--r-md); font-family: var(--font-head); font-weight: 600; font-size: var(--fs-sm);
  transition: all var(--dur) var(--ease); border: 1px solid transparent; white-space: nowrap;
}
.btn .ico { width: 15px; height: 15px; }
.btn-primary { background: var(--emerald); color: #04130D; }
.btn-primary:hover { background: #14c993; }
.btn-ghost { background: var(--bg-inset); border-color: var(--border); color: var(--text-body); }
.btn-ghost:hover { border-color: var(--border-strong); color: var(--text-primary); }
.btn-sm { padding: 6px 11px; font-size: var(--fs-xs); }

/* ---- Section heading ---- */
.sec-head { display: flex; align-items: flex-end; justify-content: space-between; margin-block-end: var(--s4); }
.sec-head h1 { font-size: var(--fs-h1); }
.sec-head p { color: var(--text-body); font-size: var(--fs-sm); margin-block-start: 3px; }

/* ---- Progress meter (horizontal) ---- */
.meter { height: 6px; background: var(--bg-inset); border-radius: 99px; overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 99px; }

/* Live status dot */
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--emerald); animation: pulse-dot 1.6s var(--ease) infinite; }

/* ---- Modal (sovereign login) ---- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200; padding: 20px;
  background: rgba(5,7,12,0.66); backdrop-filter: blur(4px);
  display: grid; place-items: center; animation: rise 140ms var(--ease) both;
}
.modal {
  width: 384px; max-width: 100%; background: var(--bg-elevated);
  border: 1px solid var(--border-strong); border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop); overflow: hidden;
}
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s4); padding: var(--s5); border-block-end: 1px solid var(--border); }
.modal-head b { font-family: var(--font-head); font-size: var(--fs-h2); display: block; }
.modal-head span { font-size: var(--fs-xs); }
.modal-x { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; color: var(--text-muted); background: var(--bg-inset); border: 1px solid var(--border); }
.modal-x:hover { color: var(--text-primary); border-color: var(--border-strong); }
.modal-x svg { width: 16px; height: 16px; }
.modal-body { padding: var(--s5); }
.modal-foot { padding: 0 var(--s5) var(--s5); display: flex; justify-content: center; }
.auth-state { display: flex; flex-direction: column; align-items: center; gap: var(--s3); padding: var(--s8) 0; text-align: center; }
.auth-state b { font-family: var(--font-head); font-size: var(--fs-h3); }
.auth-state .ico { width: 36px; height: 36px; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--border-strong); border-top-color: var(--emerald); animation: ring-spin 0.8s linear infinite; }

/* GCC jurisdiction dropdown (console filter + verifier login) */
.gcc-select {
  display: inline-flex; align-items: center; gap: var(--s2);
  background: var(--bg-inset); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 0 10px; height: 37px; color: var(--text-body); transition: border-color var(--dur) var(--ease);
}
.gcc-select:focus-within { border-color: var(--border-strong); }
.gcc-select .ico { width: 15px; height: 15px; color: var(--text-muted); flex: none; }
.gcc-select select {
  appearance: none; -webkit-appearance: none; background: transparent; border: none; outline: none;
  color: var(--text-primary); font-family: var(--font-head); font-weight: 600; font-size: var(--fs-sm);
  padding-inline-end: 16px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: right 4px center, right 0px center; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
[dir="rtl"] .gcc-select select { padding-inline-end: 16px; background-position: left 4px center, left 0px center; }
.gcc-select select option { background: var(--bg-elevated); color: var(--text-primary); }
.gcc-select.wide { width: 100%; height: 46px; }

/* Inline vendor status indicator (verified vs watch) */
.status-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-inline-end: 7px; vertical-align: middle; }
.status-dot.em { background: var(--emerald); box-shadow: 0 0 0 2px var(--emerald-soft); }
.status-dot.am { background: var(--amber);   box-shadow: 0 0 0 2px var(--amber-soft); }
.status-dot.red{ background: var(--red);     box-shadow: 0 0 0 2px var(--red-soft); }
