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

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --sidebar-grad-1: #6366f1;
    --sidebar-grad-2: #8b5cf6;
    --bg: #f5f6fa;
    --card-bg: #ffffff;
    --border: #e5e7eb;
    --text: #1f2937;
    --text-muted: #6b7280;
    --text-light: #9ca3af;
    --success: #10b981;
    --success-bg: #d1fae5;
    --warning: #f59e0b;
    --warning-bg: #fef3c7;
    --danger: #ef4444;
    --danger-bg: #fee2e2;
    --info: #3b82f6;
    --info-bg: #dbeafe;
    --purple-bg: #ede9fe;
    --purple: #8b5cf6;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text);
    background-color: var(--bg);
    line-height: 1.5;
    font-size: 14px;
}

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

/* ============================================ */
/* LAYOUT                                       */
/* ============================================ */
.layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}

/* ============================================ */
/* SIDEBAR                                      */
/* ============================================ */
.sidebar {
    background: linear-gradient(180deg, var(--sidebar-grad-1) 0%, var(--sidebar-grad-2) 100%);
    color: white;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand {
    background: rgba(255,255,255,0.12);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    backdrop-filter: blur(8px);
}

.brand-icon {
    width: 44px;
    height: 44px;
    background: white;
    color: var(--primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.brand-text strong {
    font-size: 15px;
    font-weight: 600;
}

.brand-text span {
    font-size: 13px;
    opacity: 0.85;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.15s;
}

.sidebar-nav a:hover {
    background: rgba(255,255,255,0.12);
    color: white;
}

.sidebar-nav a.active {
    background: white;
    color: var(--primary);
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.sidebar-help {
    background: rgba(255,255,255,0.12);
    border-radius: 12px;
    padding: 16px;
    margin-top: 16px;
    text-align: center;
}

.help-title {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 6px;
}

.sidebar-help p {
    font-size: 11px;
    opacity: 0.85;
    margin-bottom: 12px;
    line-height: 1.4;
}

/* ============================================ */
/* MAIN CONTENT                                 */
/* ============================================ */
.main {
    padding: 24px 32px;
    min-width: 0;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 20px;
    background: white;
    padding: 18px 24px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    margin-bottom: 20px;
}

.mobile-menu {
    display: none;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
    color: var(--primary);
}

.page-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    flex: 1;
}

.topbar-search {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 360px;
    color: var(--text-light);
}

.topbar-search svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    z-index: 1;
}

.topbar-search input,
.topbar-search input[type="text"] {
    flex: 1;
    padding: 9px 14px 9px 38px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    background: var(--bg);
}

.topbar-search input:focus {
    background: white;
}

.topbar-search-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 9px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    transition: background 0.15s;
}

.topbar-search-btn:hover {
    background: var(--primary-dark);
}

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

.user-avatar {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--primary), var(--purple));
    color: white;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
}

.user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.user-info strong {
    font-size: 13px;
    font-weight: 600;
}

.user-info span {
    font-size: 11px;
    color: var(--text-muted);
}

.page-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ============================================ */
/* CARDS / BLOCKS                               */
/* ============================================ */
.card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 22px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ============================================ */
/* STAT CARDS                                   */
/* ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 22px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    display: flex;
    align-items: center;
    gap: 16px;
}
a.stat-card {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}
a.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0,0,0,0.10);
}

/* Кликаеми редове в таблици */
tr.clickable-row { cursor: pointer; }
tr.clickable-row:hover { background: #f5f7ff; }

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon.blue { background: var(--info-bg); color: var(--info); }
.stat-icon.orange { background: var(--warning-bg); color: var(--warning); }
.stat-icon.green { background: var(--success-bg); color: var(--success); }
.stat-icon.purple { background: var(--purple-bg); color: var(--purple); }

.stat-body { flex: 1; min-width: 0; }
.stat-label { font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--text); line-height: 1.1; }
.stat-trend { font-size: 11px; color: var(--text-light); margin-top: 4px; }
.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--danger); }

/* ============================================ */
/* TABLE                                        */
/* ============================================ */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table thead th {
    background: transparent;
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: none;
    letter-spacing: 0.2px;
    border-bottom: 1px solid var(--border);
}

.table tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fafbfc; }

/* Customer cell with avatar */
.customer-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 12px;
    flex-shrink: 0;
}

.avatar-blue { background: linear-gradient(135deg, #3b82f6, #6366f1); }
.avatar-pink { background: linear-gradient(135deg, #ec4899, #f43f5e); }
.avatar-orange { background: linear-gradient(135deg, #f59e0b, #ef4444); }
.avatar-purple { background: linear-gradient(135deg, #8b5cf6, #6366f1); }
.avatar-green { background: linear-gradient(135deg, #10b981, #059669); }

.cell-primary { font-weight: 500; color: var(--text); display: block; }
.cell-secondary { font-size: 11px; color: var(--text-light); display: block; margin-top: 2px; }

/* ============================================ */
/* BADGES                                       */
/* ============================================ */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
}

.badge-warranty, .badge-completed { background: var(--success-bg); color: var(--success); }
.badge-non-warranty { background: var(--purple-bg); color: var(--purple); }
.badge-replacement { background: var(--info-bg); color: var(--info); }
.badge-intake { background: var(--info-bg); color: var(--info); }
.badge-in-progress { background: var(--warning-bg); color: var(--warning); }
.badge-delivered { background: #f3f4f6; color: var(--text-muted); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }

/* ============================================ */
/* BUTTONS                                      */
/* ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
    line-height: 1.2;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; }

.btn-info { background: white; color: var(--text); border: 1px solid var(--border); }
.btn-info:hover { background: var(--bg); }

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

.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #d97706; }

.btn-default { background: white; color: var(--text); border: 1px solid var(--border); }
.btn-default:hover { background: var(--bg); }

.btn-light { background: rgba(255,255,255,0.95); color: var(--primary); }
.btn-light:hover { background: white; }

.btn-sm { padding: 6px 12px; font-size: 12px; }

.btn-link {
    color: var(--primary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    background: none;
    padding: 0;
    border: 0;
}

/* ============================================ */
/* FORMS                                        */
/* ============================================ */
.form-group { margin-bottom: 16px; }

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 12px;
    color: var(--text-muted);
}

.form-group input,
.form-group select,
.form-group textarea,
input[type="text"],
input[type="email"],
input[type="number"],
input[type="password"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    background-color: white;
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group select,
select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

/* Inline add forms for catalogs */
.inline-add-form {
    display: grid;
    grid-template-columns: 1fr 2fr auto;
    gap: 10px;
    align-items: center;
    background: var(--bg);
    padding: 14px;
    border-radius: 10px;
    margin-bottom: 18px;
}

.inline-add-form .btn {
    white-space: nowrap;
    height: 40px;
}

/* Service case - inline add row (action / part) */
.add-row-block {
    margin-top: 18px;
    background: var(--bg);
    padding: 14px;
    border-radius: 10px;
}

.add-row-block h4 {
    font-size: 13px;
    margin-bottom: 10px;
    color: var(--text);
    font-weight: 600;
}

.add-row-inline {
    display: grid;
    grid-template-columns: 1fr 1.5fr auto;
    gap: 10px;
    align-items: center;
}

.add-row-inline.add-row-parts {
    grid-template-columns: 2fr 70px 110px auto;
}

.add-row-inline.complete-row {
    grid-template-columns: 1fr auto;
    align-items: end;
    margin-top: 8px;
}

.add-row-inline input,
.add-row-inline select {
    height: 40px;
}

.add-row-inline .btn {
    white-space: nowrap;
    height: 40px;
}

@media (max-width: 600px) {
    .inline-add-form,
    .add-row-inline,
    .add-row-inline.add-row-parts,
    .add-row-inline.complete-row {
        grid-template-columns: 1fr;
    }
}

/* ============================================ */
/* CATALOGS LIST CARD                           */
/* ============================================ */
.list-card .list-row {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    color: var(--text);
}

.list-card .list-row:last-child { border: none; }

.list-link {
    color: var(--primary);
    font-weight: 500;
    font-size: 13px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
}

/* ============================================ */
/* INTEGRATION CARD                             */
/* ============================================ */
.integration-card .integration-icon {
    width: 56px;
    height: 56px;
    background: var(--purple-bg);
    color: var(--purple);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 12px;
}

.integration-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--success);
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 10px;
}

.integration-status::before {
    content: '';
    display: block;
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
}

/* ============================================ */
/* ALERTS                                       */
/* ============================================ */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 13px;
}

.alert-error { background: var(--danger-bg); color: var(--danger); }
.alert-success { background: var(--success-bg); color: var(--success); }

.alert-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 16px;
    border-radius: 10px;
    font-size: 12px;
    line-height: 1.5;
    margin-bottom: 16px;
}

.alert-banner code {
    background: rgba(0,0,0,0.06);
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 11px;
}

.alert-banner-warning {
    background: var(--warning-bg);
    color: #92400e;
}

.alert-banner-warning .alert-banner-icon { color: #d97706; }

/* ============================================ */
/* STEPPER                                      */
/* ============================================ */
.stepper {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 18px;
    font-size: 11px;
    color: var(--text-muted);
}

.stepper-step {
    display: flex;
    align-items: center;
    gap: 6px;
}

.step-num {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--bg);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 11px;
}

.step-num.active { background: var(--primary); color: white; }

.stepper-line { flex: 1; height: 1px; background: var(--border); margin: 0 8px; }

/* ============================================ */
/* LOGIN                                        */
/* ============================================ */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--sidebar-grad-1) 0%, var(--sidebar-grad-2) 100%);
}

.login-card {
    background: white;
    padding: 36px;
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.15);
    width: 100%;
    max-width: 400px;
}

.login-card h2 {
    text-align: center;
    margin-bottom: 6px;
    color: var(--primary);
    font-size: 22px;
}

.subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 28px;
    font-size: 13px;
}

/* ============================================ */
/* FOOTER                                       */
/* ============================================ */
.app-footer {
    text-align: center;
    padding: 20px 0 4px;
    font-size: 11px;
    color: var(--text-light);
    margin-top: auto;
}

.app-footer a {
    color: var(--primary);
    text-decoration: none;
}

.app-footer a:hover { text-decoration: underline; }

.auth-footer {
    position: fixed;
    bottom: 12px;
    left: 0;
    right: 0;
    color: rgba(255,255,255,0.85);
}

.auth-footer a { color: white; }

/* ============================================ */
/* TABS / ICONS / MISC                          */
/* ============================================ */
.icon { display: inline-block; vertical-align: -0.18em; flex-shrink: 0; }
.btn .icon { margin: 0; }

/* ---- Deadline indicators ---- */
.deadline-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 6px;
    white-space: nowrap;
}
.deadline-warning { background: #fff3cd; color: #856404; border: 1px solid #ffe08a; }
.deadline-overdue { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
tr.row-warning td { background: rgba(255, 244, 199, 0.55) !important; }
tr.row-overdue td { background: rgba(254, 226, 226, 0.6) !important; }

/* ---- Global modal ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}
.modal-box {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 460px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: modalIn 0.15s ease-out;
}
@keyframes modalIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; font-size: 16px; color: var(--text); }
.modal-close {
    background: transparent;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
}
.modal-close:hover { color: var(--danger); }
.modal-body { padding: 20px; }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
}
.modal-warn-icon {
    display: flex;
    justify-content: center;
    color: #dc3545;
    margin-bottom: 10px;
}
.modal-icon-success { color: #16a34a; }
.modal-icon-error   { color: #dc3545; }
.modal-icon-warning { color: #f59e0b; }
.modal-icon-info    { color: #6366f1; }

/* ====== Унифицирани action бутони (table row actions) ====== */
.row-actions {
    display: inline-flex;
    gap: 6px;
    flex-wrap: nowrap;
    align-items: center;
}
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: white;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.15s;
    flex-shrink: 0;
    line-height: 0;
    padding: 0;
}
.icon-btn:hover:not(:disabled) { transform: translateY(-1px); }
.icon-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.icon-btn-warning:hover { background: #fff3cd; color: #b8860b; border-color: #ffe08a; }
.icon-btn-info:hover    { background: #e0f2fe; color: #0369a1; border-color: #bae6fd; }
.icon-btn-success:hover { background: #dcfce7; color: #15803d; border-color: #bbf7d0; }
.icon-btn-danger        { color: #dc3545; }
.icon-btn-danger:hover  { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }

/* Постоянно зелено копче за товарителница (показва номера) */
.waybill-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 32px;
    padding: 0 10px;
    background: #16a34a;
    color: #fff;
    border: 1px solid #15803d;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 600;
    font-family: monospace;
    text-decoration: none;
    transition: all 0.15s;
    flex-shrink: 0;
}
.waybill-btn:hover { background: #15803d; color: #fff; transform: translateY(-1px); }

/* ====== Фактури към ремонт (обозначение „Има фактура" + бутон за прикачване) ====== */
/* Баджът и бутонът са inline-block с нормално пренасяне: в тясна таблица (лаптоп 1366-1440 px)
   се чупят на два реда, вместо да разширяват таблицата и да пускат хоризонтален скрол */
.invoice-badge {
    display: inline-block;
    background: #16a34a;
    color: #fff;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
    text-decoration: none;
    margin-top: 4px;
    transition: background 0.15s;
}
.invoice-badge:hover { background: #15803d; color: #fff; }
.invoice-badge svg { vertical-align: -2px; margin-right: 2px; }
/* дълъг номер се реже с многоточие (пълният е в title) */
.invoice-badge .invoice-num { font-weight: 400; opacity: 0.9; display: inline-block; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.invoice-add {
    display: inline-block;
    background: none;
    border: 1px dashed #c7cbe6;
    color: var(--text-muted);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-family: inherit;
    line-height: 1.4;
    cursor: pointer;
    margin-top: 4px;
    text-decoration: none;
    text-align: left;
    transition: all 0.15s;
}
.invoice-add svg { vertical-align: -2px; margin-right: 2px; }
.invoice-add:hover { border-color: var(--primary); color: var(--primary); background: #eef0ff; }
/* Тесни десктопи (лаптоп 1366-1440 px): дългите IMEI/телефони в допълнителния ред могат да се пренасят,
   а широките таблици (Сервизни случаи, Табло) се скролват в рамките на картата, не цялата страница */
.table .cell-secondary { overflow-wrap: anywhere; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 768px) {
    .table-scroll { overflow: visible; }
}

/* Клетка „Цена / Фактура": цената над баджа, като един блок (на телефон се подравнява вдясно) */
.price-box { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.price-box .case-price { font-weight: 600; }
@media (max-width: 768px) {
    .price-box { align-items: flex-end; }
}

/* Обща сума под списъка (преизчислява се при всеки филтър) */
.totals-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 12px 36px;
    margin-top: 14px;
    padding: 14px 20px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
}
.totals-bar .totals-item { display: flex; flex-direction: column; align-items: flex-end; }
.totals-bar .totals-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); }
.totals-bar .totals-value { font-size: 18px; font-weight: 700; color: var(--text); line-height: 1.2; }
.totals-bar .totals-sum { font-size: 24px; color: #15803d; }
@media (max-width: 768px) {
    .totals-bar { justify-content: space-between; }
}

/* Групи във филтрите (например „Цена от - до") */
.filter-group { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; }
.filter-label { font-size: 12px; color: var(--text-muted); flex-shrink: 0; }
.dash-filters input[type="text"], .dash-filters input[type="number"] {
    font-size: 13px;
    padding: 8px 10px;
}
@media (max-width: 768px) {
    /* на телефон групата „Цена от - до" е на цял ред, полетата делят ширината и могат да се свиват */
    .dash-filters .filter-group { display: flex; width: 100%; }
    .dash-filters .filter-group input { flex: 1 1 0; min-width: 0; width: auto !important; }
}

/* Dashboard filters */
.dash-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    background: var(--bg);
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 16px;
}

.dash-filters select {
    width: auto;
    min-width: 160px;
    font-size: 13px;
    padding: 8px 28px 8px 10px;
}

.dash-filters .btn {
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .dash-filters select { width: 100%; min-width: 0; }
    .dash-filters .btn { width: 100%; }
}

.shop-favicon {
    width: 16px !important;
    height: 16px !important;
    max-width: 16px;
    max-height: 16px;
    object-fit: contain;
    display: inline-block;
    flex-shrink: 0;
    vertical-align: middle;
}

.lookup-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg);
    padding: 4px;
    border-radius: 10px;
    margin-bottom: 18px;
}

.tab-btn {
    background: transparent;
    border: none;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-muted);
    border-radius: 6px;
    flex: 1;
    transition: all 0.15s;
}

.tab-btn:hover { color: var(--primary); }

.tab-btn.active {
    background: white;
    color: var(--primary);
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* Dashboard layout helpers */
.bottom-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr 1fr;
    gap: 16px;
}

.section-divider {
    text-align: center;
    color: var(--primary);
    font-weight: 600;
    font-size: 13px;
    padding: 14px;
    cursor: pointer;
}

h1, h2, h3 { color: var(--text); font-weight: 700; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }

/* ============================================ */
/* MOBILE                                       */
/* ============================================ */
@media (max-width: 1024px) {
    .bottom-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .layout { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed;
        left: -260px;
        width: 240px;
        z-index: 200;
        transition: left 0.25s;
        height: 100vh;
    }
    .sidebar.open { left: 0; }
    .mobile-menu { display: inline-flex; }
    .topbar-search { display: none; }
    .main { padding: 16px; }
    .topbar { padding: 12px 16px; }
    .page-title { font-size: 17px; }
    .user-info { display: none; }
}

@media (max-width: 600px) {
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .stat-card { padding: 14px; gap: 12px; }
    .stat-icon { width: 44px; height: 44px; border-radius: 10px; }
    .stat-icon svg { width: 22px; height: 22px; }
    .stat-value { font-size: 20px; }
    .stat-label { font-size: 11px; }

    .table-stack thead { display: none; }
    .table-stack, .table-stack tbody, .table-stack tr { display: block; }
    .table-stack tr {
        background: white;
        border: 1px solid var(--border);
        border-radius: 10px;
        margin-bottom: 10px;
        padding: 12px;
    }
    .table-stack td {
        display: flex;
        justify-content: space-between;
        gap: 10px;
        padding: 6px 0;
        border: none;
        text-align: right;
    }
    .table-stack td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-muted);
        font-size: 11px;
        text-align: left;
    }

    .form-row { grid-template-columns: 1fr; }
}
