:root {
    color-scheme: light;
    --bg: #f4f6fb;
    --card-bg: rgba(255, 255, 255, 0.95);
    --border: rgba(15, 23, 42, 0.08);
    --border-strong: rgba(15, 23, 42, 0.14);
    --accent: #2563eb;
    --accent-dark: #1d4ed8;
    --accent-soft: rgba(37, 99, 235, 0.12);
    --text: #111827;
    --muted: #6b7280;
    --input-bg: rgba(255, 255, 255, 0.9);
    --table-header: rgba(37, 99, 235, 0.08);
    --shadow: 0 20px 45px rgba(15, 23, 42, 0.12);
    --overlay: rgba(37, 99, 235, 0.08);
    --error: #ef4444;
    --error-soft: rgba(239, 68, 68, 0.14);
    --success: #22c55e;
    --success-soft: rgba(34, 197, 94, 0.12);
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0f172a;
    --card-bg: rgba(15, 23, 42, 0.85);
    --border: rgba(148, 163, 184, 0.24);
    --border-strong: rgba(148, 163, 184, 0.35);
    --accent: #60a5fa;
    --accent-dark: #3b82f6;
    --accent-soft: rgba(96, 165, 250, 0.14);
    --text: #e2e8f0;
    --muted: #94a3b8;
    --input-bg: rgba(15, 23, 42, 0.65);
    --table-header: rgba(148, 163, 184, 0.16);
    --shadow: 0 28px 60px rgba(2, 6, 23, 0.6);
    --overlay: rgba(148, 163, 184, 0.06);
    --error: #f87171;
    --error-soft: rgba(248, 113, 113, 0.16);
    --success: #4ade80;
    --success-soft: rgba(74, 222, 128, 0.16);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    transition: background 0.3s ease, color 0.3s ease;
    min-height: 100vh;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s ease, opacity 0.2s ease;
}

a:hover {
    color: var(--accent-dark);
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

body.auth {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 0;
    position: relative;
    overflow: hidden;
}

body.auth::before {
    content: '';
    position: absolute;
    inset: -20%;
    background: radial-gradient(120% 120% at 50% 0%, rgba(37, 99, 235, 0.18), transparent 70%),
        radial-gradient(80% 80% at 0% 100%, rgba(14, 165, 233, 0.2), transparent 70%),
        radial-gradient(80% 80% at 100% 100%, rgba(192, 38, 211, 0.12), transparent 70%);
    opacity: 0.9;
    z-index: 0;
    pointer-events: none;
}

:root[data-theme="dark"] body.auth::before {
    opacity: 0.35;
}

body.auth > *:not(.auth-theme-toggle),
.auth-card {
    position: relative;
    z-index: 1;
}

.auth-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
    width: 100%;
}

.auth-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 2.5rem 2.25rem;
    max-width: 380px;
    width: 100%;
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.auth-card h1 {
    margin-top: 0;
    margin-bottom: 1.8rem;
    font-size: 1.75rem;
    letter-spacing: -0.01em;
}

.auth-theme-toggle {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 10;
}

label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--muted);
}

input,
select,
textarea,
button {
    width: 100%;
    padding: 0.7rem 0.85rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    font-size: 0.95rem;
    font-family: inherit;
    background: var(--input-bg);
    color: var(--text);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-soft);
}

button {
    margin-top: 1.25rem;
    background: var(--accent);
    color: #fff;
    border: none;
    cursor: pointer;
    font-weight: 600;
    letter-spacing: 0.01em;
    box-shadow: 0 10px 30px rgba(37, 99, 235, 0.25);
}

button:hover {
    background: var(--accent-dark);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    width: auto;
    padding: 0.7rem 1.2rem;
    border-radius: 12px;
    font-weight: 600;
    border: 1px solid transparent;
    margin-top: 0;
    box-shadow: none;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 12px 28px rgba(37, 99, 235, 0.28);
}

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

.btn-secondary {
    background: transparent;
    color: var(--accent);
    border-color: var(--accent);
}

.btn-secondary:hover {
    background: var(--accent-soft);
}

.overview-insights__grid {
    display: grid;
    gap: 1.5rem;
}

@media (min-width: 900px) {
    .overview-insights__grid {
        grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
        align-items: start;
    }
}

.overview-insights__chart {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.overview-insights__filters {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.overview-insights__filters label {
    font-weight: 600;
    color: var(--muted);
}

.time-chart-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.time-chart__heading {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--muted);
}

.time-chart {
    display: flex;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--overlay);
    min-height: 48px;
}

.time-chart__segment {
    flex: var(--size) 1 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    color: #fff;
    text-shadow: 0 1px 2px rgba(15, 23, 42, 0.35);
    padding: 0 0.75rem;
    white-space: nowrap;
}

.time-chart__segment span {
    overflow: hidden;
    text-overflow: ellipsis;
}

.time-chart__segment--work {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
}

.time-chart__segment--overtime {
    background: linear-gradient(135deg, #f97316, #ea580c);
}

.time-chart__segment--comp_time {
    background: linear-gradient(135deg, #22c55e, #16a34a);
}

.time-chart__segment--vacation {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}

.time-chart__segment--vacation-used {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}

.time-chart__segment--vacation-open {
    background: linear-gradient(135deg, #22d3ee, #0ea5e9);
}

.time-chart__segment--vacation-overdrawn {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.time-chart__segment--sick {
    background: linear-gradient(135deg, #14b8a6, #0d9488);
}

.time-chart__segment--medical {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.time-chart__total {
    margin: 0;
    font-weight: 600;
    color: var(--muted);
}

.overview-insights__details {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.time-summary {
    display: grid;
    gap: 0.75rem;
    margin: 0;
}

.time-summary__item {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
}

.time-summary__item dt {
    margin: 0;
    font-weight: 600;
    color: var(--muted);
}

.time-summary__label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.time-summary__item dd {
    margin: 0;
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
}

.time-summary__value {
    font-weight: 600;
    color: var(--text);
}

.time-summary__percentage {
    font-size: 0.85rem;
    color: var(--muted);
}

.info-tooltip {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.info-tooltip__trigger {
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 999px;
    border: 1px solid var(--accent);
    background: var(--accent-soft);
    background: color-mix(in srgb, var(--accent) 15%, transparent);
    color: var(--accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.info-tooltip__trigger--text {
    width: auto;
    height: auto;
    border-radius: 0;
    border: none;
    background: transparent;
    color: inherit;
    font: inherit;
    padding: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    cursor: pointer;
    box-shadow: none;
    border-bottom: 1px dashed color-mix(in srgb, var(--accent) 55%, transparent);
    text-decoration: none;
    transition: color 0.2s ease, border-bottom-color 0.2s ease;
}

.info-tooltip__trigger svg {
    width: 0.82rem;
    height: 0.82rem;
    fill: currentColor;
}

.info-tooltip__trigger:hover,
.info-tooltip__trigger:focus {
    background: var(--accent);
    color: var(--surface);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

.info-tooltip__trigger--text:hover,
.info-tooltip__trigger--text:focus {
    background: none;
    color: var(--accent);
    transform: none;
    border-bottom-color: var(--accent);
    box-shadow: none;
}

.info-tooltip__trigger:focus-visible {
    outline: 2px solid var(--accent);
    outline: 2px solid color-mix(in srgb, var(--accent) 55%, #ffffff);
    outline-offset: 3px;
}

.info-tooltip__trigger--text:focus-visible {
    outline-offset: 4px;
}

.info-tooltip__content {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    min-width: 220px;
    background: var(--card-bg);
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 0.75rem;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 10;
}

.info-tooltip:hover .info-tooltip__content,
.info-tooltip:focus-within .info-tooltip__content {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.info-tooltip__list {
    list-style: none;
    margin: 0.5rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.info-tooltip__list li {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    font-size: 0.9rem;
}

.info-tooltip__category {
    font-weight: 600;
    color: var(--text);
}

.info-tooltip__details {
    color: var(--muted);
    white-space: nowrap;
}

.overtime-balance {
    padding: 1.25rem;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--overlay);
}

.overtime-balance--positive {
    border-color: rgba(34, 197, 94, 0.45);
    background: rgba(34, 197, 94, 0.12);
}

.overtime-balance--negative {
    border-color: rgba(248, 113, 113, 0.45);
    background: rgba(248, 113, 113, 0.12);
}

.overtime-balance__grid {
    display: grid;
    gap: 0.75rem;
}

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

.overtime-balance__label {
    display: block;
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 0.25rem;
}

.overtime-balance__value {
    font-weight: 600;
    font-size: 1.05rem;
}

.overtime-balance__remaining {
    margin: 1rem 0 0;
    font-weight: 600;
}

.overtime-balance__remaining strong {
    color: var(--text);
}

.vacation-balance {
    padding: 1.1rem 1.25rem;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    box-shadow: var(--shadow);
}

.vacation-balance h3 {
    margin-top: 0;
    margin-bottom: 0.85rem;
}

.vacation-balance__grid {
    display: grid;
    gap: 0.75rem;
}

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

.vacation-balance__label {
    display: block;
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 0.3rem;
}

.vacation-balance__value {
    font-weight: 600;
    font-size: 1.15rem;
    color: var(--text);
}

.btn-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0;
    background: none;
    border: none;
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.btn-link:hover {
    opacity: 0.85;
}

.btn-link-danger {
    color: var(--error);
}

.btn-link-danger:hover {
    opacity: 0.85;
}

.topbar {
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
    padding: 1.25rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

:root[data-theme="dark"] .topbar {
    background: rgba(15, 23, 42, 0.75);
}

.brand {
    font-weight: 700;
    font-size: 1.2rem;
    letter-spacing: -0.01em;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.95rem;
    color: var(--muted);
}

.user-info a {
    color: var(--text);
    font-weight: 600;
}

.user-info a:hover {
    color: var(--accent);
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.95rem;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    border: 1px solid transparent;
    width: auto;
    margin-top: 0;
    box-shadow: none;
}

.theme-toggle:hover {
    background: rgba(37, 99, 235, 0.18);
}

:root[data-theme="dark"] .theme-toggle {
    color: #bfdbfe;
    border-color: rgba(96, 165, 250, 0.24);
}

.container {
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.tabs {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.55rem 1.2rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
    transition: background 0.2s ease, color 0.2s ease, border 0.2s ease;
}

.tab:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.tab.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    box-shadow: 0 12px 20px rgba(37, 99, 235, 0.2);
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 1.8rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
}

.card h1,
.card h2 {
    margin-top: 0;
    margin-bottom: 1.2rem;
    font-size: 1.5rem;
}

.card h3 {
    margin-bottom: 0.75rem;
    margin-top: 1.5rem;
    font-size: 1.15rem;
}

.quick-entry .form-grid {
    display: grid;
    gap: 1.25rem;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    margin-bottom: 1rem;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.form-field textarea {
    resize: vertical;
}

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

.stacked-form {
    display: flex;
    flex-direction: column;
    gap: 1.4rem;
}

.stacked-form .grid {
    gap: 1.5rem;
}

.stacked-form textarea {
    min-height: 120px;
}

.quick-entry__actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.quick-entry__actions .form-hint {
    flex-basis: 100%;
    margin-top: 0.25rem;
}

.quick-entry__status {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    background: var(--accent-soft);
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    padding: 0.85rem 1.2rem;
    font-weight: 600;
}

.quick-entry__status-label {
    color: var(--accent);
}

.quick-entry__status-meta {
    color: var(--muted);
    font-weight: 500;
}

.quick-entry__stop-form {
    margin-top: 1rem;
}

.alert {
    padding: 0.9rem 1.2rem;
    border-radius: 12px;
    margin-bottom: 1.75rem;
    border: 1px solid transparent;
    backdrop-filter: blur(12px);
}

.alert ul {
    margin: 0;
    padding-left: 1.2rem;
}

.alert-success {
    background: var(--success-soft);
    color: var(--success);
    border-color: rgba(34, 197, 94, 0.25);
}

.alert-error {
    background: var(--error-soft);
    color: var(--error);
    border-color: rgba(239, 68, 68, 0.25);
}

.note {
    margin-top: 1rem;
    font-size: 0.88rem;
    color: var(--muted);
}

.info-text {
    margin-bottom: 1rem;
    font-size: 0.95rem;
    color: var(--muted);
}

.list {
    list-style: disc;
    padding-left: 1.5rem;
    color: var(--text);
}

.list li {
    margin-bottom: 0.4rem;
}

.table-toolbar {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin: 1rem 0;
}

.table-sort,
.table-search {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.table-search__controls {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.5rem;
}

.table-search__controls input[type="search"] {
    flex: 1;
    min-width: 12rem;
}

.table-search__controls .btn {
    margin-top: 0;
}

.table-search__controls .btn-link {
    white-space: nowrap;
}

@media (min-width: 640px) {
    .table-toolbar {
        flex-direction: row;
        align-items: flex-end;
        justify-content: space-between;
    }

    .table-sort,
    .table-search {
        width: auto;
    }
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    font-size: 0.92rem;
    overflow: hidden;
    border-radius: 14px;
}

table thead {
    background: var(--table-header);
}

table th,
table td {
    border: 1px solid var(--border);
    padding: 0.75rem 0.8rem;
    text-align: left;
}

.table-cell__subtext {
    font-size: 0.85em;
    color: var(--muted);
    margin-top: 0.15rem;
}

table tbody tr:nth-child(even) {
    background: rgba(15, 23, 42, 0.03);
}

:root[data-theme="dark"] table tbody tr:nth-child(even) {
    background: rgba(148, 163, 184, 0.05);
}

table tbody tr:hover {
    background: var(--accent-soft);
}

table tbody tr.table-group {
    background: var(--table-header);
}

table tbody tr.table-group td {
    font-weight: 600;
    border-color: var(--border-strong);
    padding: 0;
}

table tbody tr.table-group:hover {
    background: var(--table-header);
}

.table-group__toggle {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    width: 100%;
    background: none;
    border: 0;
    color: inherit;
    font: inherit;
    padding: 0.75rem 0.8rem;
    margin: 0;
    text-align: left;
    cursor: pointer;
}

.table-group__toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 8px;
}

.table-group__icon {
    width: 1.1rem;
    height: 1.1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

.table-group__icon::before {
    content: '▾';
    font-size: 0.85rem;
}

.table-group--collapsed .table-group__icon {
    transform: rotate(-90deg);
}

.table-group__label {
    flex: 1;
}

.table-group__totals {
    margin-left: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    justify-content: flex-end;
}

.table-group__total {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--muted);
    white-space: nowrap;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.form-actions .btn,
.form-actions .btn-link {
    margin-top: 0;
}

.form-hint {
    margin-top: 0.75rem;
    font-size: 0.9rem;
    color: var(--muted);
}

.form-hint kbd {
    display: inline-block;
    padding: 0.15rem 0.45rem;
    margin: 0 0.15rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: rgba(15, 23, 42, 0.04);
    color: inherit;
    font-size: 0.85em;
    line-height: 1;
    box-shadow: inset 0 -1px 0 rgba(15, 23, 42, 0.08);
}

:root[data-theme="dark"] .form-hint kbd {
    background: rgba(148, 163, 184, 0.12);
    border-color: rgba(148, 163, 184, 0.35);
    box-shadow: inset 0 -1px 0 rgba(2, 6, 23, 0.35);
}

.table-actions {
    display: flex;
    align-items: flex-start;
    gap: 0.9rem;
}

.table-actions .inline-form {
    margin: 0;
}

.pagination {
    margin-top: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.pagination__link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.pagination__link:hover,
.pagination__link:focus {
    text-decoration: underline;
}

.pagination__info {
    color: var(--muted);
    font-size: 0.95rem;
}

.inline-form {
    display: inline;
}

.inline-form button {
    width: auto;
    padding: 0;
    margin: 0;
}

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

@media (max-width: 900px) {
    .topbar {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
    }

    .topbar-actions {
        width: 100%;
        justify-content: space-between;
    }
}

@media (max-width: 720px) {
    .container {
        padding: 1.5rem 1.2rem 3rem;
    }

    .card {
        padding: 1.5rem;
    }

    .auth-card {
        padding: 2.2rem 1.8rem;
    }

    .auth-theme-toggle {
        top: 1.5rem;
        right: 1.5rem;
    }
}

@media (max-width: 520px) {
    .topbar-actions {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.6rem;
    }

    .user-info {
        flex-wrap: wrap;
    }

    .theme-toggle {
        width: 100%;
        justify-content: center;
    }
}
