/* Clients Dashboard — невеликі оверайди поверх основного style.css.
   Основні токени (типографіка, кольори карток, layout) приходять з
   /static/style.css і /static/style-v2.css — їх копіюємо у образ
   з frontend/static/ на етапі Dockerfile-білду. */

.filters-bar__inner {
  flex-wrap: wrap;
  row-gap: 12px;
}

/* ── Compact header / cards (overrides design-system defaults) ── */

.header {
  padding: 0.55rem 1.5rem;
  background: linear-gradient(135deg, #0f3361, #1a56a0);
}
.header__brand { gap: 0.7rem; }
.header__logo { height: 32px; }
.header__title { font-size: 1.05rem; line-height: 1.1; }
.header__sub { font-size: 0.7rem; margin-top: 0.1rem; }

.main { padding: 0.85rem 1.5rem 2rem; gap: 0.85rem; }

.summary-card { padding: 0.5rem 0.75rem; }
.summary-card__icon {
  width: 22px;
  height: 22px;
  margin-bottom: 0.2rem;
}
.summary-card__icon svg { display: block; width: 14px; height: 14px; }
.summary-card--blue .summary-card__icon   { color: #1a56a0; }
.summary-card--green .summary-card__icon  { color: #38a169; }
.summary-card--orange .summary-card__icon { color: #dd6b20; }
.summary-card--purple .summary-card__icon { color: #805ad5; }

.summary-card__label { font-size: 0.55rem; }
.summary-card__value { font-size: 1rem; margin-top: 0.05rem; }
.summary-card__value--text { font-size: 0.88rem; }
.summary-card__change { font-size: 0.6rem; margin-top: 0.1rem; }
.summary-row { gap: 0.55rem; }

/* Slimmer section cards + tighter chart heights so first chart fits above the fold */
.section-card { padding: 0.75rem 1rem; }
.section-card__header { margin-bottom: 0.5rem; }
.chart-container--tall { height: 320px; }
#sec-brands .chart-container--tall,
#sec-models .chart-container--tall { height: 520px; }

/* Footer — centered logo + text, compact */
.footer {
  padding: 0.6rem 1.25rem;
}
.footer__inner {
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.4rem;
}
.footer__left {
  align-items: center;
  gap: 0.25rem;
}
.footer__logo {
  height: 28px;
}
.footer__legal {
  align-items: center;
  text-align: center;
  gap: 0.1rem;
  font-size: 0.7rem;
  line-height: 1.35;
}

/* App layout: sidebar + main */

.app-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 0;
  min-height: calc(100vh - 200px);
  align-items: stretch;
  transition: grid-template-columns 0.2s ease;
}

.app-layout.is-collapsed {
  grid-template-columns: 56px 1fr;
}

.sidebar {
  background: #fff;
  border-right: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  align-self: flex-start;
  max-height: 100vh;
  overflow: hidden;
}

.sidebar__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 18px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}

.sidebar__title {
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #1a202c;
}

.sidebar__toggle {
  background: none;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  color: #475569;
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.sidebar__toggle:hover {
  background: #e2e8f0;
  color: #1a202c;
}

.app-layout.is-collapsed .sidebar__toggle-icon {
  transform: rotate(180deg);
  display: inline-block;
}

.sidebar__body {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}

.app-layout.is-collapsed .sidebar__title,
.app-layout.is-collapsed .sidebar__body {
  display: none;
}

.app-layout.is-collapsed .sidebar__head {
  justify-content: center;
  padding: 14px 6px;
}

/* Make main column scroll independently and not be overflowed by sidebar */
.app-layout > .main {
  min-width: 0;
}

/* Filter group inside sidebar — vertical stack */

.sidebar__body .filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar__body .filter-group label {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
}

.sidebar__body input[type="date"] {
  font: inherit;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #fff;
  width: 100%;
  color: #1a202c;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.sidebar__body input[type="date"]:hover { border-color: #cbd5e0; }
.sidebar__body input[type="date"]:focus {
  outline: none;
  border-color: #1a56a0;
  box-shadow: 0 0 0 3px rgba(26, 86, 160, 0.12);
}

/* Quick date chips — single row, compact */
.date-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.date-quick button {
  flex: 1 1 auto;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 6px;
  background: #fff;
  color: #475569;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.date-quick button:hover {
  border-color: #1a56a0;
  color: #1a56a0;
}

.date-quick button.is-active {
  background: #1a56a0;
  border-color: #1a56a0;
  color: #fff;
}

/* From/to date inputs — stacked vertically for full visibility */
.date-range {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.date-range .filter-group { gap: 4px; }
.date-range .filter-group label { font-size: 10px; }
.date-range input[type="date"] {
  padding: 7px 10px;
  font-size: 13px;
  width: 100%;
}

.sidebar__body .btn-reset {
  margin-top: 8px;
  padding: 9px 12px;
  background: #1a56a0;
  color: #fff;
  border: 0;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.sidebar__body .btn-reset:hover { background: #14457f; }

.sidebar__body .btn-export {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
  padding: 9px 12px;
  background: #fff;
  color: #1a56a0;
  border: 1.5px solid #1a56a0;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.sidebar__body .btn-export:hover { background: #eff6ff; }

/* Custom multiselect */

.filter-multi {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-multi__label {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
}

.filter-multi__trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 9px 12px 9px 14px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  text-align: left;
  color: #1a202c;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.filter-multi__trigger:hover { border-color: #cbd5e0; }
.filter-multi.is-active .filter-multi__trigger {
  border-color: #1a56a0;
  box-shadow: 0 0 0 3px rgba(26, 86, 160, 0.12);
}
.filter-multi.has-value .filter-multi__trigger {
  border-color: #1a56a0;
  background: #eff6ff;
}

.filter-multi__chip {
  flex: 1;
  font-weight: 500;
  color: #475569;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.filter-multi.has-value .filter-multi__chip { color: #1a56a0; font-weight: 600; }

.filter-multi__caret {
  flex-shrink: 0;
  color: #94a3b8;
  transition: transform 0.15s, color 0.15s;
}
.filter-multi.is-active .filter-multi__caret {
  transform: rotate(180deg);
  color: #1a56a0;
}
.filter-multi.has-value .filter-multi__caret { color: #1a56a0; }

.filter-multi__panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 50;
  background: #fff;
  border: 1px solid #cbd5e0;
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  max-height: 320px;
}

.filter-multi__panel[hidden] { display: none; }
.view[hidden] { display: none; }

.filter-multi__search {
  font: inherit;
  font-size: 13px;
  padding: 8px 10px;
  margin: 8px 8px 4px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
}

.filter-multi__search:focus { outline: 2px solid #1a56a0; outline-offset: -1px; border-color: transparent; }

.filter-multi__options {
  overflow-y: auto;
  padding: 4px 0 8px;
  flex: 1;
}

.filter-multi__opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  font-size: 13px;
  color: #1a202c;
  cursor: pointer;
}

.filter-multi__opt:hover { background: #f1f5f9; }

.filter-multi__opt input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: #1a56a0;
  cursor: pointer;
}

.filter-multi__opt.is-disabled {
  opacity: 0.4;
  pointer-events: none;
}

.filter-multi__empty {
  padding: 10px 12px;
  font-size: 12px;
  color: #94a3b8;
  font-style: italic;
}

@media (max-width: 880px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: none; }
}

.filter-group input[type="date"] {
  font: inherit;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: #fff;
  min-width: 140px;
}

.filter-group input[type="date"]:focus {
  outline: 2px solid #1a56a0;
  outline-offset: 1px;
}

.footer__inner {
  display: flex;
  justify-content: center;
  padding: 16px 24px;
  font-size: 13px;
  color: #6b7280;
}

.footer__legal {
  display: flex;
  gap: 16px;
  align-items: center;
}

.footer__legal code {
  background: rgba(0, 0, 0, 0.05);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
}

/* Login page */

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f5f7fb 0%, #eef2f7 100%);
  font-family: 'Inter', system-ui, sans-serif;
}

.login-wrap {
  width: 100%;
  max-width: 380px;
  padding: 24px;
}

.login-card {
  padding: 32px 28px;
}

.login-logo {
  display: block;
  height: 56px;
  width: auto;
  max-width: 100%;
  margin: 0 auto 18px;
}

.login-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: #0f172a;
  text-align: center;
}

.login-sub {
  margin: 6px 0 22px;
  color: #6b7280;
  font-size: 14px;
  text-align: center;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: #374151;
}

.login-field input {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 8px;
  background: #fff;
  font-size: 15px;
}

.login-field input:focus {
  outline: 2px solid #1a56a0;
  outline-offset: 1px;
}

.login-submit {
  margin-top: 6px;
  padding: 11px 16px;
  background: #1a56a0;
  color: #fff;
  border: 0;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
}

.login-submit:hover { background: #14457f; }

.login-error {
  margin: 0 0 14px;
  padding: 10px 12px;
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
  border-radius: 8px;
  font-size: 13px;
}

/* Logout button in header */

.header__logout {
  display: inline-flex;
  align-items: center;
  margin-left: auto;
}

.header__logout button {
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  cursor: pointer;
}

.header__logout button:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Section header layout for view toggle */

.section-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.section-card__title-group {
  flex: 1;
  min-width: 0;
}

/* View toggle */

.view-toggle {
  display: inline-flex;
  gap: 2px;
  background: #f1f5f9;
  border-radius: 8px;
  padding: 3px;
  border: 1.5px solid rgba(0, 0, 0, 0.08);
  flex-shrink: 0;
}

.view-toggle__btn {
  background: none;
  border: none;
  color: #64748b;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.view-toggle__btn.active {
  background: #1a56a0;
  color: #fff;
  box-shadow: 0 2px 6px rgba(26, 86, 160, 0.25);
}

.view-toggle__btn:hover:not(.active) {
  color: #1a202c;
  background: #e2e8f0;
}

/* Data table */

.data-table-wrapper {
  max-height: 460px;
  overflow-y: auto;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  color: #64748b;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 10px;
  padding: 10px 12px;
  text-align: left;
  border-bottom: 2px solid #e2e8f0;
  z-index: 2;
}

.data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #edf2f7;
  color: #1a202c;
}

.data-table td:first-child {
  font-family: 'JetBrains Mono', monospace;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 600;
  width: 40px;
}

.data-table td.name-cell {
  font-weight: 600;
}

.data-table td.number-cell {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  font-size: 12px;
  text-align: right;
}

.data-table td.pct-cell {
  text-align: right;
  width: 130px;
}

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

/* Dynamics table — center all cells horizontally */
.data-table--dynamics th,
.data-table--dynamics td,
.data-table--dynamics td:first-child,
.data-table--dynamics td.name-cell,
.data-table--dynamics td.number-cell {
  text-align: center !important;
}

.pct-bar-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}

.pct-bar {
  width: 60px;
  height: 6px;
  background: #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
}

.pct-bar__fill {
  height: 100%;
  border-radius: 10px;
  background: #1a56a0;
  transition: width 0.4s ease;
}

.pct-bar__text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  color: #475569;
  min-width: 38px;
  text-align: right;
}

/* Map */

.map-container {
  height: 480px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #e2e8f0;
}

.map-tooltip {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  line-height: 1.5;
}

.map-tooltip strong {
  color: #1a202c;
  font-size: 13px;
}

.map-tooltip__val {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  color: #1a56a0;
}

.map-tooltip__pct {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  color: #64748b;
}

.map-legend {
  background: rgba(255, 255, 255, 0.95);
  padding: 8px 10px;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
  font-family: 'Inter', sans-serif;
}

.map-legend__gradient {
  height: 8px;
  width: 140px;
  border-radius: 4px;
  margin: 4px 0;
}

.map-legend__labels {
  display: flex;
  justify-content: space-between;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: #475569;
}

/* ── Modal (export pivot) ─────────────────────────────────────── */

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal[hidden] { display: none; }

.modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}

.modal__panel {
  position: relative;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
  width: 100%;
  max-width: 460px;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 18px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}

.modal__title {
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: 15px;
  color: #0f172a;
}

.modal__close {
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal__close:hover { background: #e2e8f0; color: #1a202c; }

.modal__body {
  padding: 16px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal__hint {
  margin: 0;
  font-size: 12.5px;
  color: #64748b;
  line-height: 1.5;
}

.modal__hint--err { color: #b91c1c; font-weight: 500; }

.modal__check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #1a202c;
  cursor: pointer;
  user-select: none;
}

.modal__check input { accent-color: #1a56a0; width: 14px; height: 14px; }

.modal__foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
}

.btn-cancel {
  padding: 8px 14px;
  background: #fff;
  color: #475569;
  border: 1px solid #cbd5e0;
  border-radius: 8px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
.btn-cancel:hover { background: #f1f5f9; }

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: #1a56a0;
  color: #fff;
  border: 0;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary:hover { background: #14457f; }

/* Pivot group-by checkbox grid inside modal */
.export-groupby {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
  padding: 6px 0;
  border-top: 1px dashed #e2e8f0;
  border-bottom: 1px dashed #e2e8f0;
}

.export-groupby__opt {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #1a202c;
  cursor: pointer;
  padding: 4px 2px;
  user-select: none;
}

.export-groupby__opt input { accent-color: #1a56a0; width: 14px; height: 14px; }
.export-groupby__opt:hover { color: #1a56a0; }

@media (max-width: 540px) {
  .export-groupby { grid-template-columns: 1fr; }
}
