/* ========================================
   STORICA DASHBOARDS — DESIGN SYSTEM
   Dark Premium Theme based on Brand Guide
   ======================================== */

:root {
  /* Primary Palette */
  --color-primary:        #202020;
  --color-secondary:      #FF6F5E;
  --color-white:          #FFFFFF;
  --color-black:          #000000;

  /* Dark Theme */
  --bg-body:              #141414;
  --bg-surface:           #1E1E1E;
  --bg-card:              #262626;
  --bg-card-hover:        #2E2E2E;
  --bg-input:             #2A2A2A;
  --border-subtle:        #333333;
  --border-medium:        #444444;
  --text-primary:         #FFFFFF;
  --text-secondary:       #B0B0B0;
  --text-muted:           #777777;

  /* Neutral Palette */
  --color-gray-100:       #F7F7F7;
  --color-gray-200:       #EFEFEF;
  --color-gray-300:       #DBDBDB;
  --color-gray-400:       #ABABAB;
  --color-gray-500:       #888888;
  --color-gray-600:       #666666;
  --color-gray-700:       #444444;
  --color-gray-800:       #2A2A2A;
  --color-gray-900:       #1A1A1A;

  /* Accent Variations */
  --color-coral-light:    #FF8A7A;
  --color-coral-dark:     #E85A4A;
  --color-coral-10:       rgba(255, 111, 94, 0.10);
  --color-coral-15:       rgba(255, 111, 94, 0.15);
  --color-coral-20:       rgba(255, 111, 94, 0.20);

  /* Status Colors */
  --color-positive:       #2ECC71;
  --color-positive-bg:    rgba(46, 204, 113, 0.12);
  --color-negative:       #FF6F5E;
  --color-negative-bg:    rgba(255, 111, 94, 0.12);

  /* Typography */
  --font-display:         'Roboto Condensed', sans-serif;
  --font-body:            'Open Sans', sans-serif;
  --font-accent:          'Roboto', sans-serif;

  /* Font Weights */
  --weight-light:         300;
  --weight-regular:       400;
  --weight-medium:        500;
  --weight-semibold:      600;
  --weight-bold:          700;
  --weight-extrabold:     800;

  /* Font Sizes */
  --text-xs:              0.75rem;
  --text-sm:              0.875rem;
  --text-base:            1rem;
  --text-md:              1.125rem;
  --text-lg:              1.25rem;
  --text-xl:              1.5rem;
  --text-2xl:             1.875rem;
  --text-3xl:             2.188rem;
  --text-4xl:             2.75rem;

  /* Line Heights */
  --leading-tight:        1.1;
  --leading-snug:         1.25;
  --leading-normal:       1.5;

  /* Spacing */
  --space-1:              0.25rem;
  --space-2:              0.5rem;
  --space-3:              0.75rem;
  --space-4:              1rem;
  --space-5:              1.25rem;
  --space-6:              1.5rem;
  --space-8:              2rem;
  --space-10:             2.5rem;
  --space-12:             3rem;
  --space-16:             4rem;

  /* Border Radius */
  --radius-sm:            4px;
  --radius-md:            8px;
  --radius-lg:            12px;
  --radius-xl:            16px;
  --radius-2xl:           20px;

  /* Shadows */
  --shadow-sm:            0 1px 3px rgba(0,0,0,0.3);
  --shadow-md:            0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg:            0 8px 30px rgba(0,0,0,0.5);
  --shadow-coral:         0 4px 20px rgba(255, 111, 94, 0.3);

  /* Transitions */
  --transition-fast:      150ms ease;
  --transition-base:      300ms ease;
}

/* ========================================
   RESET & BASE
   ======================================== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-weight: var(--weight-regular);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background: var(--bg-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   HEADER
   ======================================== */
.app-header {
  background: var(--bg-surface);
  color: var(--text-primary);
  padding: var(--space-5) var(--space-8);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border-subtle);
}

.app-header__left {
  display: flex;
  align-items: center;
  gap: var(--space-6);
}

.app-header__logo-img {
  height: 28px;
  width: auto;
  display: block;
}

.app-header__divider {
  width: 1px;
  height: 28px;
  background: var(--border-medium);
}

.app-header__client-name {
  font-family: var(--font-display);
  font-weight: var(--weight-bold);
  font-size: var(--text-lg);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.app-header__controls {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* ========================================
   HERO BANNER
   ======================================== */
/* ========================================
   HOME HERO
   ======================================== */

.home-hero {
  background: var(--bg-surface);
  padding: var(--space-12, 4rem) var(--space-8) var(--space-10);
  border-bottom: 1px solid var(--border-subtle);
  text-align: center;
}

.home-hero__inner {
  max-width: 800px;
  margin: 0 auto;
}

.home-hero__title {
  font-family: var(--font-display);
  font-weight: var(--weight-extrabold);
  font-size: clamp(1.8rem, 4vw, 3rem);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-primary);
  margin-bottom: var(--space-3);
}

.home-hero__brand {
  color: var(--color-secondary);
}

.home-hero__subtitle {
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.home-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-5);
  margin-bottom: var(--space-6);
}

.home-kpi-grid .home-kpi--highlight {
  border-color: var(--color-coral-20);
  background: linear-gradient(135deg, var(--bg-card) 0%, rgba(255, 111, 94, 0.06) 100%);
}

.home-kpi {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-6) var(--space-5);
  text-align: center;
  transition: all var(--transition-base);
}

.home-kpi:hover {
  border-color: var(--border-medium);
  background: var(--bg-card-hover);
}

.home-kpi__icon {
  font-size: 1.5rem;
  margin-bottom: var(--space-3);
  opacity: 0.5;
}

.home-kpi__value {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 2.5vw, 2rem);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.home-kpi__label {
  font-family: var(--font-accent);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  font-weight: var(--weight-semibold);
}

.home-kpi--highlight .home-kpi__value {
  color: var(--color-secondary);
}

.home-kpi__change {
  font-family: var(--font-accent);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  margin-top: var(--space-2);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  display: inline-block;
}

.home-kpi__change--up {
  color: var(--color-positive);
  background: var(--color-positive-bg);
}

.home-kpi__change--down {
  color: var(--color-negative);
  background: var(--color-negative-bg);
}

/* Quote card */
.home-kpi--quote {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-color: var(--border-subtle);
  background: linear-gradient(135deg, var(--bg-card) 0%, rgba(255, 111, 94, 0.04) 100%);
  padding: var(--space-6);
}

.home-kpi__quote-text {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.6;
  text-align: center;
  font-style: italic;
  margin-bottom: var(--space-3);
}

.home-kpi__quote-author {
  font-family: var(--font-accent);
  font-size: var(--text-xs);
  color: var(--color-secondary);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* Period badge */
.home-period-badge {
  font-family: var(--font-accent);
  font-size: var(--text-xs);
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full, 100px);
  padding: 4px 14px;
  margin-left: auto;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

@media (max-width: 1024px) {
  .home-kpi-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
  .home-kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .home-kpi-grid { grid-template-columns: 1fr; }
}

/* ========================================
   REPORT HERO
   ======================================== */

.report-hero {
  background: var(--bg-surface);
  padding: var(--space-10) var(--space-8) var(--space-8);
  border-bottom: 1px solid var(--border-subtle);
}

.report-hero__inner {
  max-width: 1400px;
  margin: 0 auto;
}

.report-hero__title {
  font-family: var(--font-display);
  font-weight: var(--weight-extrabold);
  font-size: clamp(1.5rem, 3vw, 2.5rem);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-primary);
  margin-bottom: var(--space-6);
}

/* ========================================
   FILTERS BAR
   ======================================== */
.filters-bar {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.filter-group {
  flex: 1;
  min-width: 200px;
  max-width: 320px;
}

.filter-select,
.filter-input {
  width: 100%;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition-fast);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.filter-select:focus,
.filter-input:focus {
  border-color: var(--color-secondary);
}

.filter-select option {
  background: var(--bg-card);
  color: var(--text-primary);
}

/* ========================================
   DATE RANGE PICKER
   ======================================== */
.drp {
  position: relative;
}

.drp__trigger {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color var(--transition-fast);
  text-align: left;
  white-space: nowrap;
}

.drp__trigger:hover {
  border-color: var(--color-secondary);
}

.drp__icon {
  font-size: 14px;
  opacity: 0.7;
}

.drp__label {
  flex: 1;
}

.drp__arrow {
  font-size: 10px;
  opacity: 0.5;
}

.drp__dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 1000;
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.drp__dropdown--open {
  display: block;
}

.drp__layout {
  display: flex;
}

.drp__presets {
  width: 180px;
  padding: var(--space-3);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.drp__presets-title {
  font-family: var(--font-accent);
  font-size: 10px;
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: var(--space-2) var(--space-3);
}

.drp__preset {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  text-align: left;
  padding: var(--space-2) var(--space-3);
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.drp__preset:hover {
  background: rgba(255,255,255,0.05);
  color: var(--text-primary);
}

.drp__preset--active {
  background: var(--color-coral-15);
  color: var(--color-secondary);
  font-weight: var(--weight-semibold);
}

.drp__presets-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: var(--space-2) 0;
}

.drp__calendar {
  width: 280px;
  padding: var(--space-4);
}

.drp__cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.drp__cal-nav-btn {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.drp__cal-nav-btn:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text-primary);
}

.drp__cal-month {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  text-transform: capitalize;
  color: var(--text-primary);
}

.drp__cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
}

.drp__cal-header {
  font-size: 10px;
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
  text-align: center;
  padding: var(--space-1) 0;
}

.drp__cal-empty {
  height: 32px;
}

.drp__cal-day {
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.drp__cal-day:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text-primary);
}

.drp__cal-day--range {
  background: var(--color-coral-10);
  border-radius: 0;
}

.drp__cal-day--start {
  background: var(--color-secondary);
  color: var(--color-white);
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  font-weight: var(--weight-bold);
}

.drp__cal-day--end {
  background: var(--color-secondary);
  color: var(--color-white);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-weight: var(--weight-bold);
}

.drp__cal-day--start.drp__cal-day--end {
  border-radius: var(--radius-sm);
}

.drp__cal-day--today {
  border: 1px solid var(--color-secondary);
}

.drp__cal-day--disabled {
  opacity: 0.25;
  cursor: default;
  pointer-events: none;
}

.drp__cal-selection {
  text-align: center;
  padding: var(--space-2) 0;
}

.drp__cal-sel-label {
  font-size: 10px;
  color: var(--text-muted);
  font-style: italic;
}

.drp__cal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
}

.drp__cal-range {
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.drp__cal-apply {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: var(--space-2) var(--space-4);
  border: none;
  border-radius: var(--radius-md);
  background: var(--color-secondary);
  color: var(--color-white);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.drp__cal-apply:hover {
  background: var(--color-coral-dark);
}

/* ========================================
   MAIN CONTAINER
   ======================================== */
.app-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--space-8);
}

/* ========================================
   SECTION HEADER (BIG NUMBERS, etc.)
   ======================================== */
.section-header {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.section-header__title {
  font-family: var(--font-display);
  font-weight: var(--weight-extrabold);
  font-size: var(--text-xl);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-primary);
  white-space: nowrap;
}

.section-header__line {
  flex: 1;
  height: 4px;
  background: linear-gradient(90deg, var(--color-secondary) 0%, transparent 100%);
  border-radius: 2px;
}

/* ========================================
   KPI CARDS — BIG NUMBERS
   ======================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.kpi-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-5);
  border: 1px solid var(--border-subtle);
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.kpi-card:hover {
  border-color: var(--border-medium);
  background: var(--bg-card-hover);
}

.kpi-card__label {
  font-family: var(--font-accent);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}

.kpi-card__value {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  line-height: var(--leading-tight);
  margin-bottom: var(--space-2);
}

.kpi-card__change {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}

.kpi-card__change--up {
  color: var(--color-positive);
  background: var(--color-positive-bg);
}

.kpi-card__change--down {
  color: var(--color-negative);
  background: var(--color-negative-bg);
}

.kpi-card__change .arrow {
  font-size: 10px;
}

/* KPI with mini chart */
.kpi-card--with-chart {
  display: flex;
  flex-direction: column;
}

.kpi-card__mini-chart {
  flex: 1;
  margin-top: var(--space-2);
  min-height: 80px;
}

.kpi-card__mini-chart canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ========================================
   CHART CARDS
   ======================================== */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

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

.chart-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  border: 1px solid var(--border-subtle);
}

.chart-card__title {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: var(--space-4);
}

.chart-card__canvas-wrap {
  position: relative;
  height: 220px;
}

.chart-card__canvas-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ========================================
   DATA TABLE
   ======================================== */
.data-table-wrap {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
  margin-bottom: var(--space-8);
}

.data-table-wrap {
  max-height: 520px;
  overflow-y: auto;
}

.data-table-wrap thead {
  position: sticky;
  top: 0;
  z-index: 2;
}

.data-table-wrap thead th {
  background: var(--color-surface-deep, #262626);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table thead {
  background: var(--bg-surface);
}

.data-table th {
  font-family: var(--font-accent);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: var(--space-3) var(--space-4);
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.data-table td {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.data-table td.value-positive {
  color: var(--color-positive);
}

.data-table td.value-negative {
  color: var(--color-negative);
}

/* ========================================
   TABS (Sidebar)
   ======================================== */
.layout-with-sidebar {
  display: flex;
  gap: 0;
  min-height: calc(100vh - 72px);
}

.sidebar-nav {
  width: 56px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  padding: var(--space-3) 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  position: sticky;
  top: 72px;
  height: calc(100vh - 72px);
  overflow-y: auto;
}

.sidebar-nav__label {
  font-family: var(--font-accent);
  font-size: 7px;
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  width: 100%;
  text-align: center;
  padding: var(--space-2) 0 2px;
  margin-top: var(--space-2);
  border-top: 1px solid var(--border-subtle);
  opacity: 0.5;
}

.sidebar-nav__label:first-child {
  border-top: none;
  margin-top: 0;
}

.sidebar-nav__item {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--text-muted);
  font-family: var(--font-accent);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  border: none;
  background: none;
  transition: all var(--transition-fast);
  position: relative;
}

.sidebar-nav__item:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.sidebar-nav__item--active {
  color: var(--color-secondary);
  background: var(--color-coral-10);
}

.sidebar-nav__item--active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  background: var(--color-secondary);
  border-radius: 0 2px 2px 0;
}

.main-content {
  flex: 1;
  min-width: 0;
}

/* ========================================
   INLINE TABS (horizontal)
   ======================================== */
.tabs {
  display: flex;
  gap: var(--space-1);
  margin-bottom: var(--space-6);
  border-bottom: 1px solid var(--border-subtle);
}

.tab {
  font-family: var(--font-accent);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: var(--space-3) var(--space-5);
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--transition-fast);
}

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

.tab--active {
  color: var(--color-secondary);
  border-bottom-color: var(--color-secondary);
  font-weight: var(--weight-semibold);
}

.tab-content {
  display: none;
}

.tab-content--active {
  display: block;
}

/* ========================================
   BADGES
   ======================================== */
.badge {
  display: inline-block;
  font-family: var(--font-accent);
  font-size: 10px;
  font-weight: var(--weight-semibold);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge--meta {
  background: rgba(21, 101, 192, 0.15);
  color: #64B5F6;
}

.badge--tiktok {
  background: rgba(229, 57, 53, 0.15);
  color: #EF9A9A;
}

.badge--google {
  background: rgba(245, 124, 0, 0.15);
  color: #FFB74D;
}

.badge--active {
  background: rgba(46, 204, 113, 0.15);
  color: var(--color-positive);
}

.badge--instagram {
  background: rgba(228, 64, 95, 0.15);
  color: #F06292;
}

.badge--facebook {
  background: rgba(24, 119, 242, 0.15);
  color: #64B5F6;
}

.badge--youtube {
  background: rgba(255, 0, 0, 0.15);
  color: #EF5350;
}

.badge--x {
  background: rgba(255, 255, 255, 0.10);
  color: #B0B0B0;
}

.badge--threads {
  background: rgba(255, 255, 255, 0.10);
  color: #B0B0B0;
}

.badge--format {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  font-size: 9px;
  padding: 2px 6px;
}

/* ========================================
   BUTTONS
   ======================================== */
.btn {
  font-family: var(--font-body);
  font-weight: var(--weight-semibold);
  font-size: var(--text-xs);
  padding: var(--space-2) var(--space-4);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

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

.btn--primary:hover {
  background: var(--color-coral-dark);
  box-shadow: var(--shadow-coral);
}

.btn--ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-medium);
}

.btn--ghost:hover {
  color: var(--text-primary);
  border-color: var(--text-secondary);
}

.btn--icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-medium);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn--icon:hover {
  color: var(--color-secondary);
  border-color: var(--color-secondary);
}

/* ========================================
   LOADING & EMPTY STATES
   ======================================== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-16);
  color: var(--text-muted);
  font-size: var(--text-md);
}

.loading::after {
  content: '';
  width: 24px;
  height: 24px;
  margin-left: var(--space-3);
  border: 3px solid var(--border-medium);
  border-top-color: var(--color-secondary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.empty-state {
  text-align: center;
  padding: var(--space-16);
  color: var(--text-muted);
}

.last-update {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* ========================================
   SIDEBAR NAV — SVG ICONS
   ======================================== */
.sidebar-nav__svg {
  width: 20px;
  height: 20px;
}

/* ========================================
   CREATIVE CARDS
   ======================================== */
.creatives-grid {
  margin-bottom: var(--space-8);
}

.creative-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--transition-base);
}

.creative-card:hover {
  border-color: var(--border-medium);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

a.creative-card--link {
  display: block;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

a.creative-card--link:hover {
  border-color: var(--color-secondary);
}

.creative-card__preview {
  width: 100%;
  height: 80px;
  background: var(--color-surface-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.creative-card__preview img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.creative-card__preview-img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

/* ════════════════════════════════════════
   MULTI-SELECT DROPDOWN
   ════════════════════════════════════════ */

.ms {
  position: relative;
  min-width: 180px;
}

.ms__trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface-card);
  border: 1px solid #333;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--color-text);
  transition: border-color 0.2s;
  gap: var(--space-2);
}

.ms__trigger:hover { border-color: #555; }

.ms__label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ms__arrow {
  font-size: 0.6rem;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.ms__dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: #1E1E1E;
  border: 1px solid #444;
  border-radius: var(--radius-md);
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,0.6);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  min-width: 240px;
}

.ms__search-wrap {
  padding: var(--space-2);
  border-bottom: 1px solid #333;
}

.ms__search {
  width: 100%;
  padding: var(--space-1) var(--space-2);
  background: var(--color-bg);
  border: 1px solid #333;
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-size: var(--text-sm);
  font-family: var(--font-body);
  outline: none;
}

.ms__search:focus { border-color: var(--color-accent); }

.ms__options {
  max-height: 240px;
  overflow-y: auto;
  padding: var(--space-1) 0;
}

.ms__option {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  transition: background 0.15s;
}

.ms__option:hover { background: rgba(255,255,255,0.05); }

.ms__option--all {
  border-bottom: 1px solid #333;
  margin-bottom: var(--space-1);
  padding-bottom: var(--space-2);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
}

.ms__option input[type="checkbox"] {
  accent-color: var(--color-accent);
  flex-shrink: 0;
}

.ms__option span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Granularity Toggle ──────────────────── */

.granularity-toggle {
  display: flex;
  gap: 0;
  margin-left: auto;
  background: var(--color-surface-deep, #262626);
  border-radius: var(--radius-md);
  border: 1px solid #444;
  overflow: hidden;
}

/* ── Sortable Table Headers ───────────────── */

.data-table th[data-sortable] { cursor: pointer; }

.data-table th.sort-asc::after,
.data-table th.sort-desc::after {
  margin-left: 4px;
  font-size: 0.6rem;
  opacity: 0.8;
}

.data-table th.sort-asc::after { content: '▲'; }
.data-table th.sort-desc::after { content: '▼'; }

.data-table th:hover {
  color: var(--color-text);
}

.gran-btn {
  background: none;
  border: none;
  border-right: 1px solid #444;
  color: var(--color-text-muted);
  font-family: var(--font-condensed);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: var(--space-2) var(--space-4);
  cursor: pointer;
  transition: all 0.2s;
}

.gran-btn:last-child { border-right: none; }
.gran-btn:hover { color: var(--color-text); background: rgba(255,255,255,0.05); }

.gran-btn:hover { color: var(--color-text); }
.gran-btn--active { background: var(--color-accent); color: #fff; }

.section-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.creative-thumb-cell {
  width: 48px;
  padding: var(--space-1) !important;
}

.creative-thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  display: block;
}

.creative-name {
  font-weight: var(--weight-semibold);
  font-size: var(--text-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}

.creative-adset {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}

.creative-card__preview-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  color: var(--text-muted);
}

.creative-card__preview-icon {
  font-size: 2rem;
  opacity: 0.4;
}

.creative-card__preview-type {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: var(--weight-semibold);
}

.creative-card__platform-badge {
  position: absolute;
  top: 8px;
  left: 8px;
}

.creative-card__body {
  padding: var(--space-4);
}

.creative-card__name {
  font-family: var(--font-accent);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.creative-card__adset {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: var(--space-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.creative-card__metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
}

.creative-card__metric {
  text-align: center;
}

.creative-card__metric-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.creative-card__metric-value {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
}

.creative-card__footer {
  padding: 0 var(--space-4) var(--space-4);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
}

.creative-card__footer .creative-card__metric-value {
  font-size: var(--text-xs);
}

/* Creative sort bar */
.creative-sort-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.creative-sort-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: var(--weight-semibold);
}

/* ========================================
   RESPONSIVE
   ======================================== */
/* ════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════ */

/* Mobile menu toggle button */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--color-text);
  font-size: 1.4rem;
  cursor: pointer;
  padding: var(--space-1);
  line-height: 1;
}

@media (max-width: 1200px) {
  .kpi-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .charts-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  /* Header */
  .app-header {
    padding: var(--space-3) var(--space-4);
    flex-wrap: wrap;
    gap: var(--space-2);
  }
  .app-header__left {
    gap: var(--space-3);
  }
  .app-header__client-name {
    display: none;
  }
  .app-header__controls {
    gap: var(--space-2);
  }
  .app-header__controls select {
    min-width: 140px !important;
    font-size: var(--text-xs);
  }
  .app-header__user {
    margin-left: var(--space-2);
    padding-left: var(--space-2);
  }
  .header-user-name {
    display: none;
  }
  .mobile-menu-btn {
    display: block;
  }

  /* Sidebar — hidden by default, shown as overlay on mobile */
  .sidebar-nav {
    position: fixed;
    top: 0;
    left: -200px;
    width: 200px;
    height: 100vh;
    z-index: 500;
    transition: left 0.25s ease;
    padding-top: var(--space-8);
    box-shadow: none;
  }
  .sidebar-nav.sidebar-nav--open {
    left: 0;
    box-shadow: 4px 0 24px rgba(0,0,0,0.5);
  }
  .sidebar-nav__item {
    width: 100%;
    justify-content: flex-start;
    padding: var(--space-2) var(--space-4);
    gap: var(--space-3);
  }
  .sidebar-nav__item::after {
    content: attr(title);
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    font-family: var(--font-condensed);
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }
  .sidebar-nav__item--active::after {
    color: var(--color-text);
  }
  .sidebar-nav__label {
    padding: var(--space-1) var(--space-4);
    text-align: left;
  }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 499;
  }
  .sidebar-overlay--open {
    display: block;
  }

  /* Content */
  .app-container {
    padding: var(--space-4);
  }
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .charts-grid,
  .charts-grid--2 {
    grid-template-columns: 1fr;
  }
  .filters-bar {
    flex-direction: column;
  }
  .filter-group {
    max-width: 100%;
    min-width: 0;
  }
  .report-hero {
    padding: var(--space-6) var(--space-4) var(--space-4);
  }
  .report-hero__title {
    font-size: 1.3rem;
  }
  .tab-hero {
    padding: var(--space-4);
  }

  /* Tables horizontal scroll */
  .data-table-wrap {
    overflow-x: auto;
  }
  .data-table {
    min-width: 600px;
  }

  /* Section headers */
  .section-header {
    flex-wrap: wrap;
  }
  .granularity-toggle {
    margin-left: 0;
    margin-top: var(--space-2);
  }

  /* Admin */
  #tab-admin {
    padding: var(--space-4);
  }
  .admin-toolbar {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-3);
  }
  .modal-card {
    margin: var(--space-4);
    max-height: 85vh;
  }

  /* Home */
  .home-hero__title {
    font-size: 1.5rem;
  }

  /* Multi-select */
  .ms {
    min-width: 0;
  }
  .ms__dropdown {
    min-width: 200px;
    right: auto;
  }

  /* Creative sort bar */
  .creative-sort-bar {
    flex-wrap: wrap;
    gap: var(--space-2);
  }
}

@media (max-width: 480px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  .home-kpi-grid {
    grid-template-columns: 1fr;
  }
  .app-header__controls select {
    min-width: 100px !important;
  }
  .data-table {
    min-width: 500px;
    font-size: var(--text-xs);
  }
}

/* ════════════════════════════════════════
   ADMIN PANEL
   ════════════════════════════════════════ */

.app-header__user {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: var(--space-4);
  padding-left: var(--space-4);
  border-left: 1px solid #333;
}

.header-user-name {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
}

#tab-admin {
  padding: var(--space-6) var(--space-8);
}

#tab-admin .tab-hero {
  margin-bottom: var(--space-6);
}

.admin-tabs {
  display: flex;
  gap: var(--space-1);
  margin-bottom: var(--space-6);
  border-bottom: 1px solid #333;
  padding-bottom: var(--space-1);
}

.admin-tab {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-family: var(--font-condensed);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: var(--space-2) var(--space-4);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}

.admin-tab:hover { color: var(--color-text); }
.admin-tab--active { color: var(--color-accent); border-bottom-color: var(--color-accent); }

.admin-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-4);
}

.section-title {
  font-family: var(--font-condensed);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
}

.btn {
  padding: var(--space-2) var(--space-4);
  border: 1px solid #444;
  border-radius: var(--radius-md);
  background: var(--color-surface-card);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.btn:hover { background: var(--color-surface-deep); border-color: #555; }
.btn--accent { background: var(--color-accent); border-color: var(--color-accent); color: #fff; }
.btn--accent:hover { opacity: 0.9; }
.btn--danger { color: var(--color-negative); border-color: rgba(255,111,94,0.3); }
.btn--danger:hover { background: rgba(255,111,94,0.1); }
.btn--sm { padding: var(--space-1) var(--space-2); font-size: var(--text-xs); }

.status-ok { color: var(--color-positive); font-weight: var(--weight-semibold); font-size: var(--text-xs); }
.status-fail { color: var(--color-negative); font-weight: var(--weight-semibold); font-size: var(--text-xs); }
.status-empty { color: var(--color-text-muted); font-size: var(--text-xs); }

.badge--sm {
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.08);
  color: var(--color-text-secondary);
}

.badge--accent { background: rgba(255,111,94,0.15); color: var(--color-accent); }
.badge--blue { background: rgba(78,149,255,0.15); color: #4E95FF; }
.badge--default { background: rgba(255,255,255,0.08); color: var(--color-text-secondary); }

/* ── Modals ──────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal-card {
  background: var(--color-surface-card);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-5);
}

.modal-header h3 {
  font-family: var(--font-condensed);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
}

.modal-close {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover { color: var(--color-text); }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

/* ── Form styles ──────────────────────────── */

.form-group {
  margin-bottom: var(--space-4);
}

.form-group label {
  display: block;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--space-1);
  font-weight: var(--weight-semibold);
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"] {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background: var(--color-bg);
  border: 1px solid #333;
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus { border-color: var(--color-accent); }

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  accent-color: var(--color-accent);
}

.analytics-prop-row {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
  align-items: center;
}

.analytics-prop-label {
  width: 35%;
  padding: var(--space-2) var(--space-3);
  background: var(--color-bg);
  border: 1px solid #333;
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  outline: none;
}

.analytics-prop-id {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  background: var(--color-bg);
  border: 1px solid #333;
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  outline: none;
}

.analytics-prop-label:focus,
.analytics-prop-id:focus {
  border-color: var(--color-accent);
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: rgba(255,255,255,0.03);
  border-radius: var(--radius-sm);
}

.form-hint code {
  background: rgba(255,111,94,0.1);
  color: var(--color-accent);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: var(--text-xs);
}

.form-validation {
  margin-top: var(--space-3);
}

.validation-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) 0;
  font-size: var(--text-sm);
}
