:root {
  --text: #1d2933;
  --muted: #6b7780;
  --subtle: #8b969d;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --line: #dfe4e7;
  --line-strong: #b9c4c9;
  --green: #16856f;
  --green-soft: #eaf6f2;
  --red: #c94747;
  --red-soft: #fff0f0;
  --amber: #d68b20;
  --mono: "Cascadia Mono", Consolas, monospace;
  --sans: "Segoe UI", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; letter-spacing: 0; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; color: var(--text); background: var(--bg); font-family: var(--sans); font-size: 13px; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: none; border-color: #7eaaa1; box-shadow: 0 0 0 1px rgba(22, 133, 111, .12); }
[v-cloak] { display: none; }

.main-shell { width: min(1500px, 100%); min-height: 100vh; margin: 0 auto; padding: 0 28px 28px; }
.page-header { display: flex; min-height: 64px; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.page-title { display: flex; align-items: center; gap: 10px; }
.page-title h1 { margin: 0 0 2px; font-size: 19px; line-height: 1.2; font-weight: 650; }
.page-title > div > span { color: var(--subtle); font-family: var(--mono); font-size: 9px; }
.brand-mark { display: flex; width: 26px; height: 26px; align-items: flex-end; gap: 3px; padding: 5px; border-radius: 4px; background: var(--text); }
.brand-mark span { width: 3px; background: #7bd4c1; }
.brand-mark span:nth-child(1) { height: 7px; }
.brand-mark span:nth-child(2) { height: 11px; }
.brand-mark span:nth-child(3) { height: 16px; }
.header-actions { display: flex; align-items: center; gap: 8px; }

/* 共用导航栏（组件定义在 navbar.js） */
.nav-bar { display: flex; gap: 2px; margin-left: auto; margin-right: 12px; }
.nav-link { display: inline-flex; height: 30px; align-items: center; padding: 0 12px; border-radius: 4px; color: var(--muted); background: transparent; text-decoration: none; font-size: 11px; transition: color .15s, background .15s; }
.nav-link:hover { color: var(--text); background: var(--bg); }
.nav-link.active { color: var(--text); background: var(--bg); font-weight: 600; }
.logout-button { color: var(--red); }
.logout-button:hover:not(:disabled) { border-color: #efcaca; color: var(--red); background: var(--red-soft); }
.service-state, .backend-state { display: inline-flex; height: 30px; align-items: center; gap: 6px; padding: 0 9px; color: var(--muted); font-size: 11px; }
.backend-state { border-left: 1px solid var(--line); }
.backend-state svg { width: 13px; height: 13px; }
.status-dot { display: inline-block; width: 6px; height: 6px; flex: 0 0 auto; border-radius: 50%; background: #a7b0b5; }
.status-dot.online { background: #23a386; }
.toolbar-button, .icon-button { display: inline-flex; height: 30px; align-items: center; justify-content: center; gap: 6px; padding: 0 9px; border: 1px solid var(--line); border-radius: 4px; color: #4f5e66; background: var(--surface); font-size: 11px; }
.toolbar-button:hover, .icon-button:hover:not(:disabled) { border-color: var(--line-strong); color: var(--text); }
.toolbar-button svg, .icon-button svg { width: 13px; height: 13px; }
.icon-button { width: 30px; padding: 0; }
.icon-button.small { width: 26px; height: 26px; }

.summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 18px 0 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.summary-item { display: flex; min-height: 58px; align-items: center; justify-content: space-between; gap: 12px; padding: 0 18px; border-right: 1px solid var(--line); }
.summary-item:last-child { border-right: 0; }
.summary-item span { color: var(--muted); font-size: 11px; }
.summary-item strong { font-family: var(--mono); font-size: 20px; font-weight: 600; }
.summary-item.available strong { color: var(--green); }
.summary-item.revoked strong { color: var(--red); }

.workspace-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 12px; }
.panel { border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.create-panel, .activity-panel { min-height: 228px; padding: 18px; }
.activity-panel { display: flex; flex-direction: column; }
.panel-heading { display: flex; min-height: 24px; align-items: center; justify-content: space-between; }
.panel-heading h2, .table-heading h2 { margin: 0; font-size: 14px; font-weight: 650; }
.count-badge { display: inline-grid; min-width: 22px; height: 22px; place-items: center; padding: 0 6px; border-radius: 4px; color: var(--muted); background: var(--bg); font-family: var(--mono); font-size: 9px; }

.create-form { display: grid; grid-template-columns: 96px 150px 150px auto auto; align-items: end; gap: 10px; margin-top: 16px; }
.field { display: grid; align-content: start; gap: 6px; color: #52616a; font-size: 11px; }
.field input { width: 100%; min-width: 0; height: 34px; padding: 0 9px; border: 1px solid var(--line); border-radius: 4px; outline: none; color: var(--text); background: #fbfcfc; font-size: 12px; }
.field input:hover { border-color: var(--line-strong); }
.switch-field { display: inline-flex; align-items: center; align-self: end; gap: 9px; height: 34px; color: #52616a; font-size: 11px; white-space: nowrap; }
.input-with-suffix { position: relative; }
.input-with-suffix input { padding-right: 30px; }
.input-with-suffix em { position: absolute; top: 50%; right: 9px; color: var(--subtle); font-family: var(--mono); font-size: 9px; font-style: normal; transform: translateY(-50%); }
.switch-row { display: inline-flex; align-items: center; gap: 7px; color: #52616a; font-size: 11px; cursor: pointer; }
.switch-input { position: absolute; opacity: 0; pointer-events: none; }
.switch-ui { position: relative; width: 32px; height: 18px; border: 1px solid #c5cdd1; border-radius: 10px; background: #e9edef; transition: .15s ease; }
.switch-ui::after { position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: #8d989e; content: ""; transition: .15s ease; }
.switch-input:focus-visible + .switch-ui { border-color: #7eaaa1; box-shadow: 0 0 0 1px rgba(22, 133, 111, .12); }
.switch-input:checked + .switch-ui { border-color: var(--green); background: var(--green); }
.switch-input:checked + .switch-ui::after { left: 16px; background: #fff; }
.primary-button, .outline-button, .danger-button, .danger-solid-button, .text-button, .copy-button, .row-copy { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-radius: 4px; font-size: 11px; }
.primary-button { width: auto; height: 34px; padding: 0 14px; border: 1px solid var(--green); color: #fff; background: var(--green); font-weight: 600; }
.primary-button:hover:not(:disabled) { border-color: #106b5b; background: #106b5b; }
.primary-button svg { width: 13px; height: 13px; }

.recent-list { display: grid; gap: 0; max-height: 135px; margin-top: 10px; overflow: auto; }
.recent-item { display: flex; min-height: 34px; align-items: center; justify-content: space-between; gap: 8px; border-bottom: 1px solid #edf0f1; }
code { color: #33434b; font-family: var(--mono); font-size: 10px; }
.recent-item code { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copy-button, .row-copy { width: 25px; height: 25px; flex: 0 0 auto; padding: 0; border: 0; color: var(--subtle); background: transparent; }
.copy-all-button { display: inline-flex; height: 28px; align-items: center; gap: 5px; padding: 0 9px; border: 1px solid var(--line); border-radius: 4px; color: var(--green); background: var(--surface); font-size: 10px; }
.copy-all-button:hover { border-color: #9bc8be; background: var(--green-soft); }
.copy-all-button svg { width: 12px; height: 12px; }
.copy-button:hover, .row-copy:hover { color: var(--green); background: var(--green-soft); }
.copy-button svg, .row-copy svg { width: 12px; height: 12px; }
.text-button { align-self: flex-start; margin-top: auto; padding: 6px 0 0; border: 0; color: var(--green); background: transparent; }
.text-button svg { width: 12px; height: 12px; }
.empty-state, .loading-state { display: flex; min-height: 130px; align-items: center; justify-content: center; gap: 7px; color: var(--subtle); font-size: 11px; }
.empty-state.compact { flex: 1; min-height: 90px; }
.loading-state svg { width: 14px; height: 14px; }

.table-panel { margin-top: 12px; }
.table-heading { display: flex; min-height: 62px; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 18px; }
.table-actions { display: flex; align-items: center; gap: 7px; }
.search-box { display: flex; width: 210px; height: 32px; align-items: center; gap: 6px; padding: 0 8px; border: 1px solid var(--line); border-radius: 4px; background: #fbfcfc; }
.search-box:focus-within { border-color: #7eaaa1; box-shadow: 0 0 0 1px rgba(22, 133, 111, .12); }
.search-box svg { width: 13px; height: 13px; color: var(--subtle); }
.search-box input { width: 100%; min-width: 0; padding: 0; border: 0; outline: 0; color: var(--text); background: transparent; font-size: 11px; box-shadow: none; }
.filter-input, .table-actions select { height: 32px; padding: 0 8px; border: 1px solid var(--line); border-radius: 4px; outline: none; color: #52616a; background: #fbfcfc; font-size: 11px; }
.filter-input { width: 100px; }
.table-actions select { padding-right: 22px; }
.outline-button { height: 32px; padding: 0 10px; border: 1px solid var(--line-strong); color: #47575f; background: var(--surface); }
.outline-button:hover:not(:disabled) { border-color: #7e8c93; color: var(--text); }
.outline-button svg { width: 12px; height: 12px; }
.table-wrap { overflow-x: auto; border-top: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { height: 34px; padding: 7px 10px; border-bottom: 1px solid var(--line); color: #78858c; background: #fafbfb; font-size: 10px; font-weight: 500; white-space: nowrap; }
th:first-child, td:first-child { padding-left: 18px; }
th:last-child, td:last-child { padding-right: 18px; }
td { height: 48px; padding: 7px 10px; border-bottom: 1px solid #edf0f1; color: #4d5c64; font-size: 11px; white-space: nowrap; }
tbody tr:hover td { background: #fafcfc; }
.card-key-cell { display: flex; min-width: 205px; align-items: center; gap: 5px; }
.row-copy { visibility: hidden; }
.card-key-cell:hover .row-copy { visibility: visible; }
.type-label { color: #35474f; font-family: var(--mono); font-size: 10px; }
.status-label { display: inline-flex; align-items: center; gap: 6px; font-size: 10px; }
.status-label.is-active, .status-label.is-ready { color: var(--green); }
.status-label.is-revoked, .status-label.is-expired { color: var(--red); }
.status-label.is-active .status-dot { background: var(--green); }
.status-label.is-ready .status-dot { background: var(--amber); }
.status-label.is-revoked .status-dot, .status-label.is-expired .status-dot { background: var(--red); }
.date-cell, .machine-cell { color: #6f7c83; font-family: var(--mono); font-size: 9px; }
.machine-cell { display: block; max-width: 130px; overflow: hidden; text-overflow: ellipsis; }
.row-actions { text-align: right; }
.danger-button { height: 26px; padding: 0 8px; border: 1px solid #efcaca; color: var(--red); background: #fff; }
.danger-button:hover { border-color: var(--red); background: var(--red-soft); }
.danger-button svg { width: 12px; height: 12px; }
.revoked-mark { color: var(--red); font-size: 10px; }
.table-footer { display: flex; min-height: 48px; align-items: center; justify-content: space-between; padding: 9px 18px; color: var(--subtle); font-family: var(--mono); font-size: 9px; }
.pager { display: flex; align-items: center; gap: 8px; }

.toast { position: fixed; z-index: 20; top: 16px; left: 50%; display: flex; min-width: 240px; max-width: min(520px, calc(100vw - 28px)); align-items: center; gap: 8px; padding: 10px 10px 10px 12px; border: 1px solid #9bd0c3; border-radius: 6px; color: #125f50; background: #effaf7; box-shadow: 0 8px 24px rgba(28, 54, 48, .12); font-size: 11px; transform: translateX(-50%); }
.toast.error { border-color: #efb1b1; color: #a93636; background: #fff2f2; }
.toast > svg { width: 14px; height: 14px; flex: 0 0 auto; }
.toast > span { min-width: 0; flex: 1; }
.toast button { display: inline-grid; width: 24px; height: 24px; flex: 0 0 auto; place-items: center; padding: 0; border: 0; border-radius: 4px; color: currentColor; background: transparent; }
.toast button:hover { background: rgba(0, 0, 0, .05); }
.toast button svg { width: 13px; height: 13px; }

.token-popover { position: fixed; z-index: 12; top: 58px; right: 28px; width: 280px; padding: 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); box-shadow: 0 10px 30px rgba(35, 48, 55, .14); }
.token-popover-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 11px; font-size: 12px; }
.token-popover-heading button { display: inline-grid; width: 24px; height: 24px; place-items: center; padding: 0; border: 0; color: var(--muted); background: transparent; }
.token-popover-heading svg { width: 13px; height: 13px; }
.token-input { display: flex; height: 34px; align-items: center; gap: 7px; padding-left: 9px; border: 1px solid var(--line); border-radius: 4px; }
.token-input:focus-within { border-color: #7eaaa1; }
.token-input > svg { width: 12px; height: 12px; color: var(--muted); }
.token-input input { min-width: 0; flex: 1; border: 0; outline: 0; color: var(--text); background: transparent; font-size: 11px; box-shadow: none; }
.token-input button { display: inline-grid; width: 32px; height: 32px; place-items: center; border: 0; color: #fff; background: var(--green); }
.token-input button svg { width: 13px; height: 13px; }

.modal-backdrop { position: fixed; inset: 0; z-index: 15; display: grid; place-items: center; padding: 18px; background: rgba(25, 35, 40, .42); }
.confirm-modal { width: min(360px, 100%); padding: 20px; border-radius: 6px; background: var(--surface); box-shadow: 0 18px 45px rgba(20, 30, 35, .22); }
.modal-icon { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 50%; color: var(--red); background: var(--red-soft); }
.modal-icon svg { width: 15px; height: 15px; }
.confirm-modal h2 { margin: 13px 0 10px; font-size: 16px; font-weight: 650; }
.confirm-modal code { display: block; overflow: hidden; padding: 9px; border: 1px solid var(--line); border-radius: 4px; background: #fafbfb; text-overflow: ellipsis; white-space: nowrap; }
.confirm-modal p { margin: 10px 0 18px; color: var(--red); font-size: 11px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.danger-solid-button { height: 32px; padding: 0 11px; border: 1px solid var(--red); color: #fff; background: var(--red); }
.danger-solid-button:hover:not(:disabled) { background: #ad3939; }
.spinning { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .create-form { grid-template-columns: 96px minmax(120px, 1fr) minmax(120px, 1fr) auto auto; }
  .workspace-grid { grid-template-columns: 1fr; }
  .create-panel, .activity-panel { min-height: auto; }
  .activity-panel { min-height: 170px; }
  .table-heading { align-items: flex-start; flex-direction: column; }
  .table-actions { width: 100%; flex-wrap: wrap; }
  .search-box { flex: 1 1 220px; }
}

@media (max-width: 640px) {
  .main-shell { padding: 0 12px 18px; }
  .page-header { min-height: 58px; }
  .page-title h1 { font-size: 17px; }
  .page-title > div > span, .backend-state, .service-state { display: none; }
  .toolbar-button span { display: none; }
  .toolbar-button { width: 30px; padding: 0; }
  .summary { margin-top: 12px; }
  .summary-item { min-height: 52px; padding: 0 12px; }
  .summary-item strong { font-size: 17px; }
  .create-form { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; }
  .field-count, .field-software, .field-days { min-width: 0; }
  .switch-field { height: 34px; }
  .create-form .primary-button { width: 100%; }
  .create-panel, .activity-panel { padding: 15px; }
  .table-heading { min-height: auto; padding: 15px; }
  .search-box { width: 100%; flex-basis: 100%; }
  .filter-input { min-width: 0; flex: 1; }
  .table-actions select { min-width: 0; flex: 1; }
  th:first-child, td:first-child { padding-left: 15px; }
  th:last-child, td:last-child { padding-right: 15px; }
  .table-footer { padding-right: 15px; padding-left: 15px; }
  .token-popover { top: 52px; right: 12px; left: 12px; width: auto; }
  .toast { top: 10px; width: calc(100vw - 24px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
