:root {
    color-scheme: light;
    --ink: #1f2933;
    --muted: #667682;
    --line: #d8e0e6;
    --paper: #ffffff;
    --canvas: #f5f7f9;
    --nav: #24343c;
    --accent: #00796b;
    --accent-strong: #005b50;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background: var(--canvas);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
}

a {
    color: inherit;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 280px;
    height: 100vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 24px;
    background: var(--nav);
    color: white;
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 28px;
}

.brand-mark {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border-radius: 8px;
    background: var(--accent);
    font-weight: 800;
}

.brand strong,
.brand small {
    display: block;
}

.brand small {
    margin-top: 3px;
    color: #c7d1d6;
}

.nav {
    display: grid;
    gap: 8px;
}

.nav a {
    padding: 12px 14px;
    border-radius: 8px;
    color: #e9eef1;
    text-decoration: none;
}

.nav a.active,
.nav a:hover {
    background: #334851;
}

.shell {
    margin-left: 280px;
    padding: 34px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 24px;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--accent-strong);
    font-size: 0.88rem;
    font-weight: 700;
}

h1 {
    margin: 0;
    font-size: 2rem;
}

h2 {
    margin: 0 0 12px;
    font-size: 1.05rem;
}

.status-pill,
.button-link,
.primary-button,
.secondary-button {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 0 14px;
    border-radius: 8px;
    background: #e5f4f1;
    color: var(--accent-strong);
    font-weight: 700;
    text-decoration: none;
}

.primary-button {
    border: 0;
    background: var(--accent);
    color: white;
    cursor: pointer;
}

.primary-button:hover {
    background: var(--accent-strong);
}

.secondary-button {
    border: 1px solid var(--line);
    background: white;
    color: var(--ink);
}

.metrics {
    display: grid;
    grid-template-columns: repeat(5, minmax(120px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.metrics article,
.panel,
.module-card,
.form-panel,
.table-panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--paper);
}

.metrics article {
    padding: 16px;
}

.metrics span {
    display: block;
    color: var(--muted);
}

.metrics strong {
    display: block;
    margin-top: 8px;
    color: var(--accent);
    font-size: 2rem;
}

.panel {
    padding: 20px;
    margin-bottom: 18px;
}

.form-panel,
.table-panel {
    padding: 20px;
    margin-bottom: 18px;
}

.supplier-form,
.data-form {
    display: grid;
    grid-template-columns: repeat(3, minmax(180px, 1fr));
    gap: 16px;
}

.field {
    display: grid;
    gap: 6px;
}

.field.wide {
    grid-column: span 2;
}

label {
    color: var(--muted);
    font-size: 0.92rem;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 10px;
    color: var(--ink);
    background: white;
    font: inherit;
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    outline: 3px solid #d8efeb;
}

.form-actions {
    display: flex;
    align-items: end;
    gap: 10px;
}

.camera-grid {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) minmax(220px, 320px);
    gap: 16px;
    align-items: start;
}

.camera-box {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #111b20;
    aspect-ratio: 16 / 10;
}

.camera-box video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-actions {
    display: grid;
    gap: 10px;
}

.hint {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.6;
}

.notice {
    margin-bottom: 14px;
    border-radius: 8px;
    padding: 12px 14px;
    font-weight: 700;
}

.notice.success {
    border: 1px solid #b8dfd8;
    background: #e5f4f1;
    color: var(--accent-strong);
}

.notice.error {
    border: 1px solid #f0b9b4;
    background: #fff0ee;
    color: #9d2c1f;
}

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.section-title h2 {
    margin: 0;
}

.section-title span {
    color: var(--muted);
}

.muted-text {
    color: var(--muted);
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 12px 10px;
    text-align: left;
    vertical-align: middle;
    white-space: nowrap;
}

th {
    color: var(--muted);
    font-size: 0.9rem;
}

.muted-row {
    color: var(--muted);
    background: #fafbfc;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 0 9px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 800;
}

.badge.ok {
    background: #e5f4f1;
    color: var(--accent-strong);
}

.badge.off {
    background: #edf1f3;
    color: #65737c;
}

.badge.info {
    background: #e8f1fb;
    color: #28629b;
}

.badge.warn {
    background: #fff4db;
    color: #936800;
}

.badge.danger {
    background: #fff0ee;
    color: #9d2c1f;
}

.row-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.row-actions form {
    margin: 0;
}

.inline-form {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.mini-input {
    width: 86px;
    min-height: 32px;
    padding: 5px 7px;
}

.small-link,
.text-button {
    border: 0;
    background: transparent;
    color: var(--accent-strong);
    cursor: pointer;
    font: inherit;
    font-weight: 800;
    text-decoration: none;
}

.flow {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.flow span {
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: #31424b;
    background: #fafbfc;
}

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

.module-card {
    display: block;
    min-height: 160px;
    padding: 18px;
    text-decoration: none;
}

.module-card:hover {
    border-color: var(--accent);
}

.module-card span {
    color: var(--accent-strong);
    font-weight: 800;
}

.module-card h2 {
    margin-top: 18px;
}

.module-card p,
.panel p,
.task-list {
    color: var(--muted);
    line-height: 1.7;
}

.task-list {
    margin: 0;
    padding-left: 20px;
}

.db-path {
    margin-top: 18px;
    color: var(--muted);
    font-size: 0.9rem;
}

@media (max-width: 920px) {
    .sidebar {
        position: static;
        width: auto;
        height: auto;
        overflow-y: visible;
    }

    .shell {
        margin-left: 0;
        padding: 22px;
    }

    .metrics,
    .grid,
    .supplier-form,
    .data-form,
    .camera-grid {
        grid-template-columns: 1fr;
    }

    .field.wide {
        grid-column: auto;
    }

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