:root {
  color-scheme: light;
  --canvas: #f4f6f8;
  --surface: #ffffff;
  --surface-muted: #f8fafb;
  --ink: #17212b;
  --muted: #65717d;
  --line: #dce2e7;
  --line-strong: #c8d0d8;
  --primary: #087e74;
  --primary-hover: #066a62;
  --primary-soft: #e5f5f2;
  --blue: #2563a7;
  --blue-soft: #eaf2fb;
  --amber: #a25b09;
  --amber-soft: #fff4dc;
  --danger: #b42318;
  --danger-soft: #ffebe9;
  --shadow: 0 12px 32px rgba(23, 33, 43, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body { margin: 0; color: var(--ink); background: var(--canvas); font-size: 14px; }
button, input, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }
[hidden] { display: none !important; }

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #edf1f4;
  border-top: 4px solid var(--primary);
}

.auth-panel {
  width: min(100%, 420px);
  padding: 34px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-brand, .brand { display: flex; align-items: center; gap: 12px; }
.auth-brand { padding-bottom: 28px; border-bottom: 1px solid var(--line); }
.auth-brand img, .brand img { display: block; }
.auth-brand p { margin: 0 0 2px; font-size: 16px; font-weight: 750; }
.auth-brand span { color: var(--muted); font-size: 12px; }
.auth-copy { margin: 30px 0 24px; }
.eyebrow { margin: 0 0 7px; color: var(--primary); font-size: 11px; font-weight: 750; text-transform: uppercase; }
.auth-copy h1, .page-heading h1 { margin: 0; letter-spacing: 0; }
.auth-copy h1 { font-size: 24px; line-height: 1.25; }
.auth-copy > p:last-child { margin: 9px 0 0; color: var(--muted); line-height: 1.6; }
.auth-form { display: grid; gap: 10px; }
.auth-form > label, .verify-form > label { font-weight: 650; }
.password-field { position: relative; }
.password-field input { width: 100%; padding-right: 64px; }
.icon-button { position: absolute; inset: 4px 4px 4px auto; width: 54px; border: 0; color: var(--primary); background: transparent; font-size: 12px; font-weight: 700; }
.auth-footnote { margin: 20px 0 0; color: var(--muted); text-align: center; font-size: 12px; }

input, textarea {
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--ink);
  background: var(--surface);
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
input { height: 42px; padding: 0 12px; }
textarea { padding: 12px; line-height: 1.55; resize: vertical; }
input::placeholder, textarea::placeholder { color: #929da7; }
input:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(8, 126, 116, 0.12); }

.button {
  min-height: 38px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  font-weight: 680;
}
.button-primary { color: #fff; background: var(--primary); border-color: var(--primary); }
.button-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.button-secondary { color: var(--ink); background: var(--surface); border-color: var(--line-strong); }
.button-secondary:hover, .button-quiet:hover { background: var(--surface-muted); border-color: var(--line-strong); }
.button-quiet { color: var(--muted); background: transparent; border-color: transparent; }
.button-block { width: 100%; margin-top: 6px; }
.text-button { padding: 0; border: 0; color: var(--primary); background: transparent; font-size: 12px; font-weight: 680; }

.app-header { height: 64px; border-bottom: 1px solid var(--line); background: var(--surface); }
.header-inner, .tabs-inner, .main-content { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }
.header-inner { height: 100%; display: flex; align-items: center; justify-content: space-between; }
.brand { color: inherit; text-decoration: none; }
.brand > span { display: grid; gap: 1px; }
.brand strong { font-size: 15px; }
.brand small { color: var(--muted); font-size: 11px; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.service-status { display: inline-flex; align-items: center; gap: 7px; color: #37645f; font-size: 12px; font-weight: 650; }
.service-status i { width: 7px; height: 7px; border-radius: 50%; background: #1e9b64; box-shadow: 0 0 0 3px #def2e8; }

.tabs { height: 48px; background: var(--surface); border-bottom: 1px solid var(--line); }
.tabs-inner { height: 100%; display: flex; gap: 26px; }
.tab { position: relative; padding: 0 2px; border: 0; color: var(--muted); background: transparent; font-weight: 650; }
.tab::after { content: ""; position: absolute; right: 0; bottom: -1px; left: 0; height: 2px; background: transparent; }
.tab.is-active { color: var(--ink); }
.tab.is-active::after { background: var(--primary); }

.main-content { padding: 30px 0 52px; }
.page-heading { min-height: 68px; margin-bottom: 22px; display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.page-heading h1 { font-size: 26px; line-height: 1.2; }
.page-heading > div > p:last-child { margin: 8px 0 0; color: var(--muted); }

.key-strip {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 2fr;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}
.key-strip > div { min-width: 0; padding: 15px 18px; border-right: 1px solid var(--line); }
.key-strip > div:last-child { border-right: 0; }
.key-strip span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 11px; }
.key-strip strong { display: block; overflow: hidden; text-overflow: ellipsis; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; white-space: nowrap; }

.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.85fr); gap: 18px; align-items: start; }
.tool-panel { border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.panel-heading { min-height: 58px; padding: 0 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.panel-heading > div { display: flex; align-items: center; gap: 10px; min-width: 0; }
.panel-heading h2 { margin: 0; font-size: 15px; }
.panel-heading p { margin: 0; color: var(--muted); font-size: 11px; }
.step-marker { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 5px; color: var(--primary); background: var(--primary-soft); font-size: 10px; font-weight: 800; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 16px; padding: 22px 20px; }
.field { min-width: 0; padding: 0; border: 0; margin: 0; }
.field-span-2 { grid-column: 1 / -1; }
.field label, .field legend { font-size: 12px; font-weight: 680; }
.field legend { margin-bottom: 9px; }
.field > input { width: 100%; }
.label-row { min-height: 19px; margin-bottom: 7px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.label-row > span { color: var(--muted); font-size: 11px; }

.segmented-control { width: min(100%, 320px); height: 40px; padding: 3px; display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-muted); }
.segmented-control input, .duration-options input, .feature-options input { position: absolute; opacity: 0; pointer-events: none; }
.segmented-control label { min-width: 0; cursor: pointer; }
.segmented-control span { height: 32px; display: grid; place-items: center; border-radius: 4px; color: var(--muted); font-size: 12px; }
.segmented-control input:checked + span { color: var(--ink); background: var(--surface); box-shadow: 0 1px 3px rgba(23, 33, 43, 0.12); }
.segmented-control input:focus-visible + span, .duration-options input:focus-visible + span, .feature-options input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

.duration-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.duration-options label { min-width: 0; cursor: pointer; }
.duration-options span { min-height: 38px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); background: var(--surface); font-size: 12px; }
.duration-options input:checked + span { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.inline-number { position: relative; width: 160px; margin-top: 10px; }
.inline-number input { width: 100%; padding-right: 42px; }
.inline-number span { position: absolute; top: 0; right: 13px; height: 42px; display: flex; align-items: center; color: var(--muted); }

.feature-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.feature-options label { position: relative; min-width: 0; cursor: pointer; }
.feature-options label > span { min-height: 64px; padding: 12px 12px 12px 42px; display: flex; flex-direction: column; justify-content: center; border: 1px solid var(--line); border-radius: 6px; }
.feature-options label > span::before { content: ""; position: absolute; top: 22px; left: 14px; width: 16px; height: 16px; border: 1px solid var(--line-strong); border-radius: 4px; background: #fff; }
.feature-options label > span::after { content: ""; position: absolute; top: 25px; left: 18px; width: 8px; height: 5px; border: solid transparent; border-width: 0 0 2px 2px; transform: rotate(-45deg); }
.feature-options input:checked + span { border-color: #7ac3bb; background: #f3fbf9; }
.feature-options input:checked + span::before { border-color: var(--primary); background: var(--primary); }
.feature-options input:checked + span::after { border-color: #fff; }
.feature-options strong { font-size: 12px; }
.feature-options small { margin-top: 4px; color: var(--muted); font-size: 11px; }

.form-actions { min-height: 54px; margin: 2px -20px -22px; padding: 12px 20px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 14px; background: var(--surface-muted); border-radius: 0 0 7px 7px; }
.form-actions > span { color: var(--muted); font-size: 11px; }
.form-error { margin: 0; padding: 9px 11px; border-radius: 6px; color: var(--danger); background: var(--danger-soft); font-size: 12px; }

.result-panel { min-height: 460px; }
.empty-state { min-height: 400px; padding: 30px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); text-align: center; }
.empty-state.compact { min-height: 330px; }
.empty-state strong { margin-top: 16px; color: var(--ink); font-size: 14px; }
.empty-state p { margin: 7px 0 0; font-size: 12px; }
.document-glyph { width: 58px; height: 70px; padding-top: 24px; border: 2px solid #b9c5cc; border-radius: 6px; display: grid; align-content: start; gap: 7px; }
.document-glyph span { width: 28px; height: 2px; margin: 0 auto; background: #cbd4d9; }
.result-content { padding: 18px; }
.success-banner { min-height: 54px; padding: 10px 12px; display: flex; align-items: center; gap: 10px; border: 1px solid #b9ded0; border-radius: 6px; background: #effaf5; }
.success-banner > span { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: #16895c; font-weight: 800; }
.success-banner > div { display: grid; gap: 2px; }
.success-banner strong { color: #176345; font-size: 12px; }
.success-banner small { color: #4f7868; font-size: 10px; }
.result-summary { margin: 16px 0; }
.result-summary > div { min-height: 36px; display: grid; grid-template-columns: 105px minmax(0, 1fr); align-items: center; border-bottom: 1px solid #edf0f2; }
.result-summary dt { color: var(--muted); font-size: 11px; }
.result-summary dd { margin: 0; overflow: hidden; text-overflow: ellipsis; text-align: right; font-size: 11px; font-weight: 650; white-space: nowrap; }
.token-label { display: block; margin-bottom: 7px; font-size: 11px; font-weight: 680; }
.token-output { width: 100%; height: 112px; color: #34414c; background: var(--surface-muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; word-break: break-all; }
.result-actions { margin-top: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.recent-section { margin-top: 28px; }
.section-heading { margin-bottom: 12px; display: flex; align-items: flex-end; justify-content: space-between; }
.section-heading h2 { margin: 0; font-size: 17px; }
.section-heading p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.table-wrap { position: relative; overflow-x: auto; min-height: 110px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; }
th, td { height: 46px; padding: 0 14px; border-bottom: 1px solid #edf0f2; text-align: left; white-space: nowrap; font-size: 11px; }
th { height: 38px; color: var(--muted); background: var(--surface-muted); font-weight: 650; }
tbody tr:last-child td { border-bottom: 0; }
td:first-child { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: #33404b; }
.status-pill { display: inline-flex; height: 24px; padding: 0 9px; align-items: center; border-radius: 12px; font-size: 10px; font-weight: 700; }
.status-active { color: #166746; background: #e8f7ef; }
.status-expired { color: var(--amber); background: var(--amber-soft); }
.table-empty { position: absolute; inset: 38px 0 0; display: grid; place-items: center; color: var(--muted); font-size: 12px; }

.verify-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.verify-form { padding: 22px 20px; }
.verify-form textarea { width: 100%; min-height: 260px; margin: 8px 0 14px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; word-break: break-all; }
.verify-form .form-actions { margin: 0 -20px -22px; }
.verification-result { min-height: 390px; }
#verify-content { padding: 20px; }
.verdict { min-height: 58px; padding: 12px 14px; display: flex; align-items: center; border-radius: 6px; font-size: 14px; font-weight: 750; }
.verdict.is-valid { color: #166746; background: #e8f7ef; border: 1px solid #b8dfca; }
.verdict.is-invalid { color: var(--danger); background: var(--danger-soft); border: 1px solid #f3c5c0; }
.check-list { margin: 15px 0 20px; border-top: 1px solid var(--line); }
.check-list > div { min-height: 42px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.check-list span { color: var(--muted); font-size: 11px; }
.check-list strong { font-size: 11px; }
.check-ok { color: #16704b; }
.check-bad { color: var(--danger); }
.verification-result h3 { margin: 0 0 8px; font-size: 12px; }
.verification-result pre { max-height: 260px; margin: 0; padding: 14px; overflow: auto; border-radius: 6px; color: #34414c; background: #f1f4f6; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }

.toast { position: fixed; right: 20px; bottom: 20px; z-index: 20; max-width: min(360px, calc(100% - 40px)); padding: 11px 14px; border-radius: 6px; color: #fff; background: #24313b; box-shadow: var(--shadow); font-size: 12px; }

@media (max-width: 900px) {
  .key-strip { grid-template-columns: repeat(2, 1fr); }
  .key-strip > div:nth-child(2) { border-right: 0; }
  .key-strip > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .workspace-grid, .verify-grid { grid-template-columns: 1fr; }
  .result-panel { min-height: 0; }
  .empty-state { min-height: 250px; }
}

@media (max-width: 620px) {
  .header-inner, .tabs-inner, .main-content { width: min(100% - 28px, 1180px); }
  .app-header { height: 58px; }
  .brand small, .service-status { display: none; }
  .header-actions { gap: 2px; }
  .tabs { height: 46px; }
  .tabs-inner { gap: 22px; }
  .main-content { padding-top: 22px; }
  .page-heading { align-items: flex-start; }
  .page-heading h1 { font-size: 23px; }
  .page-heading > .button { margin-top: 23px; }
  .key-strip { grid-template-columns: 1fr 1fr; }
  .key-strip > div { padding: 13px; }
  .key-strip > div:nth-child(3), .key-strip > div:nth-child(4) { grid-column: 1 / -1; border-right: 0; }
  .key-strip > div:nth-child(3) { border-bottom: 1px solid var(--line); }
  .form-grid { grid-template-columns: 1fr; }
  .duration-options { grid-template-columns: 1fr 1fr; }
  .feature-options { grid-template-columns: 1fr; }
  .panel-heading p { display: none; }
  .form-actions { align-items: stretch; flex-direction: column; }
  .form-actions > span { text-align: center; }
  .verify-form .form-actions { flex-direction: column-reverse; }
  .form-actions .button { width: 100%; }
  .auth-panel { padding: 26px 22px; }
}

@media (prefers-reduced-motion: no-preference) {
  .toast { animation: toast-in 180ms ease-out; }
  @keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
}
