:root {
    color-scheme: light;
    --ink: #1d2822;
    --muted: #5e6a62;
    --paper: #f3efe6;
    --card: #fffdf8;
    --line: #e3d9cb;
    --rail: #1c3028;
    --rail-soft: #294339;
    --copper: #b8613a;
    --copper-deep: #8c4326;
    --moss: #2f6f4e;
    --late: #8d2e2e;
    --soon: #8a5a12;
    --ok: #246346;
    --shadow: 0 16px 40px rgba(36, 32, 24, 0.08);
    font-family: "Segoe UI", "Avenir Next", sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; background: var(--paper); color: var(--ink); }

a { color: var(--copper-deep); }

h1, h2 { font-family: Palatino, "Palatino Linotype", Georgia, serif; font-weight: 600; letter-spacing: -0.02em; }

h1 { margin: 0; font-size: 2.2rem; }

h2 { margin: 0 0 0.4rem; font-size: 1.25rem; }

button, input { font: inherit; }

button {
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--ink);
    border-radius: 999px;
    padding: 0.45rem 0.9rem;
    cursor: pointer;
}

button.primary { background: var(--copper); border-color: var(--copper); color: white; }

button.quiet { background: transparent; }

button:disabled { opacity: 0.6; cursor: wait; }

.boot { min-height: 100vh; display: grid; place-items: center; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 272px 1fr; }

.rail {
    background: var(--rail);
    color: #e7f2eb;
    display: flex;
    flex-direction: column;
    padding: 1.2rem 1rem 1rem;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand { display: flex; gap: 0.75rem; align-items: center; color: inherit; text-decoration: none; }

.brand strong, .brand small { display: block; }

.brand small { color: #b7c9be; font-size: 0.82rem; }

.mark {
    width: 2.4rem;
    height: 2.4rem;
    display: grid;
    place-items: center;
    border-radius: 0.7rem;
    background: var(--copper);
    color: white;
    font-family: Palatino, Georgia, serif;
}

.rail nav { display: flex; flex-direction: column; gap: 0.15rem; margin-top: 1rem; flex: 1; min-height: 0; overflow: auto; padding-bottom: 0.6rem; }

.nav-label { margin: 0.85rem 0.7rem 0.15rem; font-size: 0.68rem; letter-spacing: 0.12em; text-transform: uppercase; color: #9db5a6; }

.rail nav a {
    color: #d5e4db;
    text-decoration: none;
    padding: 0.38rem 0.7rem;
    border-radius: 0.7rem;
    font-size: 0.92rem;
}

.rail nav a.active, .rail nav a:hover { background: var(--rail-soft); color: white; }

.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 0.2rem; }

.rail-foot small { color: #b7c9be; }

.rail-foot button { margin-top: 0.6rem; background: transparent; color: white; border-color: #446255; }

.workspace { min-width: 0; }

.top { padding: 0.9rem 1.4rem 0; color: var(--muted); }

.top p { margin: 0; }

.nav-toggle, .scrim { display: none; }

.page { padding: 0.4rem 1.4rem 2.5rem; }

.page-head { display: flex; justify-content: space-between; gap: 1rem; align-items: end; margin: 0.4rem 0 1.2rem; }

.eyebrow { margin: 0 0 0.2rem; text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.75rem; color: var(--copper-deep); }

.muted { color: var(--muted); }

.error { color: var(--late); }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.8rem; margin-bottom: 1rem; }

.stats article, .panel, .card, .login-card, .drawer {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 1.1rem;
    box-shadow: var(--shadow);
}

.stats article { padding: 1rem 1.1rem; }

.stats span { display: block; color: var(--muted); font-size: 0.9rem; }

.stats strong { font-family: Palatino, Georgia, serif; font-size: 2rem; }

.panel { padding: 1rem 1.1rem 1.2rem; }

.stack { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.7rem; }

.stack li, .card header, .duty { display: flex; gap: 0.8rem; align-items: center; }

.stack small, .card .muted { display: block; }

.pill { border-radius: 999px; padding: 0.2rem 0.6rem; font-size: 0.78rem; white-space: nowrap; }

.pill.kasni { background: #f8e4e1; color: var(--late); }

.pill.uskoro { background: #f8ecd4; color: var(--soon); }

.pill.u-roku { background: #e3f2e8; color: var(--ok); }

.cards, .board { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.8rem; }

.card { padding: 1rem; }

.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 1.1rem; }

table { width: 100%; border-collapse: collapse; }

th, td { text-align: left; padding: 0.75rem 0.9rem; border-bottom: 1px solid var(--line); }

th { color: var(--muted); font-weight: 600; font-size: 0.82rem; }

.actions { white-space: nowrap; }

.drawer {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    width: min(460px, calc(100vw - 2rem));
    max-height: calc(100vh - 2rem);
    overflow: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    z-index: 5;
}

label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.9rem; }

input[type="text"], input:not([type="checkbox"]), select, textarea {
    border: 1px solid var(--line);
    border-radius: 0.7rem;
    padding: 0.55rem 0.7rem;
    background: white;
}

textarea { min-height: 5rem; resize: vertical; }

.lead { color: var(--muted); margin: 0.35rem 0 0; }

.tabs { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1rem; }

.tabs button.on { background: var(--ink); color: white; border-color: var(--ink); }

.kanban { grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: start; }

.column { background: transparent; display: flex; flex-direction: column; gap: 0.6rem; }

.column h2 { font-size: 1rem; }

.actions a { margin-right: 0.45rem; }

.row { display: flex; gap: 0.5rem; }

.check { flex-direction: row; align-items: center; }

.duty { padding: 0.35rem 0; }

.login {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
}

.login-story {
    background:
        radial-gradient(circle at 20% 20%, rgba(184, 97, 58, 0.35), transparent 28%),
        linear-gradient(160deg, #1c3028, #3d5a49);
    color: #f6f1e8;
    padding: 4rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 0.8rem;
}

.login-story h1 { font-size: 3.2rem; max-width: 12ch; }

.login-card { margin: auto; width: min(440px, calc(100% - 3rem)); padding: 1.4rem; display: flex; flex-direction: column; gap: 0.75rem; }

.discipline { display: flex; gap: 0.35rem; margin: 0 0 0.8rem; }
.discipline button.on { background: var(--copper, #b8613a); color: white; border-color: transparent; }
.data-grid { width: 100%; }
.client-grid thead th { z-index: 4; }
.client-grid .col-options { z-index: 5; }
.client-grid tbody td { position: relative; z-index: 1; }
.client-grid tbody tr { cursor: pointer; }
.client-grid a.cell-hit { position: absolute; inset: 0; z-index: 1; }
.client-grid a.client-name { position: relative; z-index: 2; }
.client-grid tbody td input[type="checkbox"] { position: relative; pointer-events: none; }
.month-grid tbody td input[type="checkbox"] { cursor: pointer; width: 1.1rem; height: 1.1rem; }
.confirm-scrim {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: rgba(20, 24, 20, 0.45);
}
.confirm-scrim:focus { outline: none; }
.confirm-dialog {
    width: min(420px, 100%);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 1.1rem;
    box-shadow: var(--shadow);
    padding: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}
.filters { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-bottom: 0.8rem; }
.filters label { min-width: 9rem; flex: 1 1 9rem; }
.filter-fold { margin: 0 0 0.8rem; }
.filter-fold > summary {
    display: none;
    cursor: pointer;
    list-style: none;
    border: 1px solid var(--line);
    background: var(--card);
    border-radius: 999px;
    padding: 0.45rem 0.9rem;
    width: fit-content;
    margin-bottom: 0.7rem;
}
.filter-fold > summary::-webkit-details-marker { display: none; }
.phone-list { display: none; }
.phone-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 1.1rem;
    box-shadow: var(--shadow);
    padding: 0.9rem 1rem;
    color: inherit;
    text-decoration: none;
}
.phone-card strong { font-family: Palatino, Georgia, serif; font-size: 1.2rem; font-weight: 600; }
.phone-card .meta { color: var(--muted); font-size: 0.92rem; }
.phone-flags { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.phone-card .check { min-height: 2.2rem; }
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.chip.on { background: var(--ink); color: white; border-color: var(--ink); }

@media (max-width: 980px) {
    .stats, .cards, .board, .login { grid-template-columns: 1fr; }
    .login-story { min-height: 16rem; padding: 2rem; }
    .login-story h1 { font-size: 2.3rem; }
}

@media (max-width: 860px) {
    .shell { grid-template-columns: 1fr; }
    .rail {
        position: fixed;
        z-index: 4;
        transform: translateX(-105%);
        transition: transform 0.2s ease;
        width: min(280px, 86vw);
    }
    .rail.open { transform: none; }
    .nav-toggle { display: inline-flex; }
    .scrim { display: block; position: fixed; inset: 0; border: 0; background: rgba(20, 24, 20, 0.35); border-radius: 0; z-index: 3; }
    .page { padding: 0.4rem 0.85rem 2rem; }
    .top { padding: 0.75rem 0.85rem 0; }
    .page-head { flex-direction: column; align-items: stretch; }
    h1 { font-size: 1.7rem; }
    .row { flex-wrap: wrap; }
    .filters label { min-width: 0; flex-basis: 100%; }
    .filter-fold > summary { display: inline-flex; }
    .filter-fold:not([open]) .filters { display: none; }
    .phone-list { display: flex; flex-direction: column; gap: 0.7rem; }
    .table-wrap:has(.data-grid) { display: none; }
    .table-wrap:has(table:not(.data-grid)) {
        background: transparent;
        border: 0;
        overflow: visible;
    }
    .table-wrap:has(table:not(.data-grid)) thead { display: none; }
    .table-wrap:has(table:not(.data-grid)) table,
    .table-wrap:has(table:not(.data-grid)) tbody { display: block; width: 100%; }
    .table-wrap:has(table:not(.data-grid)) tr {
        display: flex;
        flex-direction: column;
        gap: 0.2rem;
        background: var(--card);
        border: 1px solid var(--line);
        border-radius: 1.1rem;
        box-shadow: var(--shadow);
        padding: 0.85rem 1rem;
        margin-bottom: 0.7rem;
    }
    .table-wrap:has(table:not(.data-grid)) td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 0.8rem;
        border: 0;
        padding: 0.15rem 0;
        text-align: right;
    }
    .table-wrap:has(table:not(.data-grid)) td[data-label]::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 0.78rem;
        text-align: left;
    }
    .table-wrap:has(table:not(.data-grid)) td.card-title {
        display: block;
        order: -1;
        text-align: left;
        font-family: Palatino, Georgia, serif;
        font-size: 1.2rem;
        padding-bottom: 0.2rem;
    }
    .table-wrap:has(table:not(.data-grid)) td.card-title::before { content: none; }
    .table-wrap:has(table:not(.data-grid)) td.actions {
        justify-content: flex-start;
        text-align: left;
        flex-wrap: wrap;
        padding-top: 0.35rem;
    }
}

.loading-progress { position: absolute; display: block; width: 8rem; height: 8rem; inset: 20vh 0 auto 0; margin: 0 auto; }
.loading-progress circle { fill: none; stroke: #e6dfd3; stroke-width: 0.6rem; transform-origin: 50% 50%; transform: rotate(-90deg); }
.loading-progress circle:last-child { stroke: #b8613a; stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%; transition: stroke-dasharray 0.05s ease-in-out; }
.loading-progress-text { position: absolute; text-align: center; font-weight: 600; inset: calc(20vh + 3.25rem) 0 auto 0.2rem; }
.loading-progress-text:after { content: var(--blazor-load-percentage-text, "Učitavanje"); }

#blazor-error-ui { background: #fff4d6; bottom: 0; display: none; left: 0; padding: 0.6rem 1.25rem; position: fixed; width: 100%; z-index: 1000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }
.blazor-error-boundary { background: #8d2e2e; padding: 1rem; color: white; }
