/* Daystar Merchandising — design tokens */
:root {
  --font-sans: 'Geist', -apple-system, system-ui, sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, monospace;

  /* light */
  --bg: oklch(0.99 0.003 80);
  --bg-subtle: oklch(0.975 0.004 80);
  --surface: #ffffff;
  --surface-2: oklch(0.98 0.004 80);
  --border: oklch(0.92 0.005 80);
  --border-strong: oklch(0.86 0.006 80);
  --text: oklch(0.18 0.01 60);
  --text-muted: oklch(0.50 0.008 60);
  --text-dim: oklch(0.65 0.006 60);

  --accent: #f97316;
  --accent-hover: #ea580c;
  --accent-soft: oklch(0.96 0.04 60);
  --accent-text: #c2410c;

  --success: #10b981;
  --success-soft: oklch(0.95 0.05 160);
  --warn: #f59e0b;
  --warn-soft: oklch(0.96 0.06 90);
  --danger: #ef4444;
  --danger-soft: oklch(0.96 0.04 25);
  --info: #3b82f6;
  --info-soft: oklch(0.96 0.03 240);

  --shadow-xs: 0 1px 2px rgba(15, 15, 15, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 15, 15, 0.05), 0 1px 2px rgba(15, 15, 15, 0.04);
  --shadow-md: 0 4px 12px -2px rgba(15, 15, 15, 0.06), 0 2px 4px rgba(15, 15, 15, 0.04);
  --shadow-lg: 0 12px 32px -8px rgba(15, 15, 15, 0.10), 0 4px 8px rgba(15, 15, 15, 0.04);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;

  /* density (comfortable default) */
  --row-h: 48px;
  --pad-card: 20px;
  --pad-cell: 14px 16px;
  --gap: 16px;
  --text-size: 14px;
}

[data-density="compact"] {
  --row-h: 36px;
  --pad-card: 14px;
  --pad-cell: 8px 12px;
  --gap: 10px;
  --text-size: 13px;
}

[data-theme="dark"] {
  --bg: oklch(0.16 0.005 60);
  --bg-subtle: oklch(0.18 0.005 60);
  --surface: oklch(0.20 0.006 60);
  --surface-2: oklch(0.22 0.006 60);
  --border: oklch(0.27 0.008 60);
  --border-strong: oklch(0.34 0.008 60);
  --text: oklch(0.96 0.005 80);
  --text-muted: oklch(0.68 0.008 60);
  --text-dim: oklch(0.50 0.008 60);

  --accent-soft: oklch(0.30 0.06 60);
  --accent-text: #fb923c;

  --success-soft: oklch(0.28 0.06 160);
  --warn-soft: oklch(0.30 0.07 90);
  --danger-soft: oklch(0.30 0.06 25);
  --info-soft: oklch(0.28 0.05 240);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 32px -8px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-size);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss01';
  letter-spacing: -0.005em;
}

#root { min-height: 100vh; }

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

::selection { background: var(--accent); color: white; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 14px;
  height: 36px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
  letter-spacing: -0.005em;
}
.btn-primary {
  background: linear-gradient(180deg, #fb923c 0%, var(--accent) 100%);
  color: white;
  box-shadow: 0 1px 0 rgba(255,255,255,0.2) inset, var(--shadow-sm);
}
.btn-primary:hover { background: linear-gradient(180deg, var(--accent) 0%, var(--accent-hover) 100%); }
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--bg-subtle); color: var(--text); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; }
.btn-lg { height: 42px; padding: 0 18px; font-size: 14px; }
.btn-block { width: 100%; }

/* Inputs */
.input, .select {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus, .select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input::placeholder { color: var(--text-dim); }

.label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}

.field { margin-bottom: 14px; }
.help { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
}
.card-pad { padding: var(--pad-card); }
.card-header {
  padding: 16px var(--pad-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font-mono);
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.badge-success { background: var(--success-soft); color: #047857; }
[data-theme="dark"] .badge-success { color: #34d399; }
.badge-warn { background: var(--warn-soft); color: #b45309; }
[data-theme="dark"] .badge-warn { color: #fbbf24; }
.badge-danger { background: var(--danger-soft); color: #b91c1c; }
[data-theme="dark"] .badge-danger { color: #f87171; }
.badge-info { background: var(--info-soft); color: #1d4ed8; }
[data-theme="dark"] .badge-info { color: #60a5fa; }
.badge-neutral { background: var(--bg-subtle); color: var(--text-muted); border: 1px solid var(--border); }

/* Mono numbers */
.mono { font-family: var(--font-mono); font-feature-settings: 'tnum'; }

/* Table */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table thead th {
  text-align: left;
  padding: var(--pad-cell);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table tbody td {
  padding: var(--pad-cell);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.table tbody tr { transition: background 0.1s; }
.table tbody tr:hover { background: var(--bg-subtle); cursor: pointer; }
.table tbody tr:last-child td { border-bottom: none; }

/* Sidebar */
.sidebar {
  width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
  position: sticky;
  top: 0;
}
.sidebar-brand {
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}
.sidebar-nav {
  padding: 12px 10px;
  flex: 1;
  overflow-y: auto;
}
.sidebar-section {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 14px 12px 8px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}
.nav-item:hover { background: var(--bg-subtle); color: var(--text); }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-text);
}
.nav-item.active svg { color: var(--accent); }

/* Topbar */
.topbar {
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(8px);
}

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

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.page {
  padding: 28px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* Avatar */
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: linear-gradient(135deg, #fb923c, #f97316);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-mono);
  flex-shrink: 0;
}
.avatar-lg { width: 64px; height: 64px; font-size: 22px; }
.avatar-sm { width: 24px; height: 24px; font-size: 10px; }

/* Image placeholder */
.placeholder-img {
  background:
    repeating-linear-gradient(
      45deg,
      var(--bg-subtle) 0px,
      var(--bg-subtle) 8px,
      var(--surface-2) 8px,
      var(--surface-2) 16px
    );
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 11px;
  text-align: center;
  padding: 8px;
}

/* Search */
.search {
  position: relative;
  display: flex;
  align-items: center;
}
.search input {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 36px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.search input:focus { border-color: var(--accent); background: var(--surface); }
.search svg {
  position: absolute;
  left: 12px;
  color: var(--text-dim);
  pointer-events: none;
}
.search kbd {
  position: absolute;
  right: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--text-muted);
}

/* Auth pages */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at top right, oklch(0.96 0.04 60) 0%, transparent 60%),
    radial-gradient(ellipse at bottom left, oklch(0.97 0.02 240) 0%, transparent 60%),
    var(--bg);
}
[data-theme="dark"] .auth-shell {
  background:
    radial-gradient(ellipse at top right, oklch(0.25 0.06 60) 0%, transparent 60%),
    radial-gradient(ellipse at bottom left, oklch(0.22 0.04 240) 0%, transparent 60%),
    var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 36px;
}

/* KPI tile */
.kpi-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--pad-card);
  position: relative;
  overflow: hidden;
}
.kpi-tile::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, var(--surface-2) 0%, transparent 50%);
  pointer-events: none;
  opacity: 0.6;
}
.kpi-tile > * { position: relative; }
.kpi-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}
.kpi-value {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 8px 0 4px;
  font-family: var(--font-mono);
  font-feature-settings: 'tnum';
}
.kpi-delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-mono);
}
.kpi-delta.up { color: #047857; }
.kpi-delta.down { color: #b91c1c; }
[data-theme="dark"] .kpi-delta.up { color: #34d399; }
[data-theme="dark"] .kpi-delta.down { color: #f87171; }

/* Progress bar */
.bar {
  height: 6px;
  background: var(--bg-subtle);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
}
.tab {
  padding: 10px 14px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent-text); border-bottom-color: var(--accent); }

/* Segment */
.segment {
  display: inline-flex;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}
.segment button {
  padding: 5px 10px;
  border-radius: 6px;
  background: transparent;
  border: none;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  font-family: var(--font-mono);
}
.segment button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 5px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn 0.25s ease; }

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* Checkbox */
.checkbox {
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--border-strong);
  border-radius: 4px;
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.12s;
}
.checkbox.checked {
  background: var(--accent);
  border-color: var(--accent);
}
.checkbox.checked svg { color: white; }

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}
