:root {
    --sidebar-width: 292px;
    --content-gutter: clamp(16px, 2.5vw, 36px);
    --content-max: 1760px;
    --focus-ring: #7c9cff;
    --sidebar-transition: 320ms cubic-bezier(0.22, 1, 0.36, 1);
}

[data-theme="light"] {
    --focus-ring: color-mix(in srgb, var(--brand-red) 42%, transparent);
}

html {
    scroll-behavior: smooth;
}

body {
    font-size: 15px;
    line-height: 1.5;
}

button,
input,
select,
textarea {
    font: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
}

.header {
    position: sticky;
    top: 0;
    z-index: 100;
    min-height: 76px;
    margin-left: var(--sidebar-width);
    padding: 16px var(--content-gutter);
    background: color-mix(in srgb, #16213e 90%, transparent);
    backdrop-filter: blur(16px);
    transition: margin-left var(--sidebar-transition), box-shadow 220ms ease;
}

[data-theme="light"] .header {
    border-bottom-color: color-mix(in srgb, var(--brand-red) 24%, transparent);
    background: color-mix(in srgb, #ffffff 94%, transparent);
    box-shadow: 0 8px 28px color-mix(in srgb, var(--brand-red-dark) 7%, transparent);
}

[data-theme="light"] .header h1 {
    color: var(--brand-red-dark);
}

.header h1 {
    font-size: clamp(20px, 2vw, 26px);
    letter-spacing: -0.02em;
}

.header-controls {
    flex-wrap: wrap;
    justify-content: flex-end;
}

.tab-bar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 110;
    width: var(--sidebar-width);
    height: 100vh;
    padding: 18px 14px 28px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    overflow-y: auto;
    overscroll-behavior: contain;
    border-right: 1px solid var(--border-color);
    border-bottom: 0;
    background: color-mix(in srgb, #10182e 96%, transparent);
    scrollbar-width: thin;
    transform: translateX(0);
    transition: transform var(--sidebar-transition), box-shadow 220ms ease;
    will-change: transform;
}

[data-theme="light"] .tab-bar {
    border-right-color: color-mix(in srgb, var(--brand-red) 20%, transparent);
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--brand-red) 5.5%, transparent), transparent 180px),
        color-mix(in srgb, #ffffff 97%, transparent);
    box-shadow: 8px 0 30px color-mix(in srgb, var(--brand-red-dark) 5%, transparent);
}

.sidebar-brand {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 104px;
    margin: 0 2px 16px;
    padding: 0 2px 16px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-toggle {
    position: fixed;
    z-index: 120;
    top: 50%;
    left: calc(var(--sidebar-width) - 18px);
    width: 38px;
    height: 38px;
    transform: translateY(-50%);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    background: color-mix(in srgb, #10182e 96%, transparent);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 20px;
    font-weight: 800;
    line-height: 1;
    box-shadow: 0 8px 24px rgba(4, 8, 20, 0.24);
    transition:
        left var(--sidebar-transition),
        background 180ms ease,
        color 180ms ease,
        transform 180ms ease;
}

.sidebar-toggle:hover {
    transform: translateY(-50%) scale(1.08);
}

[data-theme="light"] .sidebar-toggle {
    border-color: color-mix(in srgb, var(--brand-red) 22%, transparent);
    background: #fff;
    color: var(--brand-red);
}

.sidebar-brand-logo {
    display: block;
    width: min(100%, 252px);
    max-height: 72px;
    height: auto;
    object-fit: contain;
}

.sidebar-groups {
    display: grid;
    gap: 10px;
}

.nav-category {
    min-width: 0;
}

.nav-category > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 8px 4px;
    padding: 6px 5px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    list-style: none;
    text-transform: uppercase;
}

.nav-category > summary::-webkit-details-marker {
    display: none;
}

.nav-category > summary::after {
    content: "−";
    font-size: 14px;
}

.nav-category:not([open]) > summary::after {
    content: "+";
}

.nav-group-content {
    display: grid;
    gap: 0;
}

.tab-btn {
    position: relative;
    width: 100%;
    min-height: 44px;
    margin: 0 0 5px;
    padding: 10px 13px 15px;
    border: 1px solid transparent;
    border-left: 3px solid transparent;
    border-radius: 9px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    text-align: left;
    white-space: normal;
}

.tab-btn::after {
    position: absolute;
    bottom: 2px;
    left: 50%;
    width: 40%;
    height: 1px;
    background: color-mix(in srgb, var(--border-color) 72%, transparent);
    content: "";
    transform: translateX(-50%);
}

.tab-btn::before {
    display: none;
    content: attr(data-short-label);
}

body.sidebar-collapsed .tab-bar {
    transform: translateX(-105%);
}

body.sidebar-collapsed .header,
body.sidebar-collapsed .tab-content {
    margin-left: 0;
}

body.sidebar-collapsed .sidebar-toggle {
    left: 14px;
}

.tab-btn:hover {
    border-color: var(--border-color);
    color: var(--text-primary);
    transform: translateX(2px);
}

.tab-btn.active {
    border-color: color-mix(in srgb, var(--accent-blue) 38%, transparent);
    border-left-color: var(--accent-blue);
    background: color-mix(in srgb, var(--accent-blue) 16%, transparent);
    color: var(--text-primary);
}

[data-theme="light"] .tab-btn:hover {
    border-color: color-mix(in srgb, var(--brand-red) 20%, transparent);
    background: var(--brand-red-soft);
    color: var(--brand-red-dark);
}

[data-theme="light"] .tab-btn.active {
    border-color: color-mix(in srgb, var(--brand-red) 28%, transparent);
    border-left-color: var(--brand-red);
    background: linear-gradient(90deg, color-mix(in srgb, var(--brand-red) 13%, transparent), color-mix(in srgb, var(--brand-red) 4%, transparent));
    color: var(--brand-red-dark);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.65);
}

.tab-content {
    margin-left: var(--sidebar-width);
    padding: 0 var(--content-gutter) var(--content-gutter);
    transition: margin-left var(--sidebar-transition);
}

.daily-report-panel {
    width: min(100%, var(--content-max));
    margin: var(--content-gutter) auto 0;
    padding: clamp(20px, 2.3vw, 32px);
    border-radius: 14px;
    box-shadow: 0 14px 38px rgba(4, 8, 20, 0.12);
}

[data-theme="light"] .daily-report-panel {
    border-color: color-mix(in srgb, var(--brand-red) 13%, transparent);
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 18px 44px color-mix(in srgb, var(--brand-red-dark) 8%, transparent);
}

[data-theme="light"] .daily-report-header {
    padding-bottom: 16px;
    border-bottom: 1px solid color-mix(in srgb, var(--brand-red) 12%, transparent);
}

[data-theme="light"] .daily-report-header h2 {
    color: var(--brand-red-dark);
}

[data-theme="light"] table {
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--brand-red-dark) 6%, transparent);
}

.daily-report-panel > p {
    max-width: 110ch;
    color: var(--text-secondary) !important;
    font-size: 14px !important;
    line-height: 1.65;
}

.daily-report-header {
    gap: 18px;
    margin-bottom: 18px;
}

.daily-report-header h2 {
    font-size: clamp(19px, 2vw, 24px);
    line-height: 1.25;
    letter-spacing: -0.015em;
}

.daily-report-controls {
    flex-wrap: wrap;
    justify-content: flex-end;
}

.refresh-btn,
.submit-btn {
    min-height: 42px;
}

table {
    line-height: 1.45;
}

table th {
    font-size: 13px;
    letter-spacing: 0.01em;
}

table td {
    font-size: 13px;
}

.table-container,
.pr-table-wrap,
.rm-months-wrap {
    scrollbar-width: thin;
}

@media (max-width: 1100px) {
    :root {
        --sidebar-width: 252px;
    }

    .tab-btn {
        font-size: 13px;
    }
}

@media (max-width: 900px) {
    body {
        font-size: 14px;
    }

    .header {
        position: relative;
        min-height: auto;
        margin-left: 0;
    }

    .tab-bar {
        position: sticky;
        inset: 0 auto auto;
        width: 100%;
        height: auto;
        padding: 9px 12px;
        flex-direction: row;
        gap: 7px;
        overflow-x: auto;
        overflow-y: hidden;
        border-right: 0;
        border-bottom: 1px solid var(--border-color);
    }

    .sidebar-brand,
    .sidebar-label,
    .sidebar-toggle {
        display: none;
    }

    .sidebar-groups,
    .nav-group-content {
        display: flex !important;
        gap: 7px;
    }

    .nav-category {
        display: contents;
    }

    .nav-category > summary {
        display: none;
    }

    body.sidebar-collapsed .tab-bar {
        padding: 9px 12px;
        overflow-x: auto;
        transform: none;
    }

    body.sidebar-collapsed .tab-btn > span {
        display: inline;
    }

    body.sidebar-collapsed .tab-btn::before {
        display: none;
    }

    .tab-btn {
        width: auto;
        min-width: max-content;
        padding: 9px 13px;
        border-left-width: 1px;
        text-align: center;
        white-space: nowrap;
    }

    .tab-btn:hover {
        transform: none;
    }

    .tab-content {
        margin-left: 0;
    }
}

@media (max-width: 600px) {
    .header {
        align-items: stretch;
        padding: 14px 16px;
    }

    .header-controls {
        width: 100%;
        justify-content: space-between;
    }

    .daily-report-panel {
        padding: 18px;
    }

    .daily-report-header {
        align-items: stretch;
    }

    .daily-report-controls {
        justify-content: flex-start;
    }

    .daily-report-controls > * {
        max-width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
