:root {
  --page: #f3f6f8;
  --panel: #ffffff;
  --panel-soft: #f8fafb;
  --ink: #17222c;
  --ink-soft: #344553;
  --muted: #6b7b88;
  --faint: #96a3ad;
  --line: #dce4e9;
  --line-strong: #cbd6dd;
  --accent: #176d63;
  --accent-strong: #0f574f;
  --accent-soft: #e8f4f1;
  --good: #19734d;
  --good-soft: #e7f5ed;
  --warning: #a86b08;
  --warning-soft: #fff4dc;
  --danger: #be3f48;
  --danger-soft: #fcebed;
  --info: #366eae;
  --info-soft: #eaf2fb;
  --shadow: 0 12px 34px rgba(35, 50, 63, 0.07);
  --shadow-small: 0 4px 14px rgba(35, 50, 63, 0.06);
  --radius: 12px;
  --radius-small: 8px;
  --font: Inter, "SF Pro Text", "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--page); color: var(--ink); }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% 0, rgba(23, 109, 99, 0.045), transparent 30rem),
    var(--page);
  font: 14px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; }
button, select { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); }
strong { font-weight: 700; }
code { font-family: var(--mono); }
[hidden] { display: none !important; }

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.eyebrow, .panel-kicker {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
  line-height: 1.35;
}

/* Shared application chrome */
.topbar {
  position: sticky;
  z-index: 50;
  top: 0;
  display: grid;
  grid-template-columns: minmax(230px, auto) 1fr auto;
  align-items: center;
  min-height: 64px;
  padding: 0 26px;
  border-bottom: 1px solid rgba(203, 214, 221, 0.9);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 2px 10px rgba(30, 47, 60, 0.035);
  backdrop-filter: blur(14px);
}

.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--ink); }
.brand:hover { color: var(--ink); }
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 35px;
  height: 35px;
  flex: 0 0 auto;
  border-radius: 9px;
  color: #fff;
  background: linear-gradient(145deg, #217d71, #0e554d);
  box-shadow: 0 5px 12px rgba(15, 87, 79, 0.2);
  font-size: 16px;
  font-weight: 800;
}
.brand-mark-large { width: 43px; height: 43px; border-radius: 11px; font-size: 19px; }
.brand-copy { display: flex; flex-direction: column; line-height: 1.25; }
.brand-copy strong { font-size: 15px; letter-spacing: 0.01em; }
.brand-copy small { margin-top: 3px; color: var(--muted); font-size: 11px; }

.main-nav { align-self: stretch; display: flex; align-items: center; gap: 4px; padding-left: 30px; }
.main-nav a {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 100%;
  padding: 0 17px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}
.main-nav a:hover { color: var(--ink); }
.main-nav a[aria-current="page"] { color: var(--accent-strong); }
.main-nav a[aria-current="page"]::after {
  position: absolute;
  right: 14px;
  bottom: -1px;
  left: 14px;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--accent);
  content: "";
}

.account-menu { display: flex; align-items: center; gap: 9px; }
.account-menu form { margin-left: 4px; }
.account-avatar {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border: 1px solid #cfe1dd;
  border-radius: 50%;
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-size: 13px;
  font-weight: 800;
}
.account-avatar-small { width: 30px; height: 30px; font-size: 12px; }
.account-copy { display: flex; flex-direction: column; min-width: 70px; line-height: 1.25; }
.account-copy strong { max-width: 160px; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.account-copy small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.nav-toggle { display: none; width: 38px; height: 38px; padding: 9px; border: 0; background: transparent; }
.nav-toggle > span:not(.sr-only) { display: block; height: 2px; margin: 4px 0; border-radius: 2px; background: var(--ink-soft); }

.page-shell { width: min(1540px, calc(100% - 48px)); margin: 0 auto; padding: 26px 0 48px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; margin: 0 2px 20px; }
.page-heading h1 { margin: 0; color: var(--ink); font-size: clamp(24px, 2.2vw, 32px); line-height: 1.2; letter-spacing: -0.035em; }
.page-heading > div:first-child > p:last-child { max-width: 800px; margin: 8px 0 0; color: var(--muted); }
.page-heading > div:first-child > p:last-child strong { color: var(--ink-soft); }
.health-indicator { display: flex; align-items: center; gap: 10px; min-width: 210px; padding: 10px 13px; border: 1px solid var(--line); border-radius: var(--radius-small); background: rgba(255,255,255,.65); }
.health-indicator > span { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 5px var(--good-soft); }
.health-indicator > div { display: flex; flex-direction: column; line-height: 1.3; }
.health-indicator small { color: var(--muted); font-size: 10px; }
.health-indicator strong { margin-top: 2px; font-size: 12px; }

/* Alerts */
.flash-stack { position: fixed; z-index: 100; top: 76px; right: 22px; display: grid; width: min(430px, calc(100vw - 32px)); gap: 8px; }
.flash { display: grid; grid-template-columns: auto 1fr auto; align-items: start; gap: 10px; padding: 12px 12px 12px 14px; border: 1px solid var(--line); border-left-width: 3px; border-radius: 9px; background: #fff; box-shadow: var(--shadow); }
.flash p { margin: 0; color: var(--ink-soft); font-size: 13px; }
.flash > button { width: 25px; height: 25px; padding: 0; border: 0; color: var(--muted); background: transparent; font-size: 20px; line-height: 1; }
.flash-dot { width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: var(--info); }
.flash-success { border-left-color: var(--good); }
.flash-success .flash-dot { background: var(--good); }
.flash-error, .flash-danger { border-left-color: var(--danger); }
.flash-error .flash-dot, .flash-danger .flash-dot { background: var(--danger); }
.flash-warning { border-left-color: var(--warning); }
.flash-warning .flash-dot { background: var(--warning); }
.flash.is-hiding { opacity: 0; transform: translateX(10px); transition: .2s ease; }

/* Buttons and form controls */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 15px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--ink-soft);
  background: #fff;
  box-shadow: 0 1px 1px rgba(20, 35, 45, .03);
  font-weight: 700;
  line-height: 1.2;
  transition: border-color .15s, background-color .15s, box-shadow .15s, transform .15s;
}
.button:hover { border-color: #aebdc6; background: var(--panel-soft); }
.button:active { transform: translateY(1px); }
.button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, .table-link:focus-visible, .icon-button:focus-visible { outline: 3px solid rgba(23, 109, 99, .16); outline-offset: 1px; }
.button[disabled] { cursor: not-allowed; opacity: .62; transform: none; }
.button-primary { border-color: var(--accent); color: #fff; background: var(--accent); box-shadow: 0 5px 13px rgba(23, 109, 99, .16); }
.button-primary:hover { border-color: var(--accent-strong); color: #fff; background: var(--accent-strong); }
.button-success { border-color: #b7dfca; color: var(--good); background: var(--good-soft); }
.button-success:hover { border-color: #90ceb0; background: #dcf1e5; }
.button-danger-quiet { border-color: #ebc9cd; color: var(--danger); background: #fff; }
.button-danger-quiet:hover { border-color: #dfaab0; background: var(--danger-soft); }
.button-quiet { color: var(--muted); background: transparent; }
.button-small { min-height: 31px; padding: 5px 10px; border-radius: 7px; font-size: 11px; }
.button-block { width: 100%; min-height: 43px; }

.field { display: grid; gap: 6px; }
.field > span:first-child, .field-label-row { color: var(--ink-soft); font-size: 12px; font-weight: 700; }
.field small { color: var(--muted); font-size: 10px; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
input, select { height: 38px; padding: 0 11px; }
textarea { min-height: 100px; padding: 10px 11px; line-height: 1.55; resize: vertical; }
input:hover, textarea:hover, select:hover { border-color: #aabac4; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(23, 109, 99, .09); outline: none; }
input::placeholder, textarea::placeholder { color: #9aa8b2; }
input:invalid:not(:placeholder-shown) { border-color: #dc8e95; }
.password-field { position: relative; display: block; }
.password-field input { padding-right: 54px; }
.password-field button { position: absolute; top: 1px; right: 1px; height: 36px; padding: 0 10px; border: 0; color: var(--accent); background: transparent; font-size: 11px; font-weight: 700; }
.field-message { min-height: 16px; }
.field-message.is-error { color: var(--danger); }

/* Inventory and panels */
.inventory-strip {
  display: grid;
  grid-template-columns: minmax(190px, 1.4fr) repeat(8, minmax(88px, .65fr)) auto;
  align-items: center;
  min-height: 76px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-small);
}
.inventory-title { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 13px 18px; }
.section-icon { display: grid; place-items: center; width: 34px; height: 34px; flex: 0 0 auto; border-radius: 8px; color: var(--accent-strong); background: var(--accent-soft); font-size: 12px; font-weight: 800; }
.inventory-title > div { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.inventory-title strong { font-size: 13px; }
.inventory-title small { margin-top: 3px; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.inventory-item { display: flex; flex-direction: column; justify-content: center; min-height: 48px; padding: 5px 16px; border-left: 1px solid var(--line); }
.inventory-item span { color: var(--muted); font-size: 10px; white-space: nowrap; }
.inventory-item strong { margin-top: 2px; font-size: 19px; font-variant-numeric: tabular-nums; line-height: 1.25; }
.inventory-positive strong { color: var(--good); }
.inventory-warning strong { color: var(--warning); }
.icon-button { display: grid; place-items: center; width: 34px; height: 34px; margin: 0 16px 0 6px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); background: #fff; font-size: 19px; transition: .15s; }
.icon-button:hover { color: var(--accent); border-color: #b7d2cd; background: var(--accent-soft); }
.icon-button.is-loading span { animation: rotate .8s linear infinite; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(330px, .8fr); align-items: stretch; gap: 16px; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow-small); }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 18px 20px 14px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 17px; line-height: 1.25; letter-spacing: -.015em; }
.compact-head { align-items: center; }
.probe-chip { display: grid; grid-template-columns: auto auto; align-items: center; column-gap: 7px; min-width: 150px; padding: 7px 10px; border: 1px solid #cde2dd; border-radius: 8px; background: var(--accent-soft); line-height: 1.2; }
.probe-chip-dot { grid-row: 1 / 3; width: 7px; height: 7px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 4px rgba(25,115,77,.1); }
.probe-chip span:nth-child(2) { color: var(--muted); font-size: 9px; }
.probe-chip strong { color: var(--accent-strong); font-size: 11px; }

.upload-form { display: grid; gap: 14px; padding: 17px 20px 20px; }
.upload-config-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(285px, .72fr); align-items: stretch; gap: 12px; }
.probe-toggle-field { display: flex; align-items: center; justify-content: space-between; gap: 18px; min-height: 68px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-soft); cursor: pointer; }
.probe-toggle-copy { display: flex; flex-direction: column; min-width: 0; }
.probe-toggle-copy strong { color: var(--ink-soft); font-size: 12px; }
.probe-toggle-copy small { margin-top: 3px; color: var(--muted); font-size: 9px; line-height: 1.4; }
.switch-control { position: relative; display: grid; grid-template-columns: 38px auto; align-items: center; flex: 0 0 auto; gap: 7px; }
.switch-control input { position: absolute; z-index: 2; top: 0; left: 0; width: 38px; height: 22px; margin: 0; opacity: 0; cursor: pointer; }
.switch-control i { position: relative; display: block; width: 38px; height: 22px; border-radius: 999px; background: #bdc8ce; box-shadow: inset 0 0 0 1px rgba(53,72,85,.12); transition: background-color .16s; }
.switch-control i::after { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(26,43,54,.25); content: ""; transition: transform .16s; }
.switch-control input:checked + i { background: var(--accent); }
.switch-control input:checked + i::after { transform: translateX(16px); }
.switch-control input:focus-visible + i { outline: 3px solid rgba(23,109,99,.16); outline-offset: 2px; }
.switch-control b { min-width: 36px; color: var(--accent-strong); font-size: 10px; white-space: nowrap; }
.switch-control input:not(:checked) ~ b { color: var(--muted); }
.probe-chip.is-disabled { border-color: var(--line); background: var(--panel-soft); }
.probe-chip.is-disabled .probe-chip-dot { background: var(--faint); box-shadow: 0 0 0 4px rgba(107,123,136,.09); }
.probe-chip.is-disabled strong { color: var(--muted); }
.probe-rule.is-disabled { border-color: var(--line); background: var(--panel-soft); }
.probe-rule.is-disabled .probe-rule-icon { background: var(--muted); }
.field-label-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.privacy-note { color: var(--muted); font-size: 10px; font-weight: 500; }
.key-field textarea { min-height: 220px; font: 12px/1.65 var(--mono); white-space: pre; }
.input-counters { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: 8px; background: var(--panel-soft); }
.input-counters > div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 9px 12px; border-left: 1px solid var(--line); }
.input-counters > div:first-child { border-left: 0; }
.input-counters span { color: var(--muted); font-size: 10px; }
.input-counters strong { font-size: 16px; font-variant-numeric: tabular-nums; }
.probe-rule { display: flex; align-items: flex-start; gap: 9px; padding: 10px 12px; border: 1px solid #d5e8e4; border-radius: 8px; background: #f4faf8; }
.probe-rule-icon { display: grid; place-items: center; width: 20px; height: 20px; flex: 0 0 auto; margin-top: 1px; border-radius: 50%; color: #fff; background: var(--accent); font-size: 11px; font-weight: 800; }
.probe-rule p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.probe-rule strong { color: var(--ink-soft); }
.form-actions { display: flex; align-items: stretch; justify-content: flex-end; gap: 9px; }
.form-actions .button-primary { min-width: 190px; flex-direction: column; }
.form-actions .button-primary small { margin-top: 2px; opacity: .76; font-size: 9px; font-weight: 500; }

.upload-progress { margin: 0 20px 20px; padding: 13px; border: 1px solid #cfe1dd; border-radius: 9px; background: var(--accent-soft); }
.progress-heading, .progress-heading > div { display: flex; align-items: center; gap: 8px; }
.progress-heading { justify-content: space-between; }
.progress-heading strong { color: var(--accent-strong); font-size: 12px; }
.progress-heading > span { color: var(--muted); font-size: 10px; }
.spinner { width: 14px; height: 14px; border: 2px solid rgba(23,109,99,.18); border-top-color: var(--accent); border-radius: 50%; animation: rotate .75s linear infinite; }
.progress-track { height: 5px; margin-top: 10px; overflow: hidden; border-radius: 4px; background: rgba(23,109,99,.13); }
.progress-track span { display: block; width: 35%; height: 100%; border-radius: inherit; background: var(--accent); animation: progress-move 1.3s ease-in-out infinite; }
.upload-progress p { margin: 8px 0 0; color: var(--muted); font-size: 10px; }

.result-panel { display: flex; flex-direction: column; }
.batch-meta { display: flex; justify-content: space-between; gap: 10px; padding: 13px 17px 0; color: var(--muted); font-size: 10px; }
.batch-meta code { color: var(--ink-soft); font-weight: 700; }
.result-progress { padding: 13px 17px 14px; }
.result-progress > div { display: flex; justify-content: space-between; margin-bottom: 6px; color: var(--muted); font-size: 10px; }
.result-progress strong { color: var(--ink-soft); font-variant-numeric: tabular-nums; }
progress { width: 100%; height: 7px; overflow: hidden; border: 0; border-radius: 8px; background: #e6ecef; }
progress::-webkit-progress-bar { border-radius: 8px; background: #e6ecef; }
progress::-webkit-progress-value { border-radius: 8px; background: var(--accent); }
progress::-moz-progress-bar { border-radius: 8px; background: var(--accent); }
.result-counts { display: grid; grid-template-columns: repeat(2, 1fr); margin: 0 17px; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.result-counts > div { display: flex; align-items: center; justify-content: space-between; min-height: 48px; padding: 8px 12px; border-top: 1px solid var(--line); border-left: 1px solid var(--line); background: var(--panel-soft); }
.result-counts > div:nth-child(-n+2) { border-top: 0; }
.result-counts > div:nth-child(odd) { border-left: 0; }
.result-counts span { max-width: 100px; color: var(--muted); font-size: 10px; }
.result-counts strong { font-size: 19px; font-variant-numeric: tabular-nums; }
.result-counts .count-good strong { color: var(--good); }
.result-counts .count-bad strong { color: var(--danger); }
.result-counts .count-warn strong { color: var(--warning); }
.result-summary { display: flex; align-items: center; gap: 10px; margin: auto 17px 17px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel-soft); }
.result-summary > span { display: grid; place-items: center; width: 29px; height: 29px; flex: 0 0 auto; border-radius: 50%; color: var(--muted); background: #e9eef1; font-weight: 800; }
.result-summary p { display: flex; flex-direction: column; margin: 0; line-height: 1.35; }
.result-summary strong { font-size: 11px; }
.result-summary small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.result-summary-good { border-color: #cce4d7; background: var(--good-soft); }
.result-summary-good > span { color: #fff; background: var(--good); }
.result-summary-good strong { color: var(--good); }
.empty-state { display: grid; place-items: center; margin: auto; padding: 60px 25px; text-align: center; }
.empty-state > span { display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 14px; border-radius: 50%; color: var(--faint); background: var(--panel-soft); font-size: 24px; }
.empty-state strong { font-size: 13px; }
.empty-state p { max-width: 250px; margin: 6px 0 0; color: var(--muted); font-size: 11px; }

/* Data tables */
.table-panel { margin-top: 16px; overflow: hidden; }
.table-panel-head { align-items: center; }
.table-tools { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.table-tools-wrap { flex-wrap: wrap; }
.search-field { position: relative; display: block; min-width: min(280px, 60vw); }
.search-field input { height: 34px; padding-right: 34px; font-size: 11px; }
.search-field > span:last-child { position: absolute; top: 50%; right: 11px; color: var(--faint); font-size: 18px; transform: translateY(-52%); pointer-events: none; }
.select-field select { min-width: 130px; height: 34px; padding-right: 28px; font-size: 11px; }
.table-scroll { width: 100%; overflow-x: auto; scrollbar-color: #bdc9d0 #eef2f4; scrollbar-width: thin; }
.table-scroll-tall { max-height: min(64vh, 720px); overflow: auto; }
.data-table { width: 100%; min-width: 1080px; border-collapse: separate; border-spacing: 0; font-size: 11px; }
.detail-table { min-width: 1480px; }
.users-table { min-width: 1050px; }
.data-table th, .data-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.data-table th { position: sticky; z-index: 2; top: 0; height: 38px; color: #596b78; background: #f7f9fa; box-shadow: inset 0 -1px var(--line); font-size: 10px; font-weight: 750; white-space: nowrap; }
.data-table tbody tr { background: #fff; }
.data-table tbody tr:hover { background: #fafcfc; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table code { color: #344d5a; font-size: 10px; }
.data-table .number-cell { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.data-table .number-good { color: var(--good); font-weight: 700; }
.data-table .number-bad { color: var(--danger); font-weight: 650; }
.data-table .number-warn { color: var(--warning); font-weight: 650; }
.data-table .action-cell { text-align: right; white-space: nowrap; }
.wrap-cell { min-width: 170px; max-width: 340px; overflow-wrap: anywhere; }
.reason-cell { min-width: 300px; max-width: 650px; white-space: normal; overflow-wrap: anywhere; line-height: 1.55; }
.batch-keys-cell { min-width: 390px; max-width: 540px; vertical-align: top !important; }
.full-key-cell { min-width: 430px; max-width: 620px; vertical-align: top !important; }
.full-key-block { display: grid; min-width: 340px; gap: 5px; }
.full-key-block textarea { width: 100%; min-height: 64px; padding: 7px 8px; border-color: var(--line); border-radius: 6px; color: #20333e; background: #f9fbfc; font: 10px/1.55 var(--mono); resize: vertical; white-space: pre; }
.full-key-block textarea:focus { border-color: var(--accent); background: #fff; }
.full-key-block > div { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.full-key-block small { color: var(--muted); font-size: 9px; }
.full-key-single textarea { min-height: 48px; }
.full-key-block .table-link[disabled] { cursor: not-allowed; color: var(--faint); text-decoration: none; }
.decrypt-error { display: inline-flex; padding: 4px 7px; border-radius: 5px; color: var(--danger); background: var(--danger-soft); font-size: 9px; font-weight: 700; }
.reason-detail { display: grid; gap: 5px; }
.reason-detail strong { color: var(--ink); font-weight: 650; }
.reason-detail small { color: var(--muted); font-variant-numeric: tabular-nums; }
.reason-detail pre { margin: 0; padding: 7px 9px; overflow: visible; border: 1px solid var(--line); border-radius: 6px; background: var(--panel-soft); color: var(--ink-soft); font: 11px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; word-break: break-word; }
.key-suffix { display: inline-block; padding: 3px 7px; border: 1px solid var(--line); border-radius: 5px; color: var(--ink) !important; background: var(--panel-soft); font-weight: 700; letter-spacing: .04em; white-space: nowrap; }
.table-link { padding: 3px 0; border: 0; color: var(--accent); background: transparent; font-size: 10px; font-weight: 700; }
.table-link:hover { color: var(--accent-strong); text-decoration: underline; }
.table-empty { padding: 42px 15px; color: var(--muted); text-align: center; }
.table-footer { display: flex; align-items: center; justify-content: space-between; min-height: 48px; gap: 12px; padding: 8px 13px; border-top: 1px solid var(--line); color: var(--muted); background: #fbfcfc; font-size: 10px; }
.pagination { display: flex; align-items: center; gap: 4px; }
.pagination button { min-width: 29px; height: 29px; padding: 0 7px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); background: #fff; font-size: 10px; }
.pagination button:hover:not(:disabled) { color: var(--accent); border-color: #b7d2cd; background: var(--accent-soft); }
.pagination button[aria-current="page"] { color: #fff; border-color: var(--accent); background: var(--accent); }
.pagination button:disabled { cursor: default; opacity: .42; }
.status-badge { display: inline-flex; align-items: center; min-height: 23px; padding: 3px 8px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: var(--panel-soft); font-size: 9px; font-weight: 750; white-space: nowrap; }
.status-badge::before { width: 5px; height: 5px; margin-right: 5px; border-radius: 50%; background: currentColor; content: ""; }
.status-badge.is-positive, .status-badge[data-status="alive"], .status-badge[data-status="approved"], .status-badge[data-status="active"], .status-badge[data-status="completed"] { color: var(--good); border-color: #cbe4d6; background: var(--good-soft); }
.status-badge.is-negative, .status-badge[data-status="invalid"], .status-badge[data-status="quota_zero"], .status-badge[data-status="disabled"], .status-badge[data-status="failed"] { color: var(--danger); border-color: #efcdd1; background: var(--danger-soft); }
.status-badge.is-warning, .status-badge[data-status="pending"], .status-badge[data-status="deferred"], .status-badge[data-status="probing"] { color: var(--warning); border-color: #efdcaf; background: var(--warning-soft); }
.duplicate-mark { display: inline-flex; padding: 2px 6px; border-radius: 5px; color: var(--warning); background: var(--warning-soft); font-size: 9px; font-weight: 700; }
.detail-safety-note { display: flex; align-items: center; gap: 7px; padding: 8px 13px; border-bottom: 1px solid var(--line); color: var(--muted); background: #fbfcfc; font-size: 10px; }
.detail-safety-note span { display: grid; place-items: center; width: 16px; height: 16px; border: 1px solid #c4d4de; border-radius: 50%; color: var(--info); font-size: 9px; font-weight: 800; }

/* Administration */
.admin-heading { align-items: center; }
.admin-summary { display: flex; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: #fff; box-shadow: var(--shadow-small); }
.admin-summary > div { min-width: 100px; padding: 9px 16px; border-left: 1px solid var(--line); text-align: center; }
.admin-summary > div:first-child { border-left: 0; }
.admin-summary span { display: block; color: var(--muted); font-size: 9px; }
.admin-summary strong { display: block; margin-top: 2px; font-size: 18px; font-variant-numeric: tabular-nums; }
.pending-callout { display: flex; align-items: center; gap: 11px; margin-bottom: 16px; padding: 12px 15px; border: 1px solid #ecd9ae; border-radius: 10px; background: var(--warning-soft); }
.pending-callout-icon { display: grid; place-items: center; width: 29px; height: 29px; flex: 0 0 auto; border-radius: 50%; color: #fff; background: var(--warning); font-weight: 800; }
.pending-callout strong { color: #7b4d02; font-size: 12px; }
.pending-callout p { margin: 2px 0 0; color: #8f6b2d; font-size: 10px; }
.attention-row { background: #fffdf8 !important; }
.user-cell { display: flex; align-items: center; gap: 9px; min-width: 155px; }
.user-cell > div { display: flex; flex-direction: column; }
.user-cell strong { font-size: 11px; }
.user-cell small { margin-top: 2px; color: var(--muted); font-size: 9px; }
.role-badge { display: inline-flex; padding: 3px 7px; border-radius: 5px; color: var(--accent-strong); background: var(--accent-soft); font-size: 9px; font-weight: 700; }
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.row-actions form { margin: 0; }
.protected-label { color: var(--faint); font-size: 9px; }

/* Authentication and pending state */
.auth-page { display: grid; min-height: 100vh; place-items: center; padding: 28px; background: #eef3f4; }
.auth-page::before { position: fixed; z-index: -1; inset: 0; background: radial-gradient(circle at 76% 22%, rgba(23,109,99,.12), transparent 34rem), radial-gradient(circle at 18% 80%, rgba(54,110,174,.07), transparent 28rem); content: ""; }
.auth-shell { display: grid; grid-template-columns: minmax(360px, 450px) minmax(420px, 590px); width: min(1040px, 100%); min-height: 600px; overflow: hidden; border: 1px solid rgba(203,214,221,.9); border-radius: 17px; background: #fff; box-shadow: 0 26px 70px rgba(29, 48, 59, .13); }
.auth-shell-single { display: block; width: min(470px, 100%); min-height: 0; }
.auth-card { display: flex; flex-direction: column; justify-content: center; padding: 45px 50px; background: #fff; }
.auth-brand { position: absolute; top: 42px; display: flex; align-items: center; gap: 10px; }
.auth-brand > div { display: flex; flex-direction: column; line-height: 1.3; }
.auth-brand strong { font-size: 13px; }
.auth-brand span:not(.brand-mark) { margin-top: 2px; color: var(--muted); font-size: 10px; }
.auth-card { position: relative; }
.auth-heading { margin-top: 48px; }
.auth-heading h1 { margin: 0; font-size: 28px; letter-spacing: -.035em; }
.auth-heading > p:last-child { margin: 8px 0 0; color: var(--muted); font-size: 12px; }
.auth-form { display: grid; gap: 15px; margin-top: 27px; }
.auth-form .button-block { margin-top: 5px; }
.auth-foot { display: flex; flex-wrap: wrap; gap: 3px 7px; margin-top: 22px; color: var(--muted); font-size: 11px; }
.auth-foot a { font-weight: 750; }
.auth-foot small { width: 100%; margin-top: 5px; color: var(--faint); font-size: 9px; }
.auth-aside { position: relative; display: flex; flex-direction: column; justify-content: center; overflow: hidden; padding: 70px; color: #f1f7f6; background: linear-gradient(145deg, #163b3a, #0d292c); }
.auth-aside::before { position: absolute; top: -120px; right: -120px; width: 360px; height: 360px; border: 1px solid rgba(255,255,255,.08); border-radius: 50%; box-shadow: 0 0 0 50px rgba(255,255,255,.025), 0 0 0 100px rgba(255,255,255,.015); content: ""; }
.auth-aside .eyebrow { color: #7fc7ba; }
.auth-aside h2 { position: relative; margin: 4px 0 34px; font-size: 30px; line-height: 1.3; letter-spacing: -.04em; }
.feature-list { position: relative; display: grid; gap: 23px; margin: 0; padding: 0; list-style: none; }
.feature-list li { display: grid; grid-template-columns: 33px 1fr; gap: 12px; }
.feature-list li > span { color: #73b7ad; font: 700 10px/1.4 var(--mono); }
.feature-list strong { font-size: 12px; }
.feature-list p { margin: 4px 0 0; color: rgba(232,244,241,.65); font-size: 10px; line-height: 1.6; }
.auth-shell-single .auth-card { min-height: 620px; }

.pending-page { display: grid; min-height: 100vh; place-items: center; padding: 30px; background: var(--page); }
.state-shell { width: min(510px, 100%); }
.state-card { padding: 44px 46px; border: 1px solid var(--line); border-radius: 15px; background: #fff; box-shadow: var(--shadow); text-align: center; }
.state-icon { display: grid; place-items: center; width: 58px; height: 58px; margin: 0 auto 20px; border-radius: 50%; background: var(--warning-soft); }
.state-icon span { width: 20px; height: 20px; border: 3px solid rgba(168,107,8,.25); border-top-color: var(--warning); border-radius: 50%; animation: rotate 1.1s linear infinite; }
.state-card h1 { margin: 0; font-size: 25px; letter-spacing: -.03em; }
.state-card > p:not(.eyebrow) { margin: 10px auto 0; color: var(--muted); font-size: 12px; }
.state-card > p strong { color: var(--ink); }
.state-notes { display: grid; grid-template-columns: repeat(2, 1fr); margin: 27px 0 17px; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: var(--panel-soft); }
.state-notes > div { display: flex; flex-direction: column; padding: 12px; border-left: 1px solid var(--line); }
.state-notes > div:first-child { border-left: 0; }
.state-notes span { color: var(--muted); font-size: 9px; }
.state-notes strong { margin-top: 2px; font-size: 12px; }
.state-card .muted { font-size: 10px !important; }
.state-card form { margin-top: 25px; }
.noscript { position: fixed; z-index: 200; right: 15px; bottom: 15px; left: 15px; padding: 10px; border: 1px solid #ecd9ae; border-radius: 8px; color: #7b4d02; background: var(--warning-soft); text-align: center; font-size: 11px; }

@keyframes rotate { to { transform: rotate(360deg); } }
@keyframes progress-move { 0% { transform: translateX(-110%); } 50% { transform: translateX(120%); } 100% { transform: translateX(310%); } }

@media (max-width: 1120px) {
  .inventory-strip { grid-template-columns: minmax(170px, 1fr) repeat(8, minmax(78px, .55fr)) auto; }
  .dashboard-grid { grid-template-columns: minmax(0, 1.45fr) minmax(310px, .8fr); }
  .auth-aside { padding: 50px; }
}

@media (max-width: 900px) {
  .topbar { grid-template-columns: 1fr auto auto; padding: 0 17px; }
  .nav-toggle { display: block; order: 2; }
  .main-nav { position: absolute; top: 63px; right: 10px; left: 10px; display: none; align-self: auto; flex-direction: column; align-items: stretch; gap: 0; padding: 7px; border: 1px solid var(--line); border-radius: 10px; background: #fff; box-shadow: var(--shadow); }
  .main-nav.is-open { display: flex; }
  .main-nav a { height: 42px; padding: 0 12px; border-radius: 7px; }
  .main-nav a[aria-current="page"] { background: var(--accent-soft); }
  .main-nav a[aria-current="page"]::after { display: none; }
  .account-menu { order: 3; margin-left: 8px; }
  .account-copy { display: none; }
  .page-shell { width: min(100% - 28px, 1540px); padding-top: 20px; }
  .page-heading { align-items: flex-start; }
  .health-indicator { min-width: 190px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .upload-config-row { grid-template-columns: 1fr; }
  .result-panel { min-height: 430px; }
  .auth-shell { grid-template-columns: minmax(330px, 430px) 1fr; }
  .auth-card { padding: 42px 38px; }
  .auth-aside { padding: 38px; }
  .auth-aside h2 { font-size: 25px; }
}

@media (max-width: 720px) {
  .topbar { min-height: 58px; }
  .brand-copy small { display: none; }
  .brand-mark { width: 32px; height: 32px; }
  .main-nav { top: 57px; }
  .account-menu .account-avatar { display: none; }
  .page-shell { width: min(100% - 20px, 1540px); padding: 16px 0 32px; }
  .page-heading { display: block; margin-bottom: 15px; }
  .page-heading h1 { font-size: 25px; }
  .health-indicator { width: 100%; margin-top: 14px; }
  .inventory-strip { display: flex; min-height: 68px; overflow-x: auto; }
  .inventory-title { min-width: 190px; }
  .inventory-item { display: flex !important; min-width: 105px; }
  .icon-button { flex: 0 0 auto; }
  .panel-head { padding: 15px 14px 12px; }
  .probe-chip { min-width: auto; }
  .upload-form { padding: 14px; }
  .key-field textarea { min-height: 250px; }
  .input-counters { grid-template-columns: 1fr; }
  .input-counters > div { border-top: 1px solid var(--line); border-left: 0; }
  .input-counters > div:first-child { border-top: 0; }
  .form-actions { display: grid; grid-template-columns: 1fr 2fr; }
  .form-actions .button-primary { min-width: 0; }
  .result-counts { margin-right: 14px; margin-left: 14px; }
  .table-panel-head { display: block; }
  .table-tools { justify-content: stretch; margin-top: 12px; }
  .table-tools > label { flex: 1 1 160px; min-width: 0; }
  .search-field { min-width: 0; }
  .table-footer { align-items: flex-start; flex-direction: column; }
  .pagination { align-self: flex-end; }
  .admin-heading { display: block; }
  .admin-summary { margin-top: 14px; }
  .admin-summary > div { flex: 1; min-width: 0; padding: 8px; }
  .auth-page { padding: 15px; }
  .auth-shell { display: block; width: min(460px, 100%); min-height: 0; }
  .auth-card { min-height: 610px; padding: 38px 30px; }
  .auth-aside { display: none; }
  .auth-brand { top: 35px; }
  .auth-heading { margin-top: 58px; }
  .state-card { padding: 38px 25px; }
  .flash-stack { top: 68px; right: 10px; width: calc(100vw - 20px); }
}

@media (max-width: 440px) {
  .account-menu form { margin-left: 0; }
  .button-small { padding-right: 8px; padding-left: 8px; }
  .brand-copy strong { font-size: 13px; }
  .page-heading > div:first-child > p:last-child { font-size: 12px; }
  .probe-chip span:nth-child(2) { display: none; }
  .probe-chip { display: flex; }
  .input-counters { grid-template-columns: repeat(3, 1fr); }
  .input-counters > div { display: flex; flex-direction: column; align-items: center; border-top: 0; border-left: 1px solid var(--line); }
  .input-counters > div:first-child { border-left: 0; }
  .auth-card { padding-right: 23px; padding-left: 23px; }
}

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