:root {
  --app-bg: #f4f7fb;
  --app-surface: #ffffff;
  --app-text: #172033;
  --app-muted: #667085;
  --app-primary: #2563eb;
  --app-primary-dark: #1d4ed8;
  --app-border: #dbe3ef;
  --app-radius: 14px;
  --app-shadow: 0 12px 30px rgba(23, 32, 51, .08);
}

body { background: var(--app-bg); color: var(--app-text); }
body > .container { width: min(96%, 1480px); }
body > .container > h2 { margin: 8px 0 22px; font-weight: 700; letter-spacing: -.03em; }
.navbar-inverse {
  border-color: transparent;
  border-radius: var(--app-radius);
  background-color: #3f4650;
  background-image: linear-gradient(135deg, #252a31 0%, #454d58 48%, #69727e 100%);
  background-repeat: no-repeat;
  background-position: center;
  color: white;
  box-shadow: 0 10px 26px rgba(31, 41, 55, .18), inset 0 1px 0 rgba(255, 255, 255, .12);
}
.navbar-inverse .navbar-brand { font-weight: 700; color: #fff; }
.navbar-inverse .navbar-brand,
.navbar-inverse .navbar-nav > li > a {
  border: 0;
  outline: none;
  box-shadow: none;
}
.navbar-inverse .navbar-brand:focus,
.navbar-inverse .navbar-brand:active,
.navbar-inverse .navbar-nav > li > a:focus,
.navbar-inverse .navbar-nav > li > a:active {
  outline: none;
  box-shadow: none;
}
.navbar-inverse .navbar-brand:focus-visible,
.navbar-inverse .navbar-nav > li > a:focus-visible {
  outline: 2px solid rgba(255, 255, 255, .9);
  outline-offset: -3px;
  border-radius: 7px;
}
.navbar-inverse .navbar-nav.navbar-right > li:last-child > a {
  border-radius: 0 var(--app-radius) var(--app-radius) 0;
}
.navbar-inverse .navbar-nav > li > a:hover,
.navbar-inverse .navbar-nav > li > a:focus,
.navbar-inverse .navbar-nav > .open > a,
.navbar-inverse .navbar-nav > .open > a:hover,
.navbar-inverse .navbar-nav > .open > a:focus {
  color: #fff;
  background-color: rgba(255, 255, 255, .10);
}
.panel { border: 1px solid var(--app-border); border-radius: var(--app-radius); box-shadow: var(--app-shadow); overflow: hidden; }
.panel-default > .panel-heading { padding: 16px 20px; border-color: var(--app-border); background: #f8fafc; color: var(--app-text); }
.panel-body { padding: 20px; }
.fuvas-summary { display: grid; grid-template-columns: repeat(5, minmax(140px, 1fr)); gap: 12px; margin-bottom: 18px; }
.summary-card { position: relative; display: flex; min-height: 105px; padding: 15px; flex-direction: column; align-items: flex-start; text-align: left; background: #fff; border: 1px solid var(--app-border); border-radius: 13px; box-shadow: 0 7px 18px rgba(23,32,51,.06); transition: transform .18s, box-shadow .18s, border-color .18s; }
button.summary-card { cursor: pointer; }
button.summary-card:hover { transform: translateY(-2px); border-color: #aab6c7; box-shadow: 0 10px 22px rgba(23,32,51,.10); }
.summary-card.is-active { border-color: var(--app-primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.summary-card::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 4px; border-radius: 13px 0 0 13px; background: #667085; }
.summary-online::before { background: #12b76a; }
.summary-warning::before { background: #f79009; }
.summary-offline::before { background: #f04438; }
.summary-service::before { background: #7f56d9; }
.summary-label { color: var(--app-muted); font-size: 12px; font-weight: 700; }
.summary-card strong { margin: 5px 0 1px; color: var(--app-text); font-size: 28px; line-height: 1; }
.summary-card small { margin-top: auto; color: #98a2b3; }
.home-dashboard { padding: 18px 0 36px; }
.dashboard-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.dashboard-heading h1 { margin: 0 0 4px; font-size: 26px; font-weight: 700; }
.dashboard-heading p, .dashboard-heading > span { margin: 0; color: var(--app-muted); }
.dashboard-cards { display: grid; grid-template-columns: repeat(5, minmax(145px, 1fr)); gap: 12px; }
.dashboard-stat { position: relative; min-height: 112px; padding: 15px; background: #fff; border: 1px solid var(--app-border); border-radius: 13px; box-shadow: 0 7px 18px rgba(23,32,51,.06); }
.dashboard-stat::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 4px; background: #667085; border-radius: 13px 0 0 13px; }
.dashboard-stat.stat-online::before { background:#12b76a; }.dashboard-stat.stat-warning::before { background:#f79009; }.dashboard-stat.stat-offline::before { background:#f04438; }.dashboard-stat.stat-service::before { background:#7f56d9; }
.dashboard-stat span, .dashboard-stat small { display:block; color:var(--app-muted); }.dashboard-stat strong { display:block; margin:7px 0 2px; font-size:28px; }.dashboard-stat small { font-size:11px; }
.dashboard-grid { display:grid; grid-template-columns: minmax(0,1.2fr) minmax(0,.8fr); gap:14px; margin-top:14px; }
.dashboard-panel, .dashboard-quick-actions { padding:20px; background:#fff; border:1px solid var(--app-border); border-radius:14px; box-shadow:var(--app-shadow); }
.dashboard-panel-title { display:flex; align-items:baseline; justify-content:space-between; gap:10px; margin-bottom:18px; }.dashboard-panel-title h2, .dashboard-quick-actions h2 { margin:0; font-size:17px; }.dashboard-panel-title span { color:var(--app-muted); font-size:12px; }
.status-chart-layout { display:flex; align-items:center; justify-content:center; gap:38px; min-height:220px; }
.status-donut { display:grid; width:178px; height:178px; flex:0 0 178px; place-items:center; background:conic-gradient(#12b76a 0 var(--online),#f79009 var(--online) var(--warning),#f04438 var(--warning) 100%); border-radius:50%; }
.status-donut::before { content:''; grid-area:1/1; width:112px; height:112px; background:#fff; border-radius:50%; box-shadow:inset 0 0 0 1px #edf1f7; }.status-donut > div { z-index:1; grid-area:1/1; text-align:center; }.status-donut strong,.status-donut span { display:block; }.status-donut strong { font-size:25px; }.status-donut span { color:var(--app-muted); font-size:11px; }
.chart-legend { min-width:220px; }.chart-legend > div { display:grid; padding:10px 0; grid-template-columns:12px 1fr auto; align-items:center; gap:9px; border-bottom:1px solid #edf1f7; }.chart-legend i { width:10px; height:10px; border-radius:50%; }.legend-online{background:#12b76a}.legend-warning{background:#f79009}.legend-offline{background:#f04438}
.attention-row { display:grid; padding:14px; grid-template-columns:58px 1fr; align-items:center; gap:12px; border-radius:10px; margin-bottom:10px; }.attention-row strong { font-size:24px; }.attention-row span { color:#475467; }.attention-row.danger { background:#fff1f0; }.attention-row.danger strong { color:#b42318; }.attention-row.service { background:#f4f0ff; }.attention-row.service strong { color:#6941c6; }
.dashboard-attention .btn { margin-top:6px; }.dashboard-quick-actions { margin-top:14px; }.dashboard-quick-actions > div { display:grid; grid-template-columns:repeat(3,1fr); gap:10px; margin-top:14px; }.dashboard-quick-actions a { display:flex; padding:14px; flex-direction:column; color:var(--app-text); background:#f8fafc; border:1px solid var(--app-border); border-radius:10px; text-decoration:none; }.dashboard-quick-actions a:hover { border-color:#aab6c7; box-shadow:0 5px 12px rgba(23,32,51,.07); }.dashboard-quick-actions a span { margin-top:3px; color:var(--app-muted); font-size:12px; }

.inputs { width: 100%; margin: 0 0 18px; overflow: visible; }
.inputs tbody, .inputs tr { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; }
.inputs td { display: block; color: var(--app-muted); font-weight: 600; }
.inputs input[type="datetime-local"], .inputs .api-datetime-picker, .date-group input[type="datetime-local"], .date-group .api-datetime-picker {
  min-width: 245px; height: 44px; padding: 9px 12px; color: var(--app-text);
  background: #fff; border: 1px solid var(--app-border); border-radius: 9px;
  font: inherit; font-weight: 500; outline: none; transition: border-color .2s, box-shadow .2s;
}
.inputs input[type="datetime-local"]:focus, .inputs .api-datetime-picker:focus, .date-group input[type="datetime-local"]:focus, .date-group .api-datetime-picker:focus {
  border-color: var(--app-primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .13);
}
.date-range-hint { display: inline-flex; min-height: 44px; align-items: center; color: var(--app-muted); font-size: 0; font-weight: 500; white-space: nowrap; }
.date-range-hint::before { content: 'ⓘ'; margin-right: 6px; color: var(--app-primary); font-size: 14px; }
.date-range-hint::after { content: 'За справка за целия ден изберете от 00:00:00 (полунощ) до 23:59:59 (края на деня).'; font-size: 12px; }
.dt-datetime { position: absolute; z-index: 11000; width: min(520px, calc(100vw - 20px)); padding: 12px; color: var(--app-text); background: #fff; border: 1px solid var(--app-border); border-radius: 13px; box-shadow: 0 18px 45px rgba(23,32,51,.20); }
.dt-datetime .dt-datetime-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.dt-datetime .dt-datetime-label { display: inline-flex; margin: 0 4px; }
.dt-datetime select { padding: 5px 7px; background: #fff; border: 1px solid var(--app-border); border-radius: 7px; }
.dt-datetime table { width: 100%; border-collapse: separate; border-spacing: 3px; }
.dt-datetime th { color: var(--app-muted); font-size: 11px; text-align: center; }
.dt-datetime td { padding: 0; text-align: center; }
.dt-datetime button { width: 100%; min-width: 30px; padding: 6px 4px; color: var(--app-text); background: transparent; border: 0; border-radius: 7px; }
.dt-datetime td.selectable button:hover { background: #eef4ff; color: var(--app-primary); }
.dt-datetime td.selected button { color: #fff; background: var(--app-primary); }
.dt-datetime td.disabled button { color: #c4c9d2; cursor: default; }
.dt-datetime .dt-datetime-time { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--app-border); }
.dt-datetime .dt-datetime-time table { font-size: 11px; }
.dt-datetime .dt-datetime-buttons { display: flex; justify-content: flex-end; gap: 6px; }
.dt-datetime .dt-datetime-today, .dt-datetime .dt-datetime-clear { cursor: pointer; color: var(--app-primary); }
.table { background: var(--app-surface); }
.table > thead > tr > th { padding: 12px 10px; background: #f8fafc; border-color: var(--app-border); color: #475467; white-space: nowrap; }
.table > tbody > tr > td { padding: 11px 10px; border-color: #edf1f7; vertical-align: middle; }
#brand_data { width: 100% !important; table-layout: fixed; }
#brand_data th:nth-child(1) { width: 100px; }
#brand_data th:nth-child(2) { width: 110px; }
#brand_data th:nth-child(3) { width: 175px; }
#brand_data th:nth-child(4) { width: 120px; }
#brand_data th:nth-child(5) { width: 175px; }
#brand_data td { overflow-wrap: anywhere; }
.compact-cell { display: flex; flex-direction: column; gap: 3px; line-height: 1.3; }
.compact-cell strong { color: var(--app-text); }
.compact-cell span { color: #475467; }
.compact-cell small { color: var(--app-muted); font-size: 11px; }
.serial-value { color: var(--app-primary); font-size: 12px; }
.table-actions { display: flex; flex-direction: column; gap: 5px; }
.table-actions .btn { width: 100%; text-align: left; }
.device-toolbar { display: grid; gap: 12px; margin: 4px 0 18px; padding: 14px; background: #f8fafc; border: 1px solid var(--app-border); border-radius: 12px; }
.quick-periods, .advanced-filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar-label { margin-right: 4px; color: var(--app-muted); font-weight: 700; }
.advanced-filters .form-control { width: auto; min-width: 155px; height: 36px; border-color: var(--app-border); border-radius: 8px; }
.quick-periods .active { color: #fff; border-color: var(--app-primary); background: var(--app-primary); }
.device-check { margin: 0; color: var(--app-muted); font-size: 11px; font-weight: 500; }
.select-page { display: inline-flex; align-items: center; gap: 6px; width: auto; margin: 0 6px 0 0; color: #475467; font-weight: 600; }
.selection-limit-note { flex-basis: 100%; color: var(--app-muted); font-weight: 600; }
.status-badge { align-self: flex-start; padding: 3px 7px; border-radius: 999px; font-size: 10px; font-weight: 700; }
.status-online { color: #067647; background: #dcfae6; }
.status-warning { color: #b54708; background: #fef0c7; }
.status-offline { color: #b42318; background: #fee4e2; }
.device-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.device-detail-grid > div { padding: 12px; background: #f8fafc; border: 1px solid var(--app-border); border-radius: 9px; }
.device-detail-grid b { display: block; margin-bottom: 6px; color: var(--app-muted); font-size: 11px; text-transform: uppercase; }
.z-report-table th:nth-child(4),
.z-report-table td:nth-child(4) {
  min-width: 155px;
  white-space: nowrap;
  word-break: normal;
  overflow-wrap: normal;
}
.z-report-table { width: 100%; table-layout: fixed; font-size: 12px; }
.z-report-table th, .z-report-table td { box-sizing: border-box; padding: 8px 6px !important; white-space: normal; overflow-wrap: anywhere; }
.z-report-table > thead > tr > th,
.z-report-table > thead > th { height: auto; line-height: 1.2; vertical-align: bottom !important; white-space: normal !important; word-break: normal; overflow-wrap: anywhere; }
.z-report-table th:nth-child(1) { width: 7%; }
.z-report-table th:nth-child(2) { width: 5%; }
.z-report-table th:nth-child(3) { width: 7%; }
.z-report-table th:nth-child(4) { width: 11%; }
.z-report-table th:nth-child(5), .z-report-table th:nth-child(7) { width: 9%; }
.z-report-table th:nth-child(6), .z-report-table th:nth-child(8) { width: 10%; }
.z-report-table th:nth-child(n+9) { width: 4%; }
.table-responsive:has(.z-report-table) { overflow-x: visible; }
.table-responsive:has(.sales-report-table) {
  max-height: none;
  overflow-x: visible;
  overflow-y: visible;
}
.sales-report-table {
  width: 100%;
  table-layout: fixed;
}
.sales-report-table th,
.sales-report-table td {
  min-width: 0;
  white-space: normal;
  word-break: normal;
  overflow-wrap: anywhere;
}
.sales-report-table > thead > tr > th {
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.25;
}
.sales-report-table th:nth-child(1) { width: 9%; }
.sales-report-table th:nth-child(2) { width: 7%; }
.sales-report-table th:nth-child(3) { width: 8%; }
.sales-report-table th:nth-child(4) { width: 14%; }
.sales-report-table th:nth-child(5) { width: 20%; }
.sales-report-table th:nth-child(6),
.sales-report-table th:nth-child(7),
.sales-report-table th:nth-child(8),
.sales-report-table th:nth-child(9),
.sales-report-table th:nth-child(10) { width: 7%; }
.sales-report-table th:nth-child(11) { width: 11%; }
#brandModal .modal-body {
  max-height: none;
  overflow-y: visible;
}
.empty-report-state { display: flex; min-height: 150px; padding: 24px; flex-direction: column; align-items: center; justify-content: center; gap: 7px; color: var(--app-muted); text-align: center; background: #f8fafc; border: 1px dashed #cbd5e1; border-radius: 12px; }
.empty-report-state strong { color: var(--app-text); font-size: 18px; }
.client-report-panel { margin-top: 18px; }
.client-report-intro { color: var(--app-muted); }
.client-quick-periods { margin: 14px 0; padding: 10px 12px; background: #f8fafc; border: 1px solid var(--app-border); border-radius: 10px; }
.invoice-quick-periods { margin-bottom: 12px; }
.container_invoice .invoice-quick-periods .btn { width: auto; margin: 0; padding: 6px 12px; color: #333; background: #fff; border: 1px solid #ccc; font-size: 12px; }
.container_invoice .invoice-quick-periods .btn:hover { color: var(--app-primary-dark); background: #f8fafc; }
.container_invoice .invoice-quick-periods .btn.active { color: #fff; border-color: var(--app-primary); background: var(--app-primary); }
.client-report-form { display: grid; grid-template-columns: minmax(260px, 2fr) repeat(2, minmax(210px, 1fr)) auto auto; gap: 12px; align-items: end; }
.client-report-form label { margin: 0; color: #475467; }
.client-report-form .form-control { margin-top: 6px; height: 42px; border-color: var(--app-border); border-radius: 8px; }
.client-report-form .btn { height: 42px; }
.client-report-message { min-height: 24px; margin: 14px 0 6px; color: var(--app-muted); }
.client-report-message.is-error { color: #b42318; }
.client-report-progress { margin: 14px 0 18px; }
.client-progress-meta { display: flex; gap: 18px; flex-wrap: wrap; color: var(--app-muted); }
.client-report-totals { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 16px 0; }
.client-report-totals > div { padding: 14px; background: #f8fafc; border: 1px solid var(--app-border); border-radius: 10px; }
.client-report-totals span, .client-report-totals strong { display: block; }
.client-report-totals span { color: var(--app-muted); font-size: 12px; }
.client-report-totals strong { margin-top: 5px; font-size: 20px; }
.client-results-table-wrap { max-height: 55vh; overflow: auto; }
.client-results-table thead { position: sticky; top: 0; z-index: 1; }
.client-device-address { display: block; max-width: 260px; margin-top: 3px; color: var(--app-muted); font-size: 11px; font-weight: 400; line-height: 1.3; white-space: normal; }
.btn { border-radius: 8px; font-weight: 600; }
.btn-info, .btn-primary { border-color: var(--app-primary); background: var(--app-primary); }
.btn-info:hover, .btn-primary:hover { border-color: var(--app-primary-dark); background: var(--app-primary-dark); }
.dataTables_filter input,
.dataTables_length select,
.advanced-filters .form-control {
  color: var(--app-text);
  background-color: #fff;
  border: 1px solid var(--app-border);
  border-radius: 9px;
  box-shadow: none;
}
.dataTables_filter input { padding: 7px 10px; }
.dataTables_length select {
  width: 92px;
  min-width: 92px;
  height: 34px;
  padding: 5px 24px 5px 9px;
}
.dataTables_filter input:focus,
.dataTables_length select:focus,
.advanced-filters .form-control:focus {
  border-color: var(--app-primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
input::placeholder,
.form-control::placeholder,
.dataTables_filter input::placeholder {
  color: #98a2b3;
  opacity: 1;
}

@media (max-width: 700px) {
  body { overflow-x: hidden; }
  body > .container { width: 100%; padding-right: 10px; padding-left: 10px; }
  body > .container > h2 { font-size: 24px; }
  .navbar-inverse { border-radius: 11px; }
  .navbar-inverse .navbar-nav.navbar-right > li:last-child > a { border-radius: 0; }
  .inputs tbody, .inputs tr { display: grid; grid-template-columns: 1fr; }
  .inputs td, .inputs input[type="datetime-local"], .inputs .api-datetime-picker { width: 100%; min-width: 0; }
  .panel-body { padding: 14px; }
  .advanced-filters .form-control, .advanced-filters .btn { width: 100%; }
  .device-detail-grid { grid-template-columns: 1fr; }
  .fuvas-summary { grid-template-columns: 1fr 1fr; }
  .dashboard-heading { align-items:flex-start; flex-direction:column; gap:4px; }
  .dashboard-cards { grid-template-columns:1fr 1fr; }
  .dashboard-grid { grid-template-columns:1fr; }
  .status-chart-layout { flex-direction:column; gap:14px; }
  .chart-legend { width:100%; min-width:0; }
  .dashboard-quick-actions > div { grid-template-columns:1fr; }
  .summary-card { min-height: 92px; padding: 12px; }
  .summary-card strong { font-size: 24px; }
  .quick-periods .toolbar-label { flex-basis: 100%; }
  .quick-periods .btn { flex: 1 1 calc(50% - 8px); }
  .select-page { width: 100%; padding: 7px 0; }
  .selection-limit-note { line-height: 1.4; }
  .date-range-hint { min-height: 30px; white-space: normal; }

  #brand_data_wrapper { width: 100%; overflow: visible; }
  #brand_data { display: block; width: 100% !important; table-layout: auto; border: 0; background: transparent; }
  #brand_data thead { display: none; }
  #brand_data tbody { display: grid; width: 100%; gap: 12px; }
  #brand_data tbody tr { display: block; width: 100%; height: auto !important; box-sizing: border-box; overflow: hidden; background: #fff; border: 1px solid var(--app-border); border-radius: 12px; box-shadow: 0 7px 18px rgba(23,32,51,.06); }
  #brand_data tbody td { display: grid; width: 100% !important; min-height: 42px; padding: 10px 12px; box-sizing: border-box; grid-template-columns: 112px minmax(0, 1fr); gap: 10px; border: 0; border-bottom: 1px solid #edf1f7; text-align: left; }
  #brand_data tbody td:last-child { border-bottom: 0; }
  #brand_data tbody td::before { color: var(--app-muted); font-size: 11px; font-weight: 700; }
  #brand_data tbody td:nth-child(1)::before { content: 'Действия'; }
  #brand_data tbody td:nth-child(2)::before { content: 'Сериен номер'; }
  #brand_data tbody td:nth-child(3)::before { content: 'Обект и адрес'; }
  #brand_data tbody td:nth-child(4)::before { content: 'Последна връзка'; }
  #brand_data tbody td:nth-child(5)::before { content: 'Събитие'; }
  #brand_data tbody td:nth-child(6)::before { content: 'Клиент'; }
  #brand_data tbody td:nth-child(7)::before { content: 'Сервиз'; }
  #brand_data tbody td:nth-child(8)::before { content: 'SIM / модем'; }
  #brand_data tbody td:nth-child(9)::before { content: 'Система'; }
  #brand_data tbody td:first-child { display: block; }
  #brand_data tbody td:first-child::before { display: block; margin-bottom: 8px; }
  #brand_data .table-actions { display: grid; width: 100%; min-width: 0; box-sizing: border-box; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  #brand_data .device-check { grid-column: 1 / -1; }
  #brand_data .table-actions .btn { display: block; width: 100%; min-width: 0; min-height: 34px; padding: 6px; box-sizing: border-box; overflow: hidden; text-align: center; text-overflow: ellipsis; white-space: nowrap; border-radius: 7px; }
  #brand_data .compact-cell { min-width: 0; }
  .dataTables_wrapper .dataTables_length,
  .dataTables_wrapper .dataTables_filter { width: 100%; margin: 6px 0; text-align: left; }
  .dataTables_wrapper .dataTables_filter input { width: calc(100% - 75px); }
  .dataTables_wrapper .dt-buttons { display: flex; width: 100%; gap: 5px; flex-wrap: wrap; margin: 8px 0; }
  .dataTables_wrapper .dt-buttons .btn { flex: 1; }
  .dataTables_wrapper .pagination { display: flex; flex-wrap: wrap; }
  .modal-dialog { width: auto; margin: 10px; }
  .modal-body { padding: 12px; }
  .table-responsive { border: 0; }
  .client-report-form { grid-template-columns: 1fr; }
  .client-report-totals { grid-template-columns: 1fr 1fr; }
  .client-results-table-wrap { max-height: none; overflow: visible; }
  .client-results-table { display: block; min-width: 0; background: transparent; }
  .client-results-table thead { display: none; }
  .client-results-table tbody { display: grid; width: 100%; gap: 10px; }
  .client-results-table tbody tr,
  .client-results-table.table-striped > tbody > tr:nth-of-type(odd) {
    display: grid;
    width: 100%;
    padding: 12px;
    box-sizing: border-box;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 14px;
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(23,32,51,.05);
  }
  .client-results-table tbody tr.danger { background: #fff6f5; border-color: #fecdca; }
  .client-results-table tbody td { display: block; min-width: 0; padding: 0; border: 0; text-align: left; }
  .client-results-table tbody td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 3px;
    color: var(--app-muted);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
  }
  .client-results-table tbody td:first-child,
  .client-results-table tbody td:last-child { grid-column: 1 / -1; }
  .client-device-address { max-width: none; overflow-wrap: anywhere; font-size: 12px; }
  #client_report_results > .btn { display: block; width: 100%; min-height: 40px; margin: 7px 0 0; padding: 9px 12px; white-space: normal; }

  /* Report tables become readable cards on phones instead of squeezed columns. */
  .sales-report-table,
  .z-report-table { display: block; width: 100% !important; table-layout: auto; background: transparent; }
  .sales-report-table thead,
  .z-report-table thead { display: none; }
  .sales-report-table tbody,
  .z-report-table tbody { display: grid; width: 100%; gap: 12px; }
  .sales-report-table tbody tr,
  .z-report-table tbody tr { display: block; width: 100%; background: #fff; border: 1px solid var(--app-border); border-radius: 10px; box-shadow: 0 4px 12px rgba(23,32,51,.06); }
  .sales-report-table tbody td,
  .z-report-table tbody td { display: grid; width: 100% !important; min-height: 38px; padding: 8px 10px !important; grid-template-columns: 42% minmax(0, 1fr); gap: 8px; border: 0; border-bottom: 1px solid #edf1f7; overflow-wrap: anywhere; white-space: normal; }
  .sales-report-table tbody td:last-child,
  .z-report-table tbody td:last-child { border-bottom: 0; }
  .sales-report-table tbody td::before,
  .z-report-table tbody td::before { color: var(--app-muted); font-size: 11px; font-weight: 700; }
  .sales-report-table td:nth-child(1)::before, .z-report-table td:nth-child(1)::before { content: 'Сериен номер'; }
  .sales-report-table td:nth-child(2)::before { content: 'Номер на Z-отчет'; }
  .sales-report-table td:nth-child(3)::before { content: 'Номер на документ'; }
  .sales-report-table td:nth-child(4)::before { content: 'Дата'; }
  .sales-report-table td:nth-child(5)::before { content: 'Артикул'; }
  .sales-report-table td:nth-child(6)::before { content: 'Единична цена'; }
  .sales-report-table td:nth-child(7)::before { content: 'Количество'; }
  .sales-report-table td:nth-child(8)::before { content: 'Сума'; }
  .sales-report-table td:nth-child(9)::before { content: 'Данъчна група'; }
  .sales-report-table td:nth-child(10)::before { content: 'Платено'; }
  .sales-report-table td:nth-child(11)::before { content: 'Начин на плащане'; }
  .z-report-table td:nth-child(2)::before { content: 'Z-отчет'; }
  .z-report-table td:nth-child(3)::before { content: 'Номер на документ'; }
  .z-report-table td:nth-child(4)::before { content: 'Дата'; }
  .z-report-table td:nth-child(5)::before { content: 'Плащане в брой'; }
  .z-report-table td:nth-child(6)::before { content: 'Пояснение'; }
  .z-report-table td:nth-child(7)::before { content: 'Плащане с карта'; }
  .z-report-table td:nth-child(8)::before { content: 'Пояснение за карта'; }
  .z-report-table td:nth-child(9)::before { content: 'Дан. гр. А — код'; }
  .z-report-table td:nth-child(10)::before { content: 'Дан. гр. А — %'; }
  .z-report-table td:nth-child(11)::before { content: 'Дан. гр. А — оборот'; }
  .z-report-table td:nth-child(12)::before { content: 'Дан. гр. А — ДДС'; }
  .z-report-table td:nth-child(13)::before { content: 'Дан. гр. Б — код'; }
  .z-report-table td:nth-child(14)::before { content: 'Дан. гр. Б — %'; }
  .z-report-table td:nth-child(15)::before { content: 'Дан. гр. Б — оборот'; }
  .z-report-table td:nth-child(16)::before { content: 'Дан. гр. Б — ДДС'; }
  .z-report-table .report-total-row { padding: 8px; background: #f8fafc; }
  .z-report-table .report-total-row td { display: none; }
  .z-report-table .report-total-row td:nth-child(5),
  .z-report-table .report-total-row td:nth-child(7),
  .z-report-table .report-total-row td:nth-child(15),
  .z-report-table .report-total-row td:nth-child(16) { display: grid; }

  /* Mobile reports stay as complete tables; scrolling is contained in the modal. */
  .table-responsive:has(.sales-report-table),
  .table-responsive:has(.z-report-table) { width: 100%; overflow-x: auto; overflow-y: visible; -webkit-overflow-scrolling: touch; }
  .sales-report-table,
  .z-report-table { display: table; background: #fff; table-layout: fixed; }
  .sales-report-table { width: 1080px !important; min-width: 1080px; }
  .z-report-table { width: 1420px !important; min-width: 1420px; }
  .sales-report-table thead,
  .z-report-table thead { display: table-header-group; }
  .sales-report-table tbody,
  .z-report-table tbody { display: table-row-group; }
  .sales-report-table tbody tr,
  .z-report-table tbody tr,
  .z-report-table .report-total-row { display: table-row; background: transparent; border: 0; box-shadow: none; }
  .sales-report-table tbody td,
  .z-report-table tbody td,
  .z-report-table .report-total-row td,
  .z-report-table .report-total-row td:nth-child(5),
  .z-report-table .report-total-row td:nth-child(7),
  .z-report-table .report-total-row td:nth-child(15),
  .z-report-table .report-total-row td:nth-child(16) { display: table-cell; width: auto !important; min-height: 0; padding: 8px 6px !important; border-bottom: 1px solid #edf1f7; white-space: normal; vertical-align: middle; }
  .sales-report-table tbody td::before,
  .z-report-table tbody td::before { display: none; content: none; }
  .sales-report-table > thead > tr > th,
  .z-report-table > thead > tr > th,
  .sales-report-table > thead > th,
  .z-report-table > thead > th { height: auto; white-space: normal !important; overflow-wrap: anywhere; line-height: 1.25; vertical-align: bottom !important; }
}
@media (max-width: 420px) {
  .fuvas-summary { grid-template-columns: 1fr; }
  .dashboard-cards { grid-template-columns:1fr; }
  #brand_data tbody td { grid-template-columns: 96px minmax(0, 1fr); }
  #brand_data .table-actions { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 701px) and (max-width: 1050px) { .fuvas-summary { grid-template-columns: repeat(3, 1fr); } }

.login-page { min-height: 100vh; margin: 0; padding: 24px; display: grid; place-items: center; background-color: #eef2f6; background-image: radial-gradient(circle at 15% 20%, rgba(105,114,126,.18), transparent 30%), radial-gradient(circle at 85% 80%, rgba(37,99,235,.10), transparent 28%); }
.container-login { width: min(100%, 430px); transform: translateY(-48px); }
.container-login > h2, .container-login > br { display: none; }
.login-brand { display: flex; margin-bottom: 18px; align-items: center; justify-content: center; gap: 12px; }
.login-logo { display: grid; width: 48px; height: 48px; place-items: center; color: #fff; background: linear-gradient(135deg, #252a31, #69727e); border-radius: 14px; box-shadow: 0 8px 20px rgba(31,41,55,.22); font-size: 24px; font-weight: 800; }
.login-page .login-brand h1 { margin: 0; color: #909090 !important; background: none !important; -webkit-text-fill-color: #909090 !important; font-size: 26px; font-weight: 800; letter-spacing: .10em; }
.login-brand p { margin: 2px 0 0; color: var(--app-muted); font-size: 12px; }
.login-panel { margin: 0; border: 1px solid rgba(219,227,239,.95); border-radius: 16px; box-shadow: 0 20px 50px rgba(23,32,51,.13); }
.login-panel > .panel-heading { padding: 20px 24px; background: linear-gradient(135deg, #252a31 0%, #454d58 55%, #69727e 100%); border: 0; color: #fff; font-size: 0; }
.login-panel > .panel-heading::after { content: 'Вход в системата'; font-size: 18px; font-weight: 700; }
.login-panel .panel-body { padding: 24px; }
.login-panel label { color: #475467; font-size: 12px; font-weight: 700; }
.login-panel .form-group:nth-of-type(1) label,
.login-panel .form-group:nth-of-type(2) label,
.login-panel .form-group:nth-of-type(3) label { font-size: 0; }
.login-panel .form-group:nth-of-type(1) label::after { content: 'Email'; font-size: 12px; }
.login-panel .form-group:nth-of-type(2) label::after { content: 'Потребителско име'; font-size: 12px; }
.login-panel .form-group:nth-of-type(3) label::after { content: 'Парола'; font-size: 12px; }
.login-panel .form-control { height: 44px; border: 1px solid var(--app-border); border-radius: 9px; box-shadow: none; }
.login-panel .form-control:focus { border-color: var(--app-primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.login-page .login-panel .login-submit { width: 100%; height: 44px; margin-top: 8px; border: 0 !important; color: #fff !important; background-color: #454d58 !important; background-image: linear-gradient(135deg, #252a31 0%, #454d58 55%, #69727e 100%) !important; box-shadow: 0 7px 16px rgba(31,41,55,.18); font-size: 15px; }
.login-page .login-panel .login-submit:hover, .login-page .login-panel .login-submit:focus { color: #fff !important; background-color: #39414b !important; background-image: linear-gradient(135deg, #1c2026 0%, #39414b 55%, #59626e 100%) !important; }
@media (max-width: 480px) { .login-page { padding: 14px; } .container-login { transform: translateY(-24px); } .login-brand p { font-size: 11px; } .login-panel .panel-body { padding: 20px; } }
