/* === RinglyOS Dashboard — Dark Theme === */
*,*::before,*::after{margin:0;padding:0;box-sizing:border-box}

:root {
  --bg-base: #08080c;
  --bg-surface: #0f0f16;
  --bg-card: #151520;
  --bg-card-hover: #1a1a28;
  --bg-input: #12121c;
  --border: rgba(255,255,255,0.06);
  --border-hover: rgba(255,255,255,0.12);
  --text-primary: #eeeef2;
  --text-secondary: #8b8ba0;
  --text-muted: #55556a;
  --accent: #10b981;
  --accent-bg: rgba(16,185,129,0.08);
  --green: #10b981;
  --teal: #14b8a6;
  --amber: #f59e0b;
  --purple: #8b5cf6;
  --rose: #f43f5e;
  --red: #ef4444;
  --blue: #3b82f6;
  --sidebar-w: 220px;
  --radius: 12px;
  --radius-sm: 8px;
}

html { font-size: 15px; }
body {
  font-family: 'Space Grotesk', sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  min-height: 100vh;
}

/* === SIDEBAR === */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.25s ease;
}
.sidebar-header {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-icon { color: var(--accent); display: flex; }
.logo-text {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.5px;
}
.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
  position: relative;
}
.nav-item:hover { background: rgba(255,255,255,0.04); color: var(--text-primary); }
.nav-item.active {
  background: var(--accent-bg);
  color: var(--accent);
}
.nav-item.active svg { color: var(--accent); }
.alert-badge {
  position: absolute;
  right: 10px;
  background: var(--rose);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
}
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}
.agent-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
.agent-dot {
  width: 8px; height: 8px;
  background: var(--green);
  border-radius: 50%;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%,100% { opacity: 1; box-shadow: 0 0 0 0 rgba(16,185,129,0.4); }
  50% { opacity: 0.7; box-shadow: 0 0 0 6px rgba(16,185,129,0); }
}

/* === MOBILE HEADER === */
.mobile-header {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  z-index: 90;
}
.menu-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 4px;
}

/* === MAIN CONTENT === */
.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  padding: 32px 36px;
}

/* === VIEWS === */
.view { display: none; }
.view.active { display: block; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.view-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 28px;
}
.view-header h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.8px;
}
.subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}
.btn-refresh {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-refresh:hover { border-color: var(--border-hover); color: var(--text-primary); }

/* === KPI GRID === */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s;
}
.kpi-card:hover { border-color: var(--border-hover); }
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--text-muted);
  opacity: 0.3;
}
.kpi-card.accent-green::before { background: var(--green); opacity: 1; }
.kpi-card.accent-teal::before { background: var(--teal); opacity: 1; }
.kpi-card.accent-amber::before { background: var(--amber); opacity: 1; }
.kpi-card.accent-purple::before { background: var(--purple); opacity: 1; }
.kpi-card.accent-rose::before { background: var(--rose); opacity: 1; }
.kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 500;
}
.kpi-value {
  font-family: 'Space Mono', monospace;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -1px;
  line-height: 1.1;
}
.kpi-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}
.kpi-change {
  font-size: 12px;
  margin-top: 6px;
  font-weight: 600;
}
.kpi-change.up { color: var(--green); }
.kpi-change.down { color: var(--red); }

/* === CHARTS === */
.charts-row {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 14px;
  margin-bottom: 24px;
}
.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.chart-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}
.chart-legend {
  display: flex;
  gap: 14px;
  font-size: 11px;
  color: var(--text-muted);
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}
.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  display: inline-block;
}
.chart-body { position: relative; }
.donut-wrapper { position: relative; display: flex; align-items: center; justify-content: center; }
.donut-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -55%);
  text-align: center;
  font-family: 'Space Mono', monospace;
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
}
.breakdown-legend {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 12px;
  font-size: 11px;
  color: var(--text-muted);
}

/* === SECTION CARD === */
.section-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.section-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}
.link-btn {
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
.link-btn:hover { text-decoration: underline; }

/* === ALERT LIST === */
.alert-list { display: flex; flex-direction: column; gap: 8px; }
.alert-row {
  display: grid;
  grid-template-columns: 1fr 100px 100px 100px 120px;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.alert-row:hover { border-color: var(--border-hover); }
.alert-store-name { font-weight: 600; color: var(--text-primary); }
.alert-metric { color: var(--text-secondary); text-align: right; }
.alert-metric.bad { color: var(--red); font-weight: 600; }
.alert-metric.warn { color: var(--amber); font-weight: 600; }
.alert-type-badge {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 100px;
  font-weight: 600;
  text-align: center;
}
.alert-type-badge.low_resolution { background: rgba(239,68,68,0.12); color: var(--red); }
.alert-type-badge.high_handle_time { background: rgba(245,158,11,0.12); color: var(--amber); }
.alert-type-badge.low_sentiment { background: rgba(244,63,94,0.12); color: var(--rose); }
.alert-type-badge.high_escalation { background: rgba(139,92,246,0.12); color: var(--purple); }
.alert-type-badge.warning { background: rgba(245,158,11,0.12); color: var(--amber); }

/* === FILTER BAR === */
.filter-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.search-wrapper {
  flex: 1;
  min-width: 200px;
  position: relative;
}
.search-wrapper svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}
.search-wrapper input {
  width: 100%;
  padding: 10px 12px 10px 36px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}
.search-wrapper input:focus { border-color: var(--accent); }
.search-wrapper input::placeholder { color: var(--text-muted); }
select {
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2355556a' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
select:hover { border-color: var(--border-hover); }

/* === STORES GRID === */
.stores-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}
.store-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}
.store-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.store-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
}
.store-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.3px;
}
.store-domain {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.plan-badge {
  font-size: 10px;
  padding: 3px 10px;
  border-radius: 100px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.plan-badge.starter { background: rgba(139,92,246,0.12); color: var(--purple); }
.plan-badge.growth { background: rgba(16,185,129,0.12); color: var(--green); }
.plan-badge.pro { background: rgba(245,158,11,0.12); color: var(--amber); }
.store-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.store-metric {
  text-align: center;
  padding: 10px 4px;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
}
.store-metric-value {
  font-family: 'Space Mono', monospace;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.store-metric-value.good { color: var(--green); }
.store-metric-value.warn { color: var(--amber); }
.store-metric-value.bad { color: var(--red); }
.store-metric-label {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.store-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}
.store-revenue {
  font-family: 'Space Mono', monospace;
  font-weight: 700;
  color: var(--text-secondary);
}

/* === ALERTS FULL VIEW === */
.alerts-full { display: flex; flex-direction: column; gap: 10px; }

/* === MODAL === */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 780px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  animation: modalIn 0.2s ease;
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }
.modal-close {
  position: absolute;
  top: 16px; right: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  z-index: 10;
  transition: all 0.15s;
}
.modal-close:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.modal-body { padding: 28px; }

/* Modal content styles */
.modal-store-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
}
.modal-store-name {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.modal-store-domain {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}
.modal-kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.modal-kpi {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
}
.modal-kpi-value {
  font-family: 'Space Mono', monospace;
  font-size: 20px;
  font-weight: 700;
}
.modal-kpi-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}
.modal-chart-section {
  margin-bottom: 20px;
}
.modal-chart-section h4 {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  font-weight: 600;
}
.modal-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}
.category-tag {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 6px 14px;
  font-size: 12px;
  color: var(--text-secondary);
}
.category-tag strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* === LOADING === */
.loading-placeholder {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 13px;
}

/* === NO DATA STATE === */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  font-size: 14px;
}
.empty-state svg { margin-bottom: 12px; opacity: 0.3; }

/* === GROWTH DASHBOARD === */
.growth-kpi-grid {
  grid-template-columns: 2fr 1fr 1fr 1fr;
}
.kpi-card-wide .kpi-value {
  font-size: 34px;
}

/* Tier Breakdown */
.tier-breakdown {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
.tier-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color 0.2s;
}
.tier-card:hover { border-color: var(--border-hover); }
.tier-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.tier-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}
.tier-name {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.3px;
}
.tier-price {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-surface);
  padding: 2px 8px;
  border-radius: 100px;
}
.tier-mrr {
  font-family: 'Space Mono', monospace;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}
.tier-count {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.tier-bar {
  height: 6px;
  background: var(--bg-surface);
  border-radius: 3px;
  overflow: hidden;
}
.tier-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s ease;
}

/* Churn Grid */
.churn-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.churn-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 12px;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  text-align: center;
}
.churn-stat-icon {
  margin-bottom: 10px;
  opacity: 0.9;
}
.churn-stat-value {
  font-family: 'Space Mono', monospace;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -1px;
  line-height: 1.1;
}
.churn-stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 6px;
}

/* Event Feed */
.event-feed {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 280px;
  overflow-y: auto;
}
.event-feed::-webkit-scrollbar { width: 4px; }
.event-feed::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.event-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  font-size: 12px;
}
.event-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.event-dot.signup { background: var(--green); }
.event-dot.churn { background: var(--red); }
.event-dot.upgrade { background: var(--teal); }
.event-dot.downgrade { background: var(--amber); }
.event-text {
  flex: 1;
  color: var(--text-secondary);
  line-height: 1.3;
}
.event-text strong {
  color: var(--text-primary);
  font-weight: 600;
}
.event-date {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* === RESPONSIVE === */
@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .growth-kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-card-wide .kpi-value { font-size: 28px; }
  .charts-row { grid-template-columns: 1fr; }
  .tier-breakdown { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .mobile-header { display: flex; }
  .main-content { margin-left: 0; padding: 72px 16px 24px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-row { grid-template-columns: 1fr; }
  .stores-grid { grid-template-columns: 1fr; }
  .alert-row { grid-template-columns: 1fr 80px 80px; }
  .alert-row > :nth-child(4),
  .alert-row > :nth-child(5) { display: none; }
  .modal-kpi-row { grid-template-columns: repeat(2, 1fr); }
  .filter-bar { flex-direction: column; }
  .search-wrapper { min-width: unset; }
  .growth-kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi-card-wide .kpi-value { font-size: 24px; }
  .tier-breakdown { grid-template-columns: 1fr; }
  .churn-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi-value { font-size: 22px; }
}
