:root {
    color-scheme: light;
    --navy: #12304a;
    --blue: #1f5f8b;
    --pale: #eef4f8;
    --border: #cbd8e2;
    --text: #17212b;
    --muted: #5a6975;
    --success: #17643a;
    --warning: #8a5a00;
    --danger: #a12626;
    --white: #fff;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background: linear-gradient(145deg, #e7f0f6, #f8fafb 50%, #dbe8f0);
}

.page-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.25rem;
}

.auth-card,
.install-card {
    width: min(100%, 34rem);
    padding: clamp(1.5rem, 5vw, 2.5rem);
    background: rgba(255, 255, 255, .98);
    border: 1px solid var(--border);
    border-radius: 1rem;
    box-shadow: 0 1.25rem 3rem rgba(18, 48, 74, .16);
}

.install-card { width: min(100%, 72rem); }

.seal {
    display: grid;
    place-items: center;
    width: 4.25rem;
    height: 4.25rem;
    margin: 0 auto 1rem;
    color: var(--white);
    background: var(--navy);
    border: .2rem solid #d5a735;
    border-radius: 50%;
    font-weight: 800;
    letter-spacing: .08em;
}

.eyebrow {
    margin: 0;
    color: var(--blue);
    font-size: .82rem;
    font-weight: 800;
    letter-spacing: .12em;
    text-align: center;
    text-transform: uppercase;
}

h1 { margin: .35rem 0 .5rem; color: var(--navy); font-size: clamp(1.7rem, 6vw, 2.35rem); text-align: center; }
h2 { margin-top: 1.75rem; color: var(--navy); }
.intro { margin: 0 0 1.5rem; color: var(--muted); text-align: center; }

.login-form { display: grid; gap: .6rem; }
label { margin-top: .45rem; font-weight: 700; }
input,
select,
textarea {
    width: 100%;
    min-height: 3rem;
    padding: .72rem .85rem;
    border: 1px solid #9fb1be;
    border-radius: .5rem;
    font: inherit;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: .2rem solid rgba(31, 95, 139, .25); border-color: var(--blue); }

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 3rem;
    margin-top: .8rem;
    padding: .7rem 1.1rem;
    color: var(--white);
    background: var(--blue);
    border: 0;
    border-radius: .5rem;
    font: inherit;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
}
button:disabled, input:disabled { cursor: not-allowed; opacity: .62; }

.notice {
    margin: 1.25rem 0 0;
    padding: .85rem 1rem;
    color: var(--navy);
    background: var(--pale);
    border-left: .25rem solid var(--blue);
    border-radius: .25rem;
    line-height: 1.5;
}
.notice.error { color: #651515; background: #fbecec; border-color: var(--danger); }
.notice.success { color: #104a2b; background: #e8f6ee; border-color: var(--success); }
.notice.warning { color: #684500; background: #fff6d8; border-color: var(--warning); }

.check-list { display: grid; gap: .55rem; padding: 0; list-style: none; }
.check-list li { display: grid; grid-template-columns: 5.6rem 1fr; gap: .75rem; padding: .75rem; border: 1px solid var(--border); border-radius: .5rem; }
.badge { align-self: start; padding: .2rem .45rem; border-radius: 999px; font-size: .72rem; font-weight: 900; text-align: center; text-transform: uppercase; }
.badge.pass { color: var(--success); background: #ddf4e7; }
.badge.fail { color: var(--danger); background: #f9dddd; }
.badge.warning { color: var(--warning); background: #fff2cc; }
.check-detail { display: block; margin-top: .15rem; color: var(--muted); font-size: .9rem; overflow-wrap: anywhere; }
.key-form { display: grid; gap: .55rem; }
.footer-link { margin-top: 1.25rem; text-align: center; }
.footer-link a { color: var(--blue); }
code { overflow-wrap: anywhere; }

.field-help { margin: .1rem 0 .5rem; color: var(--muted); font-size: .88rem; line-height: 1.45; }
.message-list { margin: 0; padding-left: 1.2rem; }
.steps { padding-left: 1.35rem; line-height: 1.55; }
.steps li + li { margin-top: .55rem; }
.secret-key { padding: 1rem; background: #f3f6f8; border: 1px dashed #8298a8; border-radius: .5rem; text-align: center; font-size: 1.08rem; font-weight: 800; letter-spacing: .08em; }
.button.secondary { color: var(--navy); background: #e1ebf1; border: 1px solid #afc1cd; }
.button.compact { min-height: 2.5rem; margin: 0; padding: .5rem .8rem; }

.account-summary { display: grid; gap: .5rem; margin: 1rem 0; }
.account-summary div { display: grid; grid-template-columns: minmax(8rem, 1fr) 1.4fr; gap: .75rem; padding: .7rem 0; border-bottom: 1px solid var(--border); }
.account-summary dt { color: var(--muted); font-weight: 700; }
.account-summary dd { margin: 0; overflow-wrap: anywhere; }

.recovery-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; margin: 1rem 0; }
.recovery-grid code { display: block; padding: .75rem; background: #f3f6f8; border: 1px solid var(--border); border-radius: .4rem; text-align: center; font-size: 1.05rem; font-weight: 800; letter-spacing: .05em; }

.dashboard-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border); }
.welcome { margin: 0; font-size: 1.08rem; }
.dashboard-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-top: 1.25rem; }
.dashboard-panel { padding: 1rem; background: var(--pale); border: 1px solid var(--border); border-radius: .65rem; }
.dashboard-panel h2 { margin: 0 0 .5rem; font-size: 1.05rem; }
.dashboard-panel p { line-height: 1.5; }
.dashboard-panel a { color: var(--blue); font-weight: 700; }

.app-nav { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 1rem -1rem 1.5rem; padding: .75rem 1rem; background: var(--pale); border: 1px solid var(--border); border-radius: .65rem; }
.nav-links { display: flex; flex-wrap: wrap; gap: .4rem 1rem; }
.nav-links a { color: var(--navy); font-weight: 750; text-decoration: none; }
.nav-links a:hover { text-decoration: underline; }
.app-nav form { margin: 0; }

.page-actions { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.page-actions > p { color: var(--muted); }
.profile-title { margin: 0; }
.inline-actions, .form-actions { display: flex; flex-wrap: wrap; gap: .65rem; align-items: center; }
.form-actions { margin-top: 1rem; }

.filter-form { display: grid; grid-template-columns: 2fr repeat(3, minmax(8rem, 1fr)) auto; gap: .75rem; align-items: end; margin: 1rem 0; padding: 1rem; background: #f7f9fa; border: 1px solid var(--border); border-radius: .65rem; }
.filter-form div, .admin-form .form-grid > div { display: grid; gap: .35rem; }
.filter-form.category-filter { grid-template-columns: 2fr minmax(12rem, 1.25fr) minmax(8rem, .8fr) auto; }

.responsive-table { width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: .65rem; }
table { width: 100%; border-collapse: collapse; background: var(--white); }
th, td { padding: .8rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { color: var(--navy); background: var(--pale); font-size: .84rem; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:last-child td { border-bottom: 0; }
td a { color: var(--blue); font-weight: 700; }
.table-detail { display: block; margin-top: .18rem; color: var(--muted); font-size: .84rem; white-space: nowrap; }
.status-tag { display: inline-block; margin: .15rem .2rem; padding: .16rem .45rem; border-radius: 999px; font-size: .75rem; font-weight: 800; }
.status-tag.success { color: var(--success); background: #ddf4e7; }
.status-tag.danger { color: var(--danger); background: #f9dddd; }
.status-tag.muted { color: #4f5b63; background: #e7ecef; }

.admin-form { display: grid; gap: 1rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
fieldset { min-width: 0; margin: 0; padding: 1rem; border: 1px solid var(--border); border-radius: .6rem; }
legend { padding: 0 .35rem; color: var(--navy); font-weight: 800; }
.checkbox-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
.check-option { display: flex; align-items: flex-start; gap: .55rem; min-height: 2.6rem; margin: 0; padding: .6rem; background: #f7f9fa; border: 1px solid var(--border); border-radius: .45rem; font-weight: 650; }
.check-option input { flex: 0 0 auto; width: 1.2rem; min-height: 1.2rem; margin: .05rem 0 0; }
.account-summary.three-column { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.account-summary.three-column div { display: block; }
.account-summary.three-column dd { margin-top: .25rem; }
.action-card-grid, .department-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.dashboard-panel h3 { margin: 0 0 .45rem; color: var(--navy); }
.stacked-action { display: grid; gap: .45rem; }
.stacked-action .button { justify-self: start; }
.danger-button { background: var(--danger); }
.compact-stats { display: grid; gap: .35rem; }
.compact-stats div { display: flex; justify-content: space-between; gap: 1rem; padding: .3rem 0; }
.compact-stats dd { margin: 0; font-weight: 800; }

.management-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-top: 1rem; }
.record-card { display: flex; flex-direction: column; min-width: 0; padding: 1rem; background: var(--white); border: 1px solid var(--border); border-radius: .7rem; box-shadow: 0 .25rem .7rem rgba(18, 48, 74, .06); }
.record-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; }
.record-card h2 { margin: .1rem 0 .65rem; font-size: 1.15rem; }
.record-kicker { margin: 0; color: var(--blue); font-size: .74rem; font-weight: 850; letter-spacing: .06em; text-transform: uppercase; }
.record-meta { display: grid; gap: .4rem; margin: .25rem 0 .75rem; }
.record-meta div { display: grid; grid-template-columns: 6.5rem 1fr; gap: .7rem; }
.record-meta dt { color: var(--muted); font-weight: 700; }
.record-meta dd { min-width: 0; margin: 0; overflow-wrap: anywhere; }
.record-description { flex: 1; margin: .25rem 0 .9rem; color: #34434f; line-height: 1.5; }
.record-card > a { align-self: flex-start; color: var(--blue); font-weight: 800; }
.muted-copy, .optional { color: var(--muted); }
.optional { font-size: .82rem; font-weight: 500; }
.empty-state { grid-column: 1 / -1; margin: 0; padding: 1.5rem; color: var(--muted); background: #f7f9fa; border: 1px dashed var(--border); border-radius: .65rem; text-align: center; }
.danger-zone { margin-top: 1.5rem; padding: 1rem; background: #fff8f8; border: 1px solid #e2b7b7; border-radius: .65rem; }
.danger-zone h2 { margin: 0 0 .35rem; font-size: 1.1rem; }
.confirmation { margin-top: .45rem; }

@media (max-width: 34rem) {
    .page-shell { padding: .75rem; align-items: start; }
    .auth-card, .install-card { margin-top: .75rem; padding: 1.25rem; border-radius: .75rem; }
    .check-list li { grid-template-columns: 1fr; gap: .35rem; }
    .badge { justify-self: start; }
    .account-summary div { grid-template-columns: 1fr; gap: .2rem; }
    .recovery-grid, .dashboard-grid { grid-template-columns: 1fr; }
    .dashboard-header { align-items: flex-start; flex-direction: column; }
    .app-nav { align-items: stretch; flex-direction: column; margin-inline: 0; }
    .nav-links { flex-direction: column; gap: .55rem; }
    .filter-form, .filter-form.category-filter, .form-grid, .checkbox-grid, .account-summary.three-column, .action-card-grid, .department-grid, .management-grid { grid-template-columns: 1fr; }
    .page-actions { align-items: flex-start; flex-direction: column; }
    .inline-actions { width: 100%; }
    .record-meta div { grid-template-columns: 1fr; gap: .15rem; }
}

@media print {
    body { background: #fff; }
    .auth-card { width: 100%; box-shadow: none; border: 0; }
    .footer-link, .button { display: none !important; }
}

/* Section 5 inventory items */
.inventory-filter { grid-template-columns: 2fr repeat(6, minmax(8rem, 1fr)) auto; }
.inventory-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.inventory-card .inline-actions { margin-top: auto; }
.inventory-card .inline-actions a { color: var(--blue); font-weight: 800; }
.inventory-summary { margin-top: 1.25rem; }
.detail-section { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.detail-section h2 { margin: 0 0 .7rem; font-size: 1.15rem; }
.photo-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.photo-grid figure { margin: 0; padding: .6rem; background: #f7f9fa; border: 1px solid var(--border); border-radius: .65rem; }
.photo-grid img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: .4rem; background: #e7ecef; }
.photo-grid figcaption { margin-top: .45rem; color: var(--muted); font-size: .84rem; text-align: center; }
.edit-photo-grid fieldset { display: grid; gap: .65rem; align-content: start; }
.edit-photo-grid fieldset img { aspect-ratio: 4 / 3; object-fit: cover; }
.inventory-actions { margin-top: 1.5rem; }
.inventory-actions .dashboard-panel { background: #f7f9fa; }

@media (max-width: 58rem) {
    .inventory-filter { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .inventory-filter > div:first-child { grid-column: 1 / -1; }
}

@media (max-width: 34rem) {
    .inventory-filter, .inventory-grid, .photo-grid { grid-template-columns: 1fr; }
    .inventory-filter > div:first-child { grid-column: auto; }
}

/* Section 6 asset labels and QR codes */
.label-selection-form { display: grid; gap: 1rem; }
.label-selection-form input[type="checkbox"] { width: 1.2rem; min-height: 1.2rem; }
.single-label-stage { display: flex; justify-content: center; margin: 2rem auto; }
.asset-label-sheet {
    display: grid;
    grid-template-columns: repeat(3, 2.625in);
    grid-auto-rows: 1in;
    column-gap: .125in;
    row-gap: 0;
    justify-content: center;
    width: 8.125in;
    margin: .5in auto;
}
.asset-label {
    box-sizing: border-box;
    display: grid;
    grid-template-columns: minmax(0, 1fr) .78in;
    gap: .08in;
    width: 2.625in;
    height: 1in;
    padding: .08in .09in;
    color: #000;
    background: #fff;
    border: 1px dashed #a9b4bc;
    overflow: hidden;
}
.asset-label-copy { display: flex; flex-direction: column; min-width: 0; line-height: 1.05; }
.asset-label-copy > strong { font-size: 8pt; white-space: nowrap; }
.asset-number { margin-top: .03in; font-size: 12pt; font-weight: 900; letter-spacing: .02em; white-space: nowrap; }
.asset-name { margin-top: .02in; font-size: 8pt; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.asset-label-copy small { margin-top: auto; font-size: 6.5pt; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.asset-qr { display: flex; align-items: center; justify-content: center; width: .78in; height: .78in; align-self: center; justify-self: end; }
.asset-qr canvas, .asset-qr img, .asset-qr table { max-width: .78in !important; max-height: .78in !important; }

@media print {
    @page { size: letter portrait; margin: .5in .1875in; }
    .no-print, .app-nav, .eyebrow, .install-card > h1 { display: none !important; }
    .page-shell, .install-card { display: block; width: auto; max-width: none; margin: 0; padding: 0; background: #fff; border: 0; box-shadow: none; }
    .asset-label-sheet { margin: 0; width: 8.125in; }
    .single-label-stage { margin: 0; justify-content: flex-start; }
    .asset-label { border: 0; break-inside: avoid; page-break-inside: avoid; }
}

/* Section 7 annual inventory verification */
.status-tag.warning { color: #684500; background: #fff2cc; }
.verification-cycle-grid .record-card { min-height: 100%; }
.verification-cycle-grid .record-meta { margin-bottom: 1rem; }
.verification-cycle-grid .record-card > a { margin-top: auto; }
.detail-section { margin-top: 1.5rem; padding-top: .25rem; }
.detail-section > h2 { margin-top: 0; font-size: 1.15rem; }
@media (max-width: 48rem) {
    .verification-cycle-grid { grid-template-columns: 1fr; }
}

/* Section 8 reporting and exports */
.report-hub-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.report-stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .8rem; margin: 1rem 0; }
.report-stat-grid > div { padding: .9rem; background: #f7f9fa; border: 1px solid var(--border); border-radius: .65rem; }
.report-stat-grid span { display: block; color: var(--muted); font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.report-stat-grid strong { display: block; margin-top: .2rem; color: var(--navy); font-size: 1.25rem; }
.report-export-actions { margin: 1rem 0; align-items: center; }
.report-export-actions form { margin: 0; }
.report-filter { margin-top: 1rem; }
.report-quantity-filter { grid-template-columns: minmax(14rem, 2fr) minmax(10rem, 1fr) minmax(9rem, 1fr) minmax(9rem, 1fr) auto; }
.report-cycle-filter { grid-template-columns: minmax(18rem, 1fr) auto; }
@media (max-width: 58rem) {
    .report-hub-grid, .report-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .report-quantity-filter { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 34rem) {
    .report-hub-grid, .report-stat-grid, .report-quantity-filter, .report-cycle-filter { grid-template-columns: 1fr; }
    .report-export-actions { align-items: stretch; flex-direction: column; }
    .report-export-actions form, .report-export-actions button { width: 100%; }
}

/* Section 9 audit log and compliance activity */
.audit-filter { grid-template-columns: minmax(12rem, 1.5fr) repeat(3, minmax(10rem, 1fr)) repeat(2, minmax(9rem, .8fr)) auto; }
.audit-json { margin: .75rem 0 0; padding: 1rem; max-height: 32rem; overflow: auto; background: #f3f6f8; border: 1px solid var(--border); border-radius: .5rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.audit-user-agent { overflow-wrap: anywhere; }
.pagination { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin: 1rem 0; }
@media (max-width: 1050px) { .audit-filter { grid-template-columns: repeat(2, minmax(0, 1fr)); } .audit-filter > div:first-child { grid-column: 1 / -1; } }
@media (max-width: 680px) { .audit-filter { grid-template-columns: 1fr; } .audit-filter > div:first-child { grid-column: auto; } .pagination { align-items: flex-start; flex-direction: column; } }
