/* Albert Směny — shared styles (design "A · Klid") */

:root {
    --bg: #F5F6F8;
    --surface: #FFFFFF;
    --surface-2: #FAFBFC;
    --border: #E3E6EB;
    --border-soft: #EEF0F3;
    --border-strong: #D5DAE1;
    --ink: #16181D;
    --ink-2: #3B4250;
    --muted: #5F6672;
    --faint: #B0B6C0;
    --accent: #1F5EDC;
    --accent-hover: #1747A8;
    --accent-soft: #EAF1FE;
    --warn-bg: #FEF3C7;
    --warn-ink: #78350F;
    --ok-bg: #DCFCE7;
    --ok-ink: #166534;
    --danger: #B42318;
    --danger-border: #F1C4C4;
    --radius: 14px;
    --radius-sm: 10px;
    --hatch: repeating-linear-gradient(135deg, #F3F4F6 0 5px, #E9EBEF 5px 10px);
    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.45;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

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

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

h1, h2, h3 {
    margin: 0;
    letter-spacing: -0.01em;
}

button, input, select, textarea {
    font: inherit;
    color: inherit;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.num {
    font-variant-numeric: tabular-nums;
}

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

/* ---------- Header ---------- */

.app-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.app-header-inner {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 24px;
    min-height: 64px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 32px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--ink);
}

.brand:hover {
    color: var(--ink);
}

.brand img {
    height: 28px;
    width: auto;
}

.brand-sub {
    font-size: 15px;
    color: var(--muted);
}

.main-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    flex: 1 1 auto;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--ink-2);
    font-weight: 500;
}

.nav-link:hover {
    background: var(--bg);
    color: var(--ink);
}

.nav-link.active {
    color: var(--accent);
    background: var(--accent-soft);
    font-weight: 600;
}

.nav-link svg, .tabbar a svg {
    flex: none;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-menu .user-name {
    font-size: 14px;
    color: var(--ink-2);
}

.user-menu a {
    font-size: 14px;
    color: var(--muted);
    text-decoration: none;
}

.user-menu a:hover {
    color: var(--danger);
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #EEF1F5;
    color: var(--ink-2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    flex: none;
}

.avatar-dark {
    background: var(--ink);
    color: #FFFFFF;
}

.avatar-sm {
    width: 32px;
    height: 32px;
    font-size: 12px;
}

@media (max-width: 760px) {
    .app-header-inner {
        padding: 8px 16px;
        gap: 4px 16px;
    }

    .main-nav {
        order: 3;
        flex: 1 1 100%;
        flex-wrap: nowrap;
        overflow-x: auto;
        margin: 0 -8px;
    }

    .nav-link {
        padding: 8px 10px;
        white-space: nowrap;
    }

    .user-menu {
        margin-left: auto;
    }
}

/* ---------- Mobile tab bar (employees) ---------- */

.tabbar {
    display: none;
}

@media (max-width: 760px) {
    .app-header .main-nav.has-tabbar {
        display: none;
    }

    .app-header .user-name {
        display: none;
    }

    .tabbar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 50;
        display: grid;
        grid-template-columns: repeat(var(--tabs, 3), minmax(0, 1fr));
        background: var(--surface);
        border-top: 1px solid var(--border);
        padding: 6px 8px calc(10px + env(safe-area-inset-bottom));
    }

    .tabbar a {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        padding: 8px 0;
        text-decoration: none;
        color: var(--muted);
        font-size: 12px;
        font-weight: 500;
    }

    .tabbar a.active {
        color: var(--accent);
        font-weight: 600;
    }

    body.has-tabbar {
        padding-bottom: 84px;
    }
}

/* ---------- Page layout ---------- */

.page {
    max-width: 1600px;
    margin: 0 auto;
    padding: 28px 24px 48px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.page-narrow {
    max-width: 1280px;
}

.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
}

.page-head h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.page-head p {
    margin: 6px 0 0;
    color: var(--muted);
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.split {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    align-items: flex-start;
}

.split > .grow {
    flex: 999 1 720px;
    min-width: 0;
}

.split > .side {
    flex: 1 1 320px;
    max-width: 100%;
    min-width: 0;
}

/* ---------- Cards ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.card-pad {
    padding: 20px;
}

.card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
}

.card-foot {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    font-size: 14px;
    color: var(--muted);
}

.card h2 {
    font-size: 17px;
    font-weight: 700;
}

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

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.stat-label {
    font-size: 13px;
    color: var(--muted);
    font-weight: 500;
}

.stat-value {
    font-size: 30px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.stat-value.warn {
    color: #B45309;
}

.stat-hint {
    font-size: 13px;
    color: var(--muted);
}

.tile {
    padding: 12px;
    border-radius: var(--radius-sm);
    background: #F8FAFC;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tile-label {
    font-size: 12px;
    color: var(--muted);
    font-weight: 500;
}

.tile-value {
    font-size: 20px;
    font-weight: 700;
}

.tile-hint {
    font-size: 11px;
    color: var(--muted);
}

/* ---------- Buttons & inputs ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 44px;
    padding: 0 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--ink);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}

.btn:hover {
    background: var(--surface-2);
    color: var(--ink);
}

.btn:disabled {
    opacity: .55;
    cursor: default;
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #FFFFFF;
    font-weight: 600;
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: #FFFFFF;
}

.btn-dark {
    background: var(--ink);
    border-color: var(--ink);
    color: #FFFFFF;
    font-weight: 600;
}

.btn-dark:hover {
    background: #000000;
    color: #FFFFFF;
}

.btn-danger {
    color: var(--danger);
    border-color: var(--danger-border);
    font-weight: 600;
}

.btn-danger:hover {
    background: #FEF3F2;
    color: var(--danger);
}

.btn-sm {
    height: 36px;
    padding: 0 12px;
    border-radius: 8px;
}

.btn-lg {
    height: 54px;
    font-size: 17px;
    border-radius: 12px;
}

.btn-icon {
    width: 44px;
    padding: 0;
}

.btn-group {
    display: flex;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--surface);
}

.btn-group > * {
    height: 44px;
    border: 0;
    border-radius: 0;
    background: transparent;
}

.btn-group > * + * {
    border-left: 1px solid var(--border);
}

.seg {
    display: inline-flex;
    gap: 4px;
    background: #E9ECF0;
    padding: 4px;
    border-radius: var(--radius-sm);
}

.seg > a, .seg > button {
    height: 36px;
    padding: 0 14px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--ink-2);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.seg > .on {
    background: var(--surface);
    color: var(--ink);
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .08);
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-2);
}

.field-hint {
    font-size: 12px;
    font-weight: 400;
    color: var(--muted);
}

.input, .select, .textarea {
    height: 44px;
    width: 100%;
    padding: 0 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: 15px;
    font-weight: 400;
    color: var(--ink);
}

.textarea {
    height: auto;
    padding: 10px 12px;
    resize: vertical;
}

.input:focus, .select:focus, .textarea:focus {
    outline: 2px solid var(--accent);
    outline-offset: -1px;
    border-color: var(--accent);
}

.search {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 44px;
    padding: 0 14px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    min-width: 240px;
}

.search input {
    border: 0;
    outline: none;
    background: transparent;
    flex: 1;
    min-width: 0;
    font-size: 15px;
}

.check {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    font-size: 15px;
    font-weight: 400;
    color: var(--ink-2);
}

.check input {
    width: 20px;
    height: 20px;
    accent-color: var(--accent);
}

.opt-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 6px;
}

.opt {
    min-height: 40px;
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    font-size: 13px;
    color: var(--ink);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    text-align: left;
}

.opt small {
    font-size: 12px;
    opacity: .8;
}

.opt.on {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-hover);
    font-weight: 600;
}

.form-section {
    border: 0;
    margin: 0;
    padding: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.form-section legend {
    font-size: 15px;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 12px;
    padding: 0;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}

.fieldset {
    border: 0;
    margin: 0;
    padding: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.fieldset legend {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-2);
    margin-bottom: 8px;
    padding: 0;
}

.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* ---------- Badges, chips, alerts ---------- */

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    background: var(--st-bg, #F1F3F6);
    color: var(--st-ink, var(--ink-2));
}

.chip-none {
    background: transparent;
    color: var(--muted);
    border: 1px dashed #C4C9D2;
}

button.chip {
    border: 1.5px solid transparent;
    height: 32px;
    padding: 0 12px;
    cursor: pointer;
}

button.chip.on {
    border-color: currentColor;
    font-weight: 700;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-warn {
    background: var(--warn-bg);
    color: var(--warn-ink);
}

.badge-ok {
    background: var(--ok-bg);
    color: var(--ok-ink);
}

.badge-info {
    background: var(--accent-soft);
    color: var(--accent-hover);
}

.badge-muted {
    background: #F1F3F6;
    color: var(--muted);
}

.swatch {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    display: inline-block;
    flex: none;
    background: var(--st-solid, #9AA1AC);
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex: none;
}

.dot-online {
    background: #16A34A;
}

.dot-recent {
    background: #F59E0B;
}

.dot-old {
    background: var(--faint);
}

.alert {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.4;
}

.alert svg {
    flex: none;
}

.alert-warn {
    background: var(--warn-bg);
    color: var(--warn-ink);
}

.alert-warn a {
    color: var(--warn-ink);
    font-weight: 600;
}

.alert-info {
    background: var(--accent-soft);
    color: var(--accent-hover);
}

.alert-ok {
    background: var(--ok-bg);
    color: var(--ok-ink);
}

.alert-error {
    background: #FEE4E2;
    color: #912018;
}

/* ---------- Station colours ---------- */

.st-blue { --st-bg: #E3EDFF; --st-ink: #1E4FBF; --st-solid: #1E4FBF; }
.st-orange { --st-bg: #FFE9D6; --st-ink: #8F3F00; --st-solid: #C2570C; }
.st-purple { --st-bg: #EEE6FF; --st-ink: #5A2FB0; --st-solid: #6D3FD1; }
.st-yellow { --st-bg: #FFF1BF; --st-ink: #634A00; --st-solid: #B08900; }
.st-teal { --st-bg: #D7F3EF; --st-ink: #0D6157; --st-solid: #0E8577; }
.st-slate { --st-bg: #E8EBF0; --st-ink: #3B4556; --st-solid: #5B6577; }
.st-green { --st-bg: #DFF4DA; --st-ink: #2A6120; --st-solid: #3C8A2E; }
.st-pink { --st-bg: #FCE4F3; --st-ink: #8E1F66; --st-solid: #C0368C; }
.st-red { --st-bg: #FDE2E1; --st-ink: #9B1C1C; --st-solid: #D33A3A; }
.st-cyan { --st-bg: #D5F3FA; --st-ink: #0B5E6F; --st-solid: #118AA3; }
.st-none { --st-bg: #F1F3F6; --st-ink: #3B4250; --st-solid: #9AA1AC; }

/* ---------- Tables ---------- */

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

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table th {
    text-align: left;
    padding: 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--surface-2);
}

.table td {
    padding: 10px 12px;
    border-top: 1px solid var(--border-soft);
    vertical-align: middle;
}

.table th:first-child, .table td:first-child {
    padding-left: 20px;
}

.table th:last-child, .table td:last-child {
    padding-right: 20px;
}

.table tbody tr:hover {
    background: #F8FAFD;
}

.table .right {
    text-align: right;
}

.person {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.person-name {
    font-weight: 600;
}

.person-sub {
    font-size: 12px;
    color: var(--muted);
}

.person-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

/* ---------- Modal / drawer ---------- */

.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(22, 24, 29, .45);
}

.modal.open {
    display: flex;
}

.modal-box {
    width: 100%;
    max-width: 480px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.modal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
    padding-top: 14px;
    border-top: 1px solid var(--border-soft);
}

.modal-actions .spacer {
    flex: 1;
}

/* ---------- Toast ---------- */

.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    z-index: 200;
    transform: translate(-50%, 20px);
    opacity: 0;
    pointer-events: none;
    padding: 12px 18px;
    border-radius: 12px;
    background: var(--ink);
    color: #FFFFFF;
    font-size: 14px;
    font-weight: 500;
    transition: opacity .2s, transform .2s;
    max-width: calc(100vw - 32px);
}

.toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

.toast.error {
    background: var(--danger);
}

body.has-tabbar .toast {
    bottom: 100px;
}

/* ---------- Print ---------- */

@media print {
    .app-header, .tabbar, .no-print, .toast {
        display: none !important;
    }

    body {
        background: #FFFFFF;
        padding: 0 !important;
    }

    .page {
        padding: 0;
        max-width: none;
    }

    .card, .stat {
        border-color: #C9CED6;
    }
}
