/* ---- DASHBOARD LAYOUT ---- */

.dash-body {
  background: var(--bg);
  display: flex;
  min-height: 100vh;
}

/* ---- SIDEBAR ---- */
.dash-sidebar {
  width: 220px;
  min-height: 100vh;
  background: var(--fg);
  display: flex;
  flex-direction: column;
  padding: 1.75rem 1.25rem;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 100;
}

.dash-brand {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 2.5rem;
}

.dash-brand-name {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  color: #f0ece7;
  letter-spacing: -0.01em;
}

.dash-brand-tag {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(196,149,106,0.15);
  padding: 0.2rem 0.5rem;
  border-radius: 100px;
}

.dash-nav {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.dash-nav-item a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  color: #a09990;
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.dash-nav-item a:hover {
  background: rgba(255,255,255,0.07);
  color: #f0ece7;
}

.dash-nav-item--active a {
  background: rgba(196,149,106,0.18);
  color: var(--accent);
}

.nav-icon {
  font-size: 0.75rem;
  opacity: 0.8;
}

.dash-alert-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 1.5rem;
  padding: 0.5rem 0.85rem;
  background: rgba(220, 100, 60, 0.18);
  color: #f4846a;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid rgba(220, 100, 60, 0.3);
  transition: background 0.15s;
}

.dash-alert-badge:hover {
  background: rgba(220, 100, 60, 0.28);
}

/* ---- MAIN AREA ---- */
.dash-main {
  margin-left: 220px;
  flex: 1;
  padding: 2.25rem 2.5rem;
  max-width: 1200px;
}

.dash-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.dash-page-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 400;
  color: var(--fg);
  line-height: 1.1;
}

.dash-page-sub {
  font-size: 0.85rem;
  color: var(--fg-soft);
  margin-top: 0.25rem;
}

/* ---- PERIOD TOGGLE ---- */
.dash-period-toggle {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
}

.period-btn {
  padding: 0.5rem 1.1rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--fg-soft);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.period-btn:hover {
  background: var(--bg-warm);
  color: var(--fg);
}

.period-btn--active {
  background: var(--fg);
  color: #f0ece7;
}

/* ---- KPI GRID ---- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-grid--3 {
  grid-template-columns: repeat(3, 1fr);
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.35rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.kpi-card--accent {
  border-color: var(--accent-light);
  background: linear-gradient(135deg, var(--surface) 0%, #fdf6ef 100%);
}

.kpi-card--warn {
  border-color: rgba(220, 100, 60, 0.3);
  background: rgba(220, 100, 60, 0.04);
}

.kpi-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-soft);
}

.kpi-value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 600;
  color: var(--fg);
  line-height: 1;
}

.kpi-delta {
  font-size: 0.78rem;
  font-weight: 500;
}

.kpi-delta--up { color: #3d8f5e; }
.kpi-delta--down { color: #c44a3a; }
.kpi-delta--neutral { color: var(--fg-soft); }
.kpi-delta--warn { color: #c86835; }

/* ---- CARDS ---- */
.dash-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.dash-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.dash-card-meta {
  font-size: 0.78rem;
  color: var(--fg-soft);
}

/* ---- CHART ---- */
.dash-chart-section {
  margin-bottom: 1.5rem;
}

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

/* ---- TWO COL ---- */
.dash-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

/* ---- TABLE ---- */
.dash-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.dash-table thead th {
  text-align: left;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-soft);
  padding: 0 0.75rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.dash-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

.dash-table tbody tr:last-child {
  border-bottom: none;
}

.dash-table tbody tr:hover {
  background: var(--bg-warm);
}

.dash-table tbody td {
  padding: 0.75rem;
  color: var(--fg);
}

.text-right { text-align: right; }
.text-center { text-align: center; }
.text-soft { color: var(--fg-soft); }
.text-warn { color: #c86835; }
.fw-600 { font-weight: 600; }

.empty-state {
  text-align: center;
  color: var(--fg-soft);
  font-style: italic;
  padding: 2rem 0.75rem;
}

/* ---- RANK DOTS ---- */
.rank-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 700;
  margin-right: 0.4rem;
  background: var(--border);
  color: var(--fg-soft);
  flex-shrink: 0;
}

.rank-1 { background: var(--accent-light); color: var(--accent-dark); }
.rank-2 { background: #e8e4de; color: #7a7268; }
.rank-3 { background: #f0ece7; color: #9e9690; }

/* ---- BRAND PILLS ---- */
.brand-pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: 100px;
  white-space: nowrap;
}

.brand-vt { background: #e8f0f8; color: #3a6fa8; }
.brand-torriden { background: #e8f5ee; color: #2e7d52; }
.brand-sulwhasoo { background: var(--accent-light); color: var(--accent-dark); }
.brand-cosrx { background: #f3e8f5; color: #7a3d8a; }

/* ---- BRAND BREAKDOWN ---- */
.brand-breakdown {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.brand-row-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.35rem;
}

.brand-row-rev {
  margin-left: auto;
  font-weight: 600;
  font-size: 0.9rem;
}

.brand-row-pct {
  font-size: 0.78rem;
  color: var(--fg-soft);
  min-width: 38px;
  text-align: right;
}

.brand-bar-track {
  height: 6px;
  background: var(--bg-warm);
  border-radius: 100px;
  overflow: hidden;
}

.brand-bar-fill {
  height: 100%;
  border-radius: 100px;
  transition: width 0.6s ease;
}

.brand-bar-vt { background: #5a9fd4; }
.brand-bar-torriden { background: #4caf7d; }
.brand-bar-sulwhasoo { background: var(--accent); }
.brand-bar-cosrx { background: #ab66b8; }

/* ---- INVENTORY TABLE ---- */
.inv-table-wrap {
  overflow-x: auto;
}

.inv-sku {
  font-size: 0.78rem;
  color: var(--fg-soft);
  font-family: monospace;
}

.inv-product-name {
  max-width: 240px;
}

/* ---- STOCK BADGES ---- */
.stock-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: 100px;
  white-space: nowrap;
}

.stock-badge--ok {
  background: #e8f5ee;
  color: #2e7d52;
}

.stock-badge--low {
  background: #fef3e2;
  color: #c86835;
}

.stock-badge--out {
  background: #fcecea;
  color: #c44a3a;
}

/* ---- INVENTORY FILTERS ---- */
.inv-filter-row {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.inv-filter-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--fg-soft);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.3rem 0.75rem;
  border-radius: 100px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.inv-filter-btn:hover {
  background: var(--bg-warm);
  color: var(--fg);
}

.inv-filter-btn--active {
  background: var(--fg);
  color: #f0ece7;
  border-color: var(--fg);
}

/* ---- RESPONSIVE ---- */
@media (max-width: 1024px) {
  .kpi-grid {
    grid-template-columns: 1fr 1fr;
  }

  .dash-two-col {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .dash-sidebar {
    width: 100%;
    min-height: auto;
    position: static;
    flex-direction: row;
    align-items: center;
    padding: 1rem 1.25rem;
    gap: 1.5rem;
  }

  .dash-brand { margin-bottom: 0; }

  .dash-nav {
    flex-direction: row;
    flex: 1;
    gap: 0.25rem;
  }

  .dash-alert-badge { margin-top: 0; }

  .dash-body { flex-direction: column; }

  .dash-main {
    margin-left: 0;
    padding: 1.5rem 1rem;
  }

  .kpi-grid {
    grid-template-columns: 1fr 1fr;
  }

  .kpi-grid--3 {
    grid-template-columns: 1fr 1fr;
  }

  .dash-page-title {
    font-size: 1.6rem;
  }
}

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

  .dash-nav-item a {
    padding: 0.5rem 0.6rem;
    font-size: 0.8rem;
  }
}
