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

body {
    font-family: 'Inter', Arial, sans-serif;
    background-color: #f5f5f5;
    padding: 20px;
    font-size: 15px;
    line-height: 1.5;
    color: #333;
}

input, select, textarea, button {
    font-family: inherit;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    padding: 28px 28px 36px;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

h1 {
    color: #333;
    margin-bottom: 20px;
    text-align: center;
}

.search-form {
    background: #f8f9fb;
    padding: 16px 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    border: 1px solid #e8eaed;
}

.search-form-inner {
    width: 100%;
}

.search-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.search-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.search-field label {
    font-size: 12px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.search-field--article { flex: 2; min-width: 160px; }
.search-field--brand   { flex: 1.5; min-width: 130px; }
.search-field--sort    { flex: 1; min-width: 110px; }
.search-field--btn     { flex: 0 0 auto; }

.search-field input,
.search-field select {
    padding: 9px 12px;
    border: 1px solid #dde0e6;
    border-radius: 7px;
    font-size: 14px;
    font-family: inherit;
    background: white;
    color: #333;
    transition: border-color 0.15s, box-shadow 0.15s;
    height: 40px;
}

.search-field input:focus,
.search-field select:focus {
    outline: none;
    border-color: #1a6cff;
    box-shadow: 0 0 0 3px rgba(26, 108, 255, 0.12);
}

.search-icon {
    width: 16px;
    height: 16px;
    vertical-align: middle;
    margin-right: 5px;
    margin-top: -2px;
}

#search-btn {
    height: 40px;
    padding: 0 20px;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    font-size: 14px;
    font-weight: 600;
}

.login-form {
    background: white;
    padding: 36px 40px;
    border-radius: 12px;
    margin-bottom: 20px;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
    border: 1px solid #e8eaed;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.form-group {
    margin-bottom: 15px;
}

/* ============================================================
   Toast notifications
   ============================================================ */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    padding: 12px 18px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    color: white;
    min-width: 220px;
    max-width: 360px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    transform: translateX(40px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: auto;
}

.toast.toast-show {
    opacity: 1;
    transform: translateX(0);
}

.toast.toast-hide {
    opacity: 0;
    transform: translateX(40px);
}

.toast-success { background: #28a745; }
.toast-error   { background: #dc3545; }
.toast-info    { background: #007bff; }
.toast-warning { background: #fd7e14; }

/* ============================================================
   Orders filters
   ============================================================ */
.orders-filters {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-group label {
    font-size: 14px;
    color: #555;
    font-weight: 500;
    white-space: nowrap;
}

.filter-group select,
input.orders-search-input {
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    background: white;
    color: #333;
    min-width: 160px;
    height: 36px;
    box-sizing: border-box;
    width: auto;
}

.filter-group select {
    cursor: pointer;
}

.orders-date-input {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    background: white;
    color: #333;
    height: 36px;
    box-sizing: border-box;
    width: auto;
    max-width: 160px;
}

.orders-date-input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

/* Flatpickr calendar theme overrides */
.flatpickr-calendar {
    font-family: Inter, system-ui, sans-serif;
    font-size: 13px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    border: 1px solid #ddd;
}
.flatpickr-day.selected,
.flatpickr-day.selected:hover,
.flatpickr-day.startRange,
.flatpickr-day.endRange {
    background: #0d6efd;
    border-color: #0d6efd;
}
.flatpickr-day:hover,
.flatpickr-day.prevMonthDay:hover,
.flatpickr-day.nextMonthDay:hover {
    background: #e7f1ff;
    border-color: #e7f1ff;
}
.flatpickr-months .flatpickr-month,
.flatpickr-current-month,
.flatpickr-monthDropdown-months {
    background: #0d6efd;
    color: #fff;
}
.flatpickr-current-month .flatpickr-monthDropdown-months {
    color: #fff;
}
.flatpickr-current-month input.cur-year {
    color: #fff;
}
.flatpickr-months .flatpickr-prev-month,
.flatpickr-months .flatpickr-next-month {
    color: #fff;
    fill: #fff;
}
.flatpickr-months .flatpickr-prev-month:hover,
.flatpickr-months .flatpickr-next-month:hover {
    color: #fff;
    fill: #fff;
}
.flatpickr-months .flatpickr-prev-month:hover svg,
.flatpickr-months .flatpickr-next-month:hover svg {
    fill: rgba(255,255,255,0.8);
}
.flatpickr-weekday {
    color: #888;
    font-weight: 600;
}
.flatpickr-day.today {
    border-color: #0d6efd;
}
.flatpickr-day.today:hover {
    background: #0d6efd;
    border-color: #0d6efd;
    color: #fff;
}

.filter-group select:focus,
input.orders-search-input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

/* ============================================================
   Client balance in nav
   ============================================================ */
.client-balance {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: #f8f9fa;
    border-radius: 6px;
    font-size: 14px;
    margin-left: auto;
}

.client-balance .balance-label,
.client-balance .debt-label {
    color: #666;
    font-weight: 500;
}

.client-balance #balance-label {
    cursor: pointer;
    color: #fff;
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 13px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 123, 255, 0.2);
}

.client-balance #balance-label:hover {
    color: #fff;
    background: linear-gradient(135deg, #0056b3 0%, #004080 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 123, 255, 0.3);
}

.client-balance #balance-label::before {
    content: "📊";
    font-size: 14px;
}

.client-balance .balance-value {
    color: #28a745;
    font-weight: bold;
    font-size: 16px;
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: dotted;
}

.client-balance .balance-value:hover {
    color: #1e7e34;
    text-decoration-style: solid;
}

.client-balance .debt-value {
    color: #dc3545;
    font-weight: bold;
    font-size: 16px;
}

.client-balance .btn-history {
    padding: 4px 10px;
    font-size: 12px;
    background: #6c757d;
    border-radius: 4px;
}

.client-balance .btn-history:hover {
    background: #5a6268;
}

/* ============================================================
   Modal
   ============================================================ */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    border-radius: 8px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
}

.modal-header h3 {
    margin: 0;
    color: #333;
    font-size: 18px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #999;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

/* ============================================================
   Balance history
   ============================================================ */
.balance-history-filters {
    margin-bottom: 15px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
    display: flex;
    gap: 15px;
}

.balance-history-filters .filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.balance-history-filters label {
    font-size: 13px;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.balance-history-filters select {
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    cursor: pointer;
    min-width: 150px;
    height: 34px;
    color: #333;
}

.balance-history-filters select:focus {
    outline: none;
    border-color: #0d6efd;
    box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.15);
}

.balance-history-content {
    max-height: 500px;
    overflow-y: auto;
}

.balance-history-transactions {
    margin-top: 15px;
}

.balance-transaction-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid #eee;
    transition: background-color 0.2s;
}

.balance-transaction-item:hover {
    background-color: #f8f9fa;
}

.balance-transaction-item:last-child {
    border-bottom: none;
}

.transaction-info {
    flex: 1;
}

.transaction-description {
    font-size: 14px;
    font-weight: 500;
    color: #222;
    margin-bottom: 3px;
}

.transaction-type {
    font-size: 11px;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.transaction-type.deposit { color: #1a7f3c; }
.transaction-type.refund  { color: #dc3545; }
.transaction-type.order   { color: #0d6efd; }

.transaction-amount {
    font-size: 15px;
    font-weight: 700;
    margin-right: 20px;
    white-space: nowrap;
}

.transaction-amount.positive { color: #1a7f3c; }
.transaction-amount.negative { color: #dc3545; }

.transaction-date {
    font-size: 12px;
    color: #aaa;
    min-width: 130px;
    text-align: right;
    white-space: nowrap;
}

.balance-history-empty {
    text-align: center;
    padding: 40px;
    color: #999;
    font-size: 15px;
}

/* ============================================================
   Form elements
   ============================================================ */
label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    font-size: 14px;
    color: #555;
}

input[type="text"],
input[type="password"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
}

input[type="text"]:focus,
input[type="password"]:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.2);
}

button {
    background: #007bff;
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 15px;
    font-family: inherit;
    font-weight: 500;
    width: 100%;
    transition: background 0.15s;
}

button:hover {
    background: #0056b3;
}

button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Search button loading state */
#search-btn.loading {
    background: #6c757d;
    cursor: wait;
}

.btn {
    background: #007bff;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
    font-weight: 500;
    text-decoration: none;
    width: auto;
    display: inline-block;
    transition: background 0.15s;
}

.btn:hover {
    background: #0056b3;
}

.btn-secondary {
    background: #6c757d;
    padding: 8px 16px;
    width: auto;
    font-size: 14px;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-small {
    background: #6c757d;
    color: white;
    padding: 4px 12px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    font-family: inherit;
    text-decoration: none;
    width: auto;
    display: inline-block;
}

.btn-small:hover {
    background: #5a6268;
}

/* ============================================================
   Finance info panel
   ============================================================ */
.finance-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
}

.finance-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #f5f8ff;
    border: 1px solid #dde5ff;
    padding: 6px 16px;
    border-radius: 8px;
    min-width: 90px;
    cursor: default;
}

.finance-label {
    font-size: 11px;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    line-height: 1;
    margin-bottom: 3px;
}

.finance-value {
    font-weight: 700;
    font-size: 16px;
    color: #333;
    line-height: 1;
}

.finance-value.balance { color: #1a7f3c; }
.finance-value.debt    { color: #c0392b; }

/* ============================================================
   Telegram button
   ============================================================ */
.btn-telegram {
    background: transparent;
    color: #0088cc;
    padding: 6px 12px;
    border: 1px solid #b3d9f0;
    border-radius: 7px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
    height: 32px;
}

.btn-telegram:hover {
    background: #e8f5fd;
    border-color: #0088cc;
}

/* ============================================================
   Favorites button (header)
   ============================================================ */
.btn-favorites {
    background: transparent;
    color: #b8860b;
    padding: 6px 12px;
    border: 1px solid #f0d060;
    border-radius: 7px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
    height: 32px;
}
.btn-favorites:hover {
    background: #fffbea;
    border-color: #d4a017;
}

/* Star icon in result card */
.fav-star {
    font-size: 15px;
    color: #ddd;
    cursor: pointer;
    line-height: 1;
    flex-shrink: 0;
    user-select: none;
    transition: color 0.15s, transform 0.12s;
}
.fav-star:hover {
    color: #f5c518;
    transform: scale(1.25);
}

/* Delete button inside favorites table */
.btn-fav-delete {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    color: #ccc;
    padding: 2px 4px;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}
.btn-fav-delete:hover {
    color: #dc3545;
    background: #fee2e2;
}

/* Favorites table rows — equal height, no wrapping */
.fav-row {
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
}
.fav-row:hover .fav-cell {
    background: #fffbea;
}
.fav-cell {
    padding: 10px 14px;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 0;
}
.fav-cell-article {
    font-weight: 600;
    color: #1a1a1a;
    font-family: monospace;
    width: 22%;
}
.fav-cell-brand {
    color: #3a5bd9;
    width: 20%;
}
.fav-cell-name {
    color: #555;
    width: 52%;
}
.fav-cell-del {
    width: 32px;
    text-align: center;
    padding: 0 8px;
    max-width: none;
    overflow: visible;
}

/* Toast notification for favorites */
.fav-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #1a1a1a;
    color: #fff;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.25s, transform 0.25s;
    z-index: 9999;
    pointer-events: none;
    white-space: nowrap;
}
.fav-toast.fav-toast-show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.form-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 15px;
}

.form-actions .btn {
    flex: 0 0 auto;
    width: auto;
    min-width: 120px;
}

/* ============================================================
   Loading / Error / Success banners
   ============================================================ */
.loading {
    text-align: center;
    padding: 20px;
    display: none;
    color: #555;
    font-size: 15px;
}

.loading.active {
    display: block;
    padding: 0;
}

.error {
    background: #f8d7da;
    color: #721c24;
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 20px;
    display: none;
}

.error.active {
    display: block;
}

.success {
    background: #d4edda;
    color: #155724;
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 20px;
    display: none;
}

.success.active {
    display: block;
}

/* ============================================================
   Search results layout: sidebar + cards
   ============================================================ */
.search-results-layout {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    margin-top: 20px;
}

.brands-sidebar {
    width: 180px;
    flex-shrink: 0;
    position: sticky;
    top: 10px;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    background: #f5f6f8;
    border-radius: 8px;
    padding: 8px;
    border: 1px solid #e2e4e8;
    scrollbar-width: thin;
    scrollbar-color: #c0c4cc #f5f6f8;
}

.brands-sidebar::-webkit-scrollbar {
    width: 4px;
}

.brands-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.brands-sidebar::-webkit-scrollbar-thumb {
    background: #c0c4cc;
    border-radius: 2px;
}

.brands-sidebar-title {
    font-size: 11px;
    font-weight: 700;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    padding: 2px 6px 8px;
    margin-bottom: 4px;
    border-bottom: 1px solid #dde0e6;
}

.brand-filter-btn {
    display: block;
    width: 100%;
    text-align: left;
    padding: 7px 10px;
    margin-bottom: 3px;
    border: 1px solid #dde0e6;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    font-family: inherit;
    color: #222;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.brand-filter-btn:hover {
    background: #e8eeff;
    border-color: #a8bfff;
}

.brand-filter-btn.active {
    background: #1a6cff;
    border-color: #1a6cff;
    color: #fff;
}

.brand-filter-btn.active .bfb-price {
    color: rgba(255, 255, 255, 0.85);
}

.bfb-name {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: inherit;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bfb-price {
    display: block;
    font-size: 12px;
    color: #555;
    margin-top: 1px;
}

.brand-filter-btn.loading {
    opacity: 0.7;
    pointer-events: none;
}

.bfb-spinner {
    display: inline-block;
    width: 10px;
    height: 10px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: bfb-spin 0.6s linear infinite;
    margin-right: 5px;
    vertical-align: middle;
    opacity: 0.7;
}

@keyframes bfb-spin {
    to { transform: rotate(360deg); }
}

.brand-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 24px 16px;
    color: #555;
    font-size: 14px;
}

.brand-loading-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid #007bff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: bfb-spin 0.6s linear infinite;
    flex-shrink: 0;
}

/* ============================================================
   Search result cards
   ============================================================ */
.results {
    flex: 1;
    min-width: 0;
}

.result-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    transition: box-shadow 0.15s;
}

.result-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.result-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    min-width: 0;
}

.result-card-title {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 15px;
    font-weight: 600;
    color: #333;
    min-width: 0;
    overflow: hidden;
}

.result-card-title .result-brand,
.result-card-title .result-article {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-brand {
    color: #333;
}

.result-article {
    color: #007bff;
    margin-left: 4px;
}

.result-article a.article-link {
    color: #007bff;
    text-decoration: none;
    cursor: pointer;
}

.result-article a.article-link:hover {
    text-decoration: underline;
    color: #0056b3;
}

.result-card h3 {
    color: #333;
    margin-bottom: 4px;
    font-size: 15px;
    font-weight: 600;
}

.result-card h3 a.article-link {
    color: #007bff;
    text-decoration: none;
    cursor: pointer;
}

.result-card h3 a.article-link:hover {
    text-decoration: underline;
    color: #0056b3;
}

.result-product-name {
    font-size: 14px;
    color: #444;
    margin-bottom: 6px;
}

.result-supplier-badge {
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    background: #6c757d;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
}

.product-supplier-tag {
    font-size: 12px;
    color: #888;
    margin-bottom: 6px;
}

.product-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 6px;
    margin-bottom: 10px;
}

.info-item {
    display: flex;
    flex-direction: column;
}

.info-label {
    font-size: 11px;
    color: #888;
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.info-value {
    font-size: 14px;
    color: #333;
    font-weight: 500;
}

.price-info {
    background: #f0f7ff;
    padding: 10px 12px;
    border-radius: 6px;
    margin-top: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.price-with-markup {
    color: #1a7f3c;
    font-size: 18px;
    font-weight: 700;
}

.analog-label {
    display: inline-block;
    color: #7c4a00;
    background: #fff0cc;
    border: 1px solid #f5c542;
    font-weight: 600;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    margin-top: 6px;
}

.order-section {
    display: flex;
    gap: 10px;
    align-items: center;
}

.quantity-input {
    width: 80px;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    text-align: center;
}

.btn-order {
    background: #28a745;
    color: white;
    padding: 9px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
    font-weight: 500;
    width: auto;
    white-space: nowrap;
    transition: background 0.15s;
}

.btn-order:hover {
    background: #218838;
}

.btn-order:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.order-success {
    background: #d4edda;
    color: #155724;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
    margin-top: 8px;
}

.order-error {
    background: #f8d7da;
    color: #721c24;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
    margin-top: 8px;
}

/* ============================================================
   Empty states
   ============================================================ */
.no-results,
.empty-cart,
.empty-orders {
    text-align: center;
    padding: 56px 20px;
    color: #999;
}

.empty-state-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 12px;
}

.empty-state-title {
    font-size: 16px;
    font-weight: 600;
    color: #666;
    display: block;
    margin-bottom: 4px;
}

.empty-state-sub {
    font-size: 14px;
    color: #aaa;
}

/* ============================================================
   Show more button
   ============================================================ */
.show-more-container {
    text-align: center;
    margin-top: 20px;
}

.btn-show-more {
    background: #007bff;
    color: white;
    padding: 12px 32px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 15px;
    font-family: inherit;
    font-weight: 500;
    width: auto;
    transition: background 0.15s;
}

.btn-show-more:hover {
    background: #0056b3;
}

/* ============================================================
   Header
   ============================================================ */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 18px;
    border-bottom: 1px solid #eef0f3;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.brand-icon {
    font-size: 22px;
    line-height: 1;
}

.brand-name {
    font-size: 20px;
    font-weight: 800;
    color: #1a1a2e;
    letter-spacing: -0.5px;
}

.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-info {
    font-weight: 600;
    font-size: 13px;
    color: #555;
    background: #f3f4f6;
    padding: 5px 12px;
    border-radius: 20px;
}

.btn-logout {
    background: transparent;
    color: #666;
    border: 1px solid #dde0e6;
    border-radius: 7px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.btn-logout:hover {
    background: #fee2e2;
    color: #c0392b;
    border-color: #fca5a5;
}

/* ============================================================
   Navigation tabs
   ============================================================ */
.hidden {
    display: none !important;
}

.nav-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 22px;
    background: #f0f2f5;
    padding: 4px;
    border-radius: 10px;
    border: none;
}

.nav-tab {
    padding: 8px 18px;
    background: transparent;
    border: none;
    border-radius: 7px;
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
    font-weight: 500;
    color: #666;
    transition: background 0.15s, color 0.15s, box-shadow 0.15s;
    white-space: nowrap;
}

.nav-tab:hover {
    background: rgba(255,255,255,0.6);
    color: #333;
}

.nav-tab.active {
    background: white;
    color: #1a1a2e;
    font-weight: 600;
    box-shadow: 0 1px 4px rgba(0,0,0,0.10);
    margin-bottom: 0;
    border-bottom: none;
}

.nav-tab .badge {
    background: #dc3545;
    color: white;
    border-radius: 10px;
    padding: 1px 7px;
    font-size: 11px;
    font-weight: 700;
    margin-left: 5px;
    vertical-align: middle;
}

/* ============================================================
   Section
   ============================================================ */
.section {
    display: block;
}

.section.active {
    display: block;
}

/* ============================================================
   Status badges
   ============================================================ */
.status-badge {
    padding: 4px 10px 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.status-badge::before {
    content: '';
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    background: currentColor;
    opacity: 0.7;
}

.clickable-status {
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.clickable-status:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.clickable-status::after {
    content: ' ✕';
    font-size: 10px;
    opacity: 0.7;
}

.status-pending          { background: #fff8e1; color: #7a5500; border: 1px solid #ffe082; }
.status-pending::before  { background: #f59e0b; opacity: 1; }
.status-in_delivery      { background: #ede9fe; color: #5b21b6; border: 1px solid #c4b5fd; }
.status-in_delivery::before { background: #7c3aed; opacity: 1; }
.status-delivered        { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.status-delivered::before { background: #16a34a; opacity: 1; }
.status-cancelled        { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.status-cancelled::before { background: #dc2626; opacity: 1; }
.status-ready_for_pickup { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.status-ready_for_pickup::before { background: #059669; opacity: 1; }

/* ============================================================
   Orders table — desktop
   ============================================================ */
.orders-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

.orders-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
    font-size: 14px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e8eaed;
}

.orders-table th,
.orders-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #eef0f3;
    border-right: none;
    border-left: none;
    border-top: none;
    text-align: left;
}

.orders-table th {
    background: #f5f7fa;
    font-weight: 600;
    color: #666;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 2px solid #e0e4ea;
}

.orders-table tbody tr:nth-child(even) {
    background: #fafbfc;
}

.orders-table tbody tr:hover {
    background: #f0f5ff;
}

/* ============================================================
   Cart
   ============================================================ */
.cart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    margin-bottom: 10px;
    background: #f5f6f8;
    border-radius: 6px;
    border: 1px solid #e2e4e8;
}

.cart-select-all-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: #444;
    user-select: none;
}

.cart-select-all-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    margin: 0;
}

.cart-count {
    font-size: 13px;
    color: #888;
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 8px;
    background: #fff;
    gap: 12px;
}

.cart-item-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.cart-item-info {
    flex: 1;
    min-width: 0;
}

.cart-item-title {
    font-weight: 600;
    margin-bottom: 4px;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cart-item-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.cart-meta-tag {
    font-size: 11px;
    color: #666;
    background: #f0f2f5;
    border-radius: 3px;
    padding: 1px 6px;
    white-space: nowrap;
}

.cart-item-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.cart-item-price-block {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 1px;
    min-width: 90px;
}

.cip-unit {
    font-size: 11px;
    color: #999;
    white-space: nowrap;
}

.cip-total {
    font-size: 15px;
    font-weight: 700;
    color: #1a1a2e;
    white-space: nowrap;
}

.cart-item-checkbox {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.cart-item-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    margin: 0;
}

.cart-item-qty-stepper {
    display: flex;
    align-items: center;
    border: 1px solid #dde0e6;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
}

.cart-qty-btn {
    background: #f5f6f8;
    border: none;
    width: 30px;
    height: 32px;
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    color: #555;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.1s;
    font-family: inherit;
    line-height: 1;
}

.cart-qty-btn:hover {
    background: #e2e6ea;
    color: #222;
}

.cart-qty-value {
    min-width: 34px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: #222;
    padding: 0 4px;
    border-left: 1px solid #dde0e6;
    border-right: 1px solid #dde0e6;
    line-height: 32px;
    display: inline-block;
}

.btn-remove {
    background: transparent;
    color: #c0c4cc;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    font-family: inherit;
    padding: 0;
    flex-shrink: 0;
    line-height: 1;
}

.btn-remove:hover {
    background: #fff0f0;
    color: #dc3545;
    border-color: #dc3545;
}

.cart-summary {
    background: #fff;
    padding: 15px 20px;
    border-radius: 6px;
    margin-top: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    bottom: 0;
    z-index: 20;
    border-top: 2px solid #e8eaed;
    box-shadow: 0 -3px 12px rgba(0,0,0,0.07);
}

.cart-total {
    font-size: 18px;
    font-weight: 700;
}

.btn-checkout {
    background: #28a745;
    color: white;
    padding: 12px 32px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 15px;
    font-family: inherit;
    font-weight: 500;
    width: auto;
    transition: background 0.15s;
}

.btn-checkout:hover {
    background: #218838;
}

.btn-checkout:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.btn-add-to-cart {
    background: #17a2b8;
    color: white;
    padding: 5px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-family: inherit;
    width: auto;
}

.btn-add-to-cart:hover {
    background: #138496;
}

/* ============================================================
   Scroll to top
   ============================================================ */
.scroll-to-top {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: #007bff;
    color: white;
    border: none;
    cursor: pointer;
    font-size: 22px;
    display: none;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: opacity 0.3s, background 0.15s;
}

.scroll-to-top:hover {
    background: #0056b3;
}

.scroll-to-top.show {
    display: block;
}

/* ============================================================
   Mobile — card layout for orders tables
   Covers portrait AND landscape phones (≤ 900px wide)
   ============================================================ */
@media (max-width: 900px) {
    /* Brands sidebar: horizontal scrolling strip on top */
    .search-results-layout {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        margin-top: 10px;
    }

    .brands-sidebar {
        width: 100%;
        position: static;
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 6px;
        padding: 2px 0 6px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .brands-sidebar::-webkit-scrollbar {
        display: none;
    }

    .brands-sidebar-title {
        display: none;
    }

    .brand-filter-btn {
        display: inline-flex;
        flex-direction: column;
        width: auto;
        flex-shrink: 0;
        padding: 5px 10px;
        margin-bottom: 0;
    }

    .bfb-name {
        white-space: nowrap;
        max-width: 120px;
    }

    body {
        padding: 10px;
        font-size: 14px;
    }

    .container {
        padding: 12px;
        max-width: 100%;
    }

    h1 {
        font-size: 18px;
        margin-bottom: 15px;
    }

    .header {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }

    .header-brand {
        justify-content: center;
    }

    .header-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        justify-content: center;
        align-items: center;
        width: 100%;
    }

    .header-controls {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }

    .btn-tg-label,
    .btn-fav-label {
        display: none;
    }

    .btn-telegram,
    .btn-favorites {
        padding: 6px 10px;
        width: auto;
        flex-shrink: 0;
    }

    .finance-info {
        width: 100%;
        justify-content: center;
    }

    .search-form {
        padding: 12px;
    }

    .search-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
            "article article"
            "brand   sort"
            "btn     btn";
        gap: 8px;
        flex: none;
    }

    .search-field--article { grid-area: article; }
    .search-field--brand   { grid-area: brand; min-width: unset; }
    .search-field--sort    { grid-area: sort; min-width: unset; }
    .search-field--btn     { grid-area: btn; min-width: unset; }

    .search-field--btn label {
        display: none;
    }

    .search-field input,
    .search-field select {
        width: 100%;
        font-size: 16px; /* prevents iOS zoom */
    }

    #search-btn {
        width: 100%;
        justify-content: center;
        height: 44px;
        font-size: 15px;
    }

    input[type="text"],
    input[type="password"] {
        padding: 8px;
        font-size: 16px; /* prevents iOS zoom */
    }

    button, .btn {
        padding: 10px 16px;
        font-size: 14px;
    }

    /* Result cards */
    .result-card {
        padding: 12px;
        margin-bottom: 8px;
    }

    .product-info {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .info-item {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    .info-label {
        font-weight: 600;
        margin-right: 8px;
    }

    .price-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .order-section {
        gap: 8px;
    }

    .quantity-input {
        width: 60px;
        padding: 6px;
    }

    .btn-order {
        flex: 1;
        padding: 8px 12px;
        font-size: 13px;
    }

    /* Nav tabs */
    .tab-full {
        display: none;
    }

    .nav-tabs {
        flex-wrap: nowrap;
        gap: 3px;
        padding: 3px;
    }

    .nav-tabs button {
        flex: 1;
        min-width: 0;
        padding: 7px 6px;
        font-size: 12px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .status-badge {
        padding: 3px 8px;
        font-size: 11px;
    }

    /* Cart */
    .cart-item {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 12px;
    }

    .cart-item-left {
        align-items: flex-start;
    }

    .cart-item-right {
        justify-content: space-between;
        padding-left: 30px;
    }

    .cart-item-price-block {
        align-items: flex-start;
        min-width: unset;
    }

    .cart-summary {
        position: sticky;
        bottom: 0;
        flex-direction: column;
        gap: 10px;
        background: #fff;
        border-top: 2px solid #e8eaed;
        border-radius: 0 0 8px 8px;
        margin-top: 4px;
        z-index: 10;
        box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
    }

    .btn-checkout {
        width: 100%;
    }

    .scroll-to-top {
        width: 40px;
        height: 40px;
        font-size: 20px;
        bottom: 15px;
        right: 15px;
    }
}

/* ============================================================
   Mobile portrait: card layout + stacked filters
   ============================================================ */
@media (max-width: 900px) and (orientation: portrait) {
    .orders-filters {
        flex-direction: column;
        gap: 10px;
    }

    .filter-group {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
        width: 100%;
    }

    .filter-group select,
    input.orders-search-input,
    .orders-date-input {
        width: 100%;
        min-width: unset;
        max-width: none;
    }

    .orders-table {
        display: block;
        font-size: 13px;
    }

    .orders-table thead {
        display: none;
    }

    .orders-table tbody {
        display: block;
    }

    .orders-table tr {
        display: block;
        border: 1px solid #e0e0e0;
        border-radius: 8px;
        margin-bottom: 10px;
        padding: 4px 0;
        background: #fff;
        box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    }

    .orders-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 7px 12px;
        border: none;
        border-bottom: 1px solid #f0f0f0;
    }

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

    .orders-table td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 11px;
        color: #888;
        text-transform: uppercase;
        letter-spacing: 0.03em;
        min-width: 80px;
        flex-shrink: 0;
    }
}

/* ============================================================
   Mobile landscape: compact table with hidden columns
   ============================================================ */
@media (max-width: 900px) and (orientation: landscape) {
    .orders-filters {
        flex-wrap: wrap;
        gap: 8px;
    }

    .filter-group {
        flex-direction: row;
        align-items: center;
        gap: 6px;
    }

    .filter-group select,
    input.orders-search-input {
        min-width: unset;
        max-width: 140px;
    }

    /* Hide least-essential columns: ID, Название, Срок */
    .orders-table th:nth-child(1),
    .orders-table td:nth-child(1),
    .orders-table th:nth-child(3),
    .orders-table td:nth-child(3),
    .orders-table th:nth-child(8),
    .orders-table td:nth-child(8) {
        display: none;
    }

    .orders-table {
        font-size: 12px;
    }

    .orders-table th,
    .orders-table td {
        padding: 6px 8px;
        white-space: nowrap;
    }
}

/* ============================================================
   Tablet
   ============================================================ */
@media (min-width: 901px) and (max-width: 1024px) {
    .container {
        max-width: 95%;
        padding: 15px;
    }

    .result-card {
        padding: 12px;
    }

    .product-info {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================================
   Режим «Заказы для клиентов» — полоса администратора
   ============================================================ */
.acting-banner {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 6px;
    width: 100%;
    box-sizing: border-box;
    margin: 0 0 10px;
    padding: 4px 6px 4px 10px;
    background: #fff4d6;
    border: 1px solid #f0c24b;
    border-radius: 8px;
    font-size: 13px;
    color: #6b4e00;
    white-space: nowrap;
}
.acting-banner-label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-weight: 600;
}
.acting-icon { width: 14px; height: 14px; flex-shrink: 0; }
.acting-client-select {
    flex: 0 1 auto;
    width: auto;
    min-width: 90px;
    max-width: 180px;
    height: 28px;
    padding: 2px 6px;
    border: 1px solid #d9b45a;
    border-radius: 6px;
    background: #fff;
    font-size: 13px;
}
/* Перебиваем глобальный button { width:100%; padding:12px 24px } */
.acting-banner .acting-exit-btn {
    flex: 0 0 auto;
    margin-left: auto;
    width: auto;
    height: 28px;
    padding: 0 8px;
    border: 1px solid #d9b45a;
    border-radius: 6px;
    background: #fff;
    color: #6b4e00;
    font-size: 13px;
    font-weight: 500;
    line-height: 26px;
    white-space: nowrap;
    cursor: pointer;
}
.acting-banner .acting-exit-btn:hover { background: #ffe9a8; }
@media (max-width: 480px) {
    .acting-banner-label .acting-label-long { display: none; }
    .acting-client-select { max-width: 130px; }
}

/* Кнопка менеджера «Все заказы клиентов» в шапке кабинета */
.btn-manager-orders {
    background: transparent;
    color: #0d6efd;
    padding: 6px 12px;
    border: 1px solid #9ec5fe;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    height: 32px;
    box-sizing: border-box;
    text-decoration: none;
}
.btn-manager-orders:hover { background: #e7f1ff; border-color: #0d6efd; }
@media (max-width: 600px) {
    .btn-manager-orders { padding: 6px 10px; flex-shrink: 0; }
}
