:root {
    --sidebar-bg: #0f172a;
    --sidebar-accent: #6366f1;
    --sidebar-text: rgba(255,255,255,0.75);
    --sidebar-text-hover: #ffffff;
    --sidebar-active-bg: rgba(99,102,241,0.25);
    --sidebar-border: rgba(255,255,255,0.08);
    --topbar-bg: #ffffff;
    --topbar-border: #cbd5e1;
    --content-bg: #e2e8f0;
    --card-bg: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --border: #cbd5e1;
    --radius: 10px;
    --shadow: 0 2px 6px rgba(0,0,0,0.10), 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 6px 12px rgba(0,0,0,0.10), 0 2px 6px rgba(0,0,0,0.08);
}

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

html, body {
    font-family: 'Inter', 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--content-bg);
    margin: 0;
    padding: 0;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: var(--text-primary);
}

h3 { font-size: 1.4rem; margin-bottom: 1.25rem; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Buttons ── */
button, .btn {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.btn-primary, button[type=submit] {
    background: var(--accent);
    border-color: var(--accent);
    font-weight: 500;
    border-radius: 8px;
    transition: background 0.15s, transform 0.1s;
}
.btn-primary:hover, button[type=submit]:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
    background: white;
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-weight: 500;
    border-radius: 8px;
}
.btn-secondary:hover { background: #f8fafc; }

.btn-danger  { border-radius: 8px; font-weight: 500; }
.btn-success { border-radius: 8px; font-weight: 500; }
.btn-warning { border-radius: 8px; font-weight: 500; }
.btn-sm { font-size: 0.8rem; }

/* ── Usuń strzałki przy input[type=number] ── */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }

/* ── Split date+time picker ── */
.dt-split { display: flex; gap: 6px; align-items: center; }
.dt-split input[type=date] { flex: 1.6; min-width: 0; }
.dt-split input[type=time] { flex: 1; min-width: 0; }

/* ── Forms ── */
.form-control, .form-select,
input[type=text], input[type=password], input[type=number],
input[type=email], input[type=date], input[type=time], input[type=datetime-local],
select, textarea {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text-primary);
    background: white;
    transition: border-color 0.15s, box-shadow 0.15s;
    /* Lepsze dla mobile: */
    -webkit-appearance: none;
    appearance: none;
}
.form-control:focus, input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

/* ── Tables ── */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
thead tr { background: #f1f5f9; border-bottom: 2px solid #94a3b8; }
th {
    padding: 10px 14px;
    text-align: left;
    font-weight: 700;
    color: #334155;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}
td { padding: 10px 14px; border-bottom: 1px solid #e2e8f0; color: var(--text-primary); }
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: none; }

/* ── Cards ── */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

/* ── Page content wrapper ── */
.content { padding-top: 1rem; }

/* ── Badges ── */
.badge-success { background: #dcfce7; color: #166534; padding: 3px 8px; border-radius: 20px; font-size: 0.75rem; font-weight: 600; }
.badge-danger  { background: #fee2e2; color: #991b1b; padding: 3px 8px; border-radius: 20px; font-size: 0.75rem; font-weight: 600; }

/* Badge na linku w nawigacji (np. liczba do zamówienia) */
.nav-badge {
    display: inline-flex; align-items: center; justify-content: center;
    background: #f59e0b; color: white;
    border-radius: 999px; min-width: 18px; height: 18px;
    font-size: 0.68rem; font-weight: 700; padding: 0 5px;
    margin-left: auto; flex-shrink: 0;
}

/* ── Alerts ── */
.alert { border-radius: 8px; font-size: 0.9rem; }
.alert-danger  { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }
.alert-success { background: #dcfce7; border-color: #86efac; color: #166534; }

/* ── Error / loading ── */
#blazor-error-ui {
    background: #fff3cd;
    border-top: 2px solid #f59e0b;
    bottom: 0; left: 0; right: 0;
    padding: 0.75rem 1.5rem;
    position: fixed;
    display: none;
    z-index: 9999;
    font-size: 0.9rem;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 1rem; top: 0.75rem; }

.blazor-error-boundary {
    background: #fee2e2;
    border: 1px solid #fca5a5;
    border-radius: 8px;
    padding: 1rem 1.5rem;
    color: #991b1b;
}
.blazor-error-boundary::after { content: "Wystąpił błąd komponentu." }

/* ── Loading spinner ── */
.loading-progress {
    position: relative;
    display: block;
    width: 6rem; height: 6rem;
    margin: 25vh auto 1rem auto;
}
.loading-progress circle {
    fill: none;
    stroke: #e2e8f0;
    stroke-width: 0.5rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}
.loading-progress circle:last-child {
    stroke: var(--accent);
    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;
    color: var(--text-secondary);
    inset: calc(25vh + 2.5rem) 0 auto 0;
    font-size: 0.85rem;
}
.loading-progress-text::after { content: var(--blazor-load-percentage-text, "Ładowanie..."); }

/* ── Validation ── */
.valid.modified:not([type=checkbox]) { border-color: var(--success) !important; }
.invalid { border-color: var(--danger) !important; }
.validation-message { color: var(--danger); font-size: 0.8rem; margin-top: 4px; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ══════════════════════════════════════════════════════════
   MOBILE  (max-width: 640px)
   ══════════════════════════════════════════════════════════ */
@media (max-width: 640.98px) {

    html, body { font-size: 14px; }

    h3 { font-size: 1.2rem; margin-bottom: 1rem; }

    /* Tabele – przewijane poziomo zamiast ściśnięte */
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }

    /* Większe tap-targety dla przycisków */
    button, .btn, input[type=button], input[type=submit] {
        min-height: 40px;
        padding-left: 12px;
        padding-right: 12px;
    }

    /* Inputy zajmują całą szerokość */
    input[type=text], input[type=password], input[type=number],
    input[type=email], input[type=datetime-local], select, textarea {
        width: 100%;
        font-size: 16px; /* zapobiega zoomowi na iOS */
    }

    /* Toolbary z przyciskami – zawijają w kolumny */
    div[style*="display:flex"][style*="gap"],
    .d-flex.gap-2 {
        flex-wrap: wrap;
    }

    /* Mniejszy padding kart */
    .card { padding: 1rem; }
}

/* ══════════════════════════════════════════════════════════
   STRONY LISTY — globalne ulepszenia (Obiekty, Pojazdy itp.)
   ══════════════════════════════════════════════════════════ */

/* Tytuł strony h3 — linia pod spodem */
.content h3 {
    font-size: 1.35rem;
    font-weight: 700;
    color: #0f172a;
    padding-bottom: .75rem;
    border-bottom: 2px solid #f1f5f9;
    margin-bottom: 1.25rem;
}

/* Pasek szukania + dodaj — nadaj mu wygląd karty */
div[style*="gap:10px"][style*="margin-bottom:12px"],
div[style*="gap: 10px"][style*="margin-bottom: 12px"],
div[style*="gap:10px"][style*="margin-bottom: 12px"],
div[style*="gap: 10px"][style*="margin-bottom:12px"] {
    background: white !important;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: .875rem 1.25rem !important;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    margin-bottom: 1.25rem !important;
    align-items: center !important;
}

/* Label "Szukaj" w toolbarze */
div[style*="gap:10px"] label,
div[style*="gap: 10px"] label {
    font-size: .8rem;
    font-weight: 600;
    color: #374151;
    display: block;
    margin-bottom: 4px;
}

/* Input szukania */
div[style*="gap:10px"] input[type="text"],
div[style*="gap:10px"] input:not([type]),
div[style*="gap: 10px"] input[type="text"],
div[style*="gap: 10px"] input:not([type]) {
    border: 1.5px solid #e2e8f0;
    border-radius: 8px 0 0 8px !important;
    padding: 7px 12px;
    font-size: .875rem;
    min-width: 220px;
    border-right: none;
    transition: border-color .15s;
}
div[style*="gap:10px"] input:focus,
div[style*="gap: 10px"] input:focus {
    border-color: #6366f1;
    outline: none;
    box-shadow: none;
}

/* Przycisk "Szukaj" */
div[style*="gap:10px"] button:not([style*="margin-left"]):first-of-type,
div[style*="gap: 10px"] button:not([style*="margin-left"]):first-of-type {
    background: #6366f1;
    color: white;
    border: 1.5px solid #6366f1;
    border-radius: 0 8px 8px 0 !important;
    padding: 7px 16px;
    font-weight: 600;
    font-size: .875rem;
    cursor: pointer;
    transition: background .15s;
    margin-right: 8px;
}
div[style*="gap:10px"] button:not([style*="margin-left"]):first-of-type:hover,
div[style*="gap: 10px"] button:not([style*="margin-left"]):first-of-type:hover {
    background: #4f46e5;
}

/* Przycisk "Wyczyść" */
div[style*="gap:10px"] div:first-child button:last-of-type,
div[style*="gap: 10px"] div:first-child button:last-of-type {
    background: white;
    color: #64748b;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px !important;
    padding: 7px 14px;
    font-size: .875rem;
    cursor: pointer;
    transition: all .15s;
}
div[style*="gap:10px"] div:first-child button:last-of-type:hover,
div[style*="gap: 10px"] div:first-child button:last-of-type:hover {
    background: #f8fafc;
    border-color: #94a3b8;
}

/* Przycisk "+ Dodaj" (margin-left:auto) */
div[style*="margin-left:auto"] button,
div[style*="margin-left: auto"] button {
    background: #6366f1 !important;
    color: white !important;
    border: none !important;
    border-radius: 8px !important;
    padding: 8px 18px !important;
    font-size: .875rem !important;
    font-weight: 600 !important;
    cursor: pointer;
    transition: background .15s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
div[style*="margin-left:auto"] button:hover,
div[style*="margin-left: auto"] button:hover {
    background: #4f46e5 !important;
}

/* Przyciski Edytuj / Usuń w tabeli */
table td button {
    padding: 4px 12px;
    border-radius: 6px;
    font-size: .8rem;
    font-weight: 500;
    cursor: pointer;
    border: 1.5px solid;
    transition: all .15s;
    margin-right: 4px;
    background: white;
}
table td button:first-child {
    border-color: #6366f1;
    color: #6366f1;
}
table td button:first-child:hover {
    background: #6366f1;
    color: white;
}
table td button:last-child:not(:first-child) {
    border-color: #ef4444;
    color: #ef4444;
}
table td button:last-child:not(:first-child):hover {
    background: #ef4444;
    color: white;
}

/* Komunikat sukcesu */
p[style*="green"], p[style*="color:green"], p[style*="color: green"] {
    background: #dcfce7 !important;
    color: #166534 !important;
    border: 1px solid #86efac;
    padding: .5rem 1rem;
    border-radius: 8px;
    font-size: .875rem;
    margin: .5rem 0;
}

/* Komunikat błędu */
p[style*="red"], p[style*="color:red"], p[style*="color: red"] {
    background: #fee2e2 !important;
    color: #991b1b !important;
    border: 1px solid #fca5a5;
    padding: .5rem 1rem;
    border-radius: 8px;
    font-size: .875rem;
    margin: .5rem 0;
}

/* Sekcja formularza (po HR) */
.content hr {
    border: none;
    border-top: 2px solid #f1f5f9;
    margin: 1.5rem 0;
}
.content h4 {
    font-size: 1rem;
    font-weight: 700;
    color: #374151;
    margin-bottom: 1rem;
}

/* Grid formularzy (max-width:400px) */
div[style*="max-width:400px"],
div[style*="max-width: 400px"],
div[style*="max-width:420px"],
div[style*="max-width: 420px"] {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

/* Wyróżnienie Zamówień w menu */
.nav-link-highlight {
    background: rgba(99,102,241,.15) !important;
    color: white !important;
}
.nav-link-highlight:hover {
    background: rgba(99,102,241,.3) !important;
}
