* { box-sizing: border-box; }

:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --brand: #1e3a8a;
    --brand-dark: #172554;
    --border: #e5e7eb;
    --success: #ecfdf5;
    --error: #fef2f2;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
}

.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--brand-dark);
    color: white;
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.brand {
    font-weight: 800;
    font-size: 1.25rem;
    line-height: 1.2;
}

nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

nav a, .logout {
    color: white;
    text-decoration: none;
    padding: 10px 12px;
    border-radius: 10px;
    opacity: .86;
}

nav a.active, nav a:hover, .logout:hover {
    background: rgba(255,255,255,.12);
    opacity: 1;
}

.logout {
    margin-top: auto;
}

.content {
    flex: 1;
    padding: 32px;
    max-width: 1280px;
}

h1 { margin-top: 0; font-size: 2rem; }
h2 { margin-top: 0; }
h3 { margin-bottom: 6px; }

.grid {
    display: grid;
    gap: 18px;
}

.cards {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 18px;
}

.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.card, .panel, .entry-card, .auth-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 22px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, .05);
}

.metric {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--brand);
}

.muted {
    color: var(--muted);
}

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

.stacked-form {
    display: grid;
    gap: 16px;
}

label {
    display: grid;
    gap: 6px;
    font-weight: 650;
}

input, textarea, select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 11px 12px;
    font: inherit;
    background: white;
}

textarea {
    min-height: 96px;
}

.full {
    grid-column: 1 / -1;
}

.checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 650;
}

.checkbox input {
    width: auto;
}

button, .button-link {
    display: inline-block;
    border: 0;
    background: var(--brand);
    color: white;
    padding: 12px 16px;
    border-radius: 12px;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
}

.button-link {
    margin: 4px 8px 4px 0;
}

button:hover, .button-link:hover {
    background: var(--brand-dark);
}

table {
    width: 100%;
    border-collapse: collapse;
    overflow: hidden;
}

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

th {
    color: var(--muted);
    font-size: .9rem;
}

.auth-body {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 24px;
}

.auth-card {
    width: min(420px, 100%);
}

.alert {
    padding: 12px;
    border-radius: 10px;
    margin: 12px 0;
}

.alert.error { background: var(--error); }
.alert.success { background: var(--success); }

@media (max-width: 900px) {
    .layout {
        display: block;
    }

    .sidebar {
        width: 100%;
        border-radius: 0 0 22px 22px;
    }

    nav {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .content {
        padding: 20px;
    }

    .cards, .two, .form-grid {
        grid-template-columns: 1fr;
    }
}


hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}

.responsive-table {
    overflow-x: auto;
}

.center {
    text-align: center;
}

.summary-output pre {
    white-space: pre-wrap;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    line-height: 1.45;
    margin: 0;
}


/* PWA and mobile-first refinements */

.ios-install {
    display: none;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #172554;
    padding: 12px 14px;
    border-radius: 14px;
    margin-bottom: 18px;
}

.quick-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin: 0 0 18px 0;
}

.quick-actions a {
    background: var(--brand);
    color: white;
    text-decoration: none;
    border-radius: 999px;
    padding: 10px 14px;
    font-weight: 800;
}

.attention-list {
    display: grid;
    gap: 10px;
}

.attention-item {
    display: grid;
    gap: 3px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    text-decoration: none;
    color: var(--text);
    background: #f8fafc;
}

.attention-item:hover {
    border-color: #93c5fd;
    background: #eff6ff;
}

.bottom-nav {
    display: none;
}

@media (max-width: 900px) {
    body {
        background: #f8fafc;
        padding-bottom: 76px;
    }

    .sidebar {
        display: none;
    }

    .content {
        padding: 18px 14px 92px;
    }

    h1 {
        font-size: 1.55rem;
        margin-bottom: 14px;
    }

    h2 {
        font-size: 1.2rem;
    }

    .card, .panel, .entry-card {
        border-radius: 16px;
        padding: 16px;
        box-shadow: 0 4px 18px rgba(15, 23, 42, .05);
    }

    .metric {
        font-size: 1.45rem;
    }

    .quick-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .quick-actions a {
        text-align: center;
        border-radius: 14px;
        padding: 13px 14px;
    }

    input, textarea, select {
        min-height: 44px;
        font-size: 16px;
    }

    button, .button-link {
        width: 100%;
        text-align: center;
        min-height: 46px;
    }

    table {
        min-width: 720px;
    }

    .bottom-nav {
        position: fixed;
        z-index: 50;
        left: 0;
        right: 0;
        bottom: 0;
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 0;
        padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
        background: rgba(255, 255, 255, .96);
        border-top: 1px solid var(--border);
        box-shadow: 0 -10px 30px rgba(15, 23, 42, .08);
        backdrop-filter: blur(10px);
    }

    .bottom-nav a {
        color: var(--muted);
        text-decoration: none;
        font-size: .78rem;
        font-weight: 800;
        text-align: center;
        padding: 9px 4px;
        border-radius: 12px;
    }

    .bottom-nav a.active {
        color: white;
        background: var(--brand);
    }

    .auth-body {
        align-items: start;
        padding-top: 40px;
    }
}

@media (display-mode: standalone) {
    .ios-install {
        display: none !important;
    }
}
