:root {
    --navy: #12243d;
    --navy-2: #1a3558;
    --navy-3: #25476f;
    --blue: #2474e5;
    --blue-soft: #eaf3ff;
    --ink: #182230;
    --muted: #667085;
    --line: #e5e9f0;
    --surface: #ffffff;
    --canvas: #f4f6f9;
    --success: #138a5b;
    --success-soft: #e8f7f0;
    --warning: #b25c00;
    --warning-soft: #fff3df;
    --danger: #c63737;
    --danger-soft: #feeeee;
    --radius: 14px;
    --shadow: 0 8px 26px rgba(18, 36, 61, .07);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background: var(--canvas);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
    line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 252px 1fr; }
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    width: 252px;
    padding: 24px 16px;
    color: #dbe8f8;
    background: linear-gradient(175deg, var(--navy), #0c192c 78%);
    overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 24px; }
.brand-mark {
    display: grid;
    width: 40px;
    height: 40px;
    place-items: center;
    border-radius: 11px;
    color: white;
    background: var(--blue);
    font-weight: 800;
    letter-spacing: -.5px;
}
.brand strong { display: block; color: white; font-size: 16px; line-height: 1.1; }
.brand small { color: #8fa7c4; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.nav-section { margin-top: 12px; }
.nav-label { margin: 0 10px 7px; color: #728aa8; font-size: 10px; font-weight: 700; letter-spacing: .11em; text-transform: uppercase; }
.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 3px 0;
    padding: 10px 12px;
    border-radius: 10px;
    color: #aec0d5;
    font-weight: 600;
    transition: .15s ease;
}
.nav-link:hover { color: white; background: rgba(255, 255, 255, .07); }
.nav-link.active { color: white; background: var(--blue); box-shadow: 0 7px 18px rgba(36, 116, 229, .25); }
.nav-icon { width: 20px; text-align: center; font-size: 17px; }
.sidebar-footer { position: absolute; right: 16px; bottom: 20px; left: 16px; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.08); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px; }
.avatar { display: grid; width: 36px; height: 36px; flex: 0 0 auto; place-items: center; border-radius: 50%; color: white; background: var(--navy-3); font-weight: 700; }
.user-chip strong { display: block; color: white; font-size: 13px; }
.user-chip small { color: #8fa7c4; font-size: 11px; }
.main { grid-column: 2; min-width: 0; }
.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    min-height: 68px;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 32px;
    border-bottom: 1px solid var(--line);
    background: rgba(255,255,255,.94);
    backdrop-filter: blur(12px);
}
.topbar-title { font-size: 14px; font-weight: 700; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.content { width: min(1420px, 100%); margin: 0 auto; padding: 30px 32px 52px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.page-head h1 { margin: 0; color: var(--navy); font-size: clamp(24px, 3vw, 32px); line-height: 1.2; letter-spacing: -.025em; }
.page-head p { margin: 6px 0 0; color: var(--muted); }
.page-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; }

.btn {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 15px;
    border: 1px solid transparent;
    border-radius: 9px;
    color: white;
    background: var(--blue);
    font-weight: 700;
    line-height: 1.2;
}
.btn:hover { filter: brightness(.96); }
.btn-secondary { color: var(--navy); border-color: #d6deea; background: white; }
.btn-danger { color: var(--danger); border-color: #f4cccc; background: white; }
.btn-warning { color: #7a4300; border-color: #f0ce98; background: var(--warning-soft); }
.btn-sm { min-height: 34px; padding: 7px 11px; font-size: 13px; }
.btn-block { width: 100%; }
.link { color: var(--blue); font-weight: 700; }
.link:hover { text-decoration: underline; }

.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.card-header h2, .card-header h3 { margin: 0; color: var(--navy); font-size: 16px; }
.card-body { padding: 20px; }
.card + .card { margin-top: 18px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
.metric { position: relative; overflow: hidden; padding: 20px; }
.metric:after { position: absolute; top: -22px; right: -20px; width: 88px; height: 88px; border-radius: 50%; background: var(--blue-soft); content: ""; }
.metric-label { color: var(--muted); font-size: 13px; font-weight: 650; }
.metric-value { margin-top: 7px; color: var(--navy); font-size: 31px; font-weight: 800; line-height: 1; }
.metric-note { margin-top: 8px; color: var(--muted); font-size: 12px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(300px, 1fr); gap: 18px; }
.grid-2 > * { min-width: 0; }
.details-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; }
.detail { min-height: 74px; padding: 13px 16px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.detail:nth-child(3n) { border-right: 0; }
.detail-label { display: block; margin-bottom: 4px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.detail-value { color: var(--ink); font-weight: 650; overflow-wrap: anywhere; }

.table-wrap { width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { padding: 11px 16px; color: var(--muted); background: #fafbfc; font-size: 11px; font-weight: 750; letter-spacing: .045em; text-align: left; text-transform: uppercase; white-space: nowrap; }
.table td { padding: 14px 16px; border-top: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:hover { background: #fbfcfe; }
.table-primary { color: var(--navy); font-weight: 750; }
.table-secondary { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.nowrap { white-space: nowrap; }
.empty { padding: 42px 24px; color: var(--muted); text-align: center; }
.empty strong { display: block; margin-bottom: 5px; color: var(--navy); font-size: 16px; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: 999px; font-size: 11px; font-weight: 750; white-space: nowrap; }
.badge:before { width: 6px; height: 6px; border-radius: 50%; background: currentColor; content: ""; }
.badge-success { color: var(--success); background: var(--success-soft); }
.badge-info, .badge-primary { color: #1764c3; background: var(--blue-soft); }
.badge-warning { color: var(--warning); background: var(--warning-soft); }
.badge-danger { color: var(--danger); background: var(--danger-soft); }
.badge-neutral { color: #526072; background: #edf0f4; }
.badge-muted { color: #7b8490; background: #f1f2f4; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; padding: 16px; }
.filters .input { min-width: 220px; }
.filters .select { min-width: 180px; }
.field { margin-bottom: 17px; }
.field label, .field-label { display: block; margin-bottom: 6px; color: #344054; font-size: 13px; font-weight: 700; }
.required:after { margin-left: 3px; color: var(--danger); content: "*"; }
.input, .select, .textarea {
    width: 100%;
    min-height: 43px;
    padding: 10px 12px;
    border: 1px solid #cfd7e3;
    border-radius: 9px;
    outline: none;
    color: var(--ink);
    background: white;
    transition: border-color .15s, box-shadow .15s;
}
.textarea { min-height: 100px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(36,116,229,.12); }
.field-hint { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
.field-error { display: block; margin-top: 5px; color: var(--danger); font-size: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 6px; }
.checkbox-row { display: flex; flex-wrap: wrap; gap: 10px; }
.check-card { display: flex; min-height: 48px; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fbfcfe; }
.check-card input { width: 17px; height: 17px; accent-color: var(--blue); }
.checks-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.section-title { margin: 5px 0 15px; padding-bottom: 10px; border-bottom: 1px solid var(--line); color: var(--navy); font-size: 15px; }
.section-title:not(:first-child) { margin-top: 25px; }

.alert { margin-bottom: 18px; padding: 13px 16px; border: 1px solid; border-radius: 10px; font-weight: 600; }
.alert-success { color: #09633f; border-color: #b9e7d2; background: var(--success-soft); }
.alert-danger { color: #982c2c; border-color: #f1c2c2; background: var(--danger-soft); }
.alert-warning { color: #795019; border-color: #efd6a9; background: var(--warning-soft); }
.error-list { margin: 6px 0 0; padding-left: 18px; font-weight: 500; }

.timeline { position: relative; padding-left: 24px; }
.timeline:before { position: absolute; top: 9px; bottom: 9px; left: 7px; width: 2px; background: var(--line); content: ""; }
.timeline-item { position: relative; padding: 0 0 20px 12px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot { position: absolute; top: 6px; left: -22px; width: 12px; height: 12px; border: 3px solid white; border-radius: 50%; background: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
.timeline-title { color: var(--navy); font-weight: 750; }
.timeline-meta { color: var(--muted); font-size: 12px; }
.inspection-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.inspection-result { padding: 9px 10px; border-radius: 8px; background: #f6f8fb; font-size: 12px; }
.inspection-result.ok { color: var(--success); background: var(--success-soft); }
.inspection-result.fail { color: var(--danger); background: var(--danger-soft); }
.photo-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 9px; margin-top: 14px; }
.photo-grid img { width: 100%; height: 110px; object-fit: cover; border-radius: 9px; border: 1px solid var(--line); }

.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.pagination-links { display: flex; gap: 5px; }
.pagination a, .pagination span.page { display: grid; min-width: 32px; height: 32px; place-items: center; padding: 0 7px; border: 1px solid var(--line); border-radius: 8px; background: white; }
.pagination span.current { color: white; border-color: var(--blue); background: var(--blue); }
.pagination span.disabled { opacity: .45; }

.login-page { display: grid; min-height: 100vh; grid-template-columns: minmax(380px, .85fr) 1.15fr; background: white; }
.login-panel { display: flex; align-items: center; justify-content: center; padding: 40px; }
.login-box { width: min(420px, 100%); }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 45px; }
.login-brand strong { color: var(--navy); font-size: 18px; }
.login-box h1 { margin: 0; color: var(--navy); font-size: 32px; letter-spacing: -.03em; }
.login-box > p { margin: 9px 0 30px; color: var(--muted); }
.login-visual { position: relative; display: flex; overflow: hidden; align-items: flex-end; padding: 64px; color: white; background: linear-gradient(145deg, #142b49, #1e5da2); }
.login-visual:before, .login-visual:after { position: absolute; border: 1px solid rgba(255,255,255,.12); border-radius: 50%; content: ""; }
.login-visual:before { top: -180px; right: -130px; width: 520px; height: 520px; }
.login-visual:after { top: -70px; right: -40px; width: 310px; height: 310px; }
.visual-copy { position: relative; z-index: 1; max-width: 560px; }
.visual-copy .eyebrow { color: #9ecaff; font-size: 12px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.visual-copy h2 { margin: 12px 0 14px; font-size: clamp(32px, 4vw, 53px); line-height: 1.06; letter-spacing: -.035em; }
.visual-copy p { max-width: 480px; margin: 0; color: #c5d8ee; font-size: 17px; }
.remember { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.remember input { accent-color: var(--blue); }
.mobile-menu { display: none; }
.desktop-hide { display: none; }
.inline-form { display: inline; }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--muted); }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 14px; }

@media (max-width: 1050px) {
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .details-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .detail:nth-child(3n) { border-right: 1px solid var(--line); }
    .detail:nth-child(2n) { border-right: 0; }
    .checks-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .inspection-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 780px) {
    .app-shell { display: block; }
    .sidebar { position: static; width: auto; padding: 14px 16px; overflow: visible; }
    .brand { padding: 0; }
    .sidebar .nav-section, .sidebar-footer { display: none; }
    .sidebar.open .nav-section { display: block; }
    .sidebar.open .sidebar-footer { position: static; display: block; margin-top: 14px; }
    .mobile-menu { display: inline-flex; margin-left: auto; color: white; border: 1px solid rgba(255,255,255,.18); background: transparent; }
    .main { display: block; }
    .topbar { min-height: 55px; padding: 0 18px; }
    .content { padding: 22px 16px 42px; }
    .page-head { align-items: stretch; flex-direction: column; }
    .page-actions { justify-content: flex-start; }
    .grid-2 { grid-template-columns: 1fr; }
    .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
    .span-2, .span-3 { grid-column: span 1; }
    .login-page { grid-template-columns: 1fr; }
    .login-visual { display: none; }
    .login-panel { padding: 26px; }
    .desktop-hide { display: inline-flex; }
}

@media (max-width: 520px) {
    .metric-grid, .details-grid, .checks-grid, .inspection-grid { grid-template-columns: 1fr; }
    .detail { border-right: 0 !important; }
    .filters { align-items: stretch; flex-direction: column; }
    .filters .input, .filters .select { min-width: 0; }
    .btn { width: 100%; }
    .topbar .btn { width: auto; }
    .form-actions { flex-direction: column-reverse; }
    .photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .pagination > span:first-child { display: none; }
}
