:root {
  color-scheme: light;
  --primary: #2f6ff2;
  --primary-dark: #2157c9;
  --primary-soft: #edf3ff;
  --ink: #17233d;
  --muted: #66758f;
  --line: #dce5f4;
  --surface: #ffffff;
  --canvas: #f5f8fe;
  --success: #197148;
  --success-soft: #eaf8f0;
  --warning: #8a5b00;
  --warning-soft: #fff8e6;
  --danger: #b42332;
  --danger-soft: #fff0f1;
  font-family: "Microsoft YaHei UI", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); background: var(--canvas); font-size: 14px; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { min-height: 38px; padding: 8px 16px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--ink); cursor: pointer; transition: transform .12s ease, border-color .12s ease, background .12s ease; }
button:hover { transform: translateY(-1px); border-color: #aabde1; }
button:disabled { cursor: wait; opacity: .6; transform: none; }
.primary { color: #fff; background: var(--primary); border-color: var(--primary); font-weight: 650; }
.primary:hover { background: var(--primary-dark); }
.secondary { color: var(--primary); background: #fff; border-color: #b8c9ea; }
.danger { color: #fff; background: var(--danger); border-color: var(--danger); }
.ghost { background: transparent; }
.full { width: 100%; margin-top: 8px; }

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: 25px; }
h2 { margin-bottom: 8px; font-size: 18px; }
.eyebrow, .step { margin-bottom: 5px; color: var(--primary); font-size: 12px; font-weight: 700; letter-spacing: .06em; }
.muted { color: var(--muted); line-height: 1.65; }
.back-link { display: inline-block; margin-bottom: 24px; color: var(--primary); text-decoration: none; }

.landing { min-height: 100vh; display: grid; place-items: center; padding: 28px; background: radial-gradient(circle at top right, #e3ecff, transparent 34%), var(--canvas); }
.landing-card { width: min(760px, 100%); padding: 42px; border: 1px solid var(--line); border-radius: 22px; background: rgba(255,255,255,.96); box-shadow: 0 18px 55px rgba(30, 64, 130, .11); }
.brand-mark { display: grid; place-items: center; width: 46px; height: 46px; margin-bottom: 18px; border-radius: 13px; color: #fff; background: var(--primary); font-size: 18px; }
.landing-copy { color: var(--muted); }
.entry-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin: 28px 0 22px; }
.entry-card { padding: 23px; border: 1px solid var(--line); border-radius: 14px; color: var(--ink); background: #fff; text-decoration: none; transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease; }
.entry-card:hover { transform: translateY(-2px); border-color: #9bb5e8; box-shadow: 0 12px 30px rgba(37, 80, 160, .1); }
.entry-card strong, .entry-card span { display: block; }
.entry-card strong { margin-bottom: 8px; font-size: 18px; }
.entry-card span, .security-note { color: var(--muted); line-height: 1.6; }
.security-note { margin-bottom: 0; font-size: 12px; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(470px, 100%); padding: 34px; border: 1px solid var(--line); border-radius: 18px; background: #fff; box-shadow: 0 16px 44px rgba(31, 61, 120, .1); }
label { display: grid; gap: 7px; color: #42516d; font-weight: 600; }
input, select, textarea { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid #c7d5ec; border-radius: 8px; color: var(--ink); background: #fff; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47,111,242,.12); }
textarea { min-height: 116px; resize: vertical; font-family: Consolas, monospace; line-height: 1.55; }
.form-error { min-height: 20px; margin: 12px 0 0; color: var(--danger); }

.app-shell { width: min(1440px, calc(100% - 32px)); margin: 0 auto; padding: 24px 0 44px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 22px; padding: 18px 22px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.topbar h1, .topbar p { margin-bottom: 0; }
.top-actions, .filters { display: flex; align-items: center; gap: 10px; }
.secure-pill { padding: 7px 11px; border-radius: 999px; color: var(--success); background: var(--success-soft); font-size: 12px; }
.notice { position: sticky; top: 10px; z-index: 5; margin-bottom: 16px; padding: 12px 15px; border: 1px solid #c9d8f1; border-radius: 10px; color: #234b9a; background: #eef4ff; box-shadow: 0 8px 24px rgba(31, 61, 120, .08); }
.notice.error { color: var(--danger); border-color: #f1c3c8; background: var(--danger-soft); }
.notice.success { color: var(--success); border-color: #bfe1cf; background: var(--success-soft); }

.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; margin-bottom: 16px; }
.stat-grid.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.stat-card { min-height: 122px; padding: 19px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.stat-card.emphasis { border-color: #aac0ef; background: linear-gradient(135deg, #fff, #edf3ff); }
.stat-card span, .stat-card small { display: block; color: var(--muted); }
.stat-card strong { display: block; margin: 8px 0 5px; font-size: 30px; }

.panel { margin-bottom: 16px; padding: 20px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.split-panel { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr); gap: 24px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.section-heading h2, .section-heading p { margin-bottom: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; align-items: end; }
.form-grid .wide { grid-column: 1 / -1; }
.form-grid button { justify-self: start; }
.batch-input { min-height: 156px; }
.advanced-box { margin-top: 18px; padding: 12px 14px; border: 1px dashed #c7d5ec; border-radius: 10px; background: #fafcff; }
.advanced-box summary { color: var(--primary); font-weight: 650; cursor: pointer; }
.advanced-box[open] summary { margin-bottom: 14px; }
.token-result { padding: 18px; border: 1px solid #bbd0f5; border-radius: 12px; background: var(--primary-soft); }
.token-result textarea { background: rgba(255,255,255,.9); }

.table-wrap { overflow-x: auto; border: 1px solid #e2e9f5; border-radius: 10px; }
table { width: 100%; border-collapse: collapse; min-width: 780px; }
th, td { padding: 12px 13px; border-bottom: 1px solid #e7edf7; text-align: left; vertical-align: middle; }
th { color: #5f6f89; background: #f8faff; font-size: 12px; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafcff; }
.license-table table { min-width: 1120px; }
.speech-usage-table table { min-width: 1180px; }
.cell-title { display: block; color: var(--ink); font-weight: 650; }
.cell-subtitle { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.status-badge { display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 999px; font-size: 12px; white-space: nowrap; }
.status-unactivated { color: #365d9d; background: #edf3ff; }
.status-active { color: var(--success); background: var(--success-soft); }
.status-expired { color: var(--warning); background: var(--warning-soft); }
.status-disabled { color: var(--danger); background: var(--danger-soft); }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.row-actions button { min-height: 31px; padding: 5px 9px; font-size: 12px; }
.empty-row { padding: 28px; color: var(--muted); text-align: center; }

.audit-list { display: grid; gap: 8px; max-height: 360px; overflow: auto; }
.audit-item { padding: 11px 12px; border: 1px solid #e4ebf6; border-radius: 9px; background: #fbfcff; }
.audit-item strong, .audit-item span { display: block; }
.audit-item span { margin-top: 4px; color: var(--muted); font-size: 12px; }

@media (max-width: 1000px) {
  .stat-grid.five { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .split-panel { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .entry-grid, .stat-grid, .stat-grid.five, .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .landing-card, .login-card { padding: 25px; }
  .app-shell { width: min(100% - 18px, 1440px); padding-top: 10px; }
  .topbar, .section-heading { align-items: flex-start; flex-direction: column; }
  .top-actions { width: 100%; justify-content: space-between; }
  .filters { width: 100%; }
  .filters select { flex: 1; }
}
