:root {
    color-scheme: light;
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-muted: #f1f5f9;
    --border: #dbe3ee;
    --text: #0f172a;
    --text-muted: #475569;
    --primary: #0f4aa3;
    --primary-hover: #0a3a80;
    --danger: #b42318;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
    line-height: 1.45;
}

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

a:hover {
    text-decoration: underline;
}

.site-header {
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.site-nav {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.nav-group {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.nav-brand {
    font-weight: 700;
    color: var(--text);
}

.nav-link-active {
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 0.15rem;
}

.page {
    max-width: 1100px;
    margin: 1.25rem auto 2rem;
    padding: 0 1rem;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
}

.stack {
    display: grid;
    gap: 1rem;
}

.inline-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

.justify-between {
    justify-content: space-between;
}

.m-0 {
    margin: 0;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.btn,
button,
input[type="submit"] {
    border: 1px solid var(--primary);
    background: var(--primary);
    color: #fff;
    border-radius: 8px;
    font-size: 0.92rem;
    font-weight: 600;
    padding: 0.5rem 0.85rem;
    cursor: pointer;
}

.btn:hover,
button:hover,
input[type="submit"]:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    text-decoration: none;
}

.btn-secondary {
    border-color: var(--border);
    background: var(--surface);
    color: var(--text);
}

.btn-secondary:hover {
    background: var(--surface-muted);
    border-color: #bdccdf;
}

.btn-danger {
    border-color: var(--danger);
    background: var(--danger);
}

form p {
    margin: 0 0 0.8rem;
}

label {
    display: inline-flex;
    flex-direction: column;
    gap: 0.35rem;
    color: var(--text-muted);
    font-size: 0.92rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="datetime-local"],
select,
textarea {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.48rem 0.6rem;
    font-size: 0.94rem;
    color: var(--text);
    background: #fff;
    min-width: 180px;
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid #bfdbfe;
    outline-offset: 0;
    border-color: #93c5fd;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
}

.list-clean {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.5rem;
}

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    min-width: 640px;
    border-collapse: collapse;
    background: var(--surface);
}

th,
td {
    border-bottom: 1px solid var(--border);
    text-align: left;
    padding: 0.55rem 0.5rem;
    font-size: 0.92rem;
}

th {
    color: var(--text-muted);
    font-weight: 600;
}

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

.pill {
    display: inline-block;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.2rem 0.55rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    background: var(--surface-muted);
}

.pill-active {
    border-color: #bbf7d0;
    color: #166534;
    background: #f0fdf4;
}

.pill-inactive {
    border-color: #fecaca;
    color: #991b1b;
    background: #fef2f2;
}

.warning-note {
    border: 1px solid #fecaca;
    background: #fef2f2;
    color: #7f1d1d;
    border-radius: 8px;
    padding: 0.55rem 0.7rem;
    font-size: 0.9rem;
}

.warning-note-top {
    margin-top: 0.45rem;
}

.section-title {
    margin: 0 0 0.75rem;
}

.pagination {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-top: 0.7rem;
}

.auth-card {
    max-width: 460px;
}

.auth-field {
    display: grid;
    gap: 0.35rem;
    margin-bottom: 0.8rem;
}

.field-errors {
    color: var(--danger);
    font-size: 0.85rem;
}

.password-toggle-row {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    margin-top: 0.2rem;
}

.password-toggle-row input[type="checkbox"] {
    margin: 0;
}

.password-toggle-row label {
    display: inline;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.message-list {
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
    display: grid;
    gap: 0.5rem;
}

.message-list li {
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 8px;
    padding: 0.5rem 0.7rem;
}

.site-footer {
    border-top: 1px solid var(--border);
    background: var(--surface);
    margin-top: 1.5rem;
}

.site-footer-note {
    margin: 0;
    padding: 0.9rem 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.home-hero {
    display: grid;
    gap: 0.9rem;
}

.home-hero-image-wrap {
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    background: var(--surface-muted);
}

.home-hero-image {
    width: 100%;
    display: block;
    height: auto;
    max-height: 420px;
    object-fit: cover;
    object-position: top center;
}

.home-hero-copy {
    margin: 0;
    color: var(--text-muted);
    max-width: 80ch;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.55rem 0.9rem;
}

@media (max-width: 900px) {
    .site-nav {
        flex-direction: column;
        align-items: stretch;
        gap: 0.7rem;
    }

    .nav-group {
        flex-wrap: wrap;
        gap: 0.6rem;
    }

    .page {
        margin-top: 1rem;
        padding: 0 0.8rem;
    }

    .card {
        padding: 0.85rem;
    }

    .inline-row.justify-between {
        justify-content: flex-start;
    }

    .pagination {
        flex-wrap: wrap;
    }

    .home-hero-image {
        max-height: 360px;
    }
}

@media (max-width: 640px) {
    .site-nav {
        padding: 0.65rem 0.75rem;
    }

    .nav-group {
        width: 100%;
    }

    .site-nav .nav-group:last-child {
        justify-content: flex-start;
    }

    .site-nav .nav-group:last-child .muted,
    .site-nav .nav-group:last-child .pill {
        width: auto;
    }

    .site-nav .nav-group:last-child form {
        width: 100%;
    }

    .site-nav .nav-group:last-child form button {
        width: 100%;
    }

    .page {
        padding: 0 0.65rem;
    }

    .card {
        border-radius: 8px;
        padding: 0.75rem;
    }

    .toolbar {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr;
    }

    .toolbar .btn {
        width: 100%;
        text-align: center;
    }

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

    label {
        width: 100%;
    }

    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="datetime-local"],
    select,
    textarea {
        min-width: 0;
        width: 100%;
    }

    .auth-card {
        max-width: none;
        width: 100%;
    }

    .inline-row {
        width: 100%;
    }

    .inline-row > form {
        width: 100%;
    }

    .inline-row > form button,
    .inline-row > a.btn,
    .inline-row > a.btn-secondary {
        width: 100%;
        text-align: center;
    }

    th,
    td {
        padding: 0.5rem 0.45rem;
    }

    .home-hero-image {
        max-height: 280px;
    }

    .home-hero-copy {
        max-width: none;
    }

    .site-footer-note {
        padding: 0.8rem 0;
        font-size: 0.8rem;
    }
}