:root {
  --bg: #edf1f4;
  --surface: #ffffff;
  --surface-muted: #f7f9fa;
  --text: #17212b;
  --muted: #667382;
  --border: #d8e0e6;
  --nav: #17242f;
  --nav-active: #29404f;
  --primary: #0f766e;
  --primary-dark: #0b5f59;
  --secondary: #1f4f78;
  --warning: #a75b12;
  --danger: #b42318;
  --shadow: 0 12px 28px rgba(17, 35, 50, 0.08);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  font-size: 14px;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: var(--primary); }
h1, h2, h3, h4, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: 26px; }
h2 { margin-bottom: 0; font-size: 22px; }
h3 { margin-bottom: 4px; font-size: 17px; }
h4 { margin-bottom: 2px; font-size: 15px; }
.muted { color: var(--muted); margin-bottom: 0; }
.eyebrow { margin-bottom: 4px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0; }
.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  color: white;
  background: var(--primary);
  border-radius: 8px;
  font-weight: 800;
}
.brand-mark-small { width: 34px; height: 34px; font-size: 12px; }
.login-shell { display: grid; min-height: 100vh; padding: 24px; place-items: center; }
.login-panel {
  width: min(100%, 390px);
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.login-panel .brand-mark { margin-bottom: 18px; }
.login-panel p { margin-bottom: 22px; }
.login-panel label, .form-grid label { display: grid; gap: 7px; color: #344252; font-weight: 600; }
.login-panel input, .form-grid input, .filter-form input, .filter-form select {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  color: var(--text);
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12); }
.login-panel .button { margin-top: 18px; }
.button {
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-weight: 700;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}
.button:disabled { cursor: not-allowed; opacity: 0.5; }
.button-primary { color: white; background: var(--primary); }
.button-primary:hover { background: var(--primary-dark); }
.button-secondary { color: white; background: var(--secondary); }
.button-ghost { color: var(--text); background: white; border-color: var(--border); }
.button-danger { color: white; background: var(--danger); }
.button-small { min-height: 30px; padding: 4px 10px; font-size: 12px; }
.button-block { width: 100%; }
.form-error { min-height: 20px; margin: 10px 0 0; color: var(--danger); }
.app-shell { display: grid; min-height: 100vh; grid-template-columns: 220px minmax(0, 1fr); }
.sidebar {
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  color: white;
  background: var(--nav);
}
.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 22px; font-size: 16px; font-weight: 800; }
.sidebar nav { display: grid; gap: 6px; }
.nav-button {
  width: 100%;
  padding: 11px 12px;
  color: #c6d1da;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 6px;
  font-weight: 700;
}
.nav-button:hover { color: white; background: #20333f; }
.nav-button.is-active { color: white; background: var(--nav-active); box-shadow: inset 3px 0 var(--primary); }
.sidebar-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; padding: 18px 8px 0; }
.sidebar-footer .muted { color: #9dafbb; }
.workspace { min-width: 0; }
.topbar {
  display: flex;
  min-height: 84px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 26px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.page { padding: 24px; }
.stats-grid { display: grid; grid-template-columns: repeat(6, minmax(120px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat-card {
  min-height: 112px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--primary);
  border-radius: 7px;
}
.stat-card span { color: var(--muted); font-size: 13px; }
.stat-card strong { display: block; margin-top: 14px; font-size: 28px; line-height: 1; }
.stat-card-warning { border-top-color: var(--warning); }
.stat-card-muted { border-top-color: #7b8794; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.panel-flush { overflow: hidden; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.panel-heading-padded { padding: 16px 18px; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 13px; border-bottom: 1px solid #e7edf1; text-align: left; vertical-align: middle; white-space: nowrap; }
th { color: var(--muted); background: var(--surface-muted); font-size: 12px; font-weight: 700; }
tbody tr:hover { background: #fbfcfd; }
.empty-cell { padding: 28px; color: var(--muted); text-align: center; }
.align-right { text-align: right; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.filter-form { display: flex; flex: 1; gap: 9px; max-width: 720px; }
.filter-form input { flex: 1; min-width: 160px; }
.filter-form select { width: 130px; }
.status-pill, .state-badge { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.status-neutral { color: #344252; background: #e8edf1; }
.status-online { color: #0b5f59; background: #d9f1ed; }
.status-offline { color: #8f271f; background: #f8e1df; }
.state-active { color: #0b5f59; background: #d9f1ed; }
.state-unused { color: #1f4f78; background: #e3eef7; }
.state-expired { color: #8a4b08; background: #fbedd8; }
.state-disabled { color: #8f271f; background: #f8e1df; }
.row-actions { display: inline-flex; flex-wrap: nowrap; gap: 5px; }
.pagination { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-top: 1px solid var(--border); }
.pagination > div { display: flex; gap: 7px; }
.modal-backdrop { position: fixed; inset: 0; z-index: 40; display: grid; padding: 20px; place-items: center; background: rgba(11, 23, 32, 0.58); }
.modal { width: min(100%, 680px); max-height: calc(100vh - 40px); overflow-y: auto; padding: 20px; background: var(--surface); border-radius: 8px; box-shadow: 0 24px 70px rgba(0, 0, 0, 0.24); }
.modal-small { width: min(100%, 500px); }
.modal-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.icon-button { width: 32px; height: 32px; padding: 0; background: transparent; border: 1px solid var(--border); border-radius: 6px; font-size: 20px; line-height: 1; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field-note { color: var(--muted); font-size: 11px; font-weight: 400; }
.modal-actions { display: flex; grid-column: 1 / -1; justify-content: flex-end; gap: 8px; padding-top: 4px; }
.generated-result { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--border); }
.inline-actions { display: flex; gap: 6px; }
.generated-result textarea { width: 100%; margin-top: 12px; padding: 12px; color: #d9f1ed; background: #14212a; border: 1px solid #29404f; border-radius: 6px; font-family: Consolas, "Courier New", monospace; resize: vertical; }
.revealed-key { width: 100%; margin: 14px 0; padding: 12px; color: #0b5f59; background: #f0fdfa; border: 1px solid #9ed8cf; border-radius: 6px; font-family: Consolas, "Courier New", monospace; font-size: 16px; font-weight: 700; text-align: center; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 60; max-width: min(420px, calc(100vw - 40px)); padding: 12px 15px; color: white; background: #17242f; border-radius: 6px; box-shadow: var(--shadow); }
.toast.is-error { background: var(--danger); }
.toast.is-success { background: var(--primary-dark); }
.field-note { display: block; margin-top: 3px; }

@media (max-width: 1180px) {
  .stats-grid { grid-template-columns: repeat(3, minmax(130px, 1fr)); }
}
@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; align-items: center; gap: 10px; padding: 10px; overflow-x: auto; }
  .sidebar-brand { padding: 0 6px; white-space: nowrap; }
  .sidebar nav { display: flex; }
  .nav-button { width: auto; white-space: nowrap; }
  .sidebar-footer { margin: 0 0 0 auto; padding: 0; white-space: nowrap; }
  .sidebar-footer .muted { display: none; }
  .page { padding: 16px; }
  .topbar { padding: 14px 16px; min-height: 72px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar { align-items: stretch; flex-direction: column; }
  .filter-form { max-width: none; flex-wrap: wrap; }
  .filter-form input { flex-basis: 100%; }
  .filter-form select { flex: 1; }
}
@media (max-width: 520px) {
  .login-shell { padding: 14px; }
  .login-panel { padding: 22px; }
  .stats-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .modal-actions { grid-column: auto; }
  .sidebar-brand > span:last-child { display: none; }
  th, td { padding: 9px 10px; font-size: 12px; }
}
