:root {
    --bg: #f6f7f9;
    --ink: #18212f;
    --muted: #657186;
    --line: #d9e0ea;
    --panel: #ffffff;
    --accent: #146c63;
    --accent-strong: #0d504a;
    --warn: #a45a12;
    --shadow: 0 10px 28px rgba(23, 33, 48, 0.09);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Arial, Helvetica, sans-serif;
    color: var(--ink);
    background: var(--bg);
}

.shell {
    width: min(1180px, calc(100% - 28px));
    margin: 0 auto;
    padding: 24px 0 40px;
    display: grid;
    gap: 18px;
}

.capture-panel,
.form-panel,
.stock-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 18px;
}

.topbar,
.section-title,
.existing {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
}

.eyebrow {
    margin: 0 0 5px;
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: clamp(1.45rem, 2.3vw, 2.3rem);
}

h2 {
    margin-bottom: 0;
    font-size: 1.1rem;
}

.status,
.message {
    color: var(--muted);
    font-size: 0.95rem;
}

.analysis-details {
    margin-top: 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 12px;
    color: var(--muted);
    font-size: 0.9rem;
}

.analysis-details summary {
    cursor: pointer;
    font-weight: 700;
}

.analysis-details pre {
    white-space: pre-wrap;
    word-break: break-word;
    margin: 10px 0 0;
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
}

.camera-box {
    margin-top: 18px;
    width: 100%;
    background: #101820;
    border-radius: 8px;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    display: grid;
    place-items: center;
}

video,
#preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 14px;
}

.align-left {
    justify-content: flex-start;
}

button {
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0 15px;
    background: #fff;
    color: var(--ink);
    font-weight: 700;
    cursor: pointer;
}

.file-button {
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0 15px;
    background: #fff;
    color: var(--ink);
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.file-button input {
    display: none;
}

button.primary,
button:hover,
.file-button:hover {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}

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

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

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 700;
}

input {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px 10px;
    color: var(--ink);
    font: inherit;
}

input:focus {
    outline: 2px solid rgba(20, 108, 99, 0.2);
    border-color: var(--accent);
}

.existing {
    margin-top: 16px;
    border-top: 1px solid var(--line);
    padding-top: 16px;
}

.existing p {
    margin-bottom: 0;
    color: var(--muted);
}

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

.movement input {
    width: 96px;
}

.table-wrap {
    margin-top: 14px;
    overflow-x: auto;
}

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

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

th {
    color: var(--muted);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0;
}

td:last-child,
th:last-child {
    text-align: right;
    font-weight: 700;
}

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

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

    .topbar,
    .section-title,
    .existing,
    .movement {
        align-items: stretch;
        flex-direction: column;
    }

    .toolbar,
    .align-left {
        justify-content: stretch;
    }

    button {
        flex: 1 1 auto;
    }
}

@media (max-width: 520px) {
    .shell {
        width: min(100% - 18px, 1180px);
        padding-top: 10px;
    }

    .capture-panel,
    .form-panel,
    .stock-panel {
        padding: 14px;
    }

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

    .camera-box {
        aspect-ratio: 4 / 3;
    }
}
