:root {
    color-scheme: light;
    --bg: #f4f6f8;
    --surface: #ffffff;
    --surface-2: #eef3f7;
    --border: #d9e1e8;
    --text: #17212b;
    --muted: #657285;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #12805c;
    --success-bg: #e5f6ef;
    --warning: #a15c07;
    --warning-bg: #fff3d6;
    --danger: #b42318;
    --danger-bg: #fde7e7;
    --shadow: 0 12px 30px rgba(18, 33, 49, 0.08);
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    letter-spacing: 0;
    color: var(--text);
    background: var(--bg);
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

button,
input,
select,
textarea {
    font: inherit;
}

code {
    padding: 2px 5px;
    border-radius: 5px;
    background: var(--surface-2);
}

.app-shell {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    border-right: 1px solid var(--border);
    background: #111827;
    color: #f8fafc;
    padding: 20px 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #f8fafc;
    margin-bottom: 24px;
}

.brand:hover {
    text-decoration: none;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 8px;
    background: #2563eb;
    font-weight: 700;
}

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

.brand small {
    color: #b6c2d1;
    font-size: 12px;
}

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

.sidebar-nav a {
    display: block;
    padding: 10px 12px;
    border-radius: 8px;
    color: #d8dee9;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: #223044;
    color: #ffffff;
    text-decoration: none;
}

.content-shell {
    width: 100%;
    max-width: 1400px;
    padding: 28px;
    margin: 0 auto;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.page-header h1,
.panel h2 {
    margin: 0;
    line-height: 1.15;
}

.page-header h1 {
    font-size: 30px;
}

.panel h2 {
    font-size: 18px;
    margin-bottom: 14px;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.header-note {
    margin: 8px 0 0;
    color: var(--muted);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.stat-card,
.panel,
.install-panel {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.stat-card {
    padding: 18px;
}

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

.stat-card strong {
    font-size: 30px;
}

.panel {
    padding: 18px;
}

.two-column {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 0.45fr);
    gap: 18px;
}

.two-column.wide-left {
    grid-template-columns: minmax(0, 1.35fr) minmax(340px, 0.65fr);
}

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

.section-title h2 {
    margin: 0;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

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

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

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    background: #f9fbfd;
}

td small {
    color: var(--muted);
}

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

.alert {
    margin-bottom: 14px;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
}

.alert.success {
    color: var(--success);
    border-color: #b8e1cf;
    background: var(--success-bg);
}

.alert.danger {
    color: var(--danger);
    border-color: #f0b7b4;
    background: var(--danger-bg);
}

.alert.warning {
    color: var(--warning);
    border-color: #f3d58d;
    background: var(--warning-bg);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.status-badge.complete {
    color: var(--success);
    background: var(--success-bg);
}

.status-badge.pending {
    color: var(--warning);
    background: var(--warning-bg);
}

.form-grid {
    display: grid;
    gap: 14px;
}

.form-grid.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

label span {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-weight: 700;
}

label small {
    color: var(--muted);
    font-weight: 400;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 11px;
    color: var(--text);
    background: #ffffff;
    outline: none;
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

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

.check-row input {
    width: 18px;
    height: 18px;
}

.check-row span {
    margin: 0;
    color: var(--text);
    font-weight: 600;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 9px 13px;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    background: #ffffff;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}

.button:hover {
    text-decoration: none;
}

.button.primary {
    border-color: var(--primary);
    color: #ffffff;
    background: var(--primary);
}

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

.button.ghost {
    background: #f8fafc;
}

.button.danger {
    color: var(--danger);
}

.button.small {
    min-height: 32px;
    padding: 6px 10px;
    font-size: 13px;
}

.button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.form-actions,
.inline-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.order-form {
    display: grid;
    gap: 16px;
}

.line-list {
    display: grid;
    gap: 12px;
}

.order-line {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) 120px minmax(260px, 0.9fr) auto;
    align-items: end;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fbfcfe;
}

.order-line [hidden] {
    display: none;
}

.progress-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    padding: 12px;
    border-radius: 8px;
    background: var(--surface-2);
}

.progress-line strong {
    font-size: 24px;
}

.serial-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.serial-list span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    padding: 6px 9px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #ffffff;
    word-break: break-word;
}

.serial-list.compact span {
    display: grid;
    align-items: start;
}

.serial-list small {
    color: var(--muted);
}

.notes-box {
    margin: 16px 0 0;
    padding: 12px;
    border-radius: 8px;
    background: var(--surface-2);
}

.scanner-panel {
    display: grid;
    gap: 10px;
    padding: 12px;
    border: 1px dashed var(--border);
    border-radius: 8px;
    background: #f8fafc;
}

.scanner-panel video {
    width: 100%;
    min-height: 220px;
    max-height: 360px;
    border-radius: 8px;
    background: #0f172a;
    object-fit: cover;
}

.scanner-status {
    margin: 0;
    color: var(--muted);
}

.install-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
}

.install-shell {
    width: min(640px, 100%);
}

.install-panel {
    padding: 24px;
}

.brand-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.brand-row h1 {
    margin: 0;
}

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

@media (max-width: 1040px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
        padding: 14px;
    }

    .sidebar-nav {
        grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    }

    .content-shell {
        padding: 18px;
    }

    .two-column,
    .two-column.wide-left,
    .form-grid.three {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .order-line {
        grid-template-columns: 1fr 120px;
    }

    .order-line .serial-box,
    .order-line [data-remove-line] {
        grid-column: 1 / -1;
    }
}

@media (max-width: 640px) {
    body {
        font-size: 14px;
    }

    .content-shell {
        padding: 14px;
    }

    .page-header {
        display: grid;
    }

    .page-header h1 {
        font-size: 24px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .panel,
    .stat-card,
    .install-panel {
        padding: 14px;
    }

    .order-line {
        grid-template-columns: 1fr;
    }

    .button {
        width: 100%;
        white-space: normal;
    }

    th,
    td {
        padding: 9px 8px;
    }
}
