/* AGP admin — interface layer.
   Loaded after admin.css: redefines the tokens and refines the shared components.
   Principles: few borders (spacing and weight group things), one accent used for the primary action and the
   current location only, colour reserved for status, numbers lead and labels follow, one type scale. */

:root {
  /* AGP maritime-blue identity: one accent for actions and current location, colour only for status. */
  --bg: #f5f8fa;
  --card: #ffffff;
  --card-2: #f7fafc;
  --text: #0e1e2b;
  --muted: #5e7482;
  --accent: #12557a;
  --accent-strong: #0d3b57;
  --accent-soft: rgba(18, 85, 122, .09);
  --danger: #a32b22;
  --warn: #8a5a00;
  --ok: #12715b;
  --line: #d9e4eb;
  --line-strong: #c4d4de;
  --shadow: none;

  --st-nomination: #8a5a00;
  --st-rejected: #a32b22;
  --st-measurement: #12557a;
  --st-discharge: #3f5e86;
  --st-hold: #b45309;
  --st-dates: #5b4b8a;
  --st-completed: #12715b;

  --radius: 10px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --text-sm: 13px;
  --text-base: 15px;
  --text-lg: 17px;
  --text-xl: 22px;
  --text-num: 30px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1b26;
    --card: #102636;
    --card-2: #133041;
    --text: #e8f1f6;
    --muted: #9ab4c3;
    --accent: #5aa9cf;
    --accent-strong: #7cc0e0;
    --accent-soft: rgba(90, 169, 207, .15);
    --danger: #ff9b93;
    --warn: #e7b25c;
    --ok: #5fd3ab;
    --line: #1e3a4b;
    --line-strong: #2b4b5e;

    --st-nomination: #e7b25c;
    --st-rejected: #ff9b93;
    --st-measurement: #7cc0e0;
    --st-discharge: #93a9c9;
    --st-hold: #e9a06a;
    --st-dates: #b3a3e0;
    --st-completed: #5fd3ab;
    --st-unreleased: #46535b;
  }
}

body {
  font-family: "Segoe UI", "Noto Sans Arabic", "Tahoma", system-ui, sans-serif;
  font-size: var(--text-base);
  line-height: 1.65;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

h1, h2, h3 { line-height: 1.3; }

/* ---------- shell ---------- */

.topbar {
  padding: 10px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.brand strong { font-size: var(--text-lg); }
.brand small { font-size: var(--text-sm); }
.wrap { max-width: 1360px; padding: var(--space-5) var(--space-5) 96px; }

#appView {
  grid-template-columns: 232px minmax(0, 1fr);
  gap: var(--space-5);
}

.tabs {
  gap: 2px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  top: 76px;
}

.nav-label {
  margin: var(--space-4) var(--space-3) var(--space-1);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--muted);
}
.nav-label:first-child { margin-top: 0; }

.tab {
  position: relative;
  padding: 9px var(--space-3);
  border-radius: 8px;
  color: var(--text);
  font-size: 14.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}
.tab:hover { background: var(--accent-soft); }
.tab.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 700;
  border-color: transparent;
}
.tab.active::before {
  content: "";
  position: absolute;
  inset-block: 8px;
  inset-inline-start: -2px;
  width: 3px;
  border-radius: 3px;
  background: var(--accent);
}

/* ---------- page structure ---------- */

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin: 0 0 var(--space-5);
}
.page-head h1 { margin: 0; font-size: var(--text-xl); font-weight: 800; }
.page-sub { margin: var(--space-1) 0 0; color: var(--muted); font-size: 14px; }
.page-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }

.block {
  margin: 0 0 var(--space-5);
  padding: var(--space-5);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.block-head {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  margin: 0 0 var(--space-4);
}
.block-head h2 { margin: 0; font-size: var(--text-lg); font-weight: 700; }
.block-head .btn { margin-inline-start: auto; }

.card {
  border-radius: var(--radius);
  box-shadow: none;
  padding: var(--space-5);
}
.card-head h2 { font-size: var(--text-lg); font-weight: 700; }

.section { border-top-color: var(--line); }

.two-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: var(--space-5);
  align-items: start;
}

/* ---------- controls ---------- */

.btn {
  min-height: 38px;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14.5px;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line-strong);
  transition: background .12s ease, border-color .12s ease;
}
.btn:hover { filter: none; background: var(--accent-soft); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--accent-soft); color: var(--text); }
.btn.danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }
.btn.small { min-height: 32px; padding: 4px 12px; font-size: 13px; }
.btn:focus-visible, .tab:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn:disabled { opacity: .5; }
a.btn { display: inline-flex; align-items: center; text-decoration: none; }

input, select {
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--card);
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
input::placeholder { color: var(--muted); opacity: .8; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4) var(--space-5);
}
.form-grid .span-2 { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { margin: 0; font-size: 14px; font-weight: 600; color: var(--text); }
.field > small { color: var(--muted); font-size: 12.5px; }
.field input, .field select { margin: 0; width: 100%; }
.form-actions { display: flex; justify-content: flex-end; gap: var(--space-2); }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }

.advanced > summary, details.disclosure > summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  padding: var(--space-1) 0;
}
.advanced[open] > summary { margin-bottom: var(--space-3); }

input[type="file"] {
  min-height: 56px;
  padding: 14px;
  border: 1px dashed var(--line-strong);
  background: var(--card-2);
}

/* segmented filter */
.seg {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  flex-wrap: wrap;
}
.seg button, .seg .chip.filter {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 6px 14px;
  border-radius: 7px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}
.seg button:hover, .seg .chip.filter:hover { color: var(--text); }
.seg button.active, .seg .chip.filter.active {
  background: var(--card);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--line-strong);
  outline: none;
}
.toolbar { display: flex; align-items: center; gap: var(--space-4); margin-bottom: var(--space-4); flex-wrap: wrap; }

/* ---------- tables ---------- */

.table th {
  position: sticky;
  top: 0;
  background: var(--card);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-strong);
  text-align: start;
  z-index: 1;
}
.table td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:hover { background: var(--card-2); }
.table-scroll { border: 1px solid var(--line); border-radius: 8px; max-height: 480px; }
.table-scroll.tall { max-height: 56vh; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  background: color-mix(in srgb, var(--ok) 12%, transparent);
  color: var(--ok);
}
.badge.off { background: var(--card-2); color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); }
.badge.warn { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); }
.badge.bad { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }

.chip { font-weight: 600; }
.chip.warn { color: var(--warn); }

/* ---------- dashboard ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}
.stat {
  padding: var(--space-4) var(--space-5);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.stat .stat-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.stat .stat-value { font-size: var(--text-num); font-weight: 800; line-height: 1.25; }
.stat .stat-value small { font-size: 15px; font-weight: 600; color: var(--muted); margin-inline-start: 4px; }
.stat .stat-hint { font-size: 12.5px; color: var(--muted); }
.stat.lead { background: var(--accent-soft); border-color: transparent; }
.stat.lead .stat-value { color: var(--accent-strong); }
.stat.alert .stat-value { color: var(--warn); }
.stats-compact { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--space-3); margin-bottom: var(--space-4); }
.stats-compact .stat { padding: var(--space-3) var(--space-4); }
.stats-compact .stat-value { font-size: 24px; }

.vessel-board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: var(--space-4);
}
.vessel-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.vessel-card header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); }
.vessel-card h3 { margin: 0; font-size: var(--text-lg); font-weight: 800; }
.vessel-card .meta { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.vessel-metrics { display: flex; gap: var(--space-5); align-items: flex-end; }
.vessel-metrics strong { display: block; font-size: 26px; font-weight: 800; line-height: 1.2; }
.vessel-metrics strong small { font-size: 14px; color: var(--muted); font-weight: 600; margin-inline-start: 2px; }
.vessel-metrics span { color: var(--muted); font-size: 12.5px; }

.pipeline {
  display: flex;
  height: 10px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--line);
  gap: 2px;
}
.pipeline i { display: block; min-width: 3px; }
.pipeline-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px var(--space-4);
  font-size: 12.5px;
  color: var(--muted);
}
.pipeline-legend li { display: inline-flex; align-items: center; gap: 6px; }
.pipeline-legend b { color: var(--text); font-weight: 700; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.st-nomination { background: var(--st-nomination); }
.st-rejected { background: var(--st-rejected); }
.st-measurement { background: var(--st-measurement); }
.st-discharge { background: var(--st-discharge); }
.st-hold { background: var(--st-hold); }
.st-dates { background: var(--st-dates); }
.st-completed { background: var(--st-completed); }
.vessel-card footer { display: flex; gap: var(--space-2); margin-top: auto; padding-top: var(--space-1); }

.attention { display: flex; flex-direction: column; }
.attention-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--line);
}
.attention-item:last-child { border-bottom: 0; }
.attention-item .dot { margin-top: 2px; }
.attention-item p { margin: 0; flex: 1; font-size: 14.5px; }
.attention-item .sev-warn { background: var(--warn); }
.attention-item .sev-bad { background: var(--danger); }
.attention-item .sev-info { background: var(--st-measurement); }
.attention-ok { color: var(--muted); padding: var(--space-3) 0; }

.feed-item { padding: var(--space-3) 0; border-bottom: 1px solid var(--line); }
.feed-item strong { font-size: 14.5px; }
.feed-item div { font-size: 14px; }
.feed-item small { color: var(--muted); }

/* ---------- import wizard ---------- */

.steps {
  display: flex;
  gap: var(--space-5);
  list-style: none;
  padding: 0;
  margin: 0 0 var(--space-5);
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}
.steps li { display: inline-flex; align-items: center; gap: var(--space-2); }
.steps li span {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  font-size: 12.5px;
}
.steps li.current { color: var(--text); }
.steps li.current span { background: var(--accent); border-color: var(--accent); color: #fff; }
.steps li.done span { background: var(--accent-soft); border-color: transparent; color: var(--accent-strong); }

.review-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-4); }
.review-head h2 { margin: 0; font-size: var(--text-lg); }

.notice {
  padding: var(--space-3) var(--space-4);
  border-radius: 8px;
  background: color-mix(in srgb, var(--warn) 10%, transparent);
  color: var(--text);
  font-size: 14px;
  margin-bottom: var(--space-4);
  border-inline-start: 3px solid var(--warn);
}
.notice.info { background: var(--accent-soft); border-inline-start-color: var(--accent); }
.notice.bad { background: color-mix(in srgb, var(--danger) 9%, transparent); border-inline-start-color: var(--danger); }

.decision-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin: var(--space-3) 0;
}
.decision-bar .hint { flex: 1 1 100%; }

.action-bar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  margin: 0 calc(var(--space-5) * -1);
  background: var(--card);
  border-top: 1px solid var(--line-strong);
}
.action-bar-info { flex: 1; font-size: 14.5px; }
.action-bar-info strong { font-weight: 800; }

.done-box { text-align: center; padding: var(--space-6) var(--space-5); }
.done-box h2 { margin: 0 0 var(--space-2); font-size: var(--text-xl); }
.done-box p { margin: 0 0 var(--space-5); color: var(--muted); }
.done-box .page-actions { justify-content: center; }

details.disclosure { margin-bottom: var(--space-5); }
details.disclosure > .block { margin-top: var(--space-3); }

.danger-zone { margin-top: var(--space-6); }
.danger-zone > summary { color: var(--danger); cursor: pointer; font-size: 14px; font-weight: 600; }
.danger-zone .hint { display: block; margin: var(--space-2) 0 var(--space-3); }

/* ---------- small screens ---------- */

@media (max-width: 900px) {
  #appView { grid-template-columns: 1fr; }
  .tabs {
    position: static;
    flex-direction: row;
    flex-wrap: nowrap;
    max-height: none;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .nav-label { display: none; }
  .tab { width: auto; flex: none; white-space: nowrap; }
  .tab.active::before { display: none; }
  .wrap { padding: var(--space-4) var(--space-4) 96px; }
  .block { padding: var(--space-4); }
  .action-bar { margin: 0 calc(var(--space-4) * -1); padding: var(--space-3) var(--space-4); flex-wrap: wrap; }
}

@media (max-width: 700px) {
  .topbar { flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
  .brand { flex: 1 1 auto; }
  .brand small { display: none; }
  .brand strong { white-space: nowrap; font-size: 16px; }
  .user { flex: 1 1 100%; justify-content: space-between; }
  .page-head h1 { font-size: 20px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 12px 14px; }
  .stat .stat-value { font-size: 24px; }
  .vessel-board { grid-template-columns: 1fr; }
  .steps { gap: 14px; font-size: 13px; }
  .two-col { grid-template-columns: 1fr; }
}


/* ---------- orders and batches ---------- */

.st-unreleased { background: var(--st-unreleased); }

.vessel-group { margin-bottom: var(--space-6); }
.vessel-group > header {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-3);
}
.vessel-group > header h2 { margin: 0; font-size: var(--text-lg); }
.vessel-group > header .hint { flex: 1; }

.order-card {
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-3);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.order-head { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.order-head h3 { margin: 0; font-size: var(--text-lg); font-weight: 800; }
.order-head .order-meta { color: var(--muted); font-size: 13.5px; flex: 1; }
.order-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }

.batch-size {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-3) 0;
  flex-wrap: wrap;
}
.batch-size input { width: 110px; min-height: 36px; }
.batch-size .hint { margin-inline-start: var(--space-2); }

.batch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: var(--space-3);
}
.batch {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: var(--space-3);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--card);
}
.batch.released {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}
.batch-title { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.batch-title strong { font-size: 15px; }
.batch-title span { color: var(--muted); font-size: 12.5px; }
.batch-progress { height: 6px; border-radius: 4px; background: var(--line); overflow: hidden; }
.batch-progress i { display: block; height: 100%; background: var(--st-completed); }
.batch-stat { font-size: 12.5px; color: var(--muted); }
.batch-stat b { color: var(--text); }
.batch .btn { margin-top: auto; }
.badge.released { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent-strong); }


/* ---------- dialogs and the undo bar ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: var(--space-4);
  background: rgba(8, 14, 11, .55);
}
.modal {
  width: min(620px, 100%);
  max-height: 86vh;
  overflow: auto;
  padding: var(--space-5);
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
}
.modal h2 { margin: 0 0 var(--space-3); font-size: var(--text-lg); }
.modal .choices { display: flex; flex-direction: column; gap: var(--space-2); margin: var(--space-3) 0; }
.modal .choice { display: flex; gap: var(--space-2); align-items: flex-start; padding: var(--space-2) 0; cursor: pointer; }
.modal .choice input { width: auto; min-height: 0; margin: 4px 0 0; }
.modal .choice small { display: block; color: var(--muted); }
.modal .picklist { max-height: 220px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: var(--space-2) var(--space-3); }
.modal .actions { justify-content: flex-start; }
.batch { cursor: pointer; }
.batch:hover { border-color: var(--accent); }
.batch .btn { cursor: pointer; }

.undo-bar {
  position: fixed;
  z-index: 60;
  inset-inline: 0;
  bottom: var(--space-5);
  margin-inline: auto;
  width: min(460px, calc(100% - 32px));
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--text);
  color: var(--bg);
  border-radius: var(--radius);
}
.undo-bar span { flex: 1; }
.undo-bar .btn { background: transparent; color: inherit; border-color: color-mix(in srgb, var(--bg) 40%, transparent); }
.undo-bar .count { font-variant-numeric: tabular-nums; opacity: .8; }


/* Completed orders of a vessel: folded away until opened */
.done-orders { margin-top: 14px; border-top: 1px solid var(--line, #e4e4e0); padding-top: 10px; }
.done-orders > summary { cursor: pointer; font-weight: 700; padding: 6px 0; color: var(--muted, #5b6770); }
.done-orders .order-card { opacity: .92; }


/* optional vessel-file picker in the start-vessel form */
.file-pick { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-size: 13px; }
.file-pick input[type="file"] { max-width: 210px; }
.attention ul { margin: 6px 0 0; padding-inline-start: 18px; }


/* mandatory warning: stage work started on a vessel without its file */
.alert-banner {
  border: 1px solid var(--danger); border-radius: 12px; padding: 12px 16px; margin-bottom: 16px;
  background: color-mix(in srgb, var(--danger) 9%, var(--card)); color: var(--text);
}
.alert-banner strong { color: var(--danger); }
.alert-banner .alert-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 8px; }
.alert-banner .alert-row span { flex: 1 1 260px; }

/* vessel statistics + charts (categorical slots 1-3 of the validated palette; neutral for "remaining") */
.vs {
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s-rest: #c7d3da; --surface: var(--card);
  --ink: var(--text); --ink2: var(--muted); --grid: var(--line-soft);
}
@media (prefers-color-scheme: dark) {
  .vs { --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s-rest: #3a5668; }
}
.vs-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 14px 0 18px; }
.vs-kpi { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--surface); }
.vs-kpi b { display: block; font-size: 26px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.vs-kpi span { color: var(--ink2); font-size: 13px; }
.vs-grid { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; gap: 16px; margin-bottom: 16px; }
@media (max-width: 900px) { .vs-grid { grid-template-columns: 1fr; } }
.vs-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; background: var(--surface); position: relative; }
.vs-card h3 { margin: 0 0 2px; font-size: 15px; }
.vs-card .sub { color: var(--ink2); font-size: 12.5px; margin-bottom: 10px; }
.vs-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 6px 0 10px; font-size: 13px; color: var(--ink); }
.vs-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 6px; vertical-align: -1px; }
.vs svg { display: block; width: 100%; height: auto; overflow: visible; }
.vs svg text { fill: var(--ink2); font-size: 11px; font-family: inherit; }
.vs .grid line { stroke: var(--grid); stroke-width: 1; }
.vs .axis line { stroke: var(--line); }
.vs .hit { fill: transparent; cursor: default; }
.vs .hit:hover { fill: color-mix(in srgb, var(--ink) 5%, transparent); }
.vs-tip {
  position: absolute; pointer-events: none; z-index: 5; min-width: 150px; padding: 8px 10px; border-radius: 10px;
  background: var(--card); color: var(--ink); border: 1px solid var(--line); box-shadow: var(--shadow); font-size: 12.5px; line-height: 1.6;
}
.vs-tip b { display: block; margin-bottom: 2px; }
.vs-tip i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-inline-end: 6px; }
.vs-donut-wrap { display: flex; flex-direction: column; align-items: center; }
.vs-donut-wrap .vs-legend { align-self: stretch; flex-direction: column; gap: 4px; }
.vs-donut-wrap .vs-legend div { display: flex; justify-content: space-between; gap: 8px; }
.vs-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 10px 0; }
.vs-table td.state-remaining { color: var(--ink2); }


/* undo bar v2: countdown track, swipe either way to finish now */
.undo-bar { flex-wrap: wrap; overflow: hidden; touch-action: pan-y; user-select: none; transition: transform .18s ease-out, opacity .18s ease-out; padding-bottom: calc(var(--space-3) + 3px); }
.undo-bar .undo-hint { display: block; font-size: 12px; opacity: .7; }
.undo-bar .undo-track { position: absolute; inset-inline: 0; bottom: 0; height: 3px; background: color-mix(in srgb, var(--bg) 25%, transparent); }
.undo-bar .undo-track b { display: block; height: 100%; background: var(--bg); transform-origin: right; animation: undoShrink 5s linear forwards; }
@keyframes undoShrink { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.batch-acts { display: flex; flex-wrap: wrap; gap: 6px; }
.badge.partial { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.sel-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.sel-tools .sel-count { margin-inline-end: auto; font-weight: 700; }


/* messages: edit / removed / image viewer */
.chat-bubble.removed { opacity: .72; border-style: dashed; }
.chat-bubble.removed .msg-body, .chat-bubble.removed .chat-image { text-decoration: line-through; filter: grayscale(.6); }
.msg-note { font-size: 12px; color: var(--danger); margin: 2px 0; font-weight: 600; }
.msg-edited { font-size: 11.5px; opacity: .75; margin-inline-start: 6px; cursor: help; }
.msg-orig { font-size: 12px; opacity: .8; margin-top: 2px; }
.msg-actions { display: flex; gap: 10px; margin-top: 4px; }
.msg-act { background: none; border: 0; padding: 2px 0; color: var(--accent); font-size: 12.5px; font-weight: 600; cursor: pointer; }
.msg-act.danger { color: var(--danger); }
.msg-editor textarea { width: 100%; min-height: 60px; }
.msg-editor .row { display: flex; gap: 8px; margin-top: 6px; }
.chat-image { cursor: zoom-in; }
.img-viewer { position: fixed; inset: 0; z-index: 90; background: rgba(5, 14, 22, .88); display: grid; grid-template-rows: 1fr auto; padding: 16px; }
.img-viewer img { max-width: 100%; max-height: calc(100vh - 110px); margin: auto; border-radius: 10px; }
.img-viewer .bar { display: flex; gap: 10px; justify-content: center; padding-top: 10px; }
.img-viewer .btn { min-width: 110px; }

/* floating message bubble (manager) */
.chat-bubble-fab {
  position: fixed; z-index: 70; inset-inline-end: 20px; bottom: 20px; width: 58px; height: 58px; border-radius: 50%; border: 0;
  background: var(--accent); color: #fff; display: grid; place-items: center; cursor: pointer;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .3); transition: transform .15s;
}
.chat-bubble-fab:hover { transform: scale(1.06); }
.chat-bubble-fab svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.chat-bubble-fab .fab-badge { position: absolute; top: -4px; inset-inline-end: -4px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--danger); color: #fff; font-size: 12px; line-height: 22px; font-weight: 700; }
.chat-bubble-fab.ping { animation: fabPing .9s ease-out 2; }
@keyframes fabPing { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent); } 100% { box-shadow: 0 0 0 22px transparent; } }
.fab-preview {
  position: fixed; z-index: 71; inset-inline-end: 90px; bottom: 28px; max-width: min(320px, calc(100vw - 120px)); padding: 10px 14px;
  background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); cursor: pointer;
}
.fab-preview strong { display: block; font-size: 13px; }
.fab-preview span { display: block; font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fab-panel {
  position: fixed; z-index: 70; inset-inline-end: 20px; bottom: 90px; width: min(360px, calc(100vw - 40px)); height: min(480px, calc(100vh - 120px));
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden;
}
.fab-panel header { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.fab-panel header h3 { margin: 0; font-size: 15px; flex: 1; }
.fab-panel .fab-body { flex: 1; overflow-y: auto; padding: 8px; }
.fab-thread { display: flex; gap: 10px; align-items: center; padding: 9px 8px; border-radius: 10px; cursor: pointer; }
.fab-thread:hover { background: var(--tint); }
.fab-thread .nm { font-weight: 700; font-size: 14px; }
.fab-thread .last { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 230px; }
.fab-thread .cnt { margin-inline-start: auto; background: var(--danger); color: #fff; border-radius: 10px; min-width: 20px; text-align: center; font-size: 12px; font-weight: 700; padding: 1px 6px; }
.fab-panel form { display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--line); }
.fab-panel form textarea { flex: 1; min-height: 40px; max-height: 90px; resize: none; }
@media (prefers-reduced-motion: reduce) { .chat-bubble-fab.ping { animation: none; } }
