:root {
    --primary:      #1e3a5f;
    --primary-dark: #152a45;
    --accent:       #e67e22;
    --accent-dark:  #d35400;
    --bg:           #f0f2f5;
    --white:        #ffffff;
    --text:         #2c3e50;
    --text-light:   #7f8c8d;
    --border:       #dee2e6;
    --success:      #27ae60;
    --danger:       #e74c3c;
    --warning:      #f39c12;
    --sidebar-w:    230px;
    --shadow:       0 2px 10px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* ========= LOGIN ========= */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e3a5f 0%, #2980b9 100%);
    min-height: 100vh;
}
.login-container {
    background: var(--white);
    padding: 2.5rem 2rem;
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.25);
    width: 100%;
    max-width: 380px;
    text-align: center;
}
.login-logo  { font-size: 3.5rem; margin-bottom: 0.4rem; }
.login-title { font-size: 1.4rem; color: var(--primary); margin-bottom: 0.3rem; font-weight: 700; }
.login-sub   { font-size: 0.85rem; color: var(--text-light); margin-bottom: 1.8rem; }

/* ========= LAYOUT ========= */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: var(--primary);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 100;
    overflow-y: auto;
    transition: transform 0.3s;
}
.sidebar-logo {
    padding: 1.4rem 1.2rem;
    font-size: 1.15rem;
    font-weight: 700;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    letter-spacing: 0.02em;
}
.nav-links { list-style: none; padding: 0.8rem 0; flex: 1; }
.nav-links li a {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.72rem 1.2rem;
    color: rgba(255,255,255,0.78);
    text-decoration: none;
    font-size: 0.92rem;
    transition: background 0.18s, color 0.18s, border-left 0.18s;
    border-left: 3px solid transparent;
}
.nav-links li a:hover,
.nav-links li a.active {
    background: rgba(255,255,255,0.1);
    color: #fff;
    border-left: 3px solid var(--accent);
}
.nav-footer {
    padding: 1rem 1.2rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 0.82rem;
    color: rgba(255,255,255,0.7);
}
.nav-footer .user-name { color: #fff; font-weight: 600; margin-bottom: 0.15rem; font-size: 0.9rem; }
.nav-footer .user-role { font-size: 0.78rem; color: var(--accent); margin-bottom: 0.6rem; }
.nav-footer a { color: rgba(255,255,255,0.55); text-decoration: none; font-size: 0.82rem; }
.nav-footer a:hover { color: #fff; }

.main-content { margin-left: var(--sidebar-w); flex: 1; padding: 1.8rem 2rem; min-width: 0; }

.menu-toggle {
    display: none;
    position: fixed;
    top: 0.8rem; left: 0.8rem;
    z-index: 200;
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 0.45rem 0.7rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.1rem;
}

/* ========= PAGE HEADER ========= */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.8rem;
}
.page-title { font-size: 1.55rem; font-weight: 700; color: var(--primary); }

/* ========= STATS CARDS ========= */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 1.1rem;
    margin-bottom: 1.8rem;
}
.stat-card {
    background: var(--white);
    border-radius: 10px;
    padding: 1.1rem 1.4rem;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--accent);
}
.stat-card.blue   { border-left-color: #3498db; }
.stat-card.green  { border-left-color: var(--success); }
.stat-card.red    { border-left-color: var(--danger); }
.stat-card.orange { border-left-color: var(--accent); }
.stat-number { font-size: 2rem; font-weight: 700; color: var(--primary); line-height: 1; }
.stat-label  { font-size: 0.82rem; color: var(--text-light); margin-top: 0.3rem; }

/* ========= CARD ========= */
.card { background: var(--white); border-radius: 10px; box-shadow: var(--shadow); margin-bottom: 1.4rem; overflow: hidden; }
.card-header {
    padding: 0.9rem 1.4rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 0.97rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.card-body { padding: 1.4rem; }

/* ========= TABLE ========= */
.table-responsive { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th {
    background: #f4f6f8;
    padding: 0.65rem 0.9rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-light);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
td {
    padding: 0.65rem 0.9rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbfc; }
.actions-col { white-space: nowrap; }

/* ========= BADGES ========= */
.badge {
    display: inline-block;
    padding: 0.22rem 0.65rem;
    border-radius: 20px;
    font-size: 0.76rem;
    font-weight: 600;
    white-space: nowrap;
}
.badge-success   { background: #d4edda; color: #155724; }
.badge-warning   { background: #fff3cd; color: #856404; }
.badge-secondary { background: #e2e3e5; color: #3d4043; }
.badge-info      { background: #cff4fc; color: #055160; }
.badge-primary   { background: #cce5ff; color: #004085; }
.badge-danger    { background: #f8d7da; color: #721c24; }

tr.tr-ceka { background-color: #fffbeb; }
tr.tr-ceka td { border-left: 3px solid #e67e22; }

/* ── Zvýraznění změny stavu od řidiče ── */
@keyframes ridic-pulse {
    0%   { background-color: #fff3cd; }
    50%  { background-color: #ffc107; }
    100% { background-color: #fff3cd; }
}
tr.ridic-zmena {
    animation: ridic-pulse 1.8s ease-in-out infinite;
    cursor: default;
}
tr.ridic-zmena td:first-child { border-left: 4px solid #e67e22; }
.zm-countdown {
    display: inline-block;
    margin-left: 0.4rem;
    background: #e67e22;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.1rem 0.35rem;
    border-radius: 10px;
    vertical-align: middle;
    min-width: 2.2rem;
    text-align: center;
}

/* ========= FORMS ========= */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}
.form-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.form-group { margin-bottom: 0; }
.form-group label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--text); margin-bottom: 0.3rem; }
.form-group .hint  { font-size: 0.75rem; color: var(--text-light); margin-top: 0.2rem; }

input[type="text"],
input[type="password"],
input[type="date"],
input[type="email"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 0.52rem 0.8rem;
    border: 1.5px solid var(--border);
    border-radius: 6px;
    font-size: 0.88rem;
    font-family: inherit;
    color: var(--text);
    background: #fff;
    transition: border-color 0.18s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30,58,95,0.08);
}
textarea { resize: vertical; min-height: 72px; }

/* ========= BUTTONS ========= */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.48rem 1.1rem;
    border-radius: 6px;
    border: none;
    font-size: 0.88rem;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.18s;
    white-space: nowrap;
}
.btn-primary   { background: var(--primary);  color: #fff; }
.btn-primary:hover  { background: var(--primary-dark); }
.btn-accent    { background: var(--accent);   color: #fff; }
.btn-accent:hover   { background: var(--accent-dark); }
.btn-success   { background: var(--success);  color: #fff; }
.btn-success:hover  { background: #219a52; }
.btn-danger    { background: var(--danger);   color: #fff; }
.btn-danger:hover   { background: #c0392b; }
.btn-warning   { background: var(--warning);  color: #fff; }
.btn-warning:hover  { background: #e67e22; }
.btn-secondary { background: #6c757d;         color: #fff; }
.btn-secondary:hover { background: #5a6268; }
.btn-outline   { background: transparent; border: 1.5px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-sm   { padding: 0.28rem 0.65rem; font-size: 0.78rem; }
.btn-full { width: 100%; justify-content: center; }

/* ========= ALERTS ========= */
.alert { padding: 0.8rem 1rem; border-radius: 7px; margin-bottom: 1rem; font-size: 0.88rem; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-danger   { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert-info     { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }
.alert-warning  { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }

/* ========= UTILITIES ========= */
.text-muted   { color: var(--text-light); font-size: 0.83rem; }
.text-center  { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.d-flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: 0.4rem; }
.gap-2 { gap: 0.8rem; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.nowrap { white-space: nowrap; }

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-light); }
.empty-state .icon { font-size: 3rem; margin-bottom: 0.5rem; }

.form-section {
    background: #f8f9fb;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    padding: 1.4rem;
    margin-bottom: 1.5rem;
}
.form-section h3 {
    font-size: 1rem;
    color: var(--primary);
    margin-bottom: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.divider { height: 1px; background: var(--border); margin: 1.2rem 0; }

/* Search/filter bar */
.filter-bar {
    display: flex;
    gap: 0.8rem;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-bottom: 1.2rem;
}
.filter-bar .form-group { margin-bottom: 0; min-width: 150px; }

/* ========= RESPONSIVE ========= */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); box-shadow: 4px 0 20px rgba(0,0,0,0.25); }
    .main-content { margin-left: 0; padding: 1rem; padding-top: 3.5rem; }
    .menu-toggle { display: flex; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .form-grid.cols-3 { grid-template-columns: 1fr 1fr; }
    .form-grid.cols-2 { grid-template-columns: 1fr; }

    /* Větší touch targety pro tlačítka */
    .btn { padding: 0.6rem 1.1rem; font-size: 0.92rem; }
    .btn-sm { padding: 0.45rem 0.8rem; font-size: 0.82rem; }

    /* Stav select v tabulce – větší na mobilu */
    td select { font-size: 0.9rem; padding: 0.4rem 0.5rem; }

    /* Card-layout pro tabulky na mobilu */
    .mobile-cards table,
    .mobile-cards thead,
    .mobile-cards tbody,
    .mobile-cards th,
    .mobile-cards td,
    .mobile-cards tr { display: block; }

    .mobile-cards thead tr { display: none; }

    .mobile-cards tbody tr {
        background: var(--white);
        border: 1.5px solid var(--border);
        border-radius: 10px;
        margin-bottom: 0.9rem;
        padding: 0.8rem 1rem;
        box-shadow: var(--shadow);
        position: relative;
    }
    .mobile-cards tbody tr:hover td { background: transparent; }

    .mobile-cards td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0.35rem 0;
        border-bottom: 1px solid #f0f2f5;
        font-size: 0.9rem;
        min-height: 2rem;
    }
    .mobile-cards td:last-child { border-bottom: none; }

    .mobile-cards td::before {
        content: attr(data-label);
        font-size: 0.75rem;
        font-weight: 700;
        color: var(--text-light);
        text-transform: uppercase;
        letter-spacing: 0.04em;
        flex-shrink: 0;
        margin-right: 0.8rem;
        min-width: 80px;
    }
    .mobile-cards td.no-label::before { display: none; }
    .mobile-cards td.no-label {
        justify-content: flex-end;
        gap: 0.4rem;
        padding-top: 0.6rem;
        flex-wrap: wrap;
    }

    /* Skrýt méně důležité sloupce na mobilu pro řidiče */
    .mobile-cards td.hide-mobile { display: none; }

    /* Page header – tlačítko pod nadpisem */
    .page-header { flex-direction: column; align-items: flex-start; }
    .page-header .btn { align-self: stretch; justify-content: center; }

    /* Filter bar vertikálně */
    .filter-bar { flex-direction: column; }
    .filter-bar .form-group { min-width: 0; width: 100%; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .form-grid   { grid-template-columns: 1fr; }
    .main-content { padding: 0.7rem; padding-top: 3.5rem; }
}
