:root {
    --navy: #123c69;
    --blue: #2367a7;
    --green: #4f8a3a;
    --gold: #c6922d;
    --ink: #172330;
    --muted: #687587;
    --line: #dce4ec;
    --bg: #f4f7f9;
    --panel: #ffffff;
    --danger: #b73737;
    --shadow: 0 10px 30px rgba(18, 60, 105, .08);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    color: var(--ink);
    background: var(--bg);
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1.45;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { margin: 0; line-height: 1.15; }
h1 { color: var(--navy); font-size: clamp(1.75rem, 2.5vw, 2.45rem); }
h2 { color: var(--navy); font-size: 1.1rem; margin-bottom: 1rem; }
table { width: 100%; border-collapse: collapse; font-size: .94rem; }
th, td { padding: .85rem .7rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
small { color: var(--muted); }

.shell { display: grid; grid-template-columns: 280px 1fr; min-height: 100vh; }
.sidebar {
    background: var(--navy);
    color: white;
    display: flex;
    flex-direction: column;
    padding: 1.2rem;
    gap: 1rem;
}
.brand, .auth-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    color: inherit;
}
.brand:hover { text-decoration: none; }
.brand-with-logo {
    align-items: flex-start;
    flex-direction: column;
    gap: .65rem;
}
.sidebar-logo-card {
    display: inline-flex;
    align-items: center;
    width: 100%;
    max-width: 210px;
    padding: .45rem .55rem;
    background: white;
    border-radius: 6px;
}
.sidebar-logo {
    display: block;
    width: 100%;
    height: auto;
}
.brand-mark {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--green), #74a94f);
    color: white;
    font-weight: 800;
}
.brand small { display: block; color: #cbd7e3; }
.nav { display: grid; gap: .25rem; margin-top: 1rem; }
.nav a {
    color: #edf5ff;
    padding: .75rem .8rem;
    border-radius: 8px;
}
.nav a:hover { background: rgba(255,255,255,.1); text-decoration: none; }
.sidebar-user {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid rgba(255,255,255,.18);
    display: grid;
    gap: .25rem;
}
.sidebar-user small { color: #cbd7e3; }
.sidebar-user a { color: white; font-weight: 700; }
.main { padding: 2rem; min-width: 0; }

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1rem;
    background:
        linear-gradient(rgba(18,60,105,.85), rgba(18,60,105,.7)),
        url("https://images.unsplash.com/photo-1500530855697-b586d89ba3ee?auto=format&fit=crop&w=1800&q=80") center/cover;
}
.auth-card {
    width: min(520px, 100%);
    background: white;
    border-top: 6px solid var(--green);
    border-radius: 8px;
    padding: 2rem;
    box-shadow: var(--shadow);
}
.auth-card p { color: var(--muted); }
.auth-brand {
    display: block;
    color: var(--navy);
    margin-bottom: 1.2rem;
}
.auth-logo {
    display: block;
    width: min(300px, 100%);
    height: auto;
}
.auth-card h1 { margin-bottom: 1.25rem; }
.auth-card h1 + p { margin-top: -.5rem; margin-bottom: 1.25rem; }
.auth-brand-text {
    display: grid;
    gap: .18rem;
    min-width: 0;
    padding-top: .1rem;
}
.auth-brand-text strong {
    display: block;
    line-height: 1.22;
    font-size: 1.04rem;
}
.auth-subtitle {
    display: block;
    color: var(--muted);
    font-size: .9rem;
    font-weight: 700;
}

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.eyebrow {
    margin: 0 0 .25rem;
    color: var(--green);
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.panel, .stat {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}
.panel { padding: 1.25rem; margin-bottom: 1.25rem; overflow-x: auto; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .75rem; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1.25rem; }
.stat { padding: 1.1rem; border-top: 4px solid var(--green); }
.stat span { display: block; color: var(--muted); font-size: .82rem; text-transform: uppercase; font-weight: 700; }
.stat strong { display: block; margin-top: .25rem; color: var(--navy); font-size: 1.7rem; }

.form { display: grid; gap: 1rem; }
.grid-form { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; }
.span-2 { grid-column: span 2; }
label { display: grid; gap: .35rem; color: var(--ink); font-weight: 700; font-size: .9rem; }
input, select, textarea {
    width: 100%;
    border: 1px solid #cbd5df;
    border-radius: 8px;
    padding: .72rem .8rem;
    color: var(--ink);
    background: white;
    font: inherit;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
    outline: 3px solid rgba(35,103,167,.18);
    border-color: var(--blue);
}
.inline-form { grid-template-columns: 1fr auto auto; align-items: end; }
.filters { display: grid; grid-template-columns: 1fr 220px auto; gap: .75rem; margin-bottom: 1rem; }
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: .65rem 1rem;
    background: white;
    color: var(--navy);
    font-weight: 800;
    cursor: pointer;
}
.button:hover { text-decoration: none; border-color: var(--blue); }
.button.primary { background: var(--green); border-color: var(--green); color: white; }
.button.small { min-height: 34px; padding: .45rem .7rem; font-size: .82rem; }
.actions { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: .25rem .55rem;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 800;
    background: #edf2f7;
    color: #334155;
    white-space: nowrap;
}
.badge.blue { background: #d9ecff; color: #15548a; }
.badge.green { background: #e0f1dc; color: #2e6c25; }
.badge.amber { background: #fff1ce; color: #8a610d; }
.badge.red { background: #ffe0e0; color: #9f2a2a; }
.badge.purple { background: #eee4ff; color: #673ab0; }
.badge.muted { background: #eef1f5; color: #667085; }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(320px, .9fr); gap: 1.25rem; align-items: start; }
.details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; margin: 0 0 1rem; }
.details div { border-bottom: 1px solid var(--line); padding-bottom: .55rem; }
.details dt { color: var(--muted); font-size: .78rem; font-weight: 800; text-transform: uppercase; }
.details dd { margin: .15rem 0 0; }
.timeline, .file-list, .history-grid, .plain-list { display: grid; gap: .75rem; }
.timeline-item, .history-grid div, .file-list a {
    display: grid;
    gap: .25rem;
    padding: .8rem;
    border: 1px solid var(--line);
    border-left: 4px solid var(--blue);
    border-radius: 8px;
    background: #fbfdff;
}
.timeline-item.internal { border-left-color: var(--gold); background: #fffaf0; }
.timeline-item span, .history-grid span, .file-list span { color: var(--muted); font-size: .82rem; }
.timeline-item p, .history-grid p { margin: .25rem 0 0; }
.plain-list { padding-left: 1.1rem; }
.empty { color: var(--muted); margin: 0; }
.alert {
    margin-bottom: 1rem;
    padding: .85rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: white;
}
.alert.success { border-color: #b8deb2; background: #f0faee; color: #2e6c25; }
.alert.error { border-color: #f0b4b4; background: #fff0f0; color: #9f2a2a; }

@media (max-width: 900px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { position: static; }
    .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .main { padding: 1rem; }
    .stats, .detail-grid, .grid-form, .filters { grid-template-columns: 1fr; }
    .span-2 { grid-column: span 1; }
    .page-head { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 560px) {
    .auth-card { padding: 1.25rem; }
    .nav { grid-template-columns: 1fr; }
    .details { grid-template-columns: 1fr; }
    th:nth-child(5), td:nth-child(5), th:nth-child(6), td:nth-child(6) { display: none; }
}
