:root {
    --bg: #f4f5f7;
    --panel: #ffffff;
    --border: #d8dce1;
    --text: #1f2430;
    --muted: #6b7280;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #dc2626;
    --radius: 6px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.4;
}

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

.topbar {
    display: flex;
    align-items: center;
    gap: 24px;
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--topbar-border);
    padding: 10px 20px;
}

.topbar .brand { display: flex; align-items: center; }
.topbar .brand img { display: block; max-height: 28px; width: auto; }

.topbar nav { display: flex; gap: 16px; flex: 1; }
.topbar nav a { color: var(--topbar-text); font-size: 14px; }
.topbar nav a:hover { color: var(--topbar-accent); }

.topbar-right { display: flex; align-items: center; gap: 8px; }

details.dropdown { position: relative; }

details.dropdown summary {
    cursor: pointer;
    list-style: none;
    padding: 6px 12px;
    border-radius: var(--radius);
    color: var(--topbar-text);
    font-size: 13px;
}

details.dropdown summary::-webkit-details-marker,
details.dropdown summary::marker { display: none; content: ''; }

details.dropdown summary:hover,
details.dropdown[open] summary { background: rgba(255, 255, 255, 0.1); }

details.dropdown summary::after { content: ' \25BE'; }

.topbar-right form {
    background: none;
    border: none;
    padding: 0;
    max-width: none;
    margin: 0;
}

.theme-toggle {
    background: none;
    border: none;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: var(--radius);
}

.theme-toggle:hover { background: rgba(255, 255, 255, 0.1); }

.dropdown-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    min-width: 170px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
    z-index: 30;
    overflow: hidden;
}

.dropdown-menu a {
    display: block;
    padding: 9px 14px;
    color: var(--text);
    font-size: 14px;
}

.dropdown-menu a:hover { background: #f0f1f3; text-decoration: none; }

.content {
    max-width: 960px;
    margin: 24px auto;
    padding: 0 20px 40px;
}

h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 28px 0 10px; }
h3 { font-size: 14px; margin: 18px 0 8px; color: var(--muted); }

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

th, td {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

th { background: #eef0f3; font-weight: 600; }
th a { color: inherit; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbfc; }

.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 10px 0;
    font-size: 13px;
}
.pagination a, .pagination .page-current {
    padding: 4px 9px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.pagination .page-current {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

form {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    max-width: 480px;
}

form label {
    display: block;
    margin-bottom: 12px;
    font-size: 13px;
    color: var(--muted);
}

input, select, textarea {
    display: block;
    width: 100%;
    margin-top: 4px;
    padding: 7px 9px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    color: var(--text);
}

input[type="checkbox"] { display: inline-block; width: auto; margin-right: 6px; }

textarea { min-height: 60px; resize: vertical; }

button, input[type="submit"] {
    display: inline-block;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    background: var(--primary);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

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

.error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: var(--danger);
    padding: 8px 12px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 14px;
}

.small { font-size: 12px; color: var(--muted); }

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-page form { width: 320px; }
.portal-status { width: 380px; }
.portal-status table { width: 100%; }
.portal-status th { width: 130px; }

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

.toolbar .search-box { flex: 1; max-width: 280px; margin: 0; }
.toolbar select { width: auto; margin: 0; }

dialog {
    position: fixed;
    top: 64px;
    left: 50%;
    transform: translateX(-50%);
    margin: 0;
    border: none;
    border-radius: var(--radius);
    padding: 0;
    width: 95vw;
    max-width: 1400px;
    max-height: calc(100vh - 84px);
    overflow: auto;
}

dialog form input:not([type="color"]):not([type="checkbox"]),
dialog form select,
dialog form textarea {
    max-width: 520px;
}

.dialog-close {
    position: absolute;
    top: 10px;
    right: 12px;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 50%;
    background: none;
    color: var(--muted);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}

.dialog-close:hover { background: #f0f1f3; color: var(--text); }

dialog::backdrop { background: rgba(15, 18, 25, 0.6); }

dialog form {
    border: none;
    max-width: none;
    margin: 0;
    padding: 24px;
}

dialog h2 { margin-top: 0; }

.dialog-actions { display: flex; gap: 10px; align-items: center; margin-top: 4px; }

.btn-secondary {
    display: inline-block;
    padding: 8px 16px;
    border-radius: var(--radius);
    background: none;
    border: 1px solid var(--border);
    color: var(--text);
    font-weight: 500;
    font-size: 14px;
    text-decoration: none;
}

.btn-secondary:hover { background: #f0f1f3; text-decoration: none; }

@media print {
    .topbar, .no-print { display: none !important; }
    body { background: #fff; }
    .content { margin: 0; padding: 0; max-width: none; }
}

.label-page {
    width: 62mm;
    padding: 10px;
    margin: 16px auto;
    border: 1px dashed var(--border);
    text-align: center;
}
@media print { .label-page { border: none; margin: 0; } }

img.barcode {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    image-rendering: pixelated;
}

.label-codes { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 6px; }
.label-codes img.barcode { height: 56px; width: auto; }
.label-asset-id { font-size: 16px; font-weight: 700; }
.label-detail { font-size: 11px; color: var(--muted); }

.job-sheet { max-width: 720px; margin: 0 auto; }
.job-sheet-topbar {
    background: #e4e6ea;
    border-bottom: 1px solid #c5c9d0;
    padding: 16px 24px;
    margin-bottom: 32px;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}
@media print {
    .job-sheet-topbar { margin-top: 24px; }
}
.job-sheet-topbar-logo { display: block; height: 34px; width: auto; }
.job-sheet-header { display: grid; grid-template-columns: auto 1fr auto; align-items: center; column-gap: 16px; margin-bottom: 40px; }
.job-sheet-logo-col { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding-left: 4px; }
.job-sheet-title { text-align: center; }
.job-sheet-title h2 { font-size: 26px; }
.job-sheet-title p { font-size: 14px; }
.job-sheet-codes { display: flex; flex-direction: column; align-items: center; gap: 6px; justify-self: end; }
.job-sheet-codes img.barcode { height: 132px; width: auto; }
.job-sheet-equipment-code { display: flex; flex-direction: column; align-items: center; gap: 2px; border-top: 1px dashed var(--border); padding-top: 6px; }
.job-sheet-equipment-code img.barcode { height: 68px; }
.job-sheet-status { margin-top: 10px; }
.job-sheet-status-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.job-sheet-status-value { font-size: 20px; font-weight: 700; margin-top: 2px; }

.job-sheet-notes-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 14px 0 2px; }
.job-sheet-notes-lines {
    line-height: 24px;
    min-height: 120px;
    background-image: linear-gradient(to bottom, transparent 23px, var(--border) 23px, var(--border) 24px, transparent 24px);
    background-size: 100% 24px;
    word-break: break-word;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}
.job-sheet table { width: 100%; margin-bottom: 16px; }
.job-sheet th { width: 160px; background: #eef0f3; text-align: left; }

.tear-line {
    position: relative;
    border-top: 1px dashed var(--border);
    margin: 32px 0 20px;
    text-align: center;
}
.tear-line span {
    position: relative;
    top: -10px;
    background: #fff;
    padding: 0 10px;
    font-size: 11px;
    color: var(--muted);
    letter-spacing: 0.04em;
}
.terms-text { font-size: 10px; line-height: 1.5; color: var(--text); margin-bottom: 24px; }

.job-sheet-signoff { display: grid; grid-template-columns: 2fr 1fr 2fr 1fr; gap: 16px; margin-top: 48px; }
.signoff-line { border-bottom: 1px solid var(--text); height: 32px; margin-top: 4px; }

.parts-table td { vertical-align: middle; }
.parts-table td:nth-child(2) { width: 90px; }
.parts-table td:nth-child(2) input { width: 100%; margin: 0; }
.parts-table td:first-child select { margin: 0; }
.parts-table td:last-child { width: 1%; white-space: nowrap; }

.stats { display: flex; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }

.stat-tile {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 18px;
    min-width: 110px;
}

.stat-tile .stat-value { font-size: 24px; font-weight: 700; line-height: 1.2; }
.stat-tile .stat-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }

.dashboard-section { margin-bottom: 28px; }

.scan-form { margin: 60px auto; max-width: 500px; }
.scan-input {
    font-size: 28px;
    padding: 20px;
    text-align: center;
}

.scan-result { max-width: 500px; margin: 0 auto; }

.interval-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 20px;
}
.interval-buttons input[type="radio"] {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}
.interval-buttons label {
    display: block;
    text-align: center;
    padding: 22px 10px;
    font-size: 18px;
    font-weight: 600;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    background: var(--panel);
    color: var(--text);
}
.interval-buttons input[type="radio"]:checked + label {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}

.pass-fail-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tag-btn-pass, .tag-btn-fail {
    width: 100%;
    padding: 28px 10px;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 0.04em;
}
.tag-btn-pass { background: #15803d; }
.tag-btn-pass:hover { background: #166534; }
.tag-btn-fail { background: var(--danger); }
.tag-btn-fail:hover { background: #b91c1c; }
