:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-soft: #f9fbff;
  --text: #1d2433;
  --muted: #677186;
  --line: rgba(50, 63, 94, 0.12);
  --accent: #1947e5;
  --accent-soft: #e8efff;
  --accent-dark: #132c7d;
  --danger: #c0392b;
  --danger-soft: #ffeaea;
  --success: #1a7a1a;
  --success-soft: #e6f7e6;
  --shadow: 0 14px 32px rgba(22, 36, 78, 0.1);
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 10px;
  --font-sans: "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "SF Mono", "Cascadia Code", "Menlo", monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(25, 71, 229, 0.12), transparent 20%),
    linear-gradient(180deg, #f7f9ff 0%, var(--bg) 100%);
}

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

/* ---------- sidebar ---------- */
.sidebar {
  padding: 24px 18px;
  background: linear-gradient(180deg, #132a71 0%, #0d1743 100%);
  color: #eef2ff;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 28px;
}

.brand-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.14);
  font-weight: 800;
  font-size: 14px;
  flex-shrink: 0;
}

.brand h1 { margin: 0; font-size: 18px; }
.brand p { margin: 2px 0 0; font-size: 12px; color: rgba(238, 242, 255, 0.72); }

.menu {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  color: #eef2ff;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.04);
  transition: background 0.15s;
}

.nav-item:hover { background: rgba(255, 255, 255, 0.1); }
.nav-item.active { background: rgba(25, 71, 229, 0.5); font-weight: 700; }

.nav-sep {
  height: 1px;
  background: rgba(255, 255, 255, 0.12);
  margin: 4px 8px;
}

.sidebar-footer { margin-top: auto; padding-top: 16px; }
.sidebar-version { font-size: 11px; color: rgba(238, 242, 255, 0.45); text-align: center; }

/* ---------- main content ---------- */
.content { padding: 28px; }

.loading, .error-msg, .empty-tip {
  color: var(--muted);
  font-size: 15px;
  padding: 40px 0;
  text-align: center;
}

.error-msg { color: #c0392b; }
.text-subtle { margin-top: 4px; font-size: 12px; color: var(--muted); }

/* ---------- page header ---------- */
.page-header { margin-bottom: 24px; }

.ops-login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(145deg, #fff8f3, #f5ede6); }
.ops-login-card { width: min(100%, 360px); display: grid; gap: 14px; padding: 30px; background: #fff; border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 18px 45px rgba(94, 60, 36, 0.12); }
.ops-login-card h1 { margin: 0; font-size: 22px; }
.ops-login-card p { margin: 0; color: var(--muted); }
.ops-login-card label { display: grid; gap: 6px; font-size: 13px; font-weight: 700; }
.ops-login-card input { width: 100%; box-sizing: border-box; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.page-header h2 { margin: 0 0 6px; font-size: 24px; }
.page-desc { margin: 0; color: var(--muted); font-size: 14px; }

.back-link {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.back-link:hover { text-decoration: underline; }

/* ---------- filter bar ---------- */
.filter-bar {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.filter-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  flex-wrap: wrap;
}

.filter-input {
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font-sans);
  background: var(--surface);
  color: var(--text);
  min-width: 200px;
  outline: none;
  transition: border-color 0.15s;
}

.filter-input:focus { border-color: var(--accent); }

.filter-select {
  padding: 9px 32px 9px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font-sans);
  background: var(--surface);
  color: var(--text);
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23677186'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  transition: border-color 0.15s;
}

.filter-select:focus { border-color: var(--accent); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-sans);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, opacity 0.15s;
}

.btn:hover { opacity: 0.88; }

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-green {
  background: var(--success);
  color: #fff;
}

.btn-secondary {
  background: #eef0f5;
  color: var(--text);
}

.btn-lg { padding: 12px 28px; font-size: 15px; }
.btn-sm { padding: 4px 10px; font-size: 11px; border-radius: 6px; }

/* ---------- forms ---------- */
.form-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 28px;
  max-width: 560px;
}

.form-group { margin-bottom: 20px; }

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.form-input {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font-sans);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

.form-input:focus { border-color: var(--accent); }

.form-range {
  width: 200px;
  accent-color: var(--accent);
}

.range-val {
  display: inline-block;
  margin-left: 10px;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
}

/* ---------- action buttons row ---------- */
.action-buttons {
  display: flex;
  gap: 12px;
  margin-top: 12px;
}

/* ---------- faq draft ---------- */
.faq-draft-layout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}

.faq-draft-form {
  max-width: 100%;
}

.faq-draft-result {
  margin-top: 18px;
}

.faq-draft-slot + .faq-draft-slot {
  margin-top: 16px;
}

.faq-draft-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  padding: 18px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.faq-draft-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.faq-draft-card-head h4 {
  margin: 0;
  font-size: 16px;
}

.faq-draft-card-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.faq-draft-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.faq-draft-textarea {
  min-height: 108px;
  resize: vertical;
}

.faq-draft-meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}

.faq-draft-status {
  margin-top: 12px;
  min-height: 22px;
}

/* ---------- tables ---------- */
.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead { background: var(--surface-soft); }

.data-table th {
  text-align: left;
  padding: 12px 16px;
  font-weight: 700;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}

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

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--surface-soft); }

.cell-name { font-weight: 600; }
.cell-mono { font-family: var(--font-mono); font-size: 12px; }
.cell-desc { max-width: 300px; white-space: normal; color: var(--muted); font-size: 12px; line-height: 1.5; }

/* ---------- sort ---------- */
.sort-link {
  color: var(--muted);
  text-decoration: none;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.15s;
}

.sort-link:hover { color: var(--accent); }
.sort-link.sort-active { color: var(--accent); }

/* ---------- paginator ---------- */
.paginator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 16px 0;
  flex-wrap: wrap;
}

.paginator-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}

.paginator-btn:hover {
  background: var(--surface-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.paginator-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.paginator-btn:disabled,
.paginator-btn.paginator-disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.paginator-info {
  margin-left: 14px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

/* ---------- badges ---------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.6;
  white-space: nowrap;
}

.badge-green  { background: var(--success-soft); color: var(--success); }
.badge-blue   { background: #e6f0ff; color: #1947e5; }
.badge-red    { background: var(--danger-soft); color: var(--danger); }
.badge-orange { background: #fff3e0; color: #e67e22; }
.badge-gray   { background: #f0f0f0; color: #888; }
.badge-muted  { background: #f0f0f0; color: #888; }
.badge-yellow { background: #fff8e0; color: #b8860b; }
.badge-purple { background: #f3e6ff; color: #7b2d8e; }

/* ---------- metrics grid ---------- */
.metrics-grid, .panel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 22px;
}

.metric-card, .panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 22px;
}

.metric-card { cursor: pointer; transition: transform 0.15s; }
.metric-card:hover { transform: translateY(-2px); }

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.metric-card strong { font-size: 38px; line-height: 1; }
.metric-card p { margin: 12px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }

.panel h3 { margin: 0 0 14px; font-size: 16px; }

/* ---------- detail cards ---------- */
.detail-cards {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}

.detail-list {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 8px 12px;
  margin: 0;
  font-size: 14px;
}

.detail-list dt { color: var(--muted); font-weight: 600; }
.detail-list dd { margin: 0; word-break: break-all; }

/* ---------- quick links ---------- */
.quick-links { display: flex; flex-direction: column; gap: 8px; }

.quick-link {
  display: block;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--accent);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  transition: background 0.15s;
}

.quick-link:hover { background: var(--accent-soft); }

/* ---------- link ---------- */
.link {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  font-size: 13px;
}

.link:hover { text-decoration: underline; }

.link-danger { color: var(--danger); }

.link-sep {
  margin: 0 6px;
  color: var(--line);
  font-size: 11px;
}

/* ---------- expiry info ---------- */
.expiry-info {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.expiry-permanent { background: #f3e6ff; color: #7b2d8e; }
.expiry-ok { background: #e6f7e6; color: #1a7a1a; }
.expiry-notice { background: #e6f0ff; color: #1947e5; }
.expiry-warning { background: #fff3e0; color: #e67e22; }
.expiry-expired { background: #ffeaea; color: #c0392b; }

/* ---------- toast ---------- */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  padding: 14px 22px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  animation: toast-in 0.25s ease;
  max-width: 360px;
}

.toast.toast-out {
  opacity: 0;
  transform: translateX(40px);
  transition: opacity 0.3s, transform 0.3s;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--accent); }

/* ---------- modal ---------- */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.45);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 28px;
  max-width: 420px;
  width: 90%;
}

.modal-box h3 { margin: 0 0 12px; font-size: 18px; }
.modal-box p { margin: 0 0 20px; color: var(--muted); font-size: 14px; line-height: 1.6; }

/* ---------- diagnostics page ---------- */
.diag-card { position: relative; }
.diag-card .badge { font-size: 13px; padding: 3px 10px; }
.diag-card code { background: #f0f2f5; padding: 2px 6px; border-radius: 4px; font-size: 12px; }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { padding: 16px; }
  .metrics-grid, .panel-grid { grid-template-columns: 1fr; }
  .detail-list { grid-template-columns: 1fr; }
  .detail-list dt { margin-top: 8px; }
  .filter-bar { flex-direction: column; }
  .filter-controls { flex-direction: column; align-items: stretch; }
  .filter-input { min-width: auto; }
  .form-card { max-width: 100%; }
}
