:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-soft: #eef3f1;
  --ink: #1d2925;
  --muted: #65736e;
  --line: #d9e1de;
  --primary: #157a63;
  --primary-dark: #0f5d4c;
  --green: #1f9d69;
  --yellow: #d59b24;
  --orange: #df762d;
  --red: #d84a4a;
  --deep-red: #8f1d2c;
  --dark: #48534f;
  --white: #d7dddb;
  --shadow: 0 10px 30px rgba(29, 41, 37, .06);
  font-family: "Microsoft YaHei", "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 25px; letter-spacing: 0; }
h2 { margin-bottom: 4px; font-size: 17px; letter-spacing: 0; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; }
input, select, textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  padding: 8px 10px;
}

.input-suffix {
  display: flex;
  align-items: center;
  gap: 6px;
}

.input-suffix input {
  flex: 1;
  min-width: 0;
}

.input-suffix span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
textarea { resize: vertical; }
select[multiple] { min-height: 118px; }
input:focus, select:focus {
  outline: 2px solid rgba(21, 122, 99, .18);
  border-color: var(--primary);
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 12px; }
.mono { font-family: Consolas, "Cascadia Mono", monospace; }
.text-red { color: var(--red); }
.eyebrow { margin-bottom: 5px; color: var(--primary); font-weight: 700; font-size: 11px; letter-spacing: .12em; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 35px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 7px 13px;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.button:hover { background: var(--primary-dark); }
.button:disabled { opacity: .5; cursor: wait; }
.button.primary { background: var(--primary); }
.button.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.button.ghost:hover { background: var(--surface-soft); }
.button.danger { background: var(--red); }
.button.small { min-height: 28px; padding: 4px 8px; font-size: 11px; }
.button.wide { width: 100%; }
.icon-button {
  width: 38px;
  min-height: 38px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
}
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.admin-page { padding: 24px; }
.admin-shell { width: min(1480px, 100%); margin: 0 auto; }
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}
.panel {
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 18px;
}
.compact-panel { padding-bottom: 14px; }
.narrow { max-width: 430px; margin: 60px auto; }
.login-panel { display: grid; gap: 12px; }
.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.section-heading h2 { margin-bottom: 2px; }
.split-grid { display: grid; grid-template-columns: minmax(390px, .9fr) minmax(0, 1.1fr); gap: 22px; align-items: start; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid .span-2 { grid-column: span 2; }
.form-actions { display: flex; align-items: center; gap: 12px; }
.check-row { display: flex; grid-template-columns: auto 1fr; align-items: center; }
.check-row input { width: 16px; min-height: 16px; }
.inline-form { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; }
.inline-form label { min-width: 150px; }
.inline-form .grow { flex: 1; min-width: 240px; }
.generate-toolbar {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.generate-toolbar label { min-width: 0; }
.generate-package-field { flex: 0 1 280px; min-width: 230px; }
.generate-quantity-field { flex: 0 0 94px; }
.generate-note-field { flex: 1 1 260px; min-width: 210px; }
.generate-toolbar-message { flex-basis: 100%; min-height: 16px; }
.export-control { position: relative; flex: 0 0 auto; }
.export-menu {
  position: absolute;
  top: calc(100% + 5px);
  right: 0;
  z-index: 12;
  width: 126px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 12px 30px rgba(29, 41, 37, .14);
}
.export-menu button {
  display: block;
  width: 100%;
  border: 0;
  border-top: 1px solid #edf1ef;
  background: #fff;
  color: var(--ink);
  padding: 9px 12px;
  text-align: left;
  cursor: pointer;
}
.export-menu button:first-child { border-top: 0; }
.export-menu button:hover { background: var(--surface-soft); }
.ledger-period-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 0 0 13px;
}
.ledger-period-bar .segmented { flex: 0 0 auto; }
.package-filter-group {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 15px 0 11px;
}
.package-filter-label {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
}
.package-filter-bar { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.package-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  padding: 5px 11px;
  text-align: left;
  cursor: pointer;
}
.package-filter-chip small {
  border-radius: 4px;
  background: #f0f4f2;
  color: #81908a;
  font-size: 10px;
  font-weight: 400;
  padding: 2px 5px;
  white-space: nowrap;
}
.package-filter-chip small::before {
  content: "·";
  margin-right: 4px;
}
.package-filter-chip:hover { border-color: #9fc4b7; color: var(--ink); }
.package-filter-chip.active {
  border-color: #87b8a8;
  background: #e9f5f0;
  color: #0f674f;
  font-weight: 700;
}
.package-filter-chip.active small { background: #dcefe7; color: #3e7464; }
.batch-ledger-head {
  align-items: center;
  margin: 18px 0 10px;
}
.batch-ledger-head h2 { margin-bottom: 2px; }
.batch-ledger-table td { vertical-align: middle; }
.batch-ledger-table .batch-product-name { font-weight: 700; }
.sales-package-wall {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.sales-package-tile {
  position: relative;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 15px;
  cursor: pointer;
  transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}
.sales-package-tile:hover {
  border-color: #a8c9bd;
  box-shadow: 0 8px 22px rgba(29, 41, 37, .07);
  transform: translateY(-1px);
}
.sales-package-tile.selected {
  border-color: #157a63;
  box-shadow: inset 0 0 0 1px #157a63, 0 8px 22px rgba(21, 122, 99, .08);
}
.generate-package-filters { margin-top: 18px; }
.generate-package-card.stock-low {
  border-color: var(--orange);
  box-shadow: inset 0 0 0 1px rgba(213, 116, 43, .24);
}
.generate-package-card.stock-empty {
  border-color: var(--red);
  box-shadow: inset 0 0 0 1px rgba(194, 63, 63, .26);
}
.generate-package-card.stock-low .stock-value strong { color: var(--orange); }
.generate-package-card.stock-empty .stock-value strong { color: var(--red); }
.sales-package-tile-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.generate-card-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
}
.generate-card-actions .button { white-space: nowrap; }
.package-keys-action {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-3px);
  transition: opacity .16s ease, transform .16s ease;
}
.generate-package-card:hover .package-keys-action,
.generate-package-card:focus-within .package-keys-action {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
@media (hover: none) {
  .package-keys-action {
    opacity: 1;
    pointer-events: auto;
    transform: none;
  }
}
.package-title-block { min-width: 0; }
.sales-package-tile h3 {
  min-width: 0;
  margin: 0 0 5px;
  font-size: 16px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.package-quota-badge {
  display: inline-block;
  border-radius: 4px;
  background: #eef6f2;
  color: #356d5d;
  padding: 2px 6px;
  font: 10px Consolas, "Cascadia Mono", monospace;
}
.package-card-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.package-card-stats div {
  min-width: 0;
  border-radius: 6px;
  background: #f4f7f5;
  padding: 9px;
}
.package-card-stats small {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 10px;
}
.package-card-stats strong {
  display: block;
  font-size: 14px;
  overflow-wrap: anywhere;
}
.sales-package-wall-empty {
  grid-column: 1 / -1;
  min-height: 190px;
  display: grid;
  place-items: center;
  border: 1px dashed #cdd9d4;
  border-radius: 8px;
  background: #fafcfb;
  color: var(--muted);
  font-size: 12px;
}
.routing-settings { margin-bottom: 18px; padding: 12px; background: var(--surface-soft); border-radius: 6px; }
.channel-grid { margin-bottom: 20px; }
.role-row { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; }
.role-row .check-row { display: flex; grid-template-columns: auto 1fr; }
.subhead {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 22px 0 8px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.subhead h3 { margin: 0; font-size: 14px; }
.notice { min-height: 19px; color: var(--muted); font-size: 12px; }
.notice.success { color: var(--green); }
.notice.error { color: var(--red); }
.count-pill {
  border-radius: 999px;
  background: var(--surface-soft);
  padding: 5px 10px;
  font-size: 12px;
  color: var(--muted);
}
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 11px; font-weight: 600; white-space: nowrap; }
td { font-size: 12px; }
tbody tr:hover { background: #fafcfb; }
.key-table { min-width: 1050px; }
.actions { min-width: 330px; display: flex; gap: 4px; flex-wrap: wrap; }
.lamp {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--white);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, .03);
}
.lamp.green { background: var(--green); }
.lamp.yellow { background: var(--yellow); }
.lamp.red { background: var(--red); }
.lamp.dark { background: var(--dark); }
.lamp.white { background: var(--white); border: 1px solid #aeb8b4; }
.secret-result {
  margin-top: 14px;
  border: 1px solid #efd29d;
  border-radius: 8px;
  background: #fff9ec;
  padding: 14px;
}
.secret-result pre {
  max-height: 220px;
  overflow: auto;
  margin: 0;
  padding: 12px;
  border-radius: 6px;
  background: #202825;
  color: #dff4ec;
  font: 12px/1.6 Consolas, monospace;
}

.customer-page {
  display: grid;
  place-items: start center;
  padding: 18px 12px 40px;
  background:
    linear-gradient(180deg, rgba(21, 122, 99, .10), transparent 220px),
    var(--bg);
}
.customer-announcement {
  margin-bottom: 12px;
  border: 1px solid #e7c97a;
  border-radius: 6px;
  background: #fff8e5;
  color: #6b5011;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.55;
}
.meter-shell { width: min(960px, 100%); }
.meter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding: 2px 4px;
}
.meter-header-actions { display: flex; align-items: center; gap: 8px; }
.meter-header h1 { font-size: 22px; }
.login-panel { margin-top: 28px; }
.meter-panel { padding: 20px; }
.meter-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.period-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 8px;
}
.period-button, .record-range-switch button {
  min-height: 31px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--muted);
  padding: 3px 10px;
  font-size: 11px;
  cursor: pointer;
}
.period-button.active, .record-range-switch button.active {
  border-color: #0f6c53;
  background: #eaf6f1;
  color: #0f5d4c;
  font-weight: 700;
}
.period-button:disabled, .record-range-switch button:disabled {
  opacity: .42;
  cursor: default;
}
.range-caption { margin-bottom: 12px; color: var(--muted); font-size: 11px; }
.balance-number {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin-bottom: 2px;
  font-variant-numeric: tabular-nums;
}
.balance-number span {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: 42px;
  line-height: 1.12;
  font-weight: 800;
}
.balance-number small { color: var(--muted); }
.balance-number .balance-suffix { margin-left: 8px; font-size: 12px; font-weight: 500; }
.balance-number .balance-prefix { margin-right: 2px; font-size: 12px; font-weight: 600; letter-spacing: .02em; }
.progress-track {
  height: 12px;
  margin: 14px 0 18px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edeb;
}
.quota-meter {
  display: grid;
  grid-template-columns: auto minmax(130px, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin: 14px 0 18px;
}
.quota-meter-side { color: var(--muted); font-size: 11px; white-space: nowrap; }
.quota-meter-side strong { color: var(--ink); font-size: 12px; }
.quota-progress {
  position: relative;
  height: 18px;
  margin: 0;
  overflow: hidden;
}
.quota-percent {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #173f35;
  font-size: 9px;
  font-weight: 800;
  line-height: 18px;
  text-shadow: 0 0 4px rgba(255, 255, 255, .9);
  pointer-events: none;
}
.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
  transition: width .45s ease, background .2s ease;
}
.progress-fill.yellow, .progress-fill.dark { background: var(--yellow); }
.progress-fill.red { background: var(--red); }
.progress-fill.white { background: var(--white); }
.meter-numbers {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}
.meter-numbers > div {
  min-width: 0;
  padding: 10px 8px;
  border-radius: 6px;
  background: var(--surface-soft);
  text-align: center;
}
.meter-numbers span { display: block; font-size: 18px; font-weight: 700; overflow-wrap: anywhere; }
.meter-numbers small { color: var(--muted); font-size: 10px; }
.meter-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 12px;
}
.status-banner {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  padding: 10px 12px;
  font-size: 12px;
}
.status-banner span:last-child { color: var(--muted); }
.status-banner[data-state="blocked"], .status-banner[data-state="expired"], .status-banner[data-state="exhausted"] {
  border-color: rgba(216, 74, 74, .28);
  background: #fff7f7;
}
.status-banner[data-state="expired"] .lamp { background: var(--red); }
.status-banner[data-state="low"] {
  border-color: rgba(213, 155, 36, .32);
  background: #fffaf0;
}
.compact-table { table-layout: fixed; }
.compact-table th:nth-child(1) { width: 35%; }
.compact-table th:nth-child(2) { width: 25%; }
.compact-table td { overflow-wrap: anywhere; }
.empty-state { padding: 20px; color: var(--muted); text-align: center; }
.usage-records-panel { padding: 0; }
.usage-records-panel details > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  list-style: none;
  padding: 18px 20px;
  cursor: pointer;
}
.usage-records-panel summary::-webkit-details-marker { display: none; }
.usage-records-panel summary strong { display: block; font-size: 16px; }
.usage-records-panel summary small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.records-disclosure-hint { color: var(--primary); font-size: 12px; }
.usage-records-content { padding: 0 20px 20px; }
.record-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.record-range-switch { display: flex; flex-wrap: wrap; gap: 5px; }
.cache-definition {
  margin: 0 0 10px;
  padding: 7px 9px;
  border-left: 3px solid #b78622;
  background: #fffaf0;
  color: #6e5b2a;
  font-size: 10px;
  line-height: 1.5;
}
.usage-record-table { min-width: 760px; table-layout: fixed; }
.usage-record-table th:nth-child(1) { width: 18%; }
.usage-record-table th:nth-child(2) { width: 19%; }
.usage-record-table th:nth-child(3),
.usage-record-table th:nth-child(4),
.usage-record-table th:nth-child(5),
.usage-record-table th:nth-child(6) { width: 11%; }
.usage-record-table th:nth-child(7) { width: 8%; }
.record-time, .record-model { white-space: normal; overflow-wrap: anywhere; }
.record-inline-detail summary, .mobile-record-detail summary {
  color: var(--primary);
  cursor: pointer;
  font-size: 11px;
}
.record-inline-detail { position: relative; }
.record-inline-detail[open] {
  position: absolute;
  z-index: 3;
  right: 8px;
  width: 280px;
  margin-top: 4px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  padding: 10px;
  box-shadow: 0 8px 24px rgba(15, 43, 35, .12);
}
.record-detail-list { display: grid; gap: 6px; margin: 8px 0 0; }
.record-detail-list > div { display: grid; grid-template-columns: 74px minmax(0, 1fr); gap: 8px; }
.record-detail-list dt { color: var(--muted); font-size: 10px; }
.record-detail-list dd { min-width: 0; margin: 0; overflow-wrap: anywhere; font-size: 10px; }
.usage-records-mobile { display: none; }
.usage-mobile-card {
  border-bottom: 1px solid var(--line);
  padding: 13px 0;
}
.usage-mobile-card:last-child { border-bottom: 0; }
.mobile-record-time { color: var(--muted); font-size: 11px; }
.mobile-record-model {
  margin: 4px 0 9px;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}
.mobile-record-usage { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.mobile-record-usage > div {
  min-width: 0;
  border-left: 2px solid var(--line);
  padding-left: 8px;
}
.mobile-record-usage span { display: block; color: var(--muted); font-size: 9px; }
.mobile-record-usage strong { display: block; margin-top: 2px; overflow-wrap: anywhere; font-size: 11px; }
.mobile-record-first { margin-top: 9px; font-size: 11px; }
.mobile-record-detail { margin-top: 7px; }

@media (max-width: 760px) {
  .customer-page { padding: 12px 8px 28px; }
  .meter-header { align-items: flex-start; gap: 10px; }
  .meter-header-actions { flex-wrap: wrap; justify-content: flex-end; }
  .meter-panel { padding: 16px; }
  .balance-number span { font-size: 34px; }
  .quota-meter { grid-template-columns: 1fr; gap: 5px; }
  .quota-meter-side:last-child { text-align: right; }
  .quota-progress { margin: 0; }
  .period-switch { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .period-button { width: 100%; padding-inline: 4px; }
  .meter-numbers { gap: 6px; }
  .meter-numbers span { font-size: 15px; }
  .usage-records-panel details > summary { padding: 15px 14px; }
  .usage-records-content { padding: 0 14px 16px; }
  .record-filter-bar { align-items: flex-start; flex-direction: column; }
  .record-range-switch { width: 100%; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .record-range-switch button { padding-inline: 3px; }
  .customer-records-desktop { display: none; }
  .usage-records-mobile { display: block; }
}

@media (max-width: 860px) {
  .admin-page { padding: 14px; }
  .admin-header { align-items: flex-start; flex-direction: column; }
  .split-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: span 1; }
  .inline-form { align-items: stretch; flex-direction: column; }
  .inline-form label, .inline-form .grow { min-width: 0; }
}

.admin-v13 {
  min-height: 100vh;
  background: #f2f4f3;
}
.side-nav {
  position: fixed;
  inset: 0 auto 0 0;
  width: 214px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #d8e0dc;
  background: #ffffff;
  padding: 22px 14px 16px;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 0 8px 24px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #157a63;
  color: #fff;
  font-weight: 800;
}
.brand strong { display: block; }
.brand small { display: block; color: var(--muted); }
.side-nav nav { display: grid; gap: 4px; }
.side-nav nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 6px;
  color: #40504a;
  text-decoration: none;
  font-size: 13px;
}
.side-nav nav a:hover { background: #f2f6f4; }
.side-nav nav a.active { background: #e6f3ee; color: #0d6a55; font-weight: 700; }
.side-nav nav details { display: grid; gap: 3px; }
.side-nav nav summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 6px;
  color: #40504a;
  cursor: pointer;
  font-size: 13px;
  list-style: none;
}
.side-nav nav summary::-webkit-details-marker { display: none; }
.side-nav nav summary:hover { background: #f2f6f4; }
.side-nav nav summary.active { background: #edf4f1; color: #0d6a55; font-weight: 700; }
.nav-caret { margin-left: auto; font-size: 12px; transition: transform .16s ease; }
.nav-group[open] .nav-caret { transform: rotate(180deg); }
.nav-children { display: grid; gap: 2px; margin: 2px 0 7px 20px; padding-left: 12px; border-left: 1px solid #dce5e1; }
.side-nav nav .nav-children a { padding: 7px 10px; font-size: 12px; }
.nav-ico { width: 18px; text-align: center; font-size: 15px; }
.side-foot { margin-top: auto; display: grid; gap: 8px; padding: 12px 8px 0; border-top: 1px solid var(--line); }
.side-foot a { color: var(--primary); text-decoration: none; font-size: 12px; }
.side-foot button { text-align: left; border: 0; background: none; color: var(--muted); cursor: pointer; padding: 5px 0; }
.page-main { margin-left: 214px; padding: 24px 26px 50px; max-width: 1500px; }
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.page-head h1 { font-size: 24px; }
.page-head-actions { display: flex; gap: 8px; align-items: center; }
.session-dot { font-size: 11px; color: var(--muted); padding: 5px 9px; border-radius: 999px; background: #e8eeeb; }
.session-dot.online { color: #0f6c53; background: #e2f3ec; }
.login-card {
  width: min(420px,100%);
  margin: 80px auto;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  display: grid;
  gap: 12px;
}
.admin-section { animation: fadein .16s ease-out; }
@keyframes fadein { from { opacity: .45; transform: translateY(3px); } to { opacity: 1; transform: none; } }
.sub-tabs { display: flex; gap: 5px; margin-bottom: 15px; }
.sub-tabs button {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 14px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
}
.sub-tabs button.active { border-color: #157a63; background: #e6f3ee; color: #0d6a55; font-weight: 700; }
.compact-form { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; padding: 16px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.compact-form .span-2 { grid-column: span 2; }
.compact-form .span-3 { grid-column: span 3; }
.compact-form .span-4 { grid-column: 1 / -1; }
.compact-form label { font-size: 11px; }
.compact-form input, .compact-form select, .compact-form textarea { min-height: 36px; }
.dashboard-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 15px; }
.dashboard-grid .panel { margin-bottom: 0; box-shadow: none; }
.metric-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; margin-bottom: 15px; }
.metric-card { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; }
.metric-card small { display: block; color: var(--muted); font-size: 11px; margin-bottom: 6px; }
.metric-card strong { display: block; font-size: 24px; }
.metric-card span { color: var(--muted); font-size: 11px; }
.business-overview-card { grid-column: span 2; }
.business-overview-card strong {
  font-size: 17px;
  line-height: 1.45;
}
.metrics-list { display: grid; gap: 11px; }
.metric-line { display: grid; grid-template-columns: 88px 1fr 100px; align-items: center; gap: 9px; font-size: 11px; }
.mini-track { height: 8px; background: #e8eeeb; border-radius: 999px; overflow: hidden; }
.mini-track > i { display: block; height: 100%; background: #157a63; }
.metric-line em { font-style: normal; color: var(--muted); text-align: right; }
.anomaly-list, .alert-list { display: grid; gap: 8px; }
.anomaly-item, .alert-item { border-left: 3px solid var(--yellow); background: #fffaf0; padding: 9px 10px; border-radius: 4px; font-size: 12px; }
.alert-item { border-left-color: var(--red); background: #fff7f7; }
.filter-bar { display: flex; align-items: end; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.filter-bar label { min-width: 180px; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 15px; font-size: 12px; color: var(--muted); }
.text-button { border: 0; background: none; color: var(--primary); cursor: pointer; padding: 2px 4px; font-size: 12px; }
.text-button.danger { color: var(--red); }
.key-row-actions { display: flex; gap: 3px; flex-wrap: wrap; min-width: 210px; }
.key-secret-cell { min-width: 300px; max-width: 390px; }
.key-secret-text { display: inline-block; max-width: 290px; overflow-wrap: anywhere; word-break: break-all; white-space: normal; vertical-align: top; }
.key-copy-button { margin-left: 4px; white-space: nowrap; }
.memory-cleanup-control { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.memory-cleanup-control small { font-size: 12px; }
.schedule-editor { display: grid; gap: 12px; margin-bottom: 14px; }
.global-switch-bar {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 16px;
  padding: 13px 15px;
  border: 1px solid #bcd3ca;
  border-left: 5px solid #0f5d4c;
  border-radius: 8px;
  background: #f7fbf9;
}
.global-switch-title { flex: 0 0 auto; color: #0f5d4c; font-size: 14px; font-weight: 800; }
.global-switch-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.global-switch-controls label { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.global-switch-controls input[type="number"] { width: 82px; min-height: 32px; }
.global-threshold-input, .m-token-input { display: flex; align-items: center; gap: 6px; }
.global-threshold-input input { width: 92px; }
.m-token-input input { flex: 1; min-width: 0; }
.global-threshold-input span, .m-token-input span { color: var(--muted); font-size: 11px; white-space: nowrap; }
.global-switch-controls .global-price-toggle input { width: 16px; min-height: 16px; }
.global-separator { color: #a9b8b2; }
#global-switch-message { min-height: 18px; }
.schedule-empty {
  display: grid;
  gap: 5px;
  min-height: 82px;
  align-content: center;
  border: 1px dashed #cdd9d4;
  border-radius: 8px;
  background: #fafcfb;
  padding: 16px 18px;
  color: var(--muted);
}
.schedule-empty strong { color: var(--ink); font-size: 13px; }
.schedule-empty span { font-size: 12px; }
.routing-actions {
  flex-wrap: wrap;
  margin: 0 0 18px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fafcfb;
}
.schedule-group { border: 1px solid var(--line); border-radius: 8px; background: #fff; overflow: hidden; }
.schedule-group-bar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 0;
  background: #0f5d4c;
  color: #fff;
  padding: 12px 15px;
  text-align: left;
  cursor: pointer;
}
.schedule-group-bar:hover { background: #0b503f; }
.schedule-group-title { font-size: 13px; font-weight: 700; }
.schedule-group-caret { color: rgba(255,255,255,.82); font-size: 12px; transition: transform .16s ease; }
.schedule-group.expanded .schedule-group-caret { transform: rotate(180deg); }
.schedule-group-body { padding: 14px; border-top: 1px solid #d8e1dd; }
.schedule-group-model { margin-bottom: 10px; color: var(--muted); font-size: 11px; }
.schedule-head { display: grid; grid-template-columns: minmax(150px,1fr) minmax(180px,1fr) auto; gap: 10px; align-items: end; }
.schedule-slots { display: grid; gap: 7px; margin-top: 12px; }
.schedule-editor-layout { display: grid; grid-template-columns: minmax(220px, 270px) minmax(0, 1fr); gap: 18px; align-items: stretch; }
.schedule-settings {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7faf8;
}
.schedule-model-readonly { display: grid; gap: 4px; font-size: 11px; color: var(--muted); }
.schedule-model-readonly strong { color: var(--ink); font-size: 12px; overflow-wrap: anywhere; }
.group-priority-note { color: #0f6c53; font-size: 11px; line-height: 1.5; }
.schedule-stock { margin-top: auto; }
.schedule-time-panel { min-width: 0; overflow-x: auto; }
.schedule-time-head { display: flex; align-items: center; justify-content: flex-start; gap: 10px; flex-wrap: wrap; }
.schedule-time-head strong { font-size: 12px; }
.schedule-slot {
  display: grid;
  grid-template-columns: minmax(110px, .8fr) minmax(110px, .8fr) minmax(140px, 1fr) minmax(140px, 1fr) auto;
  gap: 8px;
  align-items: end;
  margin: 0;
}
.schedule-slot > label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin: 0;
  min-width: 0;
  font-size: 11px;
  color: var(--muted);
}
.schedule-slot > label input,
.schedule-slot > label select {
  width: 100%;
  min-width: 0;
}
.schedule-slot .slot-remove {
  align-self: end;
  white-space: nowrap;
}
.schedule-time-field input { min-width: 0; width: 100%; }
.schedule-group-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.schedule-group-actions .schedule-group-message { margin-right: auto; }
.schedule-group-message { min-height: 18px; }
.duty-number {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  margin-right: 7px;
  border-radius: 4px;
  background: #e5f1ec;
  color: #0f6c53;
  font-size: 11px;
  font-weight: 700;
}
.duty-id-cell { text-align: center; width: 54px; }
.duty-arrow {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 28px;
  border: 1px solid #c9d4d0;
  border-radius: 4px;
  background: #f0f2f1;
  color: #7a8581;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
}
.duty-arrow.up {
  border-color: #92cbb5;
  background: #e4f4ed;
  color: #15805f;
}
.duty-arrow:hover { filter: brightness(.96); }
.duty-row-ops { white-space: nowrap; }
.duty-op {
  display: inline-grid;
  place-items: center;
  min-width: 32px;
  height: 28px;
  padding: 0 6px;
  margin-left: 4px;
  border: 1px solid #c9d4d0;
  border-radius: 4px;
  background: #fff;
  color: #33413d;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}
.duty-op.danger { border-color: #e5b9b5; color: #b4342f; }
.duty-op:hover { filter: brightness(.96); }
/* count sits at the far right of the dark-green group bar */
.schedule-group-right {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}
.schedule-group-count {
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
/* +2 size vs the label, bold, orange */
.schedule-group-count .count-num {
  font-size: 20px;
  font-weight: 800;
  color: var(--orange);
  line-height: 1;
  padding: 0 3px;
  vertical-align: -2px;
}
.duty-arrow:disabled { opacity: .5; cursor: wait; }
.key-select-cell { display: flex; align-items: center; gap: 5px; }

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}
.segmented button {
  border: 0;
  border-right: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  padding: 7px 12px;
  cursor: pointer;
}
.segmented button:last-child { border-right: 0; }
.segmented button.active { background: #e6f3ee; color: #0d6a55; font-weight: 700; }
.telemetry-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.telemetry-toolbar h2 { margin-bottom: 2px; }
.telemetry-summary { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; margin-bottom: 18px; }
.telemetry-stat {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 13px 15px;
}
.telemetry-stat small, .telemetry-stat span { display: block; color: var(--muted); font-size: 11px; }
.telemetry-stat strong { display: block; margin: 4px 0 2px; font-size: 24px; font-variant-numeric: tabular-nums; }
/* single column: two-per-row made the stats row (serving/idle/capacity/queue/speed/frames) cramped and unreadable */
.module-health-wall { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin-bottom: 12px; }
.module-health-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-left: 5px solid var(--green);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}
.module-health-card:only-child { grid-column: 1 / -1; }
.module-health-card.state-yellow { border-left-color: var(--yellow); }
.module-health-card.state-orange { border-left-color: var(--orange); }
.module-health-card.state-red { border-left-color: var(--red); }
.module-health-card.state-deep_red { border-left-color: var(--deep-red); }
.module-health-head { display: flex; align-items: center; gap: 10px; padding: 14px 15px; }
.module-health-head h3 { min-width: 0; margin: 0; font-size: 15px; overflow-wrap: anywhere; }
.module-health-head .module-model { color: var(--muted); font: 11px Consolas, monospace; }
.module-health-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex: 1 1 auto;
  min-width: 0;
}
/* white text was invisible on the white card face -> orange pill, right-aligned */
.module-health-stats {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: flex-end;
  padding: 6px 14px;
  border-radius: 5px;
  background: #3a9188;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  flex: 1 1 auto;
  min-width: 0;
}
.module-health-stats b { color: #fff; font-weight: 700; }
.module-health-stats .stat-num {
  font-size: 17px;
  font-weight: 800;
  color: #fff3e0;
  line-height: 1;
  padding: 0 2px;
}
.module-health-stats .stat-state { font-weight: 700; color: #fff; }
.disclosure {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
}
.module-health-body, .module-scroll-body { border-top: 1px solid var(--line); padding: 12px 14px; }
.health-key-list { display: grid; gap: 10px; }
.health-key-row { border-top: 1px solid #edf1ef; padding-top: 10px; }
.health-key-row:first-child { border-top: 0; padding-top: 0; }
.health-key-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.health-key-top strong { font-size: 13px; }
.health-key-meta { margin-left: auto; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 11px; }
.switch { position: relative; display: inline-flex; width: 36px; height: 20px; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span { width: 100%; border-radius: 999px; background: #ccd6d2; cursor: pointer; transition: background .16s ease; }
.switch span::after {
  content: "";
  display: block;
  width: 16px;
  height: 16px;
  margin: 2px;
  border-radius: 50%;
  background: #fff;
  transition: transform .16s ease;
}
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(16px); }
.chart-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; margin-top: 9px; }
.mini-chart { min-width: 0; border: 1px solid #e6ece9; border-radius: 6px; background: #fbfcfc; padding: 9px; }
.mini-chart header { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; margin-bottom: 4px; }
.mini-chart header strong { font-size: 11px; }
.mini-chart header span { color: var(--muted); font-size: 10px; }
.mini-chart svg { display: block; width: 100%; height: 70px; overflow: visible; }
.chart-empty { display: grid; place-items: center; height: 70px; color: var(--muted); font-size: 10px; }
.waterline { position: relative; height: 18px; margin: 18px 0 8px; border: 1px solid var(--line); border-radius: 4px; background: #edf2ef; overflow: hidden; }
.waterline i { display: block; height: 100%; background: var(--green); transition: width .25s ease; }
.waterline i.warn { background: var(--yellow); }
.waterline i.danger { background: var(--red); }
.waterline b { position: absolute; inset: 0; display: grid; place-items: center; color: #26332e; font-size: 10px; font-weight: 600; }
.module-scroll-list { display: grid; gap: 12px; }
.module-scroll { border: 1px solid var(--line); border-radius: 8px; background: #fff; overflow: hidden; }
.module-scroll-head { display: flex; align-items: center; gap: 12px; padding: 14px 15px; }
.module-scroll-title { min-width: 0; }
.module-scroll-title h3 { margin: 0 0 2px; font-size: 16px; overflow-wrap: anywhere; }
.module-scroll-actions { display: flex; align-items: center; gap: 5px; margin-left: auto; }
.key-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.key-toolbar-inline { margin: 0 0 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-soft); }
.key-toolbar-inline .key-edit-select { min-width: 180px; max-width: 260px; min-height: 30px; }
.key-toolbar-inline .button.danger { color: #b4342f; border-color: #e8b4b1; }
.module-empty { padding: 34px 18px; color: var(--muted); text-align: center; }
.key-list-table td { vertical-align: middle; }
.key-list-table tbody tr:has(.module-key-select:checked) { background: #eef7f3; }
.module-key-select { width: 16px; min-height: 16px; }
.key-model-lock { display: inline-block; border: 1px solid #bcd8ce; border-radius: 4px; background: #edf7f3; color: #0f6c53; padding: 2px 6px; font: 11px Consolas, monospace; }
.chart-key-panel { margin-top: 8px; }
.reconciliation-panel { margin-top: 16px; }
.billing-form { padding: 12px; border: 1px solid var(--line); border-radius: 6px; background: #f9fbfa; }
.module-form { margin-bottom: 16px; }
.sales-package-shelf {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
}
.sales-package-plus {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 228px;
  height: 100%;
  border: 2px dashed #7fb9a5;
  border-radius: 8px;
  background: #f3faf7;
  color: #0f6c53;
  font-size: 54px;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
}
.sales-package-plus:hover { border-color: #0f6c53; background: #e8f5f0; }
.sales-package-page-message { margin-top: 10px; }
.sales-package-admin-card {
  position: relative;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 15px;
  box-shadow: 0 8px 22px rgba(29, 41, 37, .05);
}
.package-card-actions {
  position: absolute;
  top: 9px;
  right: 9px;
  display: flex;
  gap: 5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .16s ease;
}
.sales-package-admin-card:hover .package-card-actions,
.sales-package-admin-card:focus-within .package-card-actions {
  opacity: 1;
  pointer-events: auto;
}
.package-card-action {
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  padding: 4px 8px;
  font-size: 11px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(29, 41, 37, .08);
}
.package-card-action:hover { background: var(--surface-soft); }
.package-card-action.danger { color: var(--red); }
.sales-package-admin-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 13px;
}
.sales-package-admin-head h3 {
  min-width: 0;
  margin: 0;
  font-size: 16px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.inventory-badge {
  flex: 0 0 auto;
  border-radius: 999px;
  background: #e9f5f0;
  color: #0f674f;
  padding: 4px 8px;
  font-size: 10px;
  font-weight: 700;
}
.sales-package-admin-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.sales-package-admin-meta > div {
  min-width: 0;
  border-radius: 6px;
  background: #f4f7f5;
  padding: 9px;
}
.sales-package-admin-meta .span-2 { grid-column: span 2; }
.sales-package-admin-meta small {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 10px;
}
.sales-package-admin-meta strong {
  display: block;
  font-size: 13px;
  overflow-wrap: anywhere;
}
.sales-package-admin-meta .model-group {
  color: #0f674f;
}
.sales-package-admin-meta .model-logic {
  margin-top: 2px;
  color: var(--muted);
  font: 10px Consolas, "Cascadia Mono", monospace;
  overflow-wrap: anywhere;
}
.sales-package-cost {
  display: flex;
  align-items: baseline;
  gap: 7px;
  flex-wrap: wrap;
}
.sales-package-cost em {
  color: var(--muted);
  font-size: 10px;
  font-style: normal;
}
.loss-warning {
  display: inline-block;
  margin-top: 4px;
  color: var(--red);
  font-size: 10px;
  font-style: normal;
  font-weight: 700;
}
.metric-card .loss-warning {
  margin: 0 0 0 6px;
}
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(19, 31, 27, .48);
}
.modal-card {
  width: min(760px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 18px;
  box-shadow: 0 24px 70px rgba(15, 43, 35, .24);
}
.restock-card { width: min(520px, 100%); }
.restock-form { display: grid; gap: 16px; }
.package-keys-card { width: min(1120px, calc(100vw - 40px)); }
.key-usage-card { width: min(1180px, calc(100vw - 40px)); }
.key-usage-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}
.key-usage-head h2 { margin-bottom: 3px; }
.key-usage-head-actions { display: flex; align-items: center; gap: 10px; }
.key-usage-filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(170px, 1fr)) auto auto;
  align-items: end;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.key-usage-filters label { min-width: 0; }
.key-usage-filters input { width: 100%; min-height: 34px; }
.key-usage-summary {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  margin: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.key-usage-summary > div {
  min-width: 0;
  padding: 11px 13px;
  border-right: 1px solid var(--line);
}
.key-usage-summary > div:last-child { border-right: 0; }
.key-usage-summary small { display: block; color: var(--muted); font-size: 10px; margin-bottom: 4px; }
.key-usage-summary strong { display: block; color: var(--ink); font-size: 17px; line-height: 1.35; }
.key-usage-summary span { display: block; color: var(--muted); font-size: 10px; line-height: 1.4; }
.key-usage-chart-panel { margin-bottom: 14px; }
.key-usage-chart-panel h3 { margin: 0; }
.key-usage-chart { min-height: 190px; overflow-x: auto; }
.key-usage-chart svg { display: block; width: 100%; min-width: 640px; height: 190px; }
.key-usage-chart text { fill: var(--muted); font-size: 10px; }
.key-usage-chart .usage-axis { stroke: var(--line); stroke-width: 1; }
.key-usage-chart .usage-line { fill: none; stroke: var(--primary); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.key-usage-chart .usage-area { fill: rgba(21, 122, 99, .1); }
.key-usage-chart circle { fill: #fff; stroke: var(--primary); stroke-width: 2; }
.key-usage-table { min-width: 1080px; }
.usage-request-id { max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usage-state, .usage-billing { display: inline-block; font-size: 11px; font-weight: 700; }
.usage-state.success { color: #0f6c53; }
.usage-state.failed { color: var(--red); }
.usage-billing.billed { color: var(--ink); }
.usage-billing.unbilled { color: var(--muted); }
.usage-note {
  margin-top: 14px;
  padding: 13px 15px;
  border-left: 4px solid #b78622;
  background: #fffaf0;
  border-radius: 4px;
}
.usage-note h3 { margin: 0 0 8px; font-size: 14px; }
.usage-note p { margin: 5px 0; font-size: 12px; line-height: 1.6; }
.package-keys-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 8px;
}
.package-keys-head h2 { margin-bottom: 3px; }
.package-keys-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.package-keys-list {
  display: grid;
  gap: 8px;
  max-height: min(62vh, 680px);
  overflow-y: auto;
  padding: 2px 5px 2px 1px;
}
.package-key-row {
  display: grid;
  grid-template-columns: minmax(260px, 1.45fr) minmax(460px, 2fr);
  align-items: center;
  gap: 16px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 11px 12px;
  text-align: left;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.package-key-row:hover {
  border-color: #8ebdab;
  background: #f7fbf9;
  box-shadow: inset 0 0 0 1px rgba(21, 122, 99, .1);
}
.package-key-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.package-key-secret {
  flex: 1 1 auto;
  min-width: 0;
  color: #164f41;
  font: 12px/1.55 Consolas, "Cascadia Mono", monospace;
  overflow-wrap: anywhere;
  white-space: normal;
}
.package-key-copy {
  flex: 0 0 auto;
  min-width: 68px;
}
.package-key-copy.copied,
.package-key-copy:disabled {
  border-color: var(--line);
  background: #eef1f0;
  color: var(--muted);
  cursor: default;
}
.package-key-unavailable {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
}
.package-key-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: center;
}
.package-key-metrics > span {
  display: grid;
  gap: 3px;
  min-width: 0;
}
.package-key-metrics small {
  color: var(--muted);
  font-size: 9px;
  line-height: 1.25;
}
.package-key-metrics strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.package-key-status strong {
  display: flex;
  align-items: center;
  gap: 5px;
}
.package-key-status i {
  display: inline-block;
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--dark);
}
.package-key-status.is-green i { background: var(--green); }
.package-key-status.is-yellow i { background: var(--yellow); }
.package-key-status.is-red i { background: var(--red); }
.package-key-status.is-dark i { background: var(--dark); }
.package-key-status.is-white i { border: 1px solid var(--line); background: #fff; }
.package-key-row.unavailable {
  background: #f8faf9;
}
.package-key-row.unavailable:hover {
  border-color: var(--line);
  box-shadow: none;
}
.package-key-row.unavailable .package-key-secret {
  color: var(--muted);
  font-family: inherit;
}
.package-keys-empty,
.package-keys-loading {
  display: grid;
  min-height: 180px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 6px;
  background: #fafcfb;
  color: var(--muted);
  font-size: 12px;
}
.restock-quick-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.restock-quick-row > span {
  color: var(--muted);
  font-size: 12px;
}
.restock-quick-options { flex: 1 1 300px; }
.restock-quick-options button { flex: 1; min-height: 38px; }
.sales-package-card .compact-form {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 0;
  padding: 0;
}
.sales-form-actions { grid-column: span 3; }
.input-suffix { display: flex; align-items: center; gap: 7px; }
.input-suffix input { flex: 1; min-width: 0; }
.input-suffix span { flex: 0 0 auto; color: var(--muted); font-size: 12px; }
.field-hint { display: block; color: var(--muted); font-size: 10px; line-height: 1.45; }
.field-warning { display: block; color: var(--red); font-size: 10px; font-weight: 700; line-height: 1.45; }
.field-warning.hidden { display: none; }
input[readonly] { background: #f2f5f4; color: var(--text); cursor: default; }
input.price-below-floor { border-color: var(--red); box-shadow: 0 0 0 1px color-mix(in srgb, var(--red) 30%, transparent); }
.sales-formula-panel {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7faf8;
  padding: 11px 12px;
}
.sales-formula-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.sales-formula-metric {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 0 12px;
}
.sales-formula-metric:first-child { padding-left: 0; }
.sales-formula-metric:last-child { padding-right: 0; }
.sales-formula-metric + .sales-formula-metric { border-left: 1px solid var(--line); }
.sales-formula-metric small {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.3;
}
.sales-formula-metric strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sales-formula-metric span {
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sales-formula-metric strong.positive { color: var(--green); }
.sales-formula-metric strong.negative { color: var(--red); }
.sales-formula-panel.is-loss {
  border-color: color-mix(in srgb, var(--red) 45%, var(--line));
  background: #fff8f7;
}
.sales-formula-panel > .field-warning {
  border-top: 1px solid color-mix(in srgb, var(--red) 24%, transparent);
  padding-top: 7px;
}
.quota-input-pair {
  display: grid;
  grid-template-columns: minmax(115px, .8fr) minmax(0, 1.2fr);
  gap: 12px;
  min-width: 0;
}
.quota-input-pair label { min-width: 0; align-content: start; }
.quota-conversion {
  color: var(--primary);
  font-size: 10px;
  line-height: 1.35;
}
.cost-reference-preview {
  display: grid;
  gap: 2px;
  align-content: center;
  border: 1px solid #cfe2da;
  border-radius: 6px;
  background: #f3faf7;
  padding: 8px 10px;
}
.cost-reference-preview small, .cost-reference-preview span { color: var(--muted); font-size: 10px; }
.cost-reference-preview strong { color: #0f6c53; font-size: 19px; }
.cost-reference-note { color: var(--muted); font-size: 11px; }
.state-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; background: var(--green); }
.state-dot.yellow { background: var(--yellow); }
.state-dot.orange { background: var(--orange); }
.state-dot.red { background: var(--red); }
.state-dot.deep_red { background: var(--deep-red); }
.state-dot.pending { background: var(--white); border: 1px solid #aeb8b4; }
.key-window-switch button { min-height: 25px; padding: 2px 7px; font-size: 10px; }
.logs-view-tabs { margin-bottom: 14px; }
.logs-filter-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.log-level {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 58px;
  color: var(--muted);
  font-size: 11px;
}
.log-level .lamp { margin-right: 0; }
.log-level.green { color: var(--green); }
.log-level.yellow { color: #996d0e; }
.log-level.red { color: var(--red); }
.log-level.deep_red { color: var(--deep-red); }
.normal-log-fold {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
.normal-log-fold summary {
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
}
.switch-log-table { min-width: 950px; }
.gateway-event-table { min-width: 1180px; }
.gateway-event-detail {
  display: block;
  max-width: 430px;
  overflow-wrap: anywhere;
  color: var(--muted);
}
.security-subhead { margin-top: 24px; }
.group-duty-panel {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.group-duty-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.group-duty-head strong { font-size: 13px; }
.duty-message { min-height: 18px; margin-top: 8px; }
.duty-table { min-width: 980px; }
.duty-table td { vertical-align: middle; }
.duty-model-name strong { display: block; }
.duty-key-name { margin-top: 2px; color: var(--muted); font-size: 11px; }
.speed-bar {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) 58px;
  align-items: center;
  gap: 7px;
}
.speed-bar-track { height: 8px; overflow: hidden; border-radius: 999px; background: #e8eeeb; }
.speed-bar-track i { display: block; height: 100%; background: var(--green); }
.speed-bar-track i.warn { background: var(--yellow); }
.speed-bar-track i.danger { background: var(--red); }
.speed-bar span { color: var(--muted); font: 10px Consolas, monospace; text-align: right; }

@media (max-width: 1100px) {
  .compact-form { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .metric-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .key-usage-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .key-usage-summary > div:nth-child(3n) { border-right: 0; }
  .module-health-wall { grid-template-columns: 1fr; }
  .chart-grid { grid-template-columns: 1fr; }
  .schedule-slot { grid-template-columns: minmax(100px,.8fr) minmax(100px,.8fr) minmax(120px,1fr) minmax(120px,1fr) auto; }
  .sales-package-wall { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .sales-package-shelf { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 820px) {
  .side-nav { position: static; width: auto; padding: 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding-bottom: 12px; }
  .side-nav nav { grid-template-columns: repeat(4,minmax(0,1fr)); }
  .side-nav nav a { justify-content: center; padding: 8px 5px; }
  .nav-ico { display: none; }
  .side-foot { display: none; }
  .page-main { margin-left: 0; padding: 16px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .telemetry-toolbar { align-items: flex-start; flex-direction: column; }
  .telemetry-summary { grid-template-columns: 1fr; }
  .logs-filter-head { align-items: flex-start; flex-direction: column; }
  .schedule-editor-layout { grid-template-columns: 1fr; }
  .schedule-settings { min-height: 0; }
  .global-switch-bar { align-items: flex-start; flex-direction: column; }
  .generate-package-field, .generate-note-field { flex-basis: 100%; width: 100%; }
  .generate-quantity-field { flex: 1 1 100px; }
  .package-filter-group { align-items: flex-start; flex-direction: column; gap: 8px; }
  .sales-package-card .compact-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sales-package-card .span-3, .sales-form-actions { grid-column: span 2; }
  .sales-formula-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 10px; }
  .sales-formula-metric:nth-child(3) { padding-left: 0; border-left: 0; }
  .package-card-actions {
    position: static;
    justify-content: flex-end;
    margin: -5px 0 9px;
    opacity: 1;
    pointer-events: auto;
  }
  .package-keys-head { flex-direction: column; gap: 10px; }
  .package-keys-head-actions { width: 100%; justify-content: space-between; }
  .package-key-row { grid-template-columns: 1fr; gap: 10px; }
  .key-usage-head { flex-direction: column; }
  .key-usage-head-actions { width: 100%; justify-content: space-between; }
  .key-usage-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nav-group { grid-column: span 2; }
  .nav-children { margin-left: 4px; }
}
@media (max-width: 560px) {
  .compact-form { grid-template-columns: 1fr; }
  .compact-form .span-2 { grid-column: span 1; }
  .metric-grid { grid-template-columns: 1fr; }
  .business-overview-card { grid-column: span 1; }
  .side-nav nav { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .page-head { align-items: flex-start; flex-direction: column; gap: 10px; }
  .schedule-head { grid-template-columns: 1fr; }
  .module-health-head, .module-scroll-head { align-items: flex-start; flex-wrap: wrap; }
  .module-health-stats { width: 100%; margin-left: 0; }
  .module-scroll-actions { width: 100%; margin-left: 0; }
  .generate-quantity-field { flex-basis: 100%; }
  .generate-toolbar > .button, .export-control, .export-control > .button { width: 100%; }
  .export-menu { left: 0; right: auto; width: 100%; }
  .sales-package-wall { grid-template-columns: 1fr; }
  .sales-package-shelf { grid-template-columns: 1fr; }
  .package-card-stats { grid-template-columns: 1fr; }
  .generate-card-actions { flex-wrap: wrap; justify-content: flex-end; }
  .package-keys-card { width: calc(100vw - 20px); padding: 14px; }
  .key-usage-card { width: calc(100vw - 20px); padding: 14px; }
  .key-usage-filters { grid-template-columns: 1fr; }
  .key-usage-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .key-usage-summary > div { border-right: 1px solid var(--line); }
  .key-usage-summary > div:nth-child(2n) { border-right: 0; }
  .package-key-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .package-keys-head-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
  }
  .package-keys-head-actions .export-control { min-width: 0; }
  .package-keys-head-actions .export-control > .button { width: 100%; }
  .sales-package-card .compact-form { grid-template-columns: 1fr; }
  .sales-package-card .span-2, .sales-package-card .span-3, .sales-form-actions { grid-column: span 1; }
  .restock-quick-row { align-items: stretch; flex-direction: column; gap: 7px; }
  .restock-quick-options {
    flex: none;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }
  .restock-quick-options button { min-height: 40px; }
  .nav-group { grid-column: span 2; }
}


/* ---------- 错误页（404 / 405 / 500） ---------- */
.error-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  background: var(--bg);
}
.error-shell {
  width: min(520px, 100%);
  padding: 36px 32px 32px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}
.error-code {
  font-size: 56px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 2px;
  color: var(--primary);
  opacity: .22;
}
.error-title {
  margin: 12px 0 10px;
  font-size: 21px;
  color: var(--ink);
}
.error-desc {
  margin: 0 0 18px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--muted);
}
.error-hint {
  margin: 0 0 24px;
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--surface-soft);
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
}
.error-hint code {
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  color: var(--ink);
  letter-spacing: .5px;
}
.error-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.module-active-count { display: inline-flex; align-items: center; gap: 4px; }
.active-count-input {
  width: 46px; min-height: 24px; padding: 1px 4px; text-align: center;
  border: 1px solid #2c7a72; border-radius: 4px;
  background: #ffffff; color: #000000;
  font: inherit; font-weight: 700;
}
.active-count-input:focus { outline: none; border-color: #87b8a8; }

/* ===== 路由优先级三档按钮 ===== */
.group-priority-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 2px 0 4px;
}
.group-priority-label {
  font-size: 11px;
  color: #5b6b66;
  white-space: nowrap;
}
.prio-switch {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
}
.prio-btn {
  appearance: none;
  border: 1px solid #c9d1ce;
  background: #eceeed;
  color: #5b6b66;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.6;
  padding: 3px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.prio-btn:hover {
  background: #e2e6e4;
  border-color: #b3bdb9;
}
.prio-btn.is-active {
  background: #2f8a5b;
  border-color: #27774e;
  color: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .15);
}
.prio-btn.is-active:hover {
  background: #2a7d51;
  border-color: #226844;
}
.prio-btn:focus-visible {
  outline: 2px solid #7ec4a3;
  outline-offset: 1px;
}

/* 时间段排班标题行内的三档按钮：更小巧，紧贴标题 */
.schedule-time-head .prio-switch { margin-left: 4px; gap: 5px; }
.schedule-time-head .prio-btn { padding: 2px 9px; font-size: 11px; line-height: 1.5; }
.schedule-time-head .schedule-add-slot { margin-left: auto; }

/* 钥匙工具条内的三档按钮：居中展示、字号放大 */
.key-toolbar .prio-switch { margin: 0 auto; gap: 8px; align-items: center; justify-content: center; }
.key-toolbar .prio-btn { padding: 6px 18px; font-size: 13px; line-height: 1.6; letter-spacing: .3px; }

/* ===== 自动切换设定：逻辑模型/阈值横排，与时间段排班同一容器 ===== */
.auto-switch-panel {
  display: block;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7faf8;
}
.auto-switch-title {
  display: inline-block;
  margin-bottom: 10px;
  padding: 2px 10px;
  border-radius: 4px;
  background: #0f6c53;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .5px;
}
.auto-switch-fields {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
  padding-bottom: 12px;
  margin-bottom: 4px;
  border-bottom: 1px solid #dde5e1;
}
.auto-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  min-width: 0;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.auto-field input,
.auto-field select {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
.auto-field-model { min-width: 150px; justify-content: flex-end; }
.auto-field-model > span.mono { min-height: 30px; display: flex; align-items: center; }
.auto-field-model > span.mono {
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  overflow-wrap: anywhere;
  white-space: normal;
}
.auto-switch-fields .group-priority-note {
  align-self: center;
  white-space: normal;
  max-width: 260px;
}
/* 上游参考价（只读对照） */
.ref-price-box {
  display: flex;
  align-items: baseline;
  gap: 4px;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px dashed #cfd8dc;
  border-radius: 6px;
  background: #f7fbfb;
  font-size: 13px;
  line-height: 1.4;
}
.ref-price-box strong {
  color: #3a9188;
  font-weight: 600;
}
.ref-price-cell .ref-price {
  color: #3a9188;
  font-size: 12px;
  white-space: nowrap;
}
.ref-price-cell .ref-price small {
  color: #90a4ae;
}
.small-hint {
  font-size: 12px;
  line-height: 1.5;
}
/* 钥匙输入行：输入框 + 按钮并排 */
.key-input-row {
  display: flex;
  align-items: stretch;
  gap: 6px;
}
.key-input-row > input {
  flex: 1;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  letter-spacing: 0;
}
.key-input-row > .ref-price-box {
  flex: 1;
  min-width: 0;
}
.key-input-row > .button {
  white-space: nowrap;
  flex-shrink: 0;
}
