:root {
    --bg-primary: #0b1120;
    --bg-secondary: #131c31;
    --bg-surface: #1e293b;
    --bg-surface-hover: #27354f;
    --bg-surface-active: #334155;
    
    --border-color: #2e3e5c;
    --border-focus: #38bdf8;
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --accent-blue: #0284c7;
    --accent-cyan: #06b6d4;
    --accent-indigo: #6366f1;
    --accent-emerald: #10b981;
    --accent-amber: #f59e0b;
    --accent-rose: #f43f5e;
    --accent-purple: #8b5cf6;
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 20px rgba(56, 189, 248, 0.25);
    
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #f1f5f9;
    --bg-surface: #ffffff;
    --bg-surface-hover: #f8fafc;
    --bg-surface-active: #e2e8f0;
    
    --border-color: #cbd5e1;
    --border-focus: #0284c7;
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-glow: 0 0 15px rgba(2, 132, 199, 0.15);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Layout */
.app-header {
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(8px);
}

.header-container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.brand-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: white;
    box-shadow: 0 0 12px rgba(2, 132, 199, 0.4);
}

.brand-text h1 {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(90deg, #38bdf8, #818cf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-text p {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.header-search {
    flex: 1;
    max-width: 420px;
    position: relative;
}

.search-input {
    width: 100%;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    padding: 0.5rem 1rem 0.5rem 2.4rem;
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: var(--transition);
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.2);
}

.search-icon {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, #0284c7, #0369a1);
    color: white;
    box-shadow: 0 2px 8px rgba(2, 132, 199, 0.3);
}
.btn-primary:hover {
    background: linear-gradient(135deg, #0369a1, #075985);
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.4);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: var(--bg-surface);
    border-color: var(--border-color);
    color: var(--text-primary);
}
.btn-secondary:hover {
    background-color: var(--bg-surface-hover);
    border-color: var(--border-focus);
}

.btn-success {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}
.btn-success:hover {
    background: linear-gradient(135deg, #059669, #047857);
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
}
.btn-danger:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
}

.btn-sm {
    padding: 0.3rem 0.65rem;
    font-size: 0.775rem;
    border-radius: var(--radius-sm);
}

.btn-icon-only {
    padding: 0.5rem;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
}

/* User pill */
.user-pill {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.35rem 0.75rem;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    font-size: 0.825rem;
}

.user-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: var(--accent-indigo);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.75rem;
    font-weight: bold;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.55rem;
    font-size: 0.725rem;
    font-weight: 700;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-admin { background: rgba(239, 68, 68, 0.2); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.4); }
.badge-manager { background: rgba(139, 92, 246, 0.2); color: #c4b5fd; border: 1px solid rgba(139, 92, 246, 0.4); }
.badge-servis { background: rgba(14, 165, 233, 0.2); color: #7dd3fc; border: 1px solid rgba(14, 165, 233, 0.4); }
.badge-prodejna { background: rgba(16, 185, 129, 0.2); color: #6ee7b7; border: 1px solid rgba(16, 185, 129, 0.4); }

/* Navigation bar */
.nav-bar {
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.nav-container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.85rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 600;
    border-bottom: 2px solid transparent;
    transition: var(--transition);
    cursor: pointer;
    white-space: nowrap;
}

.nav-link:hover {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.02);
}

.nav-link.active {
    color: #38bdf8;
    border-bottom-color: #38bdf8;
}

.nav-count {
    background-color: var(--bg-surface-active);
    color: var(--text-primary);
    padding: 0.1rem 0.45rem;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 700;
}

/* Main Content */
.main-content {
    flex: 1;
    max-width: 1440px;
    width: 100%;
    margin: 0 auto;
    padding: 1.5rem;
}

/* Page header */
.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.page-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.2rem;
}

/* Card */
.card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1.25rem;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Filter Bar */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 1.25rem;
    background-color: var(--bg-secondary);
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.filter-label {
    font-size: 0.775rem;
    font-weight: 600;
    color: var(--text-muted);
}

.form-select, .form-input, .form-textarea {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.45rem 0.75rem;
    color: var(--text-primary);
    font-size: 0.85rem;
    transition: var(--transition);
}

.form-select:focus, .form-input:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.2);
}

/* Table */
.table-responsive {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-surface);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.875rem;
}

.data-table th {
    background-color: var(--bg-secondary);
    color: var(--text-secondary);
    font-weight: 700;
    font-size: 0.775rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.data-table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.data-table tr:hover td {
    background-color: var(--bg-surface-hover);
}

.data-table tr:last-child td {
    border-bottom: none;
}

/* SLA badge */
.sla-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-sm);
    white-space: nowrap;
}
.sla-ok { background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); }
.sla-warning { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }
.sla-danger { background: rgba(239, 68, 68, 0.2); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.4); animation: pulse 2s infinite; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Status Pill */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.65rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
}

/* Grid Forms */
.form-grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

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

.form-grid-4 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 0.75rem;
}

.form-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-group.required label::after {
    content: " *";
    color: var(--accent-rose);
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    user-select: none;
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-blue);
    cursor: pointer;
}

/* Section Divider */
.section-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1.5rem 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}
.section-divider h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent-cyan);
}

/* Modals */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
    overflow-y: auto;
}

.modal-backdrop.active {
    display: flex;
}

.modal-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.25s ease-out;
}

@keyframes modalIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Signature Pad Canvas */
.signature-box {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    background-color: white;
    touch-action: none;
    position: relative;
    overflow: hidden;
}

.signature-box canvas {
    display: block;
    cursor: crosshair;
    width: 100%;
    height: 180px;
}

.signature-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
}

/* KPI Cards Grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.kpi-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}

.kpi-card:hover {
    border-color: var(--border-focus);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.kpi-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--kpi-color, var(--accent-blue));
}

.kpi-title {
    font-size: 0.775rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.04em;
}

.kpi-value {
    font-size: 2rem;
    font-weight: 800;
    margin: 0.4rem 0 0.2rem 0;
    line-height: 1;
    color: var(--text-primary);
}

.kpi-sub {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.chart-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

.chart-bars {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
}

.chart-bar-row {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.chart-bar-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    font-weight: 600;
}

.chart-bar-track {
    height: 8px;
    background-color: var(--bg-primary);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.chart-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-cyan));
    border-radius: var(--radius-full);
    transition: width 0.8s ease-out;
}

/* Timeline */
.timeline {
    position: relative;
    padding-left: 1.5rem;
}

.timeline::before {
    content: "";
    position: absolute;
    left: 7px;
    top: 5px;
    bottom: 5px;
    width: 2px;
    background-color: var(--border-color);
}

.timeline-item {
    position: relative;
    margin-bottom: 1.25rem;
}

.timeline-dot {
    position: absolute;
    left: -1.5rem;
    top: 4px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: var(--accent-blue);
    border: 3px solid var(--bg-surface);
}

.timeline-content {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
}

.timeline-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.35rem;
}

.timeline-action {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
}

.timeline-time {
    font-size: 0.725rem;
    color: var(--text-muted);
}

.timeline-comment {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Gallery & Lightbox */
.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
}

.media-thumb {
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    aspect-ratio: 1;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
}

.media-thumb:hover {
    transform: scale(1.03);
    border-color: var(--accent-blue);
}

.media-thumb img, .media-thumb video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.media-badge {
    position: absolute;
    bottom: 4px;
    left: 4px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 4px;
}

/* Scanner view */
.scanner-container {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    background-color: black;
}

.scanner-video {
    width: 100%;
    display: block;
}

.scanner-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 220px;
    height: 220px;
    border: 2px solid #38bdf8;
    border-radius: 12px;
    box-shadow: 0 0 0 1000px rgba(0, 0, 0, 0.5);
    pointer-events: none;
}

.scanner-laser {
    position: absolute;
    width: 100%;
    height: 2px;
    background-color: #ef4444;
    box-shadow: 0 0 8px #ef4444;
    top: 0;
    animation: scanAnim 2s infinite linear;
}

@keyframes scanAnim {
    0% { top: 0; }
    50% { top: 100%; }
    100% { top: 0; }
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background-color: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--accent-blue);
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: toastIn 0.25s ease-out;
}
.toast-success { border-left-color: var(--accent-emerald); }
.toast-error { border-left-color: var(--accent-rose); }
.toast-warning { border-left-color: var(--accent-amber); }

@keyframes toastIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .header-container { flex-wrap: wrap; }
    .header-search { order: 3; max-width: 100%; }
    .main-content { padding: 1rem; }
    .charts-grid { grid-template-columns: 1fr; }
}

/* Repair type selection cards */
.repair-type-card {
    cursor: pointer;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.9rem 1.1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    background: var(--bg-surface);
    transition: all 0.2s ease;
}
.repair-type-card:hover {
    border-color: var(--accent-cyan);
    background: var(--bg-secondary);
}
.repair-type-card.selected {
    border-color: var(--accent-cyan);
    background: rgba(14, 165, 233, 0.1);
    box-shadow: 0 0 0 1px var(--accent-cyan);
}
