:root {
  color-scheme: light;
  font-family: Inter, "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  --page: #f6f8fc;
  --surface: #fff;
  --surface-soft: #f5f8fd;
  --surface-hover: #f7faff;
  --text: #1b2b40;
  --muted: #65758a;
  --faint: #93a0b1;
  --line: #dbe4ef;
  --line-soft: #edf1f6;
  --accent: #1677c8;
  --accent-hover: #0f65ad;
  --accent-soft: #eaf4ff;
  --focus: rgba(22, 119, 200, .18);
  --month: #7c3aed;
  --month-hover: #6d28d9;
  --month-text: #6b21a8;
  --month-soft: #f3e8ff;
  --month-line: #d8b4fe;
  --radius: 16px;
  --radius-small: 10px;
  --shadow: 0 4px 14px rgba(35, 58, 86, .06);
  --shadow-raised: 0 12px 28px rgba(35, 58, 86, .12);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--page); }
body { margin: 0; color: var(--text); background: var(--page); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { text-decoration: none; }
code { color: var(--text); font-family: "Cascadia Mono", Consolas, monospace; }
.container-xl { width: min(1380px, calc(100% - 40px)); max-width: none; margin: 0 auto; padding-right: 0; padding-left: 0; }
.app-shell { min-height: 100vh; }
.app-navbar { border-bottom: 1px solid #d9e6f2; background: linear-gradient(105deg, #f8fbff, #edf6ff); }
.nav-inner { display: flex; min-height: 62px; align-items: center; justify-content: space-between; gap: 18px; }
.brand { color: var(--text); font-size: 18px; font-weight: 800; letter-spacing: -.02em; }
.brand::before { margin-right: 8px; color: #2184cf; content: "●"; }
.account-actions { display: flex; align-items: center; gap: 8px; }
.account-actions form { margin: 0; }
.admin-name { display: inline-flex; min-width: 34px; height: 34px; align-items: center; justify-content: center; padding: 0 9px; border-radius: 999px; color: var(--accent); background: var(--accent-soft); font-size: 12px; font-weight: 800; }
.page-content { padding-top: 30px; padding-bottom: 42px; }
.guest-content { display: grid; min-height: 100vh; place-items: center; padding-top: 32px; padding-bottom: 32px; }

.page-heading, .detail-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 22px; }
.eyebrow { margin: 0 0 5px; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .15em; }
h1 { margin: 0; font-size: clamp(26px, 3vw, 34px); line-height: 1.2; letter-spacing: -.035em; }
.subtitle { margin: 7px 0 0; color: var(--muted); font-size: 14px; }
.generation-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

.button { display: inline-flex; min-height: 38px; align-items: center; justify-content: center; padding: 8px 13px; border: 1px solid transparent; border-radius: var(--radius-small); font-weight: 700; line-height: 1.2; transition: background-color .15s ease, border-color .15s ease, transform .15s ease; }
.button:active { transform: translateY(1px); }
.button-primary { color: #fff; border-color: var(--accent); background: var(--accent); }
.button-primary:hover { color: #fff; border-color: var(--accent-hover); background: var(--accent-hover); }
.button-quiet, .button-reset { color: var(--text); border-color: var(--line); background: var(--surface); }
.button-quiet:hover, .button-reset:hover { color: var(--text); background: var(--surface-hover); }
.button-small { min-height: 32px; padding: 6px 10px; font-size: 12px; }
.button-trial { color: #8a1260; border-color: #f3bfdc; background: #ffebf5; }
.button-week { color: #075f63; border-color: #a7e5e2; background: #e1f7f5; }
.button-month { color: #fff; border-color: var(--month); background: var(--month); }
.button-trial:hover { color: #8a1260; background: #ffdfef; }
.button-week:hover { color: #075f63; background: #d1f1ee; }
.button-month:hover { color: #fff; border-color: var(--month-hover); background: var(--month-hover); }
.button-danger { color: #fff; border-color: #cf222e; background: #cf222e; }
.button-danger:hover { color: #fff; border-color: #a40e26; background: #a40e26; }
.disabled { pointer-events: none; opacity: .55; }

.notice-stack { display: grid; gap: 10px; }
.app-notice { margin-bottom: 16px; padding: 11px 14px; border: 1px solid var(--line); border-radius: var(--radius-small); color: var(--text); background: var(--surface); box-shadow: var(--shadow); font-size: 13px; font-weight: 700; }
.notice-success { color: #137333; border-color: #a7ddb5; background: #f0fff4; }
.notice-warning { color: #8a5a00; border-color: #efd78b; background: #fff9df; }
.notice-danger { color: #a40e26; border-color: #ffc1c1; background: #fff1f0; }
.notice-info { color: #075985; border-color: #b9ddf2; background: #eff8ff; }

.metrics-grid { display: grid; grid-template-columns: repeat(5, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.metric-card { position: relative; display: flex; min-height: 96px; align-items: center; justify-content: space-between; padding: 17px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); background: var(--surface); box-shadow: var(--shadow); }
.metric-card::before { position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--metric-color, var(--accent)); content: ""; }
.metric-card:hover { color: var(--text); border-color: var(--metric-color, var(--accent)); box-shadow: var(--shadow-raised); }
.metric-card.is-selected { padding: 16px; border: 2px solid var(--metric-color, var(--accent)); background: var(--metric-soft, var(--accent-soft)); }
.metric-card.is-selected::after { position: absolute; top: 9px; right: 10px; color: var(--metric-color, var(--accent)); content: "✓"; font-size: 13px; font-weight: 900; }
.metric-card > span { color: var(--muted); font-size: 14px; font-weight: 700; }
.metric-card strong { display: flex; align-items: baseline; gap: 4px; font-size: 28px; line-height: 1; }
.metric-card small { color: var(--muted); font-size: 12px; font-weight: 600; }
.metric-all { --metric-color: var(--accent); --metric-soft: #eef6ff; }
.metric-pending { --metric-color: #6e7781; --metric-soft: #f4f6f8; }
.metric-soon7 { --metric-color: #d97706; --metric-soft: #fff8e7; }
.metric-soon30 { --metric-color: #bf8700; --metric-soft: #fffbea; }
.metric-expired { --metric-color: #cf222e; --metric-soft: #fff1f0; }

.filter-panel { margin-bottom: 16px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(255, 255, 255, .94); box-shadow: var(--shadow); }
.filter-grid { display: grid; grid-template-columns: minmax(260px, 1.55fr) repeat(5, minmax(112px, .75fr)) auto; align-items: end; gap: 10px; }
.field { display: grid; gap: 5px; min-width: 0; margin-top: 12px; }
.filter-grid .field { margin-top: 0; }
.field > span { color: var(--muted); font-size: 12px; font-weight: 700; }
.field input, .field select, .text-input { width: 100%; min-width: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-small); color: var(--text); outline: none; background: var(--surface); }
.field input, .field select { height: 40px; }
.text-input { margin: 5px 0 10px; }
textarea.text-input { min-height: 90px; resize: vertical; }
.field input:focus, .field select:focus, .text-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.field input::placeholder, .text-input::placeholder { color: var(--faint); }
.filter-actions { display: flex; gap: 8px; }

.table-shell { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.license-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.license-table th { padding: 12px 16px; border-bottom: 1px solid var(--line); color: var(--muted); background: var(--surface-soft); font-size: 12px; font-weight: 800; text-align: left; }
.license-table td { padding: 16px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.license-table tr:last-child td { border-bottom: 0; }
.license-table tbody tr:hover td { background: var(--surface-hover); }
.license-table th:nth-child(1) { width: 18%; }
.license-table th:nth-child(2) { width: 7%; }
.license-table th:nth-child(3) { width: 18%; }
.license-table th:nth-child(4) { width: 20%; }
.license-table th:nth-child(5) { width: 16%; }
.license-table th:nth-child(6) { width: 11%; }
.license-table th:nth-child(7) { width: 10%; }
.service-cell { display: grid; gap: 7px; }
.expiry-line { font-size: 13px; white-space: nowrap; }
.activation-line, .created-line { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.remark-text { margin: 0; font-size: 13px; font-weight: 700; line-height: 1.45; }
.remark-empty { color: var(--faint); font-weight: 500; }

.category-tag { display: inline-flex; width: max-content; align-items: center; padding: 4px 8px; border: 1px solid transparent; border-radius: 5px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.category-trial { color: #8a1260; border-color: #f3bfdc; background: #ffebf5; }
.category-week { color: #075f63; border-color: #a7e5e2; background: #e1f7f5; }
.category-month { color: var(--month-text); border-color: var(--month-line); background: var(--month-soft); }
.category-custom { color: #57606a; border-color: #d0d7de; background: #f6f8fa; }
.status-pill { display: inline-flex; width: max-content; align-items: center; gap: 6px; padding: 4px 9px; border-radius: 999px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.status-pill::before { width: 7px; height: 7px; border-radius: 50%; background: currentColor; content: ""; }
.status-active { color: #137333; background: #dafbe1; }
.status-pending { color: #57606a; background: #eaeef2; }
.status-expiring { color: #9a6700; background: #fff8c5; }
.status-expired { color: #cf222e; background: #ffebe9; }
.status-revoked { color: #57606a; background: #eaeef2; text-decoration: line-through; }
.binding-stack { display: grid; gap: 7px; }
.binding-line { display: grid; grid-template-columns: 48px auto minmax(86px, 1fr); align-items: center; gap: 7px; }
.binding-line > strong { font-size: 12px; }
.binding-badge { display: inline-flex; width: max-content; align-items: center; gap: 5px; padding: 3px 7px; border: 1px solid currentColor; border-radius: 5px; font-size: 11px; font-weight: 750; white-space: nowrap; }
.binding-badge::before { width: 12px; flex: 0 0 12px; font-size: 12px; line-height: 1; text-align: center; }
.binding-badge.bound::before { content: "✓"; }
.binding-badge.pending::before { content: "○"; }
.binding-badge.bound { color: #137333; background: #f0fff4; }
.binding-badge.pending { color: #6e7781; background: var(--surface); }
.binding-time { color: var(--muted); font-size: 11px; white-space: nowrap; }
.license-code-stack { display: grid; gap: 6px; }
.license-code-line { display: grid; grid-template-columns: 42px minmax(0, 1fr); align-items: center; gap: 7px; }
.license-code-line span { color: var(--muted); font-size: 11px; font-weight: 750; }
.license-code-line code { overflow: hidden; font-size: 11px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { display: flex; gap: 6px; }

.mobile-list { display: none; }
.mobile-license-card { margin-bottom: 12px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.mobile-card-head, .mobile-card-meta, .mobile-card-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mobile-card-head { margin-bottom: 12px; }
.mobile-card-head h2 { margin: 0; font-size: 15px; }
.mobile-card-meta { align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); }
.mobile-card-meta > div { display: grid; gap: 4px; }
.mobile-card-meta span { color: var(--muted); font-size: 11px; }
.mobile-card-meta strong { font-size: 12px; }
.mobile-card-bindings { margin: 11px 0; }
.mobile-license-codes { margin-top: 11px; padding: 11px; border: 1px solid var(--line-soft); border-radius: var(--radius-small); background: var(--surface-soft); }
.mobile-card-actions { justify-content: flex-end; }
.empty-state { margin: 0; padding: 52px 20px; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); background: var(--surface); text-align: center; }
.pagination-bar { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 18px; color: var(--muted); font-size: 12px; }

.auth-card, .form-panel, .panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.auth-card { width: min(420px, 100%); padding: 30px; }
.auth-card h1 { margin-bottom: 24px; font-size: 26px; }
.auth-submit { width: 100%; margin-top: 10px; }
.form-panel { width: min(620px, 100%); margin: 0 auto; padding: 26px; }
.form-panel h1 { margin-bottom: 18px; }
.form-hint { margin: -8px 0 18px; color: var(--muted); font-size: 13px; }
.form-hint-danger { color: #a40e26; }
.form-actions { display: flex; gap: 8px; margin-top: 8px; }
.detail-heading { align-items: center; }
.detail-heading-actions { display: flex; align-items: center; gap: 10px; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(320px, .9fr); gap: 18px; }
.panel { margin-bottom: 18px; padding: 22px; }
.panel h2 { margin: 0 0 16px; font-size: 17px; }
.key-card { padding: 15px 0; border-top: 1px solid var(--line-soft); }
.key-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.key-card code { display: block; margin: 10px 0 7px; overflow-wrap: anywhere; font-size: 14px; }
.key-card p, .danger-panel > p { margin: 4px 0; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.panel form .button { margin-top: 5px; }
.detail-list { display: grid; grid-template-columns: 110px minmax(0, 1fr); margin: 0; }
.detail-list dt, .detail-list dd { margin: 0; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.detail-list dt { color: var(--muted); font-weight: 600; }
.detail-list dd { overflow-wrap: anywhere; }
.danger-panel { border-color: #ffc1c1; }
.danger-panel h2 { color: #a40e26; }

@media (max-width: 1340px) {
  .binding-line { grid-template-columns: 44px auto; }
  .binding-time { grid-column: 1 / -1; padding-left: 51px; }
}

@media (max-width: 1180px) {
  .filter-grid { grid-template-columns: minmax(260px, 2fr) repeat(3, minmax(128px, 1fr)); }
}

@media (max-width: 1100px) {
  .container-xl { width: min(100% - 28px, 760px); }
  .page-heading { align-items: stretch; flex-direction: column; }
  .generation-actions { justify-content: flex-start; }
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-all { grid-column: 1 / -1; }
  .filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field-search { grid-column: 1 / -1; }
  .desktop-list { display: none; }
  .mobile-list { display: block; }
  .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .container-xl { width: calc(100% - 24px); }
  .nav-inner { min-height: 58px; }
  .brand { max-width: 150px; font-size: 15px; }
  .admin-name { display: none; }
  .account-actions { gap: 5px; }
  .account-actions .button { min-height: 32px; padding: 6px 8px; font-size: 11px; }
  .page-content { padding-top: 20px; }
  .page-heading { gap: 15px; }
  .generation-actions { display: grid; grid-template-columns: repeat(3, 1fr); }
  .generation-actions .button { padding-inline: 5px; font-size: 11px; }
  .metrics-grid { gap: 8px; }
  .metric-card { min-height: 78px; padding: 12px; }
  .metric-card.is-selected { padding: 11px; }
  .metric-card > span { font-size: 12px; }
  .metric-card strong { font-size: 22px; }
  .filter-grid { grid-template-columns: 1fr 1fr; }
  .field-search, .filter-actions { grid-column: 1 / -1; }
  .filter-actions .button { flex: 1; }
  .mobile-card-head { align-items: flex-start; }
  .mobile-card-meta { display: grid; grid-template-columns: 1fr 1fr; }
  .binding-line { grid-template-columns: 48px auto minmax(86px, 1fr); }
  .binding-time { grid-column: auto; padding-left: 0; text-align: right; }
  .detail-heading { align-items: flex-start; flex-direction: column; }
  .detail-heading-actions { width: 100%; justify-content: space-between; }
  .auth-card, .form-panel, .panel { padding: 18px; }
}

@media (max-width: 380px) {
  .filter-grid { grid-template-columns: 1fr; }
  .field-search, .filter-actions { grid-column: auto; }
  .generation-actions { grid-template-columns: 1fr; }
  .metrics-grid { grid-template-columns: 1fr; }
  .metric-all { grid-column: auto; }
  .binding-line { grid-template-columns: 44px auto; }
  .binding-time { grid-column: 1 / -1; padding-left: 51px; text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
