:root {
  color-scheme: dark;
  --bg: #0a0910;
  --sidebar: #0d0b15;
  --surface: #151321;
  --surface-2: #1b1828;
  --line: #302a3e;
  --line-strong: #544165;
  --text: #f2f0f5;
  --muted: #9690a0;
  --accent: #b34ee9;
  --accent-bg: #2b1538;
  --green: #25d8aa;
  --cyan: #46c6e8;
  --red: #f06a8b;
  --radius: 8px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { min-height: 100vh; overflow-x: hidden; background: var(--bg); color: var(--text); font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif; letter-spacing: 0; }
button, input { font: inherit; letter-spacing: 0; }
button { min-height: 38px; border: 1px solid var(--line); border-radius: var(--radius); padding: 0 14px; color: var(--text); background: var(--surface-2); cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--line-strong); background: #242032; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { border-color: #75409a; background: #57266f; }
input { width: 100%; height: 42px; min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); padding: 0 13px; outline: none; color: var(--text); background: #11101a; }
input:focus { border-color: #765196; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 220px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; border-right: 1px solid #262130; background: var(--sidebar); }
.brand { min-height: 96px; display: grid; place-content: center; text-align: center; border-bottom: 1px solid #211c2b; }
.brand strong { font-size: 19px; }
.brand span { margin-top: 5px; color: var(--muted); font-size: 12px; }
.nav-current { height: 50px; display: flex; align-items: center; gap: 13px; margin: 20px 12px; border: 1px solid #663080; border-radius: var(--radius); padding: 0 16px; color: #f2dcfa; background: var(--accent-bg); }
.nav-mark { color: #cb70f3; font-size: 18px; }
.service-state { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 18px; border-top: 1px solid #211c2b; }
.service-state div { display: grid; gap: 3px; }
.service-state strong { font-size: 13px; }
.service-state span:last-child { color: var(--muted); font-size: 12px; }
.online-dot, .heading-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.online-dot { box-shadow: 0 0 11px rgba(37, 216, 170, .65); }

.workspace { min-width: 0; padding: 20px 24px 36px; }
.page-header { min-height: 98px; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 24px; padding: 16px 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.heading { display: flex; align-items: center; gap: 12px; }
.heading-dot { background: var(--accent); }
.heading h1 { margin: 0; font-size: 21px; }
.heading span:last-child { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; }
.header-actions, .metrics, .language-switch { display: flex; align-items: center; gap: 10px; }
.header-actions { min-width: 0; flex: 1; flex-wrap: wrap; justify-content: flex-end; }
.metrics { flex-wrap: wrap; }
.metric { min-width: 104px; padding: 10px 13px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); }
.metric strong { display: block; font-family: Consolas, monospace; font-size: 23px; }
.metric span { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.metric-link strong { color: var(--cyan); }
.metric-plus strong { color: var(--green); }
.metric-trial strong { color: #ffb86b; }
.metric-sync strong { color: #f0d166; }
.metric-success strong { color: var(--green); }
.metric-failure strong { color: var(--red); }
.language-switch { gap: 0; }
.language-switch button { min-width: 48px; border-radius: 0; }
.language-switch button:first-child { border-radius: 7px 0 0 7px; }
.language-switch button:last-child { margin-left: -1px; border-radius: 0 7px 7px 0; }
.language-switch button.active { position: relative; border-color: #75409a; color: #f3dfff; background: #57266f; }
.logout-button { white-space: nowrap; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 18px; }
.login-shell { width: min(420px, 100%); }
.login-panel { display: grid; gap: 18px; border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; background: var(--surface); }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.login-brand h1 { margin: 0; font-size: 21px; }
.login-brand span:last-child { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; }
.login-panel .field { margin: 0; }
.login-panel button { width: 100%; }
.login-error { border: 1px solid #7d2e49; border-radius: var(--radius); padding: 10px 12px; color: #ffadc1; background: #2b1720; font-size: 12px; }

.toolbar { display: flex; gap: 10px; margin-top: 16px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.scan-section { margin-top: 18px; }
.section-heading { min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); padding: 0 2px 10px; }
.section-heading h2 { margin: 0; font-size: 17px; }
.section-heading div > span { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
.section-heading-actions { display: flex; align-items: center; gap: 10px; }
.section-heading-actions .live-badge { margin: 0; }
.section-heading-actions button { min-height: 32px; padding: 0 12px; }
.live-badge { min-height: 30px; display: inline-flex; align-items: center; gap: 8px; color: var(--green); font-size: 12px; }
.live-badge .online-dot { width: 7px; height: 7px; }
.artifact-table-wrap { margin-top: 10px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.artifact-table { min-width: 1180px; table-layout: fixed; }
.artifact-table th:first-child { width: 154px; }
.artifact-table th:nth-child(2) { width: 19%; }
.artifact-table th:nth-child(3) { width: 13%; }
.artifact-table th:nth-child(4) { width: 31%; }
.artifact-table th:nth-child(5) { width: 10%; }
.artifact-table th:last-child { width: 15%; }
.artifact-qr-cell { height: 152px; padding: 10px; text-align: center; }
.artifact-qr { width: 132px; height: 132px; display: block; margin: 0 auto; border: 7px solid white; border-radius: 6px; background: white; object-fit: contain; }
.artifact-qr.expired { filter: grayscale(1); opacity: .28; }
.artifact-qr-state { width: 132px; height: 132px; display: grid; place-items: center; margin: 0 auto; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); background: var(--surface-2); }
.artifact-qr-state.succeeded { border-color: #1c705d; color: var(--green); background: #102a25; }
.artifact-qr-state.failed { border-color: #6c2a43; color: #ff8dad; background: #2b1720; }
.method-badge, .artifact-status { width: fit-content; display: block; border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; white-space: nowrap; }
.method-badge { color: var(--cyan); background: #11252c; }
.artifact-status { margin-top: 8px; color: var(--muted); font-size: 11px; }
.artifact-status.pending { border-color: #796624; color: #f0d166; background: #2a2512; }
.artifact-status.succeeded { border-color: #1c705d; color: var(--green); background: #102a25; }
.artifact-status.failed { border-color: #6c2a43; color: #ff8dad; background: #2b1720; }
.search-field { flex: 1; }
.table-wrap { margin-top: 14px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; min-width: 1280px; border-collapse: collapse; table-layout: fixed; }
th, td { padding: 14px 16px; border-bottom: 1px solid #292438; text-align: left; vertical-align: middle; }
th { color: #bbb5c3; background: #11101a; font-size: 12px; }
th:first-child { width: 20%; }
th:nth-child(2) { width: 10%; }
th:nth-child(3) { width: 9%; }
th:nth-child(4) { width: 12%; }
th:nth-child(5) { width: 27%; }
th:nth-child(6) { width: 9%; }
th:last-child { width: 13%; }
td { font-size: 13px; }
tbody tr:hover { background: #191625; }
tbody tr:last-child td { border-bottom: 0; }
.email-cell strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.email-cell span { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
.link-cell { min-width: 0; }
.link-cell a { display: block; overflow: hidden; color: var(--cyan); text-decoration: none; text-overflow: ellipsis; white-space: nowrap; }
.link-cell a:hover { text-decoration: underline; }
.link-meta { margin-top: 5px; color: var(--muted); font-size: 11px; }
.link-empty { color: var(--muted); }
.row-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.row-actions button, .row-actions a { min-height: 32px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 7px; padding: 0 10px; color: var(--text); background: var(--surface-2); font-size: 11px; text-decoration: none; }
.row-actions button.extract { border-color: #75409a; background: #57266f; }
.row-status { margin-top: 5px; color: var(--green); font-size: 11px; }
.plan-status { display: inline-flex; min-height: 26px; align-items: center; border: 1px solid var(--line); border-radius: 6px; padding: 0 8px; color: var(--muted); background: var(--surface-2); font-size: 11px; white-space: nowrap; }
.plan-status.plus { border-color: #1c705d; color: var(--green); background: #102a25; }
.plan-status.free { border-color: #536172; color: #bdc7d4; background: #1b2028; }
.plan-status.checking { border-color: #285b6a; color: var(--cyan); background: #11252c; }
.plan-status.token_expired, .plan-status.error { border-color: #6c2a43; color: #ff8dad; background: #2b1720; }
.countdown { min-width: 54px; display: inline-block; color: var(--green); font-family: Consolas, monospace; font-size: 12px; font-variant-numeric: tabular-nums; }
.countdown.expired { color: var(--red); }
.link-disabled { color: var(--muted) !important; cursor: not-allowed; opacity: .65; text-decoration: none !important; }
.empty-state { padding: 72px 20px; color: var(--muted); text-align: center; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 10; max-width: 380px; padding: 11px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius); color: var(--text); background: #211c2e; opacity: 0; transform: translateY(10px); pointer-events: none; transition: .18s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-color: #7d2e49; color: #ffadc1; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

@media (max-width: 900px) {
  .page-header { align-items: flex-start; flex-direction: column; }
  .header-actions { width: 100%; justify-content: space-between; }
}

@media (max-width: 680px) {
  .app-shell { width: 100%; max-width: 100vw; grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; width: 100%; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { min-height: 66px; place-content: center start; padding: 0 16px; text-align: left; }
  .nav-current { height: 42px; margin: 8px; }
  .service-state { display: none; }
  .workspace { max-width: 100%; overflow: hidden; padding: 12px; }
  .page-header { padding: 14px; }
  .header-actions { align-items: flex-end; flex-direction: column-reverse; }
  .metrics { width: 100%; }
  .metric { min-width: 0; flex: 1; }
  .toolbar { flex-wrap: wrap; }
  .search-field { flex-basis: 100%; }
  .table-wrap { max-width: 100%; }
}
