:root {
    --bg: #0b1220;
    --surface: #121c2d;
    --surface-muted: #172338;
    --line: #26354e;
    --text: #e7edf7;
    --muted: #9aa8bd;
    --primary: #6ea8ff;
    --primary-dark: #4f8cf0;
    --teal: #2dd4bf;
    --green: #47d18c;
    --amber: #f6c453;
    --red: #ff6b6b;
    --shadow: 0 18px 48px rgba(0, 0, 0, 0.32);
    color-scheme: dark;
}

:root[data-theme="light"] {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-muted: #f8fafc;
    --line: #d9e2ec;
    --text: #1f2937;
    --muted: #667085;
    --primary: #246bfe;
    --primary-dark: #1d4ed8;
    --teal: #0f766e;
    --green: #16803c;
    --amber: #a16207;
    --red: #b42318;
    --shadow: 0 16px 42px rgba(31, 41, 55, 0.1);
    color-scheme: light;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background:
        radial-gradient(circle at 18% -10%, rgba(110, 168, 255, 0.22), transparent 34%),
        linear-gradient(180deg, #0e1729 0, rgba(14, 23, 41, 0) 360px),
        var(--bg);
    font-family: "Microsoft JhengHei", "Noto Sans TC", "Segoe UI", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
}

:root[data-theme="light"] body {
    background:
        linear-gradient(180deg, #eef4ff 0, rgba(238, 244, 255, 0) 320px),
        var(--bg);
}

.app-shell {
    width: min(1080px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0 48px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    color: #fff;
    background: linear-gradient(135deg, #6ea8ff, #2dd4bf);
    font-weight: 800;
}

.brand-title {
    margin: 0;
    font-size: 20px;
    line-height: 1.25;
}

.brand-subtitle {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.back-link,
.ghost-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    background: rgba(18, 28, 45, 0.72);
    text-decoration: none;
    font-weight: 700;
    white-space: nowrap;
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    background: rgba(18, 28, 45, 0.72);
    font: inherit;
    font-weight: 800;
    cursor: pointer;
    white-space: nowrap;
}

.theme-toggle:hover {
    border-color: #4a6287;
    background: #172338;
}

:root[data-theme="light"] .theme-toggle,
:root[data-theme="light"] .back-link,
:root[data-theme="light"] .ghost-link {
    background: var(--surface);
}

:root[data-theme="light"] .theme-toggle:hover,
:root[data-theme="light"] .back-link:hover,
:root[data-theme="light"] .ghost-link:hover {
    border-color: #b7c6d8;
    background: #f8fafc;
}

.back-link:hover,
.ghost-link:hover {
    border-color: #4a6287;
    background: #172338;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 28px;
}

.panel + .panel {
    margin-top: 18px;
}

.page-heading {
    margin-bottom: 24px;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--primary);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1,
h2,
h3 {
    margin: 0;
    line-height: 1.25;
    letter-spacing: 0;
}

h1 {
    font-size: clamp(28px, 4vw, 42px);
}

h2 {
    font-size: 24px;
}

h3 {
    font-size: 18px;
}

.lede {
    margin: 10px 0 0;
    color: var(--muted);
    max-width: 760px;
}

.menu-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.menu-item {
    display: block;
    min-height: 112px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    background: linear-gradient(180deg, rgba(255,255,255,0.035), rgba(255,255,255,0.01)), var(--surface);
    text-decoration: none;
    transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

:root[data-theme="light"] .menu-item {
    background: var(--surface);
}

.menu-item:hover {
    border-color: #6ea8ff;
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(36, 107, 254, 0.12);
}

.menu-kicker {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.menu-title {
    display: block;
    margin-top: 8px;
    font-size: 18px;
    font-weight: 800;
}

.menu-copy {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group.full {
    grid-column: 1 / -1;
}

label {
    color: #d5deea;
    font-weight: 800;
}

.required {
    color: var(--red);
}

input,
select {
    width: 100%;
    min-height: 44px;
    border: 1px solid #33445f;
    border-radius: 8px;
    background: #0f1828;
    color: var(--text);
    font: inherit;
    padding: 10px 12px;
}

:root[data-theme="light"] input,
:root[data-theme="light"] select {
    border-color: #cbd5e1;
    background: #fff;
}

input:focus,
select:focus {
    border-color: var(--primary);
    outline: 3px solid rgba(110, 168, 255, 0.16);
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 22px;
}

button,
.button,
.upload-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    border: 0;
    border-radius: 8px;
    padding: 10px 16px;
    color: #fff;
    background: var(--primary);
    font: inherit;
    font-weight: 800;
    cursor: pointer;
    text-decoration: none;
}

button:hover,
.button:hover,
.upload-button:hover {
    background: var(--primary-dark);
}

button:disabled {
    cursor: wait;
    opacity: 0.7;
}

.button.secondary {
    color: var(--text);
    background: #25344d;
}

:root[data-theme="light"] .button.secondary {
    background: #e8eef7;
}

:root[data-theme="light"] .button.secondary:hover {
    background: #dce6f3;
}

.button.secondary:hover {
    background: #31425e;
}

.button.green {
    background: var(--green);
}

.button.teal {
    background: var(--teal);
}

.button.amber {
    background: var(--amber);
}

.button.red {
    background: var(--red);
}

input[type="file"] {
    display: none;
}

.message,
.status-message {
    margin-top: 18px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: #d5deea;
    background: var(--surface-muted);
    min-height: 52px;
}

.message.center,
.status-message {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.report-status {
    width: 100%;
    color: var(--text);
}

.report-status.ok {
    color: var(--green);
}

.report-status.error {
    color: var(--red);
}

.report-status-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.progress-track {
    width: 100%;
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(154, 168, 189, 0.22);
}

.progress-bar {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--primary), var(--teal));
    transition: width 0.3s ease;
}

.status-ok {
    color: var(--green);
    font-weight: 800;
}

.status-miss {
    color: var(--red);
    font-weight: 800;
}

.section {
    margin-top: 26px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #0f1828;
}

:root[data-theme="light"] .table-wrap {
    background: #fff;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 560px;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 11px 12px;
    text-align: left;
    vertical-align: top;
}

th {
    color: #d5deea;
    background: #1a2840;
    font-weight: 800;
}

:root[data-theme="light"] th {
    color: #344054;
    background: #f1f5f9;
}

tr:last-child td {
    border-bottom: 0;
}

.no-result {
    color: var(--muted);
    text-align: center;
}

.search-box {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
}

.note {
    margin: 18px 0 0;
    color: var(--muted);
    font-size: 14px;
}

code {
    color: #dbeafe;
    background: #1c2b43;
    border-radius: 6px;
    padding: 2px 6px;
}

:root[data-theme="light"] code {
    color: #0f172a;
    background: #eef2f7;
}

.menu-item.is-disabled {
    opacity: 0.62;
}

.menu-item.is-disabled:hover {
    transform: none;
    box-shadow: none;
    border-color: var(--line);
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 2px 8px;
    border: 1px solid #33445f;
    border-radius: 999px;
    color: var(--muted);
    background: #0f1828;
    font-size: 12px;
    font-weight: 800;
}

:root[data-theme="light"] .badge {
    border-color: #d9e2ec;
    background: #f8fafc;
}

@media (max-width: 720px) {
    .app-shell {
        width: min(100% - 20px, 1080px);
        padding-top: 18px;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .panel {
        padding: 20px;
    }

    .menu-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .search-box,
    .button-row {
        flex-direction: column;
    }

    button,
    .button,
    .upload-button {
        width: 100%;
    }
}
