:root {
    --bg: #f4efe6;
    --panel: rgba(255, 252, 247, 0.96);
    --panel-strong: #fffaf2;
    --ink: #1c1815;
    --muted: #6d6258;
    --line: rgba(78, 57, 39, 0.12);
    --accent: #b6522f;
    --accent-dark: #7c3219;
    --success: #2f7b4b;
    --error: #a63131;
    --shadow: 0 14px 36px rgba(85, 56, 28, 0.12);
    --radius-lg: 20px;
    --radius-md: 16px;
    --radius-sm: 12px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(255, 210, 168, 0.75), transparent 26%),
        linear-gradient(180deg, #f9f1e7 0%, #f1e8db 100%);
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

.page-shell {
    width: min(920px, calc(100% - 18px));
    margin: 0 auto;
    padding: 10px 0 28px;
}

.topbar {
    display: flex;
    justify-content: center;
    padding: 2px 0 10px;
}

.topnav {
    width: min(100%, 540px);
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.topnav a,
.button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-height: 42px;
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--panel-strong);
    color: var(--ink);
    cursor: pointer;
    text-align: center;
    transition: transform 0.18s ease, background 0.18s ease;
}

.topnav a:hover,
.button:hover {
    transform: translateY(-1px);
}

.content {
    display: grid;
    gap: 14px;
}

.panel {
    background: var(--panel);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.52);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 16px;
}

.compact-panel {
    padding: 14px 16px;
}

.narrow-panel {
    max-width: 440px;
    margin: 40px auto 0;
}

.section-head {
    margin-bottom: 12px;
}

.section-head h2,
.section-head h3,
.detail-head h2 {
    margin: 0 0 6px;
}

.section-head p,
.subtle,
.tool-state,
.summary-count,
.summary-primary small,
.tree-product span,
.meta,
.help-text {
    color: var(--muted);
}

.meta {
    margin: 0 0 6px;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.quick-actions,
.submit-row,
.detail-head,
.timeline-head,
.history-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.button.primary {
    background: linear-gradient(135deg, var(--accent) 0%, #de7b48 100%);
    color: #fff;
    border-color: transparent;
}

.button.secondary {
    background: #f7e3d1;
}

.button.ghost {
    background: transparent;
}

.button.danger,
.danger {
    background: rgba(166, 49, 49, 0.12);
    color: var(--error);
    border-color: rgba(166, 49, 49, 0.26);
}

.small-button {
    min-height: 34px;
    padding: 8px 12px;
}

.field,
.form-stack,
.card-list,
.accordion-list,
.timeline,
.mini-tools {
    display: grid;
    gap: 10px;
}

.field label {
    font-weight: 600;
}

input,
select {
    width: 100%;
    min-height: 44px;
    border-radius: 14px;
    border: 1px solid var(--line);
    padding: 10px 12px;
    background: #fff;
    font: inherit;
}

.form-divider {
    position: relative;
    text-align: center;
    color: var(--muted);
    padding: 8px 0;
}

.form-divider::before {
    content: "";
    position: absolute;
    inset: 50% 0 auto;
    border-top: 1px solid var(--line);
}

.form-divider span {
    position: relative;
    background: var(--panel);
    padding: 0 10px;
}

.segmented {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.segmented-btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-height: 42px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: #fff;
    cursor: pointer;
    font: inherit;
    text-align: center;
}

.segmented-btn.active {
    background: linear-gradient(135deg, var(--accent) 0%, #de7b48 100%);
    color: #fff;
    border-color: transparent;
}

.mini-segmented {
    max-width: 220px;
}

.mini-tools {
    justify-items: start;
}

.mini-tools .segmented {
    width: 100%;
}

.mini-tools .segmented-btn {
    position: relative;
    overflow: hidden;
}

.mini-tools label.segmented-btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
}

.tool-state,
.scan-result {
    text-align: center;
}

.mini-tool-btn.unsupported {
    background: rgba(166, 49, 49, 0.12);
    color: var(--error);
    border-color: rgba(166, 49, 49, 0.26);
}

.mini-tool-btn.fallback-scan {
    background: rgba(182, 82, 47, 0.10);
    color: var(--accent-dark);
    border-color: rgba(182, 82, 47, 0.24);
}

.unsupported-text {
    color: var(--error);
}

.scan-video {
    width: 100%;
    max-height: 150px;
    border-radius: 16px;
    background: #000;
    object-fit: cover;
}

.scan-reader {
    width: 100%;
    max-width: 320px;
    border-radius: 16px;
    overflow: hidden;
    margin: 0 auto;
}

.scan-reader video {
    border-radius: 16px;
}

.hidden {
    display: none;
}

.scan-result,
.empty-state {
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(246, 233, 220, 0.8);
    color: var(--muted);
}

.list-card,
.detail-card,
.timeline-card,
.accordion-item,
.chip {
    background: var(--panel-strong);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
}

.list-card {
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
}

.detail-grid,
.chip-grid {
    display: grid;
    gap: 10px;
}

.detail-grid {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.detail-card,
.timeline-card {
    padding: 14px;
}

.detail-card span {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
}

.image-panel img,
.timeline-card img {
    width: 100%;
    max-width: 360px;
    display: block;
    margin-top: 10px;
    border-radius: 14px;
}

.accordion-item {
    overflow: hidden;
}

.accordion-item summary {
    cursor: pointer;
    list-style: none;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
}

.summary-primary {
    display: grid;
    gap: 4px;
}

.accordion-body {
    display: grid;
    gap: 8px;
    padding: 0 16px 16px;
}

.tree-product {
    display: grid;
    gap: 2px;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.02);
}

.chip-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.chip {
    padding: 12px 14px;
}

.strong-chip {
    display: grid;
    gap: 4px;
}

.strong-chip em {
    font-style: normal;
    color: var(--muted);
}

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

.align-right {
    text-align: right;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 14px;
}

.disabled {
    pointer-events: none;
    opacity: 0.45;
}

.flash-stack {
    display: grid;
    gap: 8px;
}

.flash {
    padding: 12px 14px;
    border-radius: 14px;
}

.flash-success {
    background: rgba(47, 123, 75, 0.14);
    color: var(--success);
}

.flash-error {
    background: rgba(166, 49, 49, 0.12);
    color: var(--error);
}

@media (max-width: 760px) {
    .topnav {
        grid-template-columns: repeat(4, 1fr);
    }

    .quick-actions,
    .submit-row,
    .detail-head,
    .list-card,
    .timeline-head,
    .history-actions,
    .pagination {
        flex-direction: column;
        align-items: stretch;
    }

    .align-right {
        text-align: left;
    }

    .mini-tools {
        justify-items: stretch;
    }
}
