/* Dana's Digitals Studio: neutral graphite, follows the device's light or dark setting.
   Chart colors are the validated categorical palette, used in fixed order. */

:root {
  color-scheme: light dark;
  --bg: #f3f3f1;
  --surface: #fcfcfb;
  --raised: #f0efec;
  --line: #e1e0da;
  --text: #1a1a19;
  --text-2: #52514e;
  --muted: #6f6e68;
  --focus: #2a78d6;
  --good: #0f7a4f;
  --warn: #8a5a00;
  --bad: #b3322f;

  --s1: #2a78d6; /* Instagram / main series */
  --s2: #eb6834; /* Facebook */
  --s3: #1baf7a; /* Website */
  --s4: #eda100; /* Email */
  --s5: #e87ba4; /* Referral */
  --s-none: #8f8e86;

  --radius: 10px;
  --font: ui-sans-serif, system-ui, -apple-system, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0f0e;
    --surface: #1a1a19;
    --raised: #232321;
    --line: #2f2e2b;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #94938b;
    --focus: #6da7ec;
    --good: #4cc38a;
    --warn: #e0a93b;
    --bad: #ee7b79;

    --s1: #3987e5;
    --s2: #d95926;
    --s3: #199e70;
    --s4: #c98500;
    --s5: #d55181;
    --s-none: #6f6e68;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }

a { color: inherit; }

button { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

.skip {
  position: absolute;
  left: -999px;
  top: 8px;
  background: var(--surface);
  padding: 8px 12px;
  border-radius: 6px;
  z-index: 10;
}
.skip:focus { left: 8px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.right { text-align: right; }

/* Layout */

.app {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  min-height: 100vh;
}

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 20px 12px;
  border-right: 1px solid var(--line);
  background: var(--surface);
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 20px;
}
.brand strong { display: block; font-size: 15px; letter-spacing: -0.01em; }
.brand span { display: block; font-size: 12px; color: var(--muted); }
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand-mark circle:first-child { fill: var(--s1); }
.brand-mark circle:last-child { fill: var(--surface); }

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav-group {
  margin: 18px 10px 6px;
  font-size: 12px;
  color: var(--muted);
}

.nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-2);
}
.nav a:hover { background: var(--raised); }
.nav a[aria-current="page"] {
  background: var(--raised);
  color: var(--text);
  font-weight: 600;
}
.nav svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.nav .tag {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 7px;
}

.content { min-width: 0; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar h1 { font-size: 20px; font-weight: 600; letter-spacing: -0.015em; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

main { padding: 24px 28px 56px; max-width: 1240px; }
main:focus { outline: none; }

.btn {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  padding: 7px 14px;
  cursor: pointer;
}
.btn:hover { background: var(--raised); }

/* Panels */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.panel-pad { padding: 20px; }
.panel h2 { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 0;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-top: 20px;
}

/* Analytics card (metric tabs + chart) */

.tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
}
.tab {
  text-align: left;
  background: none;
  border: 0;
  border-bottom: 3px solid transparent;
  padding: 18px 20px 14px;
  cursor: pointer;
  margin-bottom: -1px;
}
.tab:hover { background: var(--raised); }
.tab[aria-selected="true"] { border-bottom-color: var(--s1); }
.tab-label { display: block; font-size: 13px; color: var(--text-2); }
.tab-value { display: block; font-size: 28px; font-weight: 600; letter-spacing: -0.025em; line-height: 1.2; margin-top: 4px; }
.tab-sub { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }

.chart-wrap { position: relative; padding: 18px 20px 6px; }
.chart-title { font-size: 13px; color: var(--text-2); margin-bottom: 8px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid line { stroke: var(--line); stroke-width: 1; }
.chart .axis text { fill: var(--muted); font-size: 12px; }
.chart .bar { fill: var(--s1); pointer-events: none; }
.chart .bar-hit { fill: transparent; cursor: default; }
.chart .bar-hit:hover + .bar, .chart .bar-hit:focus + .bar { filter: brightness(1.15); }
.chart .value-label { fill: var(--text); font-size: 12px; font-weight: 600; }
.tip {
  position: absolute;
  pointer-events: none;
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.18);
  transform: translate(-50%, -100%);
  white-space: nowrap;
  z-index: 3;
}
.tip strong { font-weight: 600; }

details.table-view { padding: 0 20px 16px; }
details.table-view summary { cursor: pointer; color: var(--text-2); font-size: 13px; width: max-content; }

/* Tables */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 16px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 13px; font-weight: 500; color: var(--muted); white-space: nowrap; }
td.num, th.num { text-align: right; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
.job-title { font-weight: 500; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 9px;
  white-space: nowrap;
  color: var(--text-2);
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--s-none); }
.badge.good::before { background: var(--good); }
.badge.warn::before { background: var(--warn); }
.badge.bad::before { background: var(--bad); }
.badge.info::before { background: var(--s1); }

/* Controls */

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line);
  background: none;
  border-radius: 999px;
  padding: 5px 13px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-2);
}
.chip[aria-pressed="true"] { background: var(--text); color: var(--surface); border-color: var(--text); }
.search {
  margin-left: auto;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 12px;
  min-width: 200px;
  font: inherit;
}

/* Lists */

.rows { list-style: none; margin: 0; padding: 8px 0; }
.rows li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 20px;
  border-bottom: 1px solid var(--line);
}
.rows li:last-child { border-bottom: 0; }
.rows .main { min-width: 0; }
.rows .main strong { display: block; font-weight: 500; }
.rows .amount { font-weight: 600; white-space: nowrap; }

.hbars { padding: 14px 20px 18px; display: grid; gap: 14px; }
.hbar-top { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; margin-bottom: 5px; }
.hbar-track { height: 10px; background: var(--raised); border-radius: 5px; overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 0 5px 5px 0; }
.hbar-key { display: inline-flex; align-items: center; gap: 8px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* Empty and error states */

.empty { padding: 36px 24px; text-align: center; color: var(--text-2); }
.empty strong { display: block; color: var(--text); font-size: 16px; margin-bottom: 6px; }
.empty p { max-width: 52ch; margin: 0 auto; }

.notice {
  border: 1px solid var(--line);
  border-left: 4px solid var(--warn);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px 20px;
  max-width: 70ch;
}
.notice strong { display: block; margin-bottom: 4px; }
.notice.bad { border-left-color: var(--bad); }

.loading { color: var(--muted); padding: 40px 0; }

/* Phones and small windows */

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .rail {
    position: static;
    height: auto;
    padding: 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .brand { padding-bottom: 10px; }
  .nav { flex-direction: row; overflow-x: auto; gap: 4px; padding-bottom: 2px; }
  .nav-group { display: none; }
  .nav a { flex: none; padding: 8px 12px; }
  .nav .tag { display: none; }
  .topbar { position: static; padding: 14px 16px; }
  main { padding: 16px 16px 40px; }
  .grid-2 { grid-template-columns: 1fr; }
  .tabs { grid-template-columns: 1fr; }
  .tab { padding: 14px 16px; border-bottom: 1px solid var(--line); border-left: 3px solid transparent; margin-bottom: 0; }
  .tab[aria-selected="true"] { border-bottom-color: var(--line); border-left-color: var(--s1); }
  .search { margin-left: 0; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* Totals strip under the analytics card */

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.stats > div { padding: 18px 20px; }
.stats > div + div { border-left: 1px solid var(--line); }
@media (max-width: 860px) {
  .stats { grid-template-columns: 1fr; }
  .stats > div + div { border-left: 0; border-top: 1px solid var(--line); }
}

/* Sign-in */
.login { max-width: 400px; margin: 48px auto 0; padding: 24px; }
.login h2 { margin-bottom: 12px; }
.login-form { display: grid; gap: 10px; }
.login-form label { font-size: 13px; color: var(--text-2); }
.login-form input {
  font: inherit; font-size: 16px; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; width: 100%;
}
.btn.primary { background: var(--focus); border-color: var(--focus); color: #fff; font-weight: 600; }
.btn[disabled] { opacity: .6; cursor: default; }
[hidden] { display: none !important; }

/* Running as an installed phone app */
body { padding-bottom: env(safe-area-inset-bottom); }
@media (display-mode: standalone) { .skip { display: none; } }
