/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --c-primary: #1a5c2a;
    --c-primary-light: #27753a;
    --c-primary-gradient: linear-gradient(135deg, #1a5c2a 0%, #2e8b47 100%);
    --c-morning: #e8f4fd;
    --c-morning-border: #1565c0;
    --c-morning-icon: '\2600';
    --c-fuel: #fff8e1;
    --c-fuel-border: #ef6c00;
    --c-fuel-icon: '\26FD';
    --c-end: #e8f5e9;
    --c-end-border: #2e7d32;
    --c-end-icon: '\2714';
    --c-error: #c62828;
    --c-error-bg: #ffebee;
    --c-success: #2e7d32;
    --c-success-bg: #e8f5e9;
    --c-bg: #f0f2f5;
    --c-white: #ffffff;
    --c-text: #1a1a2e;
    --c-text-light: #6b7280;
    --c-border: #e5e7eb;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
}
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--c-bg);
    color: var(--c-text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* === Login === */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    min-height: 100vh;
    background: linear-gradient(135deg, #f0f2f5 0%, #dfe6e9 100%);
}
.login-container {
    width: 100%;
    max-width: 560px;
    text-align: center;
}
.login-container h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--c-primary);
    margin-bottom: 6px;
    letter-spacing: -0.02em;
}
.subtitle {
    color: var(--c-text-light);
    margin-bottom: 32px;
    font-size: 1.05rem;
    font-weight: 400;
}

.unit-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}
.unit-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 28px 20px;
    background: var(--c-white);
    border: 2px solid var(--c-border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition);
    min-height: 130px;
    font-size: 1rem;
    position: relative;
    overflow: hidden;
}
.unit-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--c-primary-gradient);
    opacity: 0;
    transition: opacity var(--transition);
}
.unit-btn:hover, .unit-btn:active {
    border-color: var(--c-primary);
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}
.unit-btn:hover::before, .unit-btn:active::before {
    opacity: 1;
}
.unit-name {
    font-weight: 700;
    font-size: 1.05rem;
    margin-bottom: 8px;
    color: var(--c-primary);
    line-height: 1.3;
}
.unit-stredisko {
    color: var(--c-text-light);
    font-size: 0.85rem;
    font-weight: 500;
    background: var(--c-bg);
    padding: 3px 10px;
    border-radius: 20px;
}

/* === PIN Modal === */
.pin-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.pin-modal.hidden { display: none; }
.pin-modal form {
    background: var(--c-white);
    padding: 36px 32px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 340px;
    text-align: center;
    animation: slideUp 0.25s ease;
}
@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.pin-modal h2 {
    font-size: 1.15rem;
    margin-bottom: 20px;
    color: var(--c-primary);
    font-weight: 600;
}
.pin-modal label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--c-text-light);
    font-size: 0.9rem;
}
.pin-modal input[type="password"] {
    width: 100%;
    padding: 16px;
    font-size: 1.6rem;
    text-align: center;
    border: 2px solid var(--c-border);
    border-radius: var(--radius);
    letter-spacing: 10px;
    margin-bottom: 20px;
    transition: border-color var(--transition);
}
.pin-modal input:focus {
    outline: none;
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px rgba(26, 92, 42, 0.15);
}
.pin-actions {
    display: flex;
    gap: 12px;
}

/* === Buttons === */
.btn {
    padding: 14px 24px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    line-height: 1.4;
}
.btn:active {
    transform: scale(0.97);
}
.btn-primary {
    background: var(--c-primary-gradient);
    color: var(--c-white);
    box-shadow: 0 2px 8px rgba(26, 92, 42, 0.3);
}
.btn-primary:hover {
    box-shadow: 0 4px 14px rgba(26, 92, 42, 0.4);
    filter: brightness(1.1);
}
.btn-secondary {
    background: var(--c-white);
    color: var(--c-text);
    border: 2px solid var(--c-border);
}
.btn-secondary:hover {
    background: var(--c-bg);
    border-color: #ccc;
}
.btn-sm {
    padding: 8px 16px;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
}

/* === Alerts === */
.alert {
    padding: 14px 20px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-weight: 500;
    font-size: 0.95rem;
    box-shadow: var(--shadow-sm);
}
.alert-error {
    background: var(--c-error-bg);
    color: var(--c-error);
    border-left: 4px solid var(--c-error);
}
.alert-success {
    background: var(--c-success-bg);
    color: var(--c-success);
    border-left: 4px solid var(--c-success);
}

/* === Navbar === */
.navbar {
    background: var(--c-primary-gradient);
    color: var(--c-white);
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    height: 60px;
}
.navbar h1 {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 50%;
}
.navbar-links {
    display: flex;
    gap: 4px;
    align-items: center;
}
.navbar-links a {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition);
    white-space: nowrap;
}
.navbar-links a:hover {
    background: rgba(255,255,255,0.15);
    color: var(--c-white);
}
.navbar-links a.active {
    background: rgba(255,255,255,0.2);
    color: var(--c-white);
}

.online-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}
.online-status.online {
    background: #4ade80;
    box-shadow: 0 0 6px rgba(74, 222, 128, 0.6);
}
.online-status.offline {
    background: #fb923c;
    box-shadow: 0 0 6px rgba(251, 146, 60, 0.6);
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* === Main Content === */
.main-content {
    max-width: 820px;
    margin: 0 auto;
    padding: 20px 16px 40px;
}

/* === Form Sections === */
.form-section {
    background: var(--c-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    overflow: hidden;
    border: 1px solid var(--c-border);
    transition: all var(--transition);
}
.form-section:hover {
    box-shadow: var(--shadow-lg);
}
.form-section-header {
    padding: 16px 20px;
    font-weight: 700;
    font-size: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    letter-spacing: -0.01em;
}
.form-section-body {
    padding: 20px;
}
.form-section.morning .form-section-header {
    background: linear-gradient(135deg, #e8f4fd 0%, #d0e8fc 100%);
    color: var(--c-morning-border);
    border-bottom: 2px solid var(--c-morning-border);
}
.form-section.fuel .form-section-header {
    background: linear-gradient(135deg, #fff8e1 0%, #ffecb3 100%);
    color: #bf360c;
    border-bottom: 2px solid var(--c-fuel-border);
}
.form-section.end .form-section-header {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    color: var(--c-end-border);
    border-bottom: 2px solid var(--c-end-border);
}
.form-section.completed {
    opacity: 0.65;
}
.form-section.completed:hover {
    opacity: 0.85;
}
.form-section.completed .form-section-header::after {
    content: '\2713 Uloženo';
    font-size: 0.85rem;
    font-weight: 600;
    background: rgba(255,255,255,0.7);
    padding: 4px 12px;
    border-radius: 20px;
}

/* === Form Fields === */
.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-bottom: 16px;
}
.form-row:last-child {
    margin-bottom: 0;
}
.form-group {
    flex: 1;
    min-width: 200px;
}
.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 0.85rem;
    color: var(--c-text-light);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 14px;
    font-size: 1rem;
    border: 2px solid var(--c-border);
    border-radius: var(--radius-sm);
    background: var(--c-white);
    transition: all var(--transition);
    color: var(--c-text);
    font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px rgba(26, 92, 42, 0.12);
}
.form-group input::placeholder {
    color: #c0c0c0;
}
.form-group textarea {
    resize: vertical;
    min-height: 90px;
}
.form-group input[type="number"] {
    -moz-appearance: textfield;
    font-variant-numeric: tabular-nums;
}
.form-group input::-webkit-outer-spin-button,
.form-group input::-webkit-inner-spin-button {
    -webkit-appearance: none;
}
.form-group input.error,
.form-group select.error {
    border-color: var(--c-error);
    background: var(--c-error-bg);
    animation: shake 0.3s ease;
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

.form-actions {
    padding: 16px 20px;
    display: flex;
    gap: 12px;
    background: #fafbfc;
    border-top: 1px solid var(--c-border);
}

/* === Warehouse radio === */
.warehouse-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.warehouse-option {
    flex: 1;
    min-width: 110px;
}
.warehouse-option input[type="radio"] {
    display: none;
}
.warehouse-option label {
    display: block;
    padding: 12px 14px;
    text-align: center;
    border: 2px solid var(--c-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all var(--transition);
    background: var(--c-white);
}
.warehouse-option label:hover {
    border-color: var(--c-primary-light);
    background: #f0faf0;
}
.warehouse-option input:checked + label {
    border-color: var(--c-primary);
    background: #e8f5e9;
    color: var(--c-primary);
    box-shadow: 0 0 0 2px rgba(26, 92, 42, 0.15);
}

/* === History === */
.history-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--c-white);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
    border: 1px solid var(--c-border);
}
.history-table th {
    background: var(--c-primary-gradient);
    color: var(--c-white);
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.history-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--c-border);
    font-size: 0.95rem;
}
.history-table tr:last-child td {
    border-bottom: none;
}
.history-table tbody tr {
    transition: background var(--transition);
}
.history-table tbody tr:hover td {
    background: #f8fafb;
}
.history-table a {
    color: var(--c-primary);
    text-decoration: none;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    display: inline-block;
}
.history-table a:hover {
    background: #e8f5e9;
}
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.status-badge.complete { background: var(--c-success-bg); color: var(--c-success); }
.status-badge.partial { background: var(--c-fuel); color: #bf360c; }
.status-badge.morning { background: var(--c-morning); color: var(--c-morning-border); }

/* === Date navigation === */
.date-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 24px;
    background: var(--c-white);
    padding: 14px 20px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--c-border);
}
.date-nav input[type="date"],
.date-nav input[type="month"] {
    padding: 10px 14px;
    font-size: 1.05rem;
    border: 2px solid var(--c-border);
    border-radius: var(--radius-sm);
    font-weight: 600;
    color: var(--c-text);
    font-family: inherit;
    transition: border-color var(--transition);
}
.date-nav input:focus {
    outline: none;
    border-color: var(--c-primary);
}
.date-nav button {
    padding: 10px 16px;
    font-size: 1.2rem;
    background: var(--c-primary-gradient);
    color: var(--c-white);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    line-height: 1;
}
.date-nav button:hover {
    filter: brightness(1.1);
}
.date-nav button:active {
    transform: scale(0.95);
}
.date-label {
    padding: 10px 14px;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--c-text);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
.date-label:hover {
    color: var(--c-primary);
}

/* === Collapsible sections === */
.form-section-header.collapsible {
    cursor: pointer;
    user-select: none;
}
.form-section-header.collapsible:hover {
    filter: brightness(0.95);
}
.collapse-icon {
    font-size: 0.75rem;
    transition: transform 0.2s;
}

/* === Export === */
.export-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    background: var(--c-white);
    padding: 16px 20px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--c-border);
}
.export-bar input[type="month"] {
    padding: 10px 14px;
    font-size: 1rem;
    border: 2px solid var(--c-border);
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-family: inherit;
}

/* === Toast === */
#toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    min-width: 300px;
    max-width: 90vw;
    text-align: center;
    animation: toastIn 0.3s ease;
    box-shadow: var(--shadow-lg);
}
#toast.hidden {
    display: none;
}
@keyframes toastIn {
    from { transform: translateX(-50%) translateY(20px); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

/* === Page title === */
h2 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--c-text);
    letter-spacing: -0.02em;
}

/* === Login Form === */
.login-form {
    background: var(--c-white);
    padding: 32px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    text-align: left;
}
.login-form .form-group {
    margin-bottom: 16px;
}
.login-form .btn-login {
    width: 100%;
    margin-top: 8px;
    padding: 16px;
    font-size: 1.1rem;
}

/* === Auto-filled MTH === */
.auto-filled {
    background: #f0faf0 !important;
    border-color: var(--c-primary-light) !important;
}
.auto-fill-note {
    font-size: 0.82rem;
    color: var(--c-primary-light);
    font-style: italic;
    margin-top: 4px;
}

/* === Crew select === */
.crew-select {
    font-size: 1.05rem !important;
    padding: 14px !important;
}

/* === Responsive === */
@media (max-width: 768px) {
    .unit-grid { grid-template-columns: 1fr; gap: 12px; }
    .form-group { min-width: 100%; }
    .navbar {
        padding: 0 12px;
        height: 56px;
    }
    .navbar h1 {
        font-size: 0.85rem;
        max-width: 45%;
    }
    .navbar-links a {
        padding: 6px 10px;
        font-size: 0.8rem;
    }
    .main-content {
        padding: 14px 12px 30px;
    }
    .form-section-body {
        padding: 16px 14px;
    }
    .date-nav {
        gap: 8px;
        padding: 12px;
    }
    .warehouse-option {
        min-width: 45%;
    }
    .history-table th,
    .history-table td {
        padding: 10px 12px;
        font-size: 0.85rem;
    }
}

@media (max-width: 400px) {
    .navbar-links a:not(.active):not([href*="logout"]) {
        display: none;
    }
    .unit-btn {
        padding: 20px 16px;
        min-height: 100px;
    }
}

/* === Fuel Items === */
.fuel-item {
    background: #fafbfc;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin-bottom: 12px;
}
.fuel-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.fuel-label {
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--c-text);
}
.fuel-total {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--c-primary);
    background: var(--c-success-bg);
    padding: 2px 8px;
    border-radius: 12px;
}
.fuel-entry-row {
    display: flex;
    gap: 8px;
    margin-bottom: 6px;
    align-items: center;
}
.fuel-entry-row input[type="number"] {
    flex: 1;
    padding: 10px 12px;
    font-size: 1rem;
    border: 2px solid var(--c-border);
    border-radius: var(--radius-sm);
}
.fuel-entry-row input[type="time"] {
    width: 120px;
    padding: 10px;
    border: 2px solid var(--c-border);
    border-radius: var(--radius-sm);
}
.btn-add-fuel {
    background: none;
    border: 2px dashed var(--c-border);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    color: var(--c-primary);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    width: 100%;
    margin-top: 4px;
    transition: all var(--transition);
}
.btn-add-fuel:hover {
    border-color: var(--c-primary);
    background: #f0faf0;
}
.btn-remove-fuel {
    background: var(--c-error);
    color: white;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: 1.1rem;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* === Admin === */
.admin-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    background: var(--c-white);
    padding: 4px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--c-border);
}
.admin-tab {
    flex: 1;
    text-align: center;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--c-text);
    font-weight: 600;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    font-size: 0.95rem;
}
.admin-tab.active {
    background: var(--c-primary-gradient);
    color: var(--c-white);
}
.admin-tab:hover:not(.active) {
    background: var(--c-bg);
}
.unit-chip {
    display: inline-block;
    padding: 4px 10px;
    margin: 2px;
    border: 2px solid var(--c-border);
    border-radius: 20px;
    background: var(--c-white);
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition);
}
.unit-chip.active {
    background: var(--c-success-bg);
    border-color: var(--c-success);
    color: var(--c-success);
}
.unit-chip:hover {
    transform: scale(1.05);
}
details summary {
    list-style: none;
}
details summary::-webkit-details-marker {
    display: none;
}

/* === Dashboard Cards === */
.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.dash-card {
    background: var(--c-white);
    border-radius: var(--radius-lg);
    border: 1px solid var(--c-border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.dash-card-header {
    padding: 12px 16px;
    background: #fafbfc;
    border-bottom: 1px solid var(--c-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}
.dash-card-body {
    padding: 16px;
}
.dash-detail {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.88rem;
    color: var(--c-text-light);
}

/* === Audit Changes === */
.change-item {
    margin-bottom: 3px;
    line-height: 1.4;
}
.change-old {
    color: var(--c-error);
    text-decoration: line-through;
}
.change-new {
    color: var(--c-success);
    font-weight: 600;
}

/* === Scrollbar === */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #c0c0c0;
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: #999;
}
