:root {
    color-scheme: light;
    --ink: #17211e;
    --muted: #65716c;
    --line: #dce3df;
    --surface: #ffffff;
    --canvas: #f3f6f4;
    --sidebar: #16201d;
    --sidebar-muted: #96a39e;
    --accent: #16745d;
    --accent-hover: #0f604d;
    --accent-soft: #e7f3ef;
    --warning: #9c6417;
    --danger: #b64040;
    --shadow: 0 10px 30px rgba(24, 42, 36, 0.08);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    min-width: 320px;
    color: var(--ink);
    background: var(--canvas);
    font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    line-height: 1.5;
    letter-spacing: 0;
}

button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.app-shell { min-height: 100vh; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    display: flex;
    width: 248px;
    flex-direction: column;
    padding: 24px 16px;
    color: #f8fbf9;
    background: var(--sidebar);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 8px 28px;
}

.brand-mark {
    display: grid;
    width: 40px;
    height: 40px;
    place-items: center;
    color: #fff;
    background: var(--accent);
    border-radius: 8px;
}

.brand-mark svg { width: 22px; height: 22px; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 16px; }
.brand small { margin-top: 1px; color: var(--sidebar-muted); font-size: 12px; }

.sidebar-nav { display: grid; gap: 6px; }

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    padding: 0 12px;
    color: var(--sidebar-muted);
    border-radius: 6px;
    text-decoration: none;
    transition: color .18s ease, background .18s ease;
}

.sidebar-nav a:hover { color: #fff; background: rgba(255,255,255,.06); }
.sidebar-nav a.active { color: #fff; background: #26332f; }
.sidebar-nav svg { width: 18px; height: 18px; }

.sidebar-footer {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 2px 9px;
    margin-top: auto;
    padding: 14px 12px 0;
    color: #dce5e1;
    border-top: 1px solid rgba(255,255,255,.09);
    font-size: 13px;
}

.sidebar-footer small { grid-column: 2; color: var(--sidebar-muted); }
.status-dot { width: 8px; height: 8px; background: #4fc79f; border-radius: 50%; box-shadow: 0 0 0 3px rgba(79,199,159,.13); }

.main-area { min-height: 100vh; margin-left: 248px; }

.topbar {
    display: flex;
    min-height: 86px;
    align-items: center;
    gap: 14px;
    padding: 16px clamp(24px, 4vw, 56px);
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.eyebrow, .section-kicker { margin: 0 0 2px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.topbar h1 { margin: 0; font-size: 22px; line-height: 1.25; letter-spacing: 0; }
.topbar-meta { display: flex; align-items: center; gap: 16px; margin-left: auto; }
.status-badge { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; color: #155e4b; background: var(--accent-soft); border-radius: 999px; font-size: 12px; font-weight: 700; }
.updated-at { color: var(--muted); font-size: 12px; }
.mobile-menu { display: none; }

main { width: min(1240px, calc(100% - 48px)); margin: 0 auto; padding: 32px 0 48px; }

.summary-strip {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr;
    margin-bottom: 24px;
    padding: 20px 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.summary-strip > div { min-width: 0; padding: 0 24px; }
.summary-strip > div + div { border-left: 1px solid var(--line); }
.summary-strip span, .summary-strip strong { display: block; }
.summary-strip span { margin-bottom: 4px; color: var(--muted); font-size: 12px; }
.summary-strip strong { overflow: hidden; font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }

.notice { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 20px; padding: 12px 14px; border: 1px solid; border-radius: 6px; }
.notice svg { flex: 0 0 auto; width: 18px; height: 18px; margin-top: 1px; }
.notice p { margin: 0; }
.notice.success { color: #155e4b; background: #eff8f5; border-color: #b9ddd1; }
.notice.error { color: #8f3030; background: #fff3f3; border-color: #efc4c4; }

.workspace { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(320px, .75fr); gap: 24px; align-items: stretch; }
.config-panel, .preview-panel, .api-section { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.config-panel { padding: 28px; }
.preview-panel { display: flex; flex-direction: column; padding: 24px; }

.section-heading, .preview-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 28px; }
.section-heading h2, .preview-heading h2, .api-section h2 { margin: 0; font-size: 18px; line-height: 1.35; letter-spacing: 0; }
.saved-state, .live-indicator { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.saved-state svg { width: 15px; height: 15px; }
.live-indicator span { width: 7px; height: 7px; background: #43b892; border-radius: 50%; }

.field-group { margin-bottom: 24px; }
.field-group label { display: block; margin-bottom: 8px; font-weight: 700; }
.field-group small { display: block; margin-top: 7px; color: var(--muted); font-size: 12px; }
.label-row { display: flex; justify-content: space-between; gap: 16px; }
.label-row span { color: var(--muted); font-size: 12px; }
.input-with-icon { position: relative; }
.input-with-icon svg { position: absolute; top: 50%; left: 13px; width: 18px; height: 18px; color: #7c8984; transform: translateY(-50%); pointer-events: none; }

input, textarea {
    width: 100%;
    color: var(--ink);
    background: #fbfcfb;
    border: 1px solid #cbd5d0;
    border-radius: 6px;
    outline: none;
    transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

input { height: 44px; padding: 0 13px; }
.input-with-icon input { padding-left: 42px; }
textarea { min-height: 164px; padding: 12px 13px; line-height: 1.65; resize: vertical; }
input:focus, textarea:focus { background: #fff; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(22,116,93,.11); }

.form-actions { display: flex; gap: 10px; padding-top: 2px; }
.primary-button, .secondary-button, .download-button {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 16px;
    border-radius: 6px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: background .18s ease, border-color .18s ease, transform .18s ease;
}
.primary-button { color: #fff; background: var(--accent); border: 1px solid var(--accent); }
.primary-button:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.secondary-button { color: var(--ink); background: #fff; border: 1px solid #cbd5d0; }
.secondary-button:hover { background: #f5f7f6; border-color: #aebbb5; }
.danger-button { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; gap: 8px; padding: 0 15px; color: var(--danger); background: #fff; border: 1px solid #dc8e8e; border-radius: 6px; font-weight: 700; cursor: pointer; }
.danger-button:hover { color: #fff; background: var(--danger); border-color: var(--danger); }
.danger-button.solid { color: #fff; background: var(--danger); border-color: var(--danger); }
.danger-button.solid:hover { background: #963333; border-color: #963333; }
.danger-button:disabled { color: #9aa49f; background: #f2f4f3; border-color: #d8dfdb; cursor: not-allowed; }
.danger-button svg { width: 17px; height: 17px; }
.primary-button:active, .secondary-button:active, .download-button:active, .danger-button:active { transform: translateY(1px); }
.primary-button svg, .secondary-button svg, .download-button svg { width: 17px; height: 17px; }

.qr-stage { display: grid; aspect-ratio: 1; place-items: center; padding: 20px; background: #edf2ef; border-radius: 8px; }
.qr-stage img { display: block; width: 100%; max-width: 300px; height: auto; aspect-ratio: 1; background: #fff; box-shadow: var(--shadow); }
.preview-content { margin: 18px 0; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.preview-content span { color: var(--muted); font-size: 12px; }
.preview-content p { display: -webkit-box; overflow: hidden; margin: 5px 0 0; overflow-wrap: anywhere; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.download-button { width: 100%; margin-top: auto; color: var(--ink); background: #fff; border: 1px solid #cbd5d0; }
.download-button:hover { background: #f5f7f6; border-color: #aebbb5; }

.api-section { margin-top: 24px; padding: 28px; }
.api-title { margin-bottom: 18px; }
.method-badge { padding: 5px 9px; color: #155e4b; background: var(--accent-soft); border-radius: 4px; font-family: Consolas, monospace; font-size: 12px; font-weight: 700; }
.endpoint-stack { display: grid; gap: 8px; }
.endpoint-row { display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 14px; background: #17211e; border-radius: 6px; }
.endpoint-row > span { flex: 0 0 auto; color: #91a59d; font-size: 11px; font-weight: 700; }
.endpoint-row code { min-width: 0; flex: 1; overflow: hidden; color: #ecf5f1; text-overflow: ellipsis; white-space: nowrap; }
.icon-button { display: inline-grid; width: 36px; height: 36px; flex: 0 0 auto; place-items: center; padding: 0; color: var(--ink); background: transparent; border: 0; border-radius: 5px; cursor: pointer; }
.icon-button:hover { background: rgba(22,116,93,.09); }
.icon-button svg { width: 18px; height: 18px; }
.endpoint-row .icon-button { color: #fff; }
.endpoint-row .icon-button:hover { background: rgba(255,255,255,.1); }
.api-grid { display: grid; grid-template-columns: 1.25fr .75fr; gap: 28px; margin-top: 26px; }
.api-grid h3 { margin: 0 0 12px; font-size: 14px; }
.parameter-table { border-top: 1px solid var(--line); }
.parameter-row { display: grid; grid-template-columns: 88px 1fr 44px; gap: 12px; align-items: center; min-height: 46px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.parameter-row code { color: var(--accent); font-weight: 700; }
.table-head { min-height: 34px; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.code-heading { display: flex; align-items: center; justify-content: space-between; }
pre { min-height: 130px; margin: 0; padding: 16px; overflow: auto; color: #dbe9e3; background: #17211e; border-radius: 6px; font-family: Consolas, "SFMono-Regular", monospace; font-size: 12px; line-height: 1.7; }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 50; padding: 10px 14px; color: #fff; background: #17211e; border-radius: 6px; box-shadow: var(--shadow); opacity: 0; transform: translateY(10px); pointer-events: none; transition: opacity .2s ease, transform .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.sidebar-backdrop { display: none; }

.success-text { color: var(--accent); }

.list-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
}

.list-toolbar h2, .list-api-bar h2 { margin: 0; font-size: 18px; letter-spacing: 0; }
.toolbar-actions { display: flex; align-items: center; gap: 10px; }

.filter-row {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    padding-bottom: 1px;
    border-bottom: 1px solid var(--line);
}

.filter-row a {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 38px;
    padding: 0 12px;
    color: var(--muted);
    border-bottom: 2px solid transparent;
    text-decoration: none;
    font-weight: 700;
}

.filter-row a:hover { color: var(--ink); }
.filter-row a.active { color: var(--accent); border-bottom-color: var(--accent); }
.filter-row a span { padding: 1px 6px; color: var(--muted); background: #e8ecea; border-radius: 999px; font-size: 11px; }

.qr-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.qr-card {
    min-width: 0;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.qr-card.is-used { background: #f9faf9; }
.qr-card-head { display: flex; align-items: center; justify-content: space-between; padding: 13px 14px; border-bottom: 1px solid var(--line); }
.qr-card-head strong { font-size: 13px; }
.record-status { padding: 3px 7px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.record-status.unused { color: #155e4b; background: var(--accent-soft); }
.record-status.used { color: #7a5143; background: #f1e9e5; }
.qr-card-image { aspect-ratio: 1; padding: 16px; background: #edf2ef; }
.qr-card-image img { display: block; width: 100%; height: 100%; object-fit: contain; background: #fff; }

.used-state {
    display: grid;
    aspect-ratio: 1;
    place-items: center;
    align-content: center;
    gap: 10px;
    color: #8a9691;
    background: #eef1ef;
    font-weight: 700;
}

.used-state svg { width: 34px; height: 34px; }
.qr-card-body { padding: 14px; }
.qr-card-body > code { display: block; overflow: hidden; color: var(--accent); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.qr-card-body dl { display: grid; gap: 7px; margin: 13px 0 0; }
.qr-card-body dl div { display: flex; justify-content: space-between; gap: 10px; font-size: 11px; }
.qr-card-body dt { color: var(--muted); }
.qr-card-body dd { margin: 0; text-align: right; }

.qr-card-actions { display: flex; min-height: 52px; align-items: center; gap: 8px; padding: 9px 14px; border-top: 1px solid var(--line); }
.compact-button { min-height: 34px; padding: 0 11px; font-size: 12px; }
.qr-card-actions .icon-button { border: 1px solid #cbd5d0; }
.card-action-status { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; padding: 4px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.card-action-status > span { width: 6px; height: 6px; border-radius: 50%; }
.card-action-status.unused { color: #155e4b; background: var(--accent-soft); }
.card-action-status.unused > span { background: #35a980; }
.card-action-status.used { color: #7a5143; background: #f1e9e5; }
.card-action-status.used > span { background: #9c6856; }
.expired-label { display: inline-flex; align-items: center; gap: 7px; margin-left: auto; color: var(--muted); font-size: 12px; }
.expired-label svg { width: 15px; height: 15px; }

.empty-state {
    display: grid;
    min-height: 320px;
    place-items: center;
    align-content: center;
    padding: 40px;
    text-align: center;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.empty-state > span { display: grid; width: 58px; height: 58px; margin-bottom: 16px; place-items: center; color: var(--accent); background: var(--accent-soft); border-radius: 8px; }
.empty-state svg { width: 28px; height: 28px; }
.empty-state h2 { margin: 0; font-size: 17px; }
.empty-state p { margin: 6px 0 0; color: var(--muted); }

.pagination { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 24px; }
.pagination a { display: grid; width: 36px; height: 36px; place-items: center; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 5px; }
.pagination a:hover { border-color: #aebbb5; }
.pagination a.disabled { opacity: .4; pointer-events: none; }
.pagination svg { width: 17px; height: 17px; }
.pagination span { color: var(--muted); font-size: 12px; }

.list-api-bar {
    display: grid;
    grid-template-columns: minmax(170px, .45fr) minmax(0, 1.55fr);
    align-items: center;
    gap: 24px;
    margin-top: 24px;
    padding: 22px 24px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.list-api-bar .endpoint-row { min-width: 0; }

.confirm-dialog {
    width: min(calc(100% - 32px), 430px);
    padding: 0;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 24px 70px rgba(10, 24, 19, .22);
}

.confirm-dialog::backdrop { background: rgba(10, 22, 18, .52); }
.confirm-dialog form { padding: 28px; }
.dialog-icon { display: grid; width: 44px; height: 44px; margin-bottom: 18px; place-items: center; color: var(--danger); background: #fff0f0; border-radius: 8px; }
.dialog-icon svg { width: 23px; height: 23px; }
.confirm-dialog h2 { margin: 0; font-size: 19px; letter-spacing: 0; }
.confirm-dialog p { margin: 9px 0 24px; color: var(--muted); line-height: 1.7; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }

@media (max-width: 1040px) {
    .workspace { grid-template-columns: 1fr; }
    .preview-panel { display: grid; grid-template-columns: minmax(220px, .7fr) 1fr; gap: 0 24px; }
    .preview-heading { grid-column: 1 / -1; }
    .qr-stage { grid-row: 2 / 5; }
    .download-button { align-self: end; }
    .api-grid { grid-template-columns: 1fr; }
    .qr-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
    .sidebar.open { transform: translateX(0); }
    .sidebar-backdrop { position: fixed; inset: 0; z-index: 20; display: block; background: rgba(8,18,14,.42); opacity: 0; pointer-events: none; transition: opacity .2s ease; }
    .sidebar-backdrop.show { opacity: 1; pointer-events: auto; }
    .main-area { margin-left: 0; }
    .mobile-menu { display: inline-grid; }
    .updated-at { display: none; }
    main { width: min(100% - 28px, 680px); padding-top: 20px; }
    .topbar { min-height: 74px; padding: 12px 14px; }
    .topbar h1 { font-size: 19px; }
    .summary-strip { grid-template-columns: 1fr; padding: 0; }
    .summary-strip > div { padding: 15px 18px; }
    .summary-strip > div + div { border-top: 1px solid var(--line); border-left: 0; }
    .config-panel, .preview-panel, .api-section { padding: 20px; }
    .preview-panel { display: flex; }
    .qr-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .list-api-bar { grid-template-columns: 1fr; gap: 14px; }
}

@media (max-width: 480px) {
    .status-badge { padding: 5px 8px; }
    .status-badge .status-dot { display: none; }
    .section-heading { align-items: center; }
    .saved-state { display: none; }
    .form-actions { flex-direction: column; }
    .form-actions button { width: 100%; }
    .parameter-row { grid-template-columns: 64px 1fr 36px; gap: 8px; font-size: 12px; }
    .endpoint-row code { font-size: 11px; }
    .list-toolbar { align-items: flex-end; }
    .list-toolbar .primary-button span { display: none; }
    .list-toolbar .primary-button { width: 42px; padding: 0; }
    .list-toolbar .danger-button { min-width: 42px; padding: 0 10px; }
    .list-toolbar .danger-button span { display: none; }
    .qr-grid { grid-template-columns: 1fr; }
    .filter-row { overflow-x: auto; }
}

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