:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --text: #1f2933;
    --muted: #657282;
    --line: #d9e0e7;
    --primary: #0f766e;
    --primary-dark: #115e59;
    --accent: #d97706;
    --danger: #b42318;
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1.45;
}

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

.topbar {
    align-items: center;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 16px;
    justify-content: space-between;
    min-height: 64px;
    padding: 12px clamp(16px, 4vw, 40px);
    position: sticky;
    top: 0;
    z-index: 5;
}

.brand,
.top-actions,
.detail-actions,
.scanner-actions,
.form-actions {
    align-items: center;
    display: flex;
    gap: 10px;
}

.brand {
    font-weight: 700;
}

.brand-mark {
    align-items: center;
    background: var(--primary);
    border-radius: 6px;
    color: #fff;
    display: inline-flex;
    height: 36px;
    justify-content: center;
    width: 36px;
}

.container {
    margin: 0 auto;
    max-width: 1180px;
    padding: 24px clamp(14px, 4vw, 32px) 48px;
}

.page-head,
.detail-head {
    align-items: flex-start;
    display: flex;
    gap: 18px;
    justify-content: space-between;
    margin-bottom: 18px;
}

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

h1 {
    font-size: clamp(1.8rem, 4vw, 2.4rem);
    line-height: 1.1;
    margin-bottom: 6px;
}

h2 {
    font-size: 1.15rem;
    margin-bottom: 14px;
}

.page-head p,
.detail-head p,
.muted {
    color: var(--muted);
}

.button {
    align-items: center;
    background: var(--primary);
    border: 0;
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-weight: 700;
    justify-content: center;
    min-height: 42px;
    padding: 9px 14px;
    white-space: nowrap;
}

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

.button-ghost {
    background: #eef4f3;
    color: var(--primary-dark);
}

.button-ghost:hover {
    background: #dcebe8;
}

.button-small {
    min-height: 34px;
    padding: 7px 10px;
}

.button-large {
    min-height: 48px;
}

.messages {
    display: grid;
    gap: 8px;
    margin-bottom: 16px;
}

.message {
    border-radius: var(--radius);
    padding: 10px 12px;
}

.message-success {
    background: #dcfce7;
    color: #166534;
}

.message-error {
    background: #fee4e2;
    color: var(--danger);
}

.filters,
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.filters {
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(220px, 1fr) 220px auto;
    margin-bottom: 16px;
    padding: 12px;
}

input,
select,
textarea {
    background: #fff;
    border: 1px solid #cbd5df;
    border-radius: 6px;
    color: var(--text);
    font: inherit;
    min-height: 42px;
    padding: 9px 10px;
    width: 100%;
}

textarea {
    resize: vertical;
}

.table-wrap {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}

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

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

.repair-table th {
    background: #eef2f6;
    color: #40505f;
    font-size: .88rem;
}

.repair-table td span {
    color: var(--muted);
    display: block;
    font-size: .88rem;
    margin-top: 2px;
}

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

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

.status-pill {
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 999px;
    color: #9a3412;
    display: inline-flex;
    font-size: .88rem;
    font-weight: 700;
    padding: 4px 9px;
}

.panel {
    padding: 18px;
}

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

label {
    color: #40505f;
    display: grid;
    font-size: .92rem;
    font-weight: 700;
    gap: 6px;
}

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

.form-actions {
    justify-content: flex-end;
}

.detail-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: 220px 1fr;
    margin-bottom: 16px;
}

.qr-panel {
    align-items: center;
    display: grid;
    gap: 10px;
    justify-items: center;
}

.qr-panel img {
    height: 170px;
    image-rendering: pixelated;
    width: 170px;
}

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

.info-grid span {
    color: var(--muted);
    display: block;
    font-size: .82rem;
    margin-bottom: 3px;
}

.info-grid strong {
    overflow-wrap: anywhere;
}

.text-block {
    margin-bottom: 16px;
}

.split {
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.photo-form,
.history-form,
.manual-code {
    display: grid;
    gap: 10px;
}

.photos {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    margin-top: 14px;
}

.photo {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}

.photo img {
    aspect-ratio: 4 / 3;
    display: block;
    object-fit: cover;
    width: 100%;
}

.photo span {
    color: var(--muted);
    display: block;
    font-size: .82rem;
    padding: 7px;
}

.timeline {
    border-left: 2px solid var(--line);
    display: grid;
    gap: 14px;
    list-style: none;
    margin: 18px 0 0;
    padding: 0 0 0 16px;
}

.timeline li {
    position: relative;
}

.timeline li::before {
    background: var(--accent);
    border-radius: 50%;
    content: "";
    height: 10px;
    left: -22px;
    position: absolute;
    top: 6px;
    width: 10px;
}

.timeline time {
    color: var(--muted);
    display: block;
    font-size: .82rem;
}

.timeline p {
    margin-bottom: 0;
}

.eyebrow {
    color: var(--accent);
    font-size: .84rem;
    font-weight: 800;
    text-transform: uppercase;
}

.scanner {
    display: grid;
    gap: 14px;
    margin-bottom: 16px;
}

#qr-video {
    aspect-ratio: 16 / 9;
    background: #111827;
    border-radius: var(--radius);
    object-fit: cover;
    width: 100%;
}

@media (max-width: 760px) {
    .topbar,
    .page-head,
    .detail-head {
        align-items: stretch;
        flex-direction: column;
    }

    .top-actions,
    .detail-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .filters,
    .form-grid,
    .detail-grid,
    .info-grid,
    .split {
        grid-template-columns: 1fr;
    }

    .span-2 {
        grid-column: span 1;
    }

    .repair-table,
    .repair-table thead,
    .repair-table tbody,
    .repair-table tr,
    .repair-table th,
    .repair-table td {
        display: block;
    }

    .repair-table thead {
        display: none;
    }

    .repair-table tr {
        border-bottom: 1px solid var(--line);
        padding: 10px 12px;
    }

    .repair-table td {
        border: 0;
        display: grid;
        gap: 8px;
        grid-template-columns: 110px 1fr;
        padding: 6px 0;
    }

    .repair-table td::before {
        color: var(--muted);
        content: attr(data-label);
        font-size: .82rem;
        font-weight: 700;
    }

    .row-action {
        display: block !important;
        text-align: left;
    }

    .row-action::before {
        content: "";
    }
}
