:root {
    --color-primary: #1F4E79;
    --color-success: #2e7d32;
    --color-danger: #c62828;
    --color-secondary: #5f6f7e;
    --color-muted: #595959;
    --color-bg: #f4f8fb;
    --color-card: #ffffff;
    --color-border: #d4dde6;
    --color-row-alt: #f5f9fd;
    --color-weekend: #f2f2f2;
    --shadow-soft: 0 10px 30px rgba(31, 78, 121, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, Arial, sans-serif;
    background: var(--color-bg);
    color: #111;
}

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

a:hover {
    text-decoration: underline;
}

img {
    max-width: 100%;
    display: block;
}

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

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 280px;
    background: #fff;
    border-right: 1px solid var(--color-border);
    padding: 1.25rem 1rem;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 20;
    overflow-y: auto;
}

.sidebar.is-open {
    transform: translateX(0);
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.sidebar__version {
    margin-top: 0.2rem;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--color-secondary);
    letter-spacing: 0.02em;
}

.sidebar__logo,
.auth-logo {
    width: 56px;
    height: 56px;
    object-fit: contain;
    border-radius: 12px;
    background: #eef4f9;
    padding: 0.35rem;
}

.sidebar__nav {
    display: grid;
    gap: 0.45rem;
}

.sidebar__section {
    display: grid;
    gap: 0.3rem;
}

.sidebar__section + .sidebar__section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #edf2f7;
}

.sidebar__section-title {
    display: block;
    padding: 0.35rem 0.85rem;
    color: #6d7781;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.78rem;
    font-weight: 700;
}

.sidebar__section-link {
    border-radius: 10px;
}

.sidebar__section-link:hover,
.sidebar__section-link.is-active {
    background: #ebf2f9;
    color: var(--color-primary);
    text-decoration: none;
}

.sidebar__link {
    display: block;
    padding: 0.8rem 0.9rem;
    color: #26323d;
    border-radius: 14px;
    font-weight: 600;
    transition: background-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.sidebar__accordion {
    display: block;
    border-radius: 16px;
    transition: background-color 0.18s ease, box-shadow 0.18s ease;
}

.sidebar__accordion[open] {
    background: linear-gradient(180deg, rgba(241, 247, 252, 0.9) 0%, rgba(255, 255, 255, 0.95) 100%);
    box-shadow: inset 0 0 0 1px #edf3f8;
}

.sidebar__accordion + .sidebar__accordion {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid #dbe6ef;
}

.sidebar__accordion-summary {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.8rem 0.9rem;
    border-radius: 14px;
    border: 0;
    background: transparent;
    font-weight: 700;
    color: #26323d;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.18s ease, color 0.18s ease;
    text-align: left;
}

.sidebar__accordion-summary::-webkit-details-marker {
    display: none;
}

.sidebar__accordion-summary::marker {
    content: "";
}

.sidebar__accordion-label {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    min-width: 0;
    gap: 0.5rem;
    flex: 1 1 auto;
}

.sidebar__accordion-title-text {
    display: inline-flex;
    align-items: center;
    min-width: 0;
}

.sidebar__accordion-summary:hover,
.sidebar__accordion[open] > .sidebar__accordion-summary {
    background: #ebf2f9;
    color: var(--color-primary);
}

.sidebar__accordion-icon {
    width: 1.5rem;
    height: 1.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: #edf3f8;
    color: var(--color-primary);
    font-size: 0.78rem;
    line-height: 1;
    transition: transform 0.2s ease;
    flex: 0 0 auto;
}

.sidebar__accordion[open] .sidebar__accordion-icon {
    transform: rotate(180deg);
}

.sidebar__submenu {
    display: grid;
    gap: 0.35rem;
    margin: 0.25rem 0 0.2rem 1rem;
    padding: 0.55rem 0 0.25rem 0.95rem;
    border-left: 1px solid #dbe6ef;
}

.sidebar__sublink {
    display: block;
    margin-left: 0;
    padding: 0.6rem 0.8rem;
    color: #2f3a45;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.94rem;
    position: relative;
}

.sidebar__sublink::before {
    content: "";
    position: absolute;
    left: -1.18rem;
    top: 50%;
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 999px;
    background: #b3c8da;
    transform: translateY(-50%);
}

.sidebar__link:hover,
.sidebar__link.is-active,
.sidebar__sublink:hover,
.sidebar__sublink.is-active {
    background: #ebf2f9;
    color: var(--color-primary);
    text-decoration: none;
}

.sidebar__link:hover,
.sidebar__accordion-summary:hover,
.sidebar__sublink:hover {
    transform: translateX(2px);
}

.sidebar__sublink.is-active::before,
.sidebar__sublink:hover::before {
    background: var(--color-primary);
}

.main-panel {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(244, 248, 251, 0.96);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1rem 0.75rem;
    border-bottom: 1px solid rgba(212, 221, 230, 0.75);
}

.page-title,
.card h2,
.card h3 {
    margin: 0 0 0.35rem;
}

.content {
    padding: 1rem;
    display: grid;
    gap: 1rem;
}

.footer {
    padding: 1rem;
}

.card {
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: 20px;
    padding: 1rem;
    box-shadow: var(--shadow-soft);
}

.form-card {
    max-width: 860px;
}

.section-header,
.card-header,
.button-row,
.inline-form,
.logout-form,
.detail-list,
.alert-list,
.legend {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.section-header,
.card-header {
    justify-content: space-between;
}

.wrap {
    flex-wrap: wrap;
}

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

.form-label {
    display: grid;
    gap: 0.45rem;
    font-weight: 600;
}

.compact-label {
    min-width: 220px;
}

.form-input,
textarea,
select,
button {
    font: inherit;
}

.form-input,
textarea,
select {
    width: 100%;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 0.8rem 0.9rem;
    background: #fff;
}

.form-input:focus,
textarea:focus,
select:focus {
    outline: 2px solid rgba(31, 78, 121, 0.15);
    border-color: var(--color-primary);
}

.small-input {
    max-width: 120px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    border: 0;
    border-radius: 12px;
    padding: 0.85rem 1.15rem;
    cursor: pointer;
    font-weight: 700;
    text-decoration: none;
}

.button:hover {
    text-decoration: none;
    filter: brightness(0.96);
}

.button-block {
    width: 100%;
}

.button-large {
    min-height: 60px;
    font-size: 1.05rem;
}

.button-small {
    padding: 0.55rem 0.8rem;
    font-size: 0.9rem;
}

.button-primary {
    background: var(--color-primary);
    color: #fff;
}

.button-success {
    background: var(--color-success);
    color: #fff;
}

.button-danger {
    background: var(--color-danger);
    color: #fff;
}

.button-secondary {
    background: #e9eef3;
    color: #243446;
}

.alert {
    border-radius: 14px;
    padding: 0.9rem 1rem;
    border: 1px solid transparent;
}

.alert-success {
    background: #edf8ef;
    border-color: #b8dfbf;
    color: #1f5f26;
}

.alert-danger {
    background: #fff0f0;
    border-color: #efb9b9;
    color: #8e1f1f;
}

.alert-warning {
    background: #fff8e8;
    border-color: #f0d597;
    color: #8a5a00;
}

.compact-alert {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.75rem;
}

.form-error {
    color: var(--color-danger);
    font-size: 0.9rem;
    font-weight: 500;
}

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

.top-gap {
    margin-top: 1rem;
}

.bottom-gap {
    margin-bottom: 1rem;
}

.page-grid {
    display: grid;
    gap: 1rem;
}

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

.stat-card {
    background: linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    padding: 1rem;
    display: grid;
    gap: 0.35rem;
}

.stat-card strong,
.hero-number {
    font-size: 1.9rem;
    line-height: 1;
    color: var(--color-primary);
}

.hero-number {
    margin: 0.75rem 0;
}

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

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 640px;
}

th,
td {
    padding: 0.8rem 0.9rem;
    border-bottom: 1px solid var(--color-border);
    text-align: left;
    vertical-align: top;
}

th {
    background: #eef4f9;
    color: var(--color-primary);
    font-size: 0.92rem;
}

tbody tr:nth-child(odd) {
    background: var(--color-row-alt);
}

tbody tr:nth-child(even) {
    background: #fff;
}

tbody tr:hover {
    background: #eaf3fb;
}

tbody tr.hours-row-non-working td {
    background: #ffd6d6 !important;
    color: #101010;
    font-weight: 600;
}

.hours-summary {
    margin-top: 1rem;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    background: #f8fbff;
    padding: 0.9rem 1rem;
    display: grid;
    gap: 0.4rem;
}

.status-pill {
    display: inline-flex;
    border-radius: 999px;
    padding: 0.35rem 0.7rem;
    font-size: 0.85rem;
    font-weight: 700;
}

.status-pill.is-success {
    background: #e4f3e6;
    color: #1f5f26;
}

.status-pill.is-muted {
    background: #f0f0f0;
    color: #555;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.password-hints {
    display: grid;
    gap: 0.25rem;
    padding: 0.8rem 0.9rem;
    background: #f6f9fc;
    border: 1px dashed var(--color-border);
    border-radius: 12px;
    color: var(--color-muted);
    font-size: 0.92rem;
}

.password-hints div.is-valid {
    color: var(--color-success);
    font-weight: 700;
}

.hamburger {
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 12px;
    background: #fff;
    box-shadow: var(--shadow-soft);
    cursor: pointer;
}

.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.2rem;
    background: radial-gradient(circle at top left, rgba(31, 78, 121, 0.18), transparent 35%), #f4f8fb;
}

.auth-card {
    width: min(100%, 460px);
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: 24px;
    padding: 1.5rem;
    box-shadow: var(--shadow-soft);
}

.auth-brand {
    text-align: center;
    display: grid;
    justify-items: center;
    gap: 0.65rem;
    margin-bottom: 1.25rem;
}

.auth-links {
    margin-top: 1rem;
}

.rcp-widget {
    display: grid;
    gap: 1rem;
}

.calendar-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr;
}

.calendar-month {
    padding: 0.85rem;
}

@media (min-width: 900px) {
    .calendar-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1280px) {
    .calendar-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.calendar-weekdays,
.calendar-week {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.25rem;
}

.calendar-day {
    min-height: 76px;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 0.35rem;
    background: #fff;
    font-size: 0.8rem;
}

.calendar-day strong {
    display: block;
    margin-bottom: 0.25rem;
}

.calendar-day.is-weekend {
    background: var(--color-weekend);
}

.calendar-day.is-empty {
    visibility: hidden;
}

.holiday-national { background: #fdeaea; }
.holiday-church { background: #e7f0ff; }
.holiday-company { background: #edf8ef; }
.holiday-saturday-work { background: #fff3e0; }
.holiday-day-off-for-saturday { background: #f0e7ff; }

.dashboard-calendar-card {
    overflow: hidden;
}

.dashboard-calendar-grid {
    margin-top: 0.5rem;
}

.dashboard-calendar-month {
    padding: 0.7rem;
}

.dashboard-calendar-month h3 {
    margin: 0 0 0.6rem;
    font-size: 1rem;
}

.dashboard-calendar-day {
    min-height: 58px;
    padding: 0.25rem;
    font-size: 0.72rem;
}

.dashboard-calendar-day strong {
    margin-bottom: 0.15rem;
}

.dashboard-calendar-day small {
    display: block;
    line-height: 1.15;
}

.dashboard-calendar-day.is-today {
    border-color: var(--color-primary);
    box-shadow: inset 0 0 0 2px var(--color-primary);
    background-image: linear-gradient(180deg, rgba(31, 78, 121, 0.08), rgba(31, 78, 121, 0.02));
}

.dashboard-calendar-legend-today {
    background: #fff;
    border: 2px solid var(--color-primary);
    color: var(--color-primary);
}

.calendar-saturday-row.is-configured {
    background: #fffaf0;
}

.calendar-saturday-more {
    margin-top: 1rem;
    border: 1px solid var(--color-border);
    border-radius: 16px;
    background: #fbfdff;
    overflow: hidden;
}

.calendar-saturday-more__summary {
    padding: 0.95rem 1rem;
    font-weight: 700;
    color: var(--color-primary);
    cursor: pointer;
    list-style: none;
}

.calendar-saturday-more__summary::-webkit-details-marker {
    display: none;
}

.calendar-saturday-more__summary::marker {
    content: "";
}

.calendar-saturday-more__summary::after {
    content: "▾";
    float: right;
    transition: transform 0.2s ease;
}

.calendar-saturday-more[open] .calendar-saturday-more__summary::after {
    transform: rotate(180deg);
}

.calendar-saturday-more[open] .calendar-saturday-more__summary {
    border-bottom: 1px solid var(--color-border);
    background: #f5f9fd;
}

.top-gap-small {
    margin-top: 0.75rem;
}

.table-placeholder {
    padding: 1rem;
    text-align: center;
}

.logo-preview {
    width: 120px;
    height: 120px;
    object-fit: contain;
    border: 1px solid var(--color-border);
    border-radius: 16px;
    padding: 1rem;
    background: #fff;
}

.audit-json {
    white-space: pre-wrap;
    word-break: break-word;
    max-width: 300px;
    font-size: 0.82rem;
}

.legend {
    flex-wrap: wrap;
    margin: 1rem 0;
}

.legend-item {
    padding: 0.45rem 0.7rem;
    border-radius: 999px;
    font-size: 0.82rem;
}

@media (min-width: 960px) {
    .sidebar {
        transform: none;
    }

    .main-panel {
        margin-left: 280px;
    }

    .two-columns {
        grid-template-columns: 1.1fr 0.9fr;
    }

    .hamburger {
        display: none;
    }
}
