/* ==========================================================================
   Mint Glass Operations UI - IP Purity Console
   Tokens follow references/style-guide.md (light + dark semantic contract).
   ========================================================================== */

:root {
  color-scheme: light;

  --primary: #2cad82;
  --primary-strong: #198966;
  --primary-soft: #dff5eb;
  --blue: #5d9fe8;
  --blue-soft: #e7f1fd;
  --amber: #e6a53b;
  --amber-soft: #fff3dc;
  --danger: #dc6671;
  --danger-soft: #fde9eb;
  --violet: #9179cf;
  --surface: #ffffff;
  --surface-muted: #f5faf7;
  --text: #263934;
  --muted: #758a84;
  --faint: #9fb0ab;
  --line: rgba(48, 101, 84, 0.11);
  --shadow-sm: 0 8px 24px -16px rgba(31, 105, 82, 0.34);
  --shadow: 0 20px 48px -28px rgba(31, 105, 82, 0.36);
  --shadow-lg: 0 28px 72px -30px rgba(31, 105, 82, 0.45);
  --radius-panel: 20px;
  --radius-card: 14px;
  --radius-control: 11px;

  --page-bg: linear-gradient(135deg, #eef7f2 0%, #edf4f8 48%, #f8f5ef 100%);
  --panel: rgba(255, 255, 255, 0.92);
  --sidebar: rgba(255, 255, 255, 0.72);
  --control: #f5faf7;
  --overlay: rgba(20, 40, 34, 0.38);
  --focus-ring: rgba(44, 173, 130, 0.26);
  --header-bg: rgba(245, 250, 247, 0.94);
  --row-hover: rgba(44, 173, 130, 0.055);
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --primary: #63d6aa;
  --primary-strong: #90e8c4;
  --primary-soft: #183d32;
  --blue: #8bbcf3;
  --blue-soft: #1d3047;
  --amber: #efc16d;
  --amber-soft: #3d3221;
  --danger: #f197a1;
  --danger-soft: #42282f;
  --violet: #bba4ed;
  --surface: #18251f;
  --surface-muted: #132019;
  --text: #e1eee7;
  --muted: #a0b5aa;
  --faint: #829c8e;
  --line: rgba(172, 211, 190, 0.15);
  --shadow-sm: 0 8px 24px -16px rgba(0, 0, 0, 0.55);
  --shadow: 0 20px 48px -28px rgba(0, 0, 0, 0.65);
  --shadow-lg: 0 28px 72px -30px rgba(0, 0, 0, 0.75);

  --page-bg: linear-gradient(135deg, #101c17 0%, #142029 52%, #211f1a 100%);
  --panel: rgba(24, 37, 31, 0.94);
  --sidebar: rgba(17, 29, 23, 0.88);
  --control: #132019;
  --overlay: rgba(0, 0, 0, 0.62);
  --focus-ring: rgba(99, 214, 170, 0.3);
  --header-bg: rgba(19, 32, 25, 0.94);
  --row-hover: rgba(99, 214, 170, 0.07);
}

* { box-sizing: border-box; }

/* author display rules must never beat the hidden attribute */
[hidden] { display: none !important; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--page-bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", ui-sans-serif, system-ui,
    -apple-system, "Segoe UI", sans-serif;
  font-size: 13px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }

::selection { background: var(--primary-soft); color: var(--text); }

:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
  border-radius: var(--radius-control);
}

/* ------------------------------------------------------------------ boot */

.boot {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  color: var(--muted);
  font-size: 12px;
  z-index: 40;
}

.spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--primary);
  animation: spin 0.75s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ----------------------------------------------------------------- login */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  padding: 28px;
  border-radius: var(--radius-panel);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(18px) saturate(1.2);
  display: grid;
  gap: 16px;
  animation: rise 0.28s ease-out both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.login-brand { display: flex; align-items: center; gap: 12px; }
.login-brand strong { display: block; font-size: 17px; font-weight: 740; letter-spacing: 0.2px; }
.login-brand small { display: block; font-size: 11px; color: var(--muted); }
.login-desc { font-size: 12px; color: var(--muted); }

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  flex: none;
  background: linear-gradient(135deg, var(--primary), var(--blue));
  box-shadow: var(--shadow-sm);
  position: relative;
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 10px 9px;
  border-left: 2.4px solid rgba(255, 255, 255, 0.92);
  border-bottom: 2.4px solid rgba(255, 255, 255, 0.92);
  transform: skewX(-18deg) rotate(-8deg);
  border-radius: 1px;
}

.login-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 10.5px;
  color: var(--faint);
  border-top: 1px solid var(--line);
  padding-top: 12px;
  flex-wrap: wrap;
}

.theme-mini {
  border: 1px solid var(--line);
  background: var(--control);
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 10.5px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.theme-mini:hover { color: var(--primary-strong); border-color: var(--primary); }

/* ------------------------------------------------------------------ shell */

.shell {
  display: grid;
  grid-template-columns: 276px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px 16px 16px;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(20px) saturate(1.25);
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 11px; padding: 0 6px; }
.brand-text strong { display: block; font-size: 14px; font-weight: 740; letter-spacing: 0.2px; }
.brand-text small { display: block; font-size: 10px; color: var(--faint); letter-spacing: 0.6px; text-transform: uppercase; }

.nav { display: grid; gap: 3px; }
.nav-group {
  font-size: 10px;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  color: var(--faint);
  padding: 12px 10px 5px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 10px;
  border-radius: 12px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 560;
  position: relative;
  transition: background 0.15s, color 0.15s, transform 0.15s;
}

.nav-item:hover { background: var(--primary-soft); color: var(--primary-strong); transform: translateX(2px); }

.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-weight: 680;
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: -16px;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--primary);
}

.nav-icon {
  width: 28px;
  height: 28px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}

.nav-item.active .nav-icon { color: var(--primary-strong); background: var(--surface); }

.sidebar-foot {
  margin-top: auto;
  display: grid;
  gap: 8px;
  padding: 12px 6px 0;
  border-top: 1px solid var(--line);
}

.main {
  min-width: 0;
  padding: 26px 34px 48px;
  max-width: 1720px;
  width: 100%;
}

.view {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  animation: rise 0.24s ease-out both;
}

.view > * { min-width: 0; }

/* ----------------------------------------------------------- page header */

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  min-width: 0;
}

.ph-left { display: flex; gap: 13px; align-items: flex-start; min-width: 0; }
.ph-left > div { min-width: 0; }

.ph-icon {
  width: 40px;
  height: 40px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-size: 16px;
  flex: none;
  border: 1px solid var(--line);
}

.ph-eyebrow { font-size: 10px; letter-spacing: 1px; text-transform: uppercase; color: var(--faint); }
.ph-title { font-size: 24px; font-weight: 750; letter-spacing: -0.2px; line-height: 1.25; }
.ph-desc { font-size: 12px; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.ph-title { overflow-wrap: anywhere; }
.ph-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ------------------------------------------------------------------ panel */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.panel-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.panel-sub { font-size: 11px; color: var(--muted); }
.panel-body { padding: 18px; }
.panel-body.tight { padding: 0; }

/* ------------------------------------------------------------------ stats */

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 14px 16px 14px 19px;
  box-shadow: var(--shadow-sm);
  position: relative;
  transition: transform 0.15s, box-shadow 0.15s;
}

.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.stat::before {
  content: "";
  position: absolute;
  left: 0;
  top: 14px;
  bottom: 14px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--primary);
}

.stat.blue::before { background: var(--blue); }
.stat.amber::before { background: var(--amber); }
.stat.danger::before { background: var(--danger); }
.stat.violet::before { background: var(--violet); }

.stat-label { font-size: 11px; color: var(--muted); letter-spacing: 0.2px; }
.stat-value {
  font-size: 27px;
  font-weight: 750;
  letter-spacing: -0.5px;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.stat-value small { font-size: 12px; font-weight: 600; color: var(--muted); margin-left: 3px; }
.stat-hint { font-size: 10.5px; color: var(--faint); }

/* ---------------------------------------------------------------- controls */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 15px;
  border-radius: var(--radius-control);
  border: 1px solid transparent;
  font-size: 12.5px;
  font-weight: 620;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.12s, box-shadow 0.15s, background 0.15s, color 0.15s, border-color 0.15s;
}

.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: #fff;
  box-shadow: var(--shadow-sm);
}
:root[data-theme="dark"] .btn-primary { color: #0d2a20; }

.btn-soft { background: var(--primary-soft); color: var(--primary-strong); }
.btn-soft:hover:not(:disabled) { border-color: var(--primary); }

.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--text); }
.btn-ghost:hover:not(:disabled) { border-color: var(--primary); color: var(--primary-strong); }

.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.btn-danger:hover:not(:disabled) { border-color: var(--danger); }

.btn-sm { height: 30px; padding: 0 10px; font-size: 11.5px; border-radius: 9px; }
.btn-block { width: 100%; }

.btn.is-busy { pointer-events: none; opacity: 0.8; }

.icon-btn {
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, transform 0.12s;
}
.icon-btn:hover { color: var(--primary-strong); border-color: var(--primary); transform: translateY(-1px); }

.field { display: grid; gap: 6px; min-width: 0; }
.field-label { font-size: 11.5px; font-weight: 600; color: var(--muted); }
.field-hint { font-size: 10.5px; color: var(--faint); }

.input, .select, .textarea {
  width: 100%;
  background: var(--control);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
  padding: 9px 11px;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.input, .select { height: 38px; }
.textarea { min-height: 260px; resize: vertical; line-height: 1.6; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }

.input::placeholder, .textarea::placeholder { color: var(--faint); }

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.select option { background: var(--surface); color: var(--text); }

.field-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.field-grid .span-2 { grid-column: span 2; }
.field-grid .span-4 { grid-column: span 4; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-muted);
}

.toolbar .input, .toolbar .select { height: 34px; font-size: 12px; }
.toolbar .grow { flex: 1 1 180px; min-width: 140px; }
.toolbar-spacer { flex: 1 1 auto; }

/* ------------------------------------------------------------------- pills */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 640;
  line-height: 1.7;
  white-space: nowrap;
  border: 1px solid transparent;
}

.pill-ok { background: var(--primary-soft); color: var(--primary-strong); }
.pill-run { background: var(--blue-soft); color: var(--blue); }
.pill-warn { background: var(--amber-soft); color: var(--amber); }
.pill-err { background: var(--danger-soft); color: var(--danger); }
.pill-muted { background: var(--surface-muted); color: var(--muted); border-color: var(--line); }

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.pill-run .dot { animation: pulse 1.6s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.8); }
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 7px;
  font-size: 10px;
  font-weight: 620;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface-muted);
  white-space: nowrap;
}

.badge-primary { color: var(--primary-strong); background: var(--primary-soft); border-color: transparent; }
.badge-blue { color: var(--blue); background: var(--blue-soft); border-color: transparent; }
.badge-amber { color: var(--amber); background: var(--amber-soft); border-color: transparent; }
.badge-danger { color: var(--danger); background: var(--danger-soft); border-color: transparent; }

.badge-group { display: flex; gap: 4px; flex-wrap: wrap; }

/* ------------------------------------------------------------------ tables */

.table-wrap { overflow-x: auto; }

table.data {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
  min-width: 900px;
}

table.data thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--header-bg);
  backdrop-filter: blur(8px);
  text-align: left;
  font-size: 10.5px;
  font-weight: 680;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--faint);
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

table.data tbody td {
  padding: 9px 11px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

table.data tbody tr:hover td { background: var(--row-hover); }
table.data tbody tr.expanded td { background: var(--surface-muted); }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11.5px; }

.trunc {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  vertical-align: bottom;
}

@media (max-width: 1520px) {
  .trunc { max-width: 108px; }
}

.cell-actions { display: flex; gap: 5px; justify-content: flex-end; }

.score-cell { display: flex; align-items: center; gap: 8px; }
.score-num { font-size: 16px; font-weight: 760; font-variant-numeric: tabular-nums; letter-spacing: -0.3px; }
.score-num.great, .score-num.good { color: var(--primary-strong); }
.score-num.fair { color: var(--amber); }
.score-num.risk { color: var(--danger); }
.score-num.unknown { color: var(--faint); }

.score-bar {
  width: 46px;
  height: 4px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
  flex: none;
}

.score-bar > i { display: block; height: 100%; border-radius: 999px; background: var(--primary); }
.score-bar > i.fair { background: var(--amber); }
.score-bar > i.risk { background: var(--danger); }

.row-detail td { background: var(--surface-muted); padding: 0 !important; }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px 20px;
  padding: 14px 18px;
}

.kv { display: grid; gap: 2px; min-width: 0; }
.kv dt { font-size: 10px; letter-spacing: 0.4px; text-transform: uppercase; color: var(--faint); }
.kv dd { margin: 0; font-size: 12px; word-break: break-all; }

.code {
  margin: 0 18px 14px;
  padding: 12px;
  border-radius: 12px;
  background: var(--control);
  border: 1px solid var(--line);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  color: var(--muted);
  max-height: 240px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ---------------------------------------------------------------- progress */

.progress {
  height: 7px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--blue), var(--primary));
  transition: width 0.4s ease;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
  flex-wrap: wrap;
  gap: 6px;
}

/* ---------------------------------------------------------------- banners */

.banner {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 10px 13px;
  border-radius: var(--radius-card);
  font-size: 12px;
  border: 1px solid transparent;
}

.banner-danger { background: var(--danger-soft); color: var(--danger); }
.banner-warn { background: var(--amber-soft); color: var(--amber); }
.banner-info { background: var(--blue-soft); color: var(--blue); }
.banner-ok { background: var(--primary-soft); color: var(--primary-strong); }

/* ----------------------------------------------------------------- toasts */

.toasts {
  position: fixed;
  top: 18px;
  right: 18px;
  display: grid;
  gap: 8px;
  z-index: 60;
  max-width: min(360px, calc(100vw - 36px));
}

.toast {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 11px 14px;
  border-radius: var(--radius-card);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-size: 12px;
  animation: toast-in 0.22s ease-out both;
  backdrop-filter: blur(12px);
}

.toast-ok { border-left: 3px solid var(--primary); }
.toast-err { border-left: 3px solid var(--danger); }
.toast-warn { border-left: 3px solid var(--amber); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

/* ------------------------------------------------------------------ empty */

.empty {
  display: grid;
  place-items: center;
  gap: 6px;
  padding: 44px 20px;
  text-align: center;
  color: var(--muted);
}

.empty-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--surface-muted);
  border: 1px dashed var(--line);
  color: var(--faint);
  font-size: 17px;
}

.empty strong { font-size: 13px; color: var(--text); font-weight: 680; }
.empty span { font-size: 11.5px; max-width: 340px; }

.skeleton { padding: 16px 18px; display: grid; gap: 10px; }

.skeleton-line {
  height: 11px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--line), var(--surface-muted), var(--line));
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}

@keyframes shimmer { to { background-position: -200% 0; } }

/* ------------------------------------------------------------------ pager */

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 18px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--muted);
  flex-wrap: wrap;
}

.pager-actions { display: flex; align-items: center; gap: 6px; }

/* ----------------------------------------------------------------- layout */

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.stack { display: grid; gap: 16px; }

.inline-meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); }
.inline-meta b { color: var(--text); font-variant-numeric: tabular-nums; }

.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }

/* ----------------------------------------------------------------- dialog */

.dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--panel);
  color: var(--text);
  padding: 0;
  box-shadow: var(--shadow-lg);
  max-width: min(420px, calc(100vw - 32px));
  backdrop-filter: blur(18px);
}

.dialog::backdrop { background: var(--overlay); backdrop-filter: blur(2px); }

.dialog-body { padding: 20px; display: grid; gap: 10px; }
.dialog-body h2 { font-size: 15px; font-weight: 720; }
.dialog-body p { font-size: 12.5px; color: var(--muted); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

/* --------------------------------------------------------------- responsive */

@media (max-width: 1180px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field-grid .span-4 { grid-column: span 2; }
  .split { grid-template-columns: minmax(0, 1fr); }
  .main { padding: 22px 20px 40px; }
}

@media (max-width: 860px) {
  .shell { grid-template-columns: 92px minmax(0, 1fr); }
  .sidebar { padding: 18px 10px 12px; align-items: center; }
  .brand-text, .nav-label, .nav-group { display: none; }
  .brand { justify-content: center; padding: 0; }
  .nav { width: 100%; }
  .nav-item { justify-content: center; padding: 0; }
  .nav-item.active::before { left: -10px; }
  .sidebar-foot { width: 100%; }
  .theme-mini { width: 100%; text-align: center; padding: 4px 2px; font-size: 9px; }
  #logoutBtn { width: 100%; padding: 0; font-size: 10px; }
  .ph-title { font-size: 20px; }
}

@media (max-width: 640px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: sticky;
    top: 0;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-right: none;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
  }
  .brand { flex: none; }
  .nav { display: flex; gap: 4px; width: auto; flex: 1; }
  .nav-item { min-height: 36px; width: 36px; padding: 0; flex: none; }
  .nav-item.active::before { display: none; }
  .nav-icon { width: 26px; height: 26px; font-size: 11px; }
  .sidebar-foot {
    margin: 0;
    padding: 0;
    border-top: none;
    display: flex;
    gap: 6px;
    width: auto;
    flex: none;
  }
  .theme-mini { width: auto; font-size: 9.5px; padding: 4px 8px; }
  #logoutBtn { width: auto; height: 30px; padding: 0 10px; font-size: 11px; }
  .main { padding: 16px 14px 36px; }
  .stats { grid-template-columns: minmax(0, 1fr); }
  .field-grid, .field-grid .span-2, .field-grid .span-4 { grid-template-columns: minmax(0, 1fr); grid-column: span 1; }
  .page-header { gap: 12px; }
  .ph-actions { width: 100%; }
  .ph-actions .btn { flex: 1; }
  .panel-body { padding: 14px; }
  .toolbar { padding: 10px 14px; }
  .login-card { padding: 22px; }
  .ph-title { font-size: 19px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}


/* ==========================================================================
   Review hardening + v2 components (settings threshold, TXT export, a11y)
   ========================================================================== */

:root {
  --amber-ink: #8a5a10;
  --blue-ink: #23599b;
  --danger-ink: #9c2f3a;
  --muted-strong: #5d736d;
}

:root[data-theme="dark"] {
  --amber-ink: #f3d29a;
  --blue-ink: #b9d6f7;
  --danger-ink: #f7c2c8;
  --muted-strong: #b9cbc0;
}

html { background: #eef7f2; }
html[data-theme="dark"] { background: #101c17; }
body { min-height: 100dvh; }

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  box-shadow: 0 0 0 3px var(--focus-ring);
  border-radius: 4px;
}

.btn-primary {
  background: linear-gradient(135deg, #1f9c74, #147a5b);
  color: #fff;
}

:root[data-theme="dark"] .btn-primary {
  background: linear-gradient(135deg, var(--primary), #47b98d);
  color: #0d2a20;
}

.pill-ok { color: var(--primary-strong); }
.pill-run { color: var(--blue-ink); }
.pill-warn { color: var(--amber-ink); }
.pill-err { color: var(--danger-ink); }
.badge-blue { color: var(--blue-ink); }
.badge-amber { color: var(--amber-ink); }
.badge-danger { color: var(--danger-ink); }
.banner-warn { color: var(--amber-ink); }
.banner-info { color: var(--blue-ink); }
.banner-danger { color: var(--danger-ink); }
.banner-ok { color: var(--primary-strong); }

.ph-eyebrow,
.stat-hint,
.field-hint,
.kv dt,
.nav-group,
.panel-sub,
.login-foot,
.pager { color: var(--muted-strong); }

table.data thead th { color: var(--muted-strong); }

.table-wrap {
  overflow: auto;
  max-height: min(66vh, 760px);
  -webkit-overflow-scrolling: touch;
}

#detailBody {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.progress-row { display: flex; align-items: center; gap: 8px; }

.threshold-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--muted-strong);
  white-space: nowrap;
}

.threshold-field .input { width: 76px; height: 34px; text-align: center; }

.threshold-form {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
}

.threshold-form .field { flex: 1 1 260px; max-width: 440px; }

.input:-webkit-autofill,
.input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 40px var(--control) inset;
  caret-color: var(--text);
}

.login-card,
.sidebar,
.panel,
.toast,
.dialog,
table.data thead th {
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
}

@media (max-width: 640px) {
  .sidebar { padding-top: max(10px, env(safe-area-inset-top)); }
  .nav { flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .theme-mini {
    width: 34px;
    height: 30px;
    padding: 0;
    font-size: 0;
    overflow: hidden;
  }
  .theme-mini::after { content: "\25D0"; font-size: 13px; }
  .ph-actions .btn { flex: 1 1 calc(50% - 4px); }
  .toasts { top: auto; bottom: 14px; left: 12px; right: 12px; max-width: none; }
  .meta-between { justify-content: flex-start !important; }
  .code { margin: 0 12px 12px; font-size: 10.5px; }
  .threshold-field { flex: 1 1 100%; }
  .threshold-field .input { flex: 1 1 auto; width: auto; }
}

@media (min-width: 641px) {
  .toasts { top: 72px; }
}

/* ---------------------------------------------------- IP marks (used/note) */

.mark-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-muted);
  color: var(--muted-strong);
  font-size: 10.5px;
  font-weight: 640;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.12s;
}

.mark-btn::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--faint);
}

.mark-btn:hover:not(:disabled) { transform: translateY(-1px); border-color: var(--primary); }
.mark-btn:disabled { opacity: 0.55; cursor: not-allowed; }

.mark-btn.is-used {
  background: var(--primary-soft);
  color: var(--primary-strong);
  border-color: transparent;
}

.mark-btn.is-used::before { background: var(--primary); }

.mark-note {
  display: block;
  max-width: 150px;
  margin-top: 3px;
  font-size: 10px;
  color: var(--muted-strong);
}

.note-used {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text);
  cursor: pointer;
}

.note-used input { width: 16px; height: 16px; accent-color: var(--primary); }

.note-text { min-height: 88px; font-family: inherit; font-size: 12.5px; }

@media (max-width: 640px) {
  .mark-note { max-width: 110px; }
}

.stats { grid-template-columns: repeat(auto-fit, minmax(186px, 1fr)); }

.mark-cell { display: flex; align-items: center; gap: 5px; flex-wrap: nowrap; }
.mark-cell .badge { flex: none; }
.mark-note { display: none; }

@media (max-width: 1180px) {
  .stats { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
}

.proxy-cell {
  display: block;
  max-width: 300px;
  word-break: break-all;
  line-height: 1.45;
  color: var(--text);
}

@media (max-width: 640px) {
  .proxy-cell { max-width: 180px; }
}

/* ------------------------------------------------------- country chips */

.country-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-muted);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted-strong);
  font-size: 11.5px;
  font-weight: 620;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.12s;
}

.chip:hover { border-color: var(--primary); color: var(--primary-strong); transform: translateY(-1px); }

.chip.active {
  background: var(--primary-soft);
  color: var(--primary-strong);
  border-color: transparent;
  box-shadow: inset 0 0 0 1px var(--primary);
}

@media (max-width: 640px) {
  .country-chips { flex-wrap: nowrap; overflow-x: auto; padding: 10px 14px; scrollbar-width: none; }
  .country-chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; }
}

/* ---------------------------------------------------------- quick claim bar */

.claim-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 11px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, var(--primary-soft) 0%, transparent 68%);
}

.claim-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--primary-strong);
  margin-right: 2px;
}

.claim-btn { display: inline-flex; align-items: center; gap: 6px; }

.claim-count {
  font-size: 10px;
  font-weight: 640;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted-strong);
}

@media (max-width: 640px) {
  .claim-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 10px 14px;
    scrollbar-width: none;
  }
  .claim-bar::-webkit-scrollbar { display: none; }
  .claim-btn { flex: none; }
}
