body{
  letter-spacing:-0.01em;
}

h1,h2,h3{
  letter-spacing:-0.025em;
}

#page-title{
  font-size:24px;
  font-weight:700;
  letter-spacing:-0.035em;
}

#kpis > div{
  min-height:150px;
  padding:24px;
  transition:transform .18s ease,box-shadow .18s ease;
}

#kpis > div:hover{
  transform:translateY(-2px);
  box-shadow:0 12px 30px rgba(16,24,40,.06);
}

#kpis h3{
  font-size:32px;
  line-height:1;
  font-weight:700;
  letter-spacing:-0.04em;
  font-variant-numeric:tabular-nums;
}

#kpis p:first-child{
  font-size:13px;
  font-weight:500;
}

#kpis p:last-child{
  font-size:12px;
  line-height:1.4;
}

table{
  font-variant-numeric:tabular-nums;
}

aside{
  box-shadow:1px 0 0 rgba(16,24,40,.02);
}

/* =========================================================
   CITYCAR UI POLISH V3
   ========================================================= */

/* Общая типографика */
body {
  font-size: 15px;
  line-height: 1.5;
  color: #344054;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.dark body {
  color: #d0d5dd;
}

/* ---------- SIDEBAR ---------- */

aside {
  padding-left: 22px !important;
  padding-right: 22px !important;
}

/* Логотип */
aside > div:first-child {
  padding-top: 28px !important;
  padding-bottom: 30px !important;
}

/* Навигацию опускаем ниже */
aside nav {
  margin-top: 10px !important;
  gap: 8px !important;
}

/* Убираем маленький заголовок ANALYTICS, если где-то остался */
aside nav > p {
  display: none !important;
}

/* Пункты меню */
.cc-nav {
  min-height: 52px !important;
  padding: 0 16px !important;
  border-radius: 12px !important;
  gap: 13px !important;

  font-size: 15px !important;
  font-weight: 500 !important;
  line-height: 1 !important;

  color: #344054 !important;
}

/* Иконки */
.cc-nav > span:first-child {
  display: inline-flex;
  width: 20px;
  min-width: 20px;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

/* Активный пункт */
.cc-nav.bg-brand-50 {
  color: #465fff !important;
  font-weight: 600 !important;
}

/* Нижний блок sidebar */
aside > div:last-child {
  margin-top: 22px !important;
  padding: 24px 16px !important;
}

aside > div:last-child div {
  font-size: 13px !important;
  line-height: 1.6 !important;
  color: #667085 !important;
}

/* ---------- HEADER ---------- */

header > div {
  min-height: 88px;
  padding-top: 17px !important;
  padding-bottom: 17px !important;
}

#page-title {
  margin: 0;
  font-size: 26px !important;
  line-height: 1.15 !important;
  font-weight: 700 !important;
  color: #101828;
}

.dark #page-title {
  color: #f9fafb;
}

header p {
  margin-top: 5px;
  font-size: 13px !important;
  line-height: 1.4 !important;
  color: #667085 !important;
}

/* ---------- MAIN ---------- */

main {
  padding-top: 28px !important;
}

/* Filters */
main > div:first-child {
  padding: 20px !important;
}

main label > span {
  margin-bottom: 7px !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  color: #667085 !important;
}

/* Inputs */
main select,
main input[type="date"],
#search {
  min-height: 44px !important;
  font-size: 14px !important;
  color: #101828 !important;
}

.dark main select,
.dark main input,
.dark #search {
  color: #f9fafb !important;
}

/* ---------- KPI ---------- */

#kpis {
  gap: 18px !important;
}

#kpis > div {
  min-height: 176px !important;
  padding: 26px !important;
  border-radius: 18px !important;
}

#kpis p:first-child {
  font-size: 14px !important;
  line-height: 1.4 !important;
  font-weight: 500 !important;
  color: #667085 !important;
}

#kpis h3 {
  margin-top: 18px !important;
  font-size: 34px !important;
  line-height: 1 !important;
  font-weight: 700 !important;
  color: #101828 !important;
}

.dark #kpis h3 {
  color: #fff !important;
}

#kpis p:last-child {
  margin-top: 13px !important;
  font-size: 13px !important;
  line-height: 1.45 !important;
  color: #98a2b3 !important;
}

/* ---------- SECTION TITLES ---------- */

#view-overview h2,
#view-creatives h2,
#view-leads h2 {
  font-size: 20px !important;
  line-height: 1.25 !important;
  font-weight: 650 !important;
  letter-spacing: -0.025em;
  color: #101828 !important;
}

.dark #view-overview h2,
.dark #view-creatives h2,
.dark #view-leads h2 {
  color: #fff !important;
}

#view-overview h2 + p,
#view-creatives h2 + p,
#view-leads h2 + p {
  margin-top: 5px !important;
  font-size: 14px !important;
  line-height: 1.5 !important;
  color: #667085 !important;
}

/* Funnel */
#funnel-bars {
  margin-top: 28px;
}

#funnel-bars .text-sm {
  font-size: 14px !important;
}

/* ---------- TABLE ---------- */

#view-creatives table th {
  padding-top: 17px !important;
  padding-bottom: 17px !important;
  font-size: 11px !important;
  line-height: 1.3 !important;
  font-weight: 600 !important;
  letter-spacing: .035em;
  color: #667085 !important;
}

#view-creatives table td {
  padding-top: 18px !important;
  padding-bottom: 18px !important;
  font-size: 14px !important;
  line-height: 1.45 !important;
  color: #344054;
}

/* ---------- MOBILE ---------- */

@media (max-width: 1279px) {
  aside {
    padding-left: 18px !important;
    padding-right: 18px !important;
  }
}


/* ===== SIDEBAR ACTIVE STATE V4 ===== */

.cc-nav {
  position: relative;
  background: transparent !important;
  border: 1px solid transparent !important;
  box-shadow: none !important;
  transition:
    background-color .16s ease,
    color .16s ease,
    border-color .16s ease !important;
}

/* Обычный hover */
.cc-nav:hover {
  background: #f2f4f7 !important;
  color: #101828 !important;
}

/* ТЕКУЩАЯ ВКЛАДКА */
.cc-nav.cc-nav-active {
  background: #eef4ff !important;
  color: #465fff !important;
  border-color: #e0eaff !important;
  font-weight: 600 !important;
}

/* Иконка активной вкладки */
.cc-nav.cc-nav-active > span:first-child {
  color: #465fff !important;
}

/* Убираем серый focus после клика */
.cc-nav:focus,
.cc-nav:focus-visible {
  outline: none !important;
  box-shadow: none !important;
}

/* Dark */
.dark .cc-nav:hover {
  background: rgba(255,255,255,.05) !important;
  color: #fff !important;
}

.dark .cc-nav.cc-nav-active {
  background: rgba(70,95,255,.14) !important;
  border-color: rgba(70,95,255,.22) !important;
  color: #8ea0ff !important;
}


/* =========================================================
   CITYCAR — MOBILE + DARK MODE FIX
   ========================================================= */

/* ---------- SELECTS / DARK MODE ---------- */

select {
  color-scheme: light;
}

.dark select {
  color-scheme: dark;
  background-color: #111827 !important;
  color: #f9fafb !important;
  border-color: #374151 !important;
}

.dark select option {
  background-color: #111827 !important;
  color: #f9fafb !important;
}

.dark select option:checked {
  background-color: #2563eb !important;
  color: #ffffff !important;
}

.dark input {
  background-color: #111827;
  color: #f9fafb;
  border-color: #374151;
}


/* ---------- MOBILE ---------- */

@media (max-width: 767px) {

  /* Main content */
  main {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  /* Prevent horizontal page overflow */
  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
  }

  /* Filters */
  select,
  input[type="date"],
  input[type="text"] {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    height: 44px;
    font-size: 16px !important;
  }

  /* Filter containers */
  .grid {
    min-width: 0;
  }

  /* Cards */
  .rounded-2xl,
  .rounded-xl {
    max-width: 100%;
  }

  /* Tables can scroll instead of breaking layout */
  table {
    min-width: 700px;
  }

  .overflow-x-auto {
    -webkit-overflow-scrolling: touch;
  }

  /* Smaller card spacing */
  .p-6 {
    padding: 16px !important;
  }

  .p-5 {
    padding: 14px !important;
  }

  /* Headings */
  h1 {
    font-size: 22px !important;
    line-height: 1.25 !important;
  }

  h2 {
    font-size: 18px !important;
  }

  /* KPI values */
  .text-3xl {
    font-size: 26px !important;
  }

  /* Buttons */
  button {
    min-height: 42px;
  }

  /* Header should not force page width */
  header > div {
    max-width: 100%;
  }
}


/* Extra-small phones */
@media (max-width: 420px) {

  main {
    padding-left: 10px !important;
    padding-right: 10px !important;
  }

  .p-6 {
    padding: 14px !important;
  }

  .gap-6 {
    gap: 12px !important;
  }

  .gap-5 {
    gap: 10px !important;
  }
}


/* =========================================================
   CITYCAR MOBILE LAYOUT V2
   ========================================================= */

@media (max-width: 1279px) {

  /* Sidebar must be off-canvas by default */
  aside {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    z-index: 9999 !important;
    width: min(290px, 82vw) !important;
    max-width: 82vw !important;
    transform: translateX(-105%) !important;
    transition: transform .25s ease !important;
    box-shadow: 20px 0 50px rgba(0,0,0,.25);
  }

  /* TailAdmin opens sidebar when sidebarToggle = true */
  aside.translate-x-0,
  aside[data-mobile-open="true"] {
    transform: translateX(0) !important;
  }

  /* Main application always uses full phone width */
  body > div,
  main,
  header {
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Header */
  header {
    position: relative;
    z-index: 50;
  }

  /* Content must never sit underneath a permanent sidebar */
  .flex-1 {
    min-width: 0 !important;
  }
}


@media (max-width: 767px) {

  /* General page */
  main {
    padding: 12px !important;
  }

  /* Header becomes compact */
  header {
    min-height: 64px;
  }

  header > div {
    padding-left: 12px !important;
    padding-right: 12px !important;
    gap: 8px !important;
  }

  /* Filters */
  select,
  input[type="date"] {
    width: 100% !important;
    min-width: 0 !important;
    height: 46px !important;
  }

  /* All dashboard grids collapse safely */
  main .grid {
    min-width: 0 !important;
  }

  /* Cards */
  main .rounded-2xl {
    min-width: 0 !important;
  }

  /* Tables */
  .overflow-x-auto {
    width: 100%;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 720px;
  }
}


/* Proper native controls in dark mode */
.dark select {
  color-scheme: dark !important;
  background: #111827 !important;
  color: #f9fafb !important;
}

.dark select option {
  background: #111827 !important;
  color: #f9fafb !important;
}


/* =========================================================
   CITYCAR MOBILE V3
   ========================================================= */

@media (max-width: 767px) {

  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden !important;
  }

  /* ---------- HEADER ---------- */

  header {
    min-height: 72px !important;
    height: auto !important;
  }

  header > div {
    min-height: 72px !important;
    padding: 10px 12px !important;
    gap: 8px !important;
  }

  /* Main title area */
  h1 {
    font-size: 24px !important;
    line-height: 1.1 !important;
    margin: 0 !important;
  }

  header p {
    font-size: 13px !important;
    line-height: 1.25 !important;
  }

  /* Smaller header controls */
  header button {
    min-height: 42px !important;
  }

  /* ---------- MAIN ---------- */

  main {
    width: 100% !important;
    max-width: 100% !important;
    padding: 12px !important;
    overflow-x: hidden !important;
  }

  /* ---------- FILTER CARD ---------- */

  main select,
  main input[type="date"],
  main input[type="text"] {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: 48px !important;
    font-size: 16px !important;
  }

  /* Force filter grids into one column */
  main .grid-cols-2,
  main .grid-cols-3,
  main .grid-cols-4,
  main .md\:grid-cols-2,
  main .md\:grid-cols-3,
  main .md\:grid-cols-4,
  main .lg\:grid-cols-2,
  main .lg\:grid-cols-3,
  main .lg\:grid-cols-4 {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  /* Generic dashboard grids */
  main .grid {
    width: 100% !important;
    min-width: 0 !important;
  }

  /* ---------- CARDS ---------- */

  main .rounded-2xl,
  main .rounded-xl {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  main .p-6 {
    padding: 18px !important;
  }

  main .p-5 {
    padding: 16px !important;
  }

  /* ---------- TABLES ---------- */

  .overflow-x-auto {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 720px !important;
  }

  /* ---------- ERROR ---------- */

  #error {
    width: 100% !important;
    margin-top: 12px !important;
    margin-bottom: 12px !important;
    padding: 16px !important;
    font-size: 14px !important;
  }
}


/* =========================================================
   MOBILE SIDEBAR — independent of Alpine
   ========================================================= */

@media (max-width: 1279px) {

  aside {
    position: fixed !important;
    left: 0 !important;
    top: 0 !important;
    bottom: 0 !important;
    width: min(300px, 84vw) !important;
    max-width: 84vw !important;
    height: 100dvh !important;

    z-index: 10001 !important;

    transform: translateX(-105%) !important;
    transition: transform .22s ease !important;

    overflow-y: auto !important;

    box-shadow:
      20px 0 60px rgba(0,0,0,.35);
  }

  aside.cc-mobile-open {
    transform: translateX(0) !important;
  }

  body.cc-menu-open {
    overflow: hidden !important;
  }

  #cc-mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0,0,0,.55);
    backdrop-filter: blur(2px);
  }

  #cc-mobile-overlay.cc-show {
    display: block;
  }
}


/* Dark native select */
.dark select,
html.dark select {
  color-scheme: dark !important;
  background-color: #111827 !important;
  color: #f9fafb !important;
}

.dark select option,
html.dark select option {
  background-color: #111827 !important;
  color: #f9fafb !important;
}


/* =========================================================
   CITYCAR MOBILE V3
   ========================================================= */

@media (max-width: 767px) {

  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden !important;
  }

  /* ---------- HEADER ---------- */

  header {
    min-height: 72px !important;
    height: auto !important;
  }

  header > div {
    min-height: 72px !important;
    padding: 10px 12px !important;
    gap: 8px !important;
  }

  /* Main title area */
  h1 {
    font-size: 24px !important;
    line-height: 1.1 !important;
    margin: 0 !important;
  }

  header p {
    font-size: 13px !important;
    line-height: 1.25 !important;
  }

  /* Smaller header controls */
  header button {
    min-height: 42px !important;
  }

  /* ---------- MAIN ---------- */

  main {
    width: 100% !important;
    max-width: 100% !important;
    padding: 12px !important;
    overflow-x: hidden !important;
  }

  /* ---------- FILTER CARD ---------- */

  main select,
  main input[type="date"],
  main input[type="text"] {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: 48px !important;
    font-size: 16px !important;
  }

  /* Force filter grids into one column */
  main .grid-cols-2,
  main .grid-cols-3,
  main .grid-cols-4,
  main .md\:grid-cols-2,
  main .md\:grid-cols-3,
  main .md\:grid-cols-4,
  main .lg\:grid-cols-2,
  main .lg\:grid-cols-3,
  main .lg\:grid-cols-4 {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  /* Generic dashboard grids */
  main .grid {
    width: 100% !important;
    min-width: 0 !important;
  }

  /* ---------- CARDS ---------- */

  main .rounded-2xl,
  main .rounded-xl {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  main .p-6 {
    padding: 18px !important;
  }

  main .p-5 {
    padding: 16px !important;
  }

  /* ---------- TABLES ---------- */

  .overflow-x-auto {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 720px !important;
  }

  /* ---------- ERROR ---------- */

  #error {
    width: 100% !important;
    margin-top: 12px !important;
    margin-bottom: 12px !important;
    padding: 16px !important;
    font-size: 14px !important;
  }
}


/* =========================================================
   MOBILE SIDEBAR — independent of Alpine
   ========================================================= */

@media (max-width: 1279px) {

  aside {
    position: fixed !important;
    left: 0 !important;
    top: 0 !important;
    bottom: 0 !important;
    width: min(300px, 84vw) !important;
    max-width: 84vw !important;
    height: 100dvh !important;

    z-index: 10001 !important;

    transform: translateX(-105%) !important;
    transition: transform .22s ease !important;

    overflow-y: auto !important;

    box-shadow:
      20px 0 60px rgba(0,0,0,.35);
  }

  aside.cc-mobile-open {
    transform: translateX(0) !important;
  }

  body.cc-menu-open {
    overflow: hidden !important;
  }

  #cc-mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0,0,0,.55);
    backdrop-filter: blur(2px);
  }

  #cc-mobile-overlay.cc-show {
    display: block;
  }
}


/* Dark native select */
.dark select,
html.dark select {
  color-scheme: dark !important;
  background-color: #111827 !important;
  color: #f9fafb !important;
}

.dark select option,
html.dark select option {
  background-color: #111827 !important;
  color: #f9fafb !important;
}


/* Creative visibility */

.cc-creative-tabs {
  display: flex;
  gap: 6px;
  padding: 16px 20px 0;
}

.cc-creative-tabs button {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 8px 13px;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: #6b7280;
  cursor: pointer;
}

.cc-creative-tabs button.cc-tab-active {
  border-color: #465fff;
  background: #465fff;
  color: #fff;
}

.dark .cc-creative-tabs button {
  border-color: #374151;
  color: #d1d5db;
}

.dark .cc-creative-tabs button.cc-tab-active {
  border-color: #465fff;
  background: #465fff;
  color: #fff;
}
