:root {
  --bg: #0b1224;
  --panel: #121b34;
  --panel-2: #16213f;
  --border: #223055;
  --text: #e7ecf7;
  --text-dim: #93a0c2;
  --accent: #3b82f6;
  --accent-2: #7c5cff;
  --accent-rgb: 59, 130, 246;
  --accent-2-rgb: 124, 92, 255;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
}

/* Per-business accent theme - same dark neutral base everywhere, only the
   brand hue changes, so each dashboard feels distinct without breaking the
   universal green=up/red=down chart convention. */
body[data-business="ueno-coffee"] {
  --accent: #c17f3e;
  --accent-2: #e0a458;
  --accent-rgb: 193, 127, 62;
  --accent-2-rgb: 224, 164, 88;
}

body[data-business="nona-laras"] {
  --accent: #9f2b45;
  --accent-2: #c9a227;
  --accent-rgb: 159, 43, 69;
  --accent-2-rgb: 201, 162, 39;
}

body[data-business="lombok-idjo"] {
  --accent: #1f9d63;
  --accent-2: #3fbf8f;
  --accent-rgb: 31, 157, 99;
  --accent-2-rgb: 63, 191, 143;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  flex-shrink: 0;
  background:
    linear-gradient(180deg, rgba(var(--accent-rgb), 0.14), transparent 45%),
    linear-gradient(180deg, #0d1730, #0a1122);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 22px 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
}

.brand-title { font-weight: 700; font-size: 15px; letter-spacing: 0.5px; }
.brand-sub { font-size: 12px; color: var(--text-dim); }

.sidebar-close {
  display: none;
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  align-self: flex-start;
}

.mobile-topbar { display: none; }
.sidebar-toggle {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 16px;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 20, 0.6);
  z-index: 40;
}
.sidebar-overlay.visible { display: block; }

.biz-switcher { display: flex; flex-direction: column; gap: 6px; }

.biz-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 14px;
  position: relative;
}

.biz-item:hover { background: var(--panel-2); color: var(--text); }

.biz-item.active {
  background: linear-gradient(90deg, rgba(var(--accent-rgb), 0.25), rgba(var(--accent-2-rgb), 0.15));
  color: var(--text);
  border: 1px solid var(--border);
}

.biz-item.disabled { opacity: 0.55; }

.biz-icon { font-size: 18px; width: 22px; text-align: center; }
.biz-name { flex: 1; }

.biz-badge {
  font-size: 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 999px;
  color: var(--text-dim);
}

.content { flex: 1; min-width: 0; padding: 24px 28px; max-width: 1500px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.topbar h1 { font-size: 20px; margin: 0; }

.topbar-right { display: flex; align-items: center; gap: 12px; }

.asof { font-size: 13px; color: var(--text-dim); }

.btn-refresh, .btn-settings, .btn-save {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  text-decoration: none;
}

.btn-refresh:hover, .btn-settings:hover { background: var(--accent); border-color: var(--accent); }

.btn-save { background: var(--accent); border-color: var(--accent); }
.btn-save:hover { background: var(--accent-2); border-color: var(--accent-2); }

.kpi-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  min-height: 110px;
}

.kpi-accent { background: linear-gradient(160deg, rgba(var(--accent-rgb), 0.22), var(--panel)); }
.kpi-accent-purple { background: linear-gradient(160deg, rgba(var(--accent-2-rgb), 0.22), var(--panel)); }

.kpi-label { font-size: 12px; color: var(--text-dim); margin-bottom: 8px; }
.kpi-value { font-size: 20px; font-weight: 700; }
.kpi-sub { font-size: 12px; color: var(--text-dim); margin-top: 6px; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 20px;
}

.grid-1 { margin-bottom: 20px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  min-width: 0;
}

.panel-title { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.panel-sub { font-size: 12px; color: var(--text-dim); margin-bottom: 10px; }

.chart-md { min-height: 260px; }
.chart-lg { min-height: 320px; }

.pct-up { color: var(--green); }
.pct-down { color: var(--red); }
.pct-flat { color: var(--text-dim); }

.placeholder-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 60px 24px;
  text-align: center;
  color: var(--text-dim);
}

.placeholder-icon { font-size: 48px; margin-bottom: 12px; }
.placeholder-card h2 { color: var(--text); margin: 6px 0 10px; }

.target-form { display: flex; flex-direction: column; gap: 14px; }
.target-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-dim); }
.target-form input, .target-form select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 14px;
}

.target-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.target-table th, .target-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.target-table th { color: var(--text-dim); font-weight: 500; }

.simple-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px; }
.simple-table th, .simple-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.simple-table th { color: var(--text-dim); font-weight: 500; }
.simple-table th:not(:first-child), .simple-table td:not(:first-child) { text-align: right; }
.simple-table tbody tr:hover { background: var(--panel-2); }

.compare-table td.period-cell {
  font-weight: 400;
  font-size: 12px;
  color: var(--text-dim);
}

.explain-text { font-size: 13px; color: var(--text-dim); line-height: 1.6; margin: 4px 0 10px; }
.explain-list { font-size: 13px; color: var(--text-dim); line-height: 1.7; margin: 0 0 14px; padding-left: 20px; }
.explain-list b, .explain-text b { color: var(--text); }
.explain-dim { color: var(--text-dim); font-size: 12px; }

.quadrant-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.quadrant-chip {
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  border: 1px solid var(--border);
}

.quadrant-chip.stars { background: rgba(34,197,94,0.12); border-color: rgba(34,197,94,0.35); }
.quadrant-chip.plowhorses { background: rgba(245,158,11,0.12); border-color: rgba(245,158,11,0.35); }
.quadrant-chip.puzzles { background: rgba(59,130,246,0.12); border-color: rgba(59,130,246,0.35); }
.quadrant-chip.dogs { background: rgba(239,68,68,0.12); border-color: rgba(239,68,68,0.35); }

.data-quality { color: var(--amber); }

.insights-list { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }

.insight-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
}

.insight-card.tag-positive, .insight-card.tag-good, .insight-card.tag-growth { border-left-color: var(--green); }
.insight-card.tag-action { border-left-color: var(--amber); }
.insight-card.tag-focus { border-left-color: var(--red); }

.insight-icon { font-size: 16px; line-height: 1.5; }
.insight-body { flex: 1; min-width: 0; }
.insight-title { font-size: 13px; font-weight: 600; line-height: 1.4; }
.insight-action { font-size: 12px; color: var(--text-dim); margin-top: 3px; line-height: 1.4; }

.insight-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
  align-self: flex-start;
}

.insight-tag.tag-positive, .insight-tag.tag-good, .insight-tag.tag-growth {
  background: rgba(34, 197, 94, 0.15);
  color: var(--green);
}
.insight-tag.tag-action { background: rgba(245, 158, 11, 0.15); color: var(--amber); }
.insight-tag.tag-focus { background: rgba(239, 68, 68, 0.15); color: var(--red); }

.insight-empty { color: var(--text-dim); font-size: 13px; padding: 8px 0; }

.load-progress-wrap {
  margin-bottom: 18px;
  transition: opacity 0.3s ease, height 0.3s ease;
}

.load-progress-wrap.done { opacity: 0; height: 0; margin: 0; overflow: hidden; pointer-events: none; }

.load-progress-track {
  height: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3);
}

.load-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 999px;
  transition: width 0.35s ease;
  position: relative;
  overflow: hidden;
}

.load-progress-wrap.active .load-progress-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 50%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.45), transparent);
  animation: load-progress-shimmer 1.1s ease-in-out infinite;
}

@keyframes load-progress-shimmer {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(300%); }
}

.load-progress-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 8px;
}

.load-step {
  font-size: 11px;
  color: var(--text-dim);
  position: relative;
  padding-left: 14px;
  transition: color 0.25s ease;
}

.load-step::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.25s ease, box-shadow 0.25s ease;
}

.load-step.done { color: var(--text); }
.load-step.done::before { background: var(--green); box-shadow: 0 0 6px rgba(34, 197, 94, 0.7); }

.load-progress-label {
  display: inline-block;
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 6px;
}

.user-box {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.user-box-info { display: flex; align-items: center; gap: 10px; padding: 6px 8px; }

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: var(--text-dim); }

.user-box-links { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
.user-box-links a {
  font-size: 12px;
  color: var(--text-dim);
  text-decoration: none;
  padding: 6px 8px;
  border-radius: 8px;
}
.user-box-links a:hover { background: var(--panel-2); color: var(--text); }

/* Auth pages (login, change password) */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(59, 130, 246, 0.12), transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(124, 92, 255, 0.12), transparent 40%),
    var(--bg);
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 28px;
}

.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.auth-brand .brand-mark { width: 44px; height: 44px; border-radius: 12px; }
.auth-title { font-size: 17px; font-weight: 700; }
.auth-sub { font-size: 12px; color: var(--text-dim); }

.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-dim); }
.auth-form input {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
}
.auth-form input:focus { outline: none; border-color: var(--accent); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  color: #0b1224;
  font-weight: 700;
  padding: 11px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  margin-top: 4px;
}
.btn-primary:hover { filter: brightness(1.08); }

.auth-alert {
  font-size: 13px;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 16px;
}
.auth-alert.error { background: rgba(239, 68, 68, 0.12); border: 1px solid rgba(239, 68, 68, 0.35); color: var(--red); }
.auth-alert.ok { background: rgba(34, 197, 94, 0.12); border: 1px solid rgba(34, 197, 94, 0.35); color: var(--green); }

.auth-back { display: block; text-align: center; margin-top: 16px; font-size: 12px; color: var(--text-dim); text-decoration: none; }
.auth-back:hover { color: var(--text); }

/* Admin user management */
.user-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.user-table th, .user-table td { text-align: left; padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.user-table th { color: var(--text-dim); font-weight: 500; }
.user-table tbody tr:hover { background: var(--panel-2); }

.badge-admin { font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: rgba(124, 92, 255, 0.15); color: var(--accent-2); }
.badge-inactive { font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: rgba(239, 68, 68, 0.15); color: var(--red); }
.biz-tag-list { display: flex; flex-wrap: wrap; gap: 4px; }
.biz-tag { font-size: 10px; padding: 2px 7px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--border); color: var(--text-dim); }

.checkbox-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.checkbox-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}
.checkbox-chip input { accent-color: var(--accent); }

.row-actions { display: flex; gap: 8px; }
.row-actions a, .row-actions button {
  font-size: 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
}
.row-actions a:hover { background: var(--accent); border-color: var(--accent); }
.row-actions button.btn-danger:hover { background: var(--red); border-color: var(--red); }

@media (max-width: 1200px) {
  .quadrant-legend { grid-template-columns: 1fr; }
  .kpi-row { grid-template-columns: repeat(3, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}

/* Tablet / narrow desktop: sidebar becomes an off-canvas drawer */
@media (max-width: 900px) {
  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
  }

  .mobile-topbar-title { font-weight: 700; font-size: 15px; }

  .sidebar-close { display: block; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 0 0 24px rgba(0, 0, 0, 0.4);
  }

  .sidebar.open { transform: translateX(0); }

  .content { padding: 16px; max-width: none; }

  .kpi-row { grid-template-columns: repeat(2, 1fr); }

  .topbar {
    flex-wrap: wrap;
    gap: 10px;
  }

  .topbar-right { flex-wrap: wrap; gap: 8px; }
}

/* Phone-width screens */
@media (max-width: 560px) {
  .content { padding: 12px; }

  .kpi-row { grid-template-columns: 1fr; }

  .topbar h1 { font-size: 17px; }
  .topbar-right { width: 100%; }
  .asof { width: 100%; }

  .panel { padding: 14px; }

  .quadrant-legend { grid-template-columns: 1fr; }

  .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-scroll table { min-width: 480px; }
}
