:root {
    --bg: #f4f6f8;
    --panel: #ffffff;
    --line: #d9e0e7;
    --text: #18212f;
    --muted: #617083;
    --primary: #116466;
    --primary-dark: #0b4547;
    --warning: #b7791f;
    --danger: #b42318;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
}

a {
    color: inherit;
    text-decoration: none;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 240px 1fr;
    transition: grid-template-columns 0.18s ease;
}

.auth-shell {
    display: block;
}

body.sidebar-collapsed .app-shell {
    grid-template-columns: 0 1fr;
}

.sidebar {
    background: #15202b;
    color: #ffffff;
    padding: 18px 14px;
    overflow: hidden;
    transition: padding 0.18s ease;
}

body.sidebar-collapsed .sidebar {
    padding-left: 0;
    padding-right: 0;
}

.brand {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 24px;
}

.nav-link {
    display: block;
    padding: 10px 12px;
    border-radius: 6px;
    color: #d7dee7;
    margin-bottom: 4px;
}

.nav-link.active,
.nav-link:hover {
    background: #223242;
    color: #ffffff;
}

.main {
    min-width: 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    height: 56px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.sidebar-toggle {
    width: 36px;
    height: 36px;
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #ffffff;
    cursor: pointer;
    padding: 0 9px;
}

.sidebar-toggle span {
    display: block;
    width: 16px;
    height: 2px;
    background: var(--text);
}

.content {
    padding: 20px;
}

.page-title {
    margin: 0 0 4px;
    font-size: 22px;
}

.page-subtitle {
    margin: 0 0 18px;
    color: var(--muted);
}

.page-actions {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.toolbar-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #ffffff;
    color: var(--text);
    font-weight: 700;
    cursor: pointer;
}

.btn-primary {
    border-color: var(--primary);
    background: var(--primary);
    color: #ffffff;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.btn-small {
    min-height: 28px;
    padding: 4px 8px;
    font-size: 12px;
}

.alert {
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 12px;
    border: 1px solid var(--line);
}

.alert-success {
    background: #e5f6ed;
    border-color: #b7e3c7;
    color: #17633a;
}

.alert-danger {
    background: #ffe9e6;
    border-color: #ffc9c2;
    color: var(--danger);
}

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

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
}

.kpi-label {
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 8px;
}

.kpi-value {
    font-size: 26px;
    font-weight: 700;
}

.kpi-text {
    font-size: 18px;
}

.table-wrap {
    max-height: 420px;
    overflow: auto;
    position: relative;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--panel);
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 10px;
    text-align: left;
    white-space: nowrap;
}

th {
    background: #edf2f7;
    font-size: 12px;
    text-transform: uppercase;
    color: #425266;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 1px 0 var(--line), 0 2px 4px rgba(15, 23, 42, 0.08);
}

.badge {
    display: inline-block;
    min-width: 44px;
    text-align: center;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.badge-day {
    background: #d9f0ea;
    color: #0b5d4d;
}

.badge-night {
    background: #dde7ff;
    color: #233f8f;
}

.badge-vacant {
    background: #ffe4df;
    color: var(--danger);
}

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

.text-ok {
    color: var(--primary);
    font-weight: 700;
}

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

.filter-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(120px, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

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

.form-field label {
    font-weight: 700;
    color: #334155;
}

.form-field label span {
    color: var(--danger);
}

.form-field input,
.form-field select {
    width: 100%;
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px 10px;
    font: inherit;
    background: #ffffff;
}

.field-error {
    color: var(--danger);
    font-size: 12px;
}

.form-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    border-top: 1px solid var(--line);
    padding-top: 14px;
}

.filter-actions {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.check-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.check-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #ffffff;
}

.print-header {
    margin-bottom: 14px;
}

.print-header h1 {
    margin: 0 0 4px;
    font-size: 20px;
}

.print-header p {
    margin: 0;
    color: var(--muted);
}

.section-title {
    margin: 0 0 10px;
    font-size: 16px;
}

.daily-section {
    margin-bottom: 14px;
}

.calendar-card {
    padding: 0;
}

.calendar-table th,
.calendar-table td {
    white-space: normal;
    min-width: 110px;
    vertical-align: top;
}

.calendar-table th:first-child,
.calendar-table td:first-child,
.calendar-table th:nth-child(2),
.calendar-table td:nth-child(2),
.calendar-table th:nth-child(3),
.calendar-table td:nth-child(3) {
    min-width: 90px;
    white-space: nowrap;
}

.calendar-empty {
    color: var(--muted);
    background: #f8fafc;
}

.log-pre {
    margin: 0;
    white-space: pre-wrap;
    font-family: Consolas, "Courier New", monospace;
    font-size: 12px;
}

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    width: min(100%, 380px);
}

.login-actions {
    justify-content: stretch;
}

.login-actions .btn {
    width: 100%;
}

@media (max-width: 900px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        display: none;
    }

    body.sidebar-collapsed .app-shell {
        grid-template-columns: 1fr;
    }

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

}

@media (max-width: 560px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .topbar {
        padding: 0 12px;
    }

    .content {
        padding: 12px;
    }

    .page-actions,
    .toolbar-actions,
    .form-actions {
        align-items: stretch;
        flex-direction: column;
    }

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

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

    .table-wrap {
        max-height: 360px;
        overflow-x: auto;
    }
}

@media print {
    body {
        background: #ffffff;
    }

    .sidebar,
    .topbar,
    .no-print {
        display: none !important;
    }

    .app-shell {
        display: block;
    }

    .content {
        padding: 0;
    }

    .card {
        border: 0;
        padding: 0;
    }

    th,
    td {
        border: 1px solid #333333;
        padding: 6px;
    }

    th {
        background: #eeeeee !important;
        color: #000000;
    }
}
