:root {
    color-scheme: dark;
    --bg: #101418;
    --panel: #171d23;
    --panel-soft: #1d252d;
    --panel-raised: #202a33;
    --border: #303a44;
    --text: #edf2f7;
    --muted: #a4b0bd;
    --accent: #5fb3a7;
    --accent-strong: #8bd6cb;
    --danger: #e07a7a;
    --warning: #d9b65f;
    --success: #79c58a;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Inter", "Segoe UI", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.45;
}

a { color: var(--accent-strong); }
h1, h2, h3 { margin: 0 0 0.75rem; color: var(--text); letter-spacing: 0; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1rem; }
h3 { font-size: 0.92rem; }
p { color: var(--muted); }

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

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 1rem;
    padding: 0.72rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: rgba(16, 20, 24, 0.96);
    backdrop-filter: blur(12px);
}

.brand {
    display: flex;
    flex-direction: column;
    gap: 0.12rem;
}

.brand-title {
    font-weight: 800;
    font-size: 1rem;
}

.brand-subtitle {
    color: var(--muted);
    font-size: 0.78rem;
}

.user-box {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    color: var(--muted);
    font-size: 0.86rem;
}

.page-nav {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    gap: 0.4rem;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: thin;
}

.page-tab {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 0.42rem 0.68rem;
    border-radius: 8px;
    color: var(--muted);
    text-decoration: none;
    font-weight: 700;
    border: 1px solid transparent;
}

.page-tab:hover {
    background: var(--panel-soft);
    color: var(--text);
}

.page-tab.active {
    background: var(--panel-raised);
    color: var(--text);
    border-color: var(--accent);
}

.content {
    min-width: 0;
    padding: 1.1rem 1.25rem 2rem;
    width: 100%;
}

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.page-lead {
    max-width: 820px;
    margin: 0.15rem 0 0;
    color: var(--muted);
}

.card,
.work-panel {
    border: 1px solid var(--border);
    padding: 1rem;
    margin-bottom: 0.85rem;
    border-radius: 8px;
    background: var(--panel);
}

.card {
    overflow-x: auto;
}

.work-panel.primary {
    border-color: rgba(95, 179, 167, 0.65);
    background: #17211f;
}

.split-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem;
    margin-bottom: 0.85rem;
}

.kpi-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.85rem;
    background: var(--panel-soft);
}

.kpi-title {
    color: var(--muted);
    font-size: 0.74rem;
    font-weight: 800;
    text-transform: uppercase;
}

.kpi-value {
    margin-top: 0.25rem;
    color: var(--text);
    font-size: 1.35rem;
    font-weight: 800;
}

.row,
.filter-form,
.actionbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-end;
}

.actionbar {
    padding: 0.75rem;
    margin: 0.75rem 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel-soft);
}

label {
    display: block;
    margin-bottom: 0.32rem;
    color: var(--muted);
    font-weight: 700;
}

input,
select,
textarea {
    min-width: 180px;
    padding: 0.52rem 0.65rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #11171d;
    color: var(--text);
}

input[type="checkbox"] { min-width: 0; }
textarea { width: 100%; resize: vertical; }

button {
    min-height: 36px;
    padding: 0.52rem 0.82rem;
    cursor: pointer;
    border-radius: 8px;
    border: 1px solid rgba(139, 214, 203, 0.45);
    background: #223f3b;
    color: #eafffb;
    font-weight: 800;
}

button:hover { background: #2a4b46; }
button:disabled { opacity: 0.45; cursor: not-allowed; }

.button-danger,
button[value="init_db"],
button[value="delete_shift"],
button[value="delete_fiken_customer_group"],
button[value="delete_fiken_override"] {
    border-color: rgba(224, 122, 122, 0.45);
    background: #422426;
    color: #ffe9e9;
}

fieldset { border: 0; padding: 0; margin: 0; }

.message,
.error,
.warning {
    padding: 0.78rem 0.9rem;
    margin-bottom: 0.85rem;
    border-radius: 8px;
}

.message { background: #173122; border: 1px solid #2e6b45; color: #dff7e6; }
.error { background: #3a1f22; border: 1px solid #77383f; color: #ffe7e7; }
.warning { background: #352c18; border: 1px solid #8c7334; color: #f4e1aa; }

.schema-alert {
    border-color: rgba(217, 182, 95, 0.7);
    background: #2e281a;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
}

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

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

th {
    position: sticky;
    top: 62px;
    z-index: 2;
    background: #202932;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
}

tr:nth-child(even) td { background: rgba(255, 255, 255, 0.018); }
.shift-row--not-invoiced td { background: rgba(245, 158, 11, 0.08); }
.shift-row--not-invoiced:nth-child(even) td { background: rgba(245, 158, 11, 0.12); }
.shift-row--non-billable td { background: rgba(59, 130, 246, 0.08); }
.shift-row--non-billable:nth-child(even) td { background: rgba(59, 130, 246, 0.12); }

.customer-band-0 td { box-shadow: inset 3px 0 0 #fb7185; }
.customer-band-1 td { box-shadow: inset 3px 0 0 #f59e0b; }
.customer-band-2 td { box-shadow: inset 3px 0 0 #10b981; }
.customer-band-3 td { box-shadow: inset 3px 0 0 #22d3ee; }
.customer-band-4 td { box-shadow: inset 3px 0 0 #60a5fa; }
.customer-band-5 td { box-shadow: inset 3px 0 0 #a78bfa; }
.customer-band-custom td { box-shadow: inset 3px 0 0 var(--customer-band-color); }

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    background: var(--panel-raised);
    color: var(--muted);
    font-weight: 800;
    font-size: 0.75rem;
}

.badge.ok { color: #dff7e6; background: #183221; }
.badge.warn { color: #f4e1aa; background: #3b3018; }
.badge.danger { color: #ffe7e7; background: #3a1f22; }

.chart-wrapper {
    background: var(--panel-soft);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
}

.chart-meta {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    color: var(--muted);
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

.chart-empty,
.filter-label { color: var(--muted); }
.col-invoice-toggle { width: 48px; text-align: center; }
.color-field {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 180px;
    min-height: 40px;
    padding: 0.3rem 0.55rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #11171d;
}
.color-field input[type="color"] {
    min-width: 34px;
    width: 34px;
    height: 24px;
    padding: 0;
    border: 0;
    background: transparent;
}
.color-hex-input {
    min-width: 98px;
    width: 106px;
    padding: 0.28rem 0.42rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: #0f151b;
    color: var(--text);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    text-transform: uppercase;
}
.color-preview-chip {
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: #60A5FA;
    flex: 0 0 auto;
}
.color-preview-code {
    font-size: 0.78rem;
    color: var(--muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

@media (max-width: 900px) {
    .topbar {
        grid-template-columns: 1fr;
        gap: 0.55rem;
        align-items: flex-start;
    }
    .page-nav {
        flex-wrap: wrap;
        justify-content: flex-start;
        max-width: 100%;
        padding-bottom: 0.1rem;
    }
    .page-header { align-items: flex-start; flex-direction: column; }
    .split-grid { grid-template-columns: 1fr; }
}
