/*
 * The DailyPlus admin dashboard, in the app's design system "Bahi"
 * (docs/DESIGN-SYSTEM.md, src/theme/tokens.ts; the same tokens as the
 * website): Manrope; ink on a lilac ground; white cards with 24px corners and
 * one soft ink shadow; a full-bleed violet band; white text only on violet;
 * no state told by colour alone.
 */

@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url('/fonts/manrope-latin-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+20B9, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url('/fonts/manrope-latin-ext-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+20A0-20AB, U+20AD-20C0;
}

:root {
  --ink: #15112e;
  --violet: #6a4cff;
  --violet-deep: #4a2fe0;
  --ground: #f4f0ff;
  --white: #ffffff;
  --muted: #5e5880;
  --placeholder: #6e6890;
  --soft: #f1edfc;
  --lilac: #ece8fa;
  --ring: #ddd6f3;
  --tab-pill: #eee9ff;
  --lime-soft: #e9f9b8;
  --error-fill: #ffe1e5;
  --late: #d0254f;
  --orange: #ff7a1a;
  --orange-soft: #ffe6d2;
  --orange-ink: #8a3a00;
  --sky-soft: #ddf3ff;
  --teal-soft: #ccf3ec;
  --teal-ink: #0b5e55;
  --shadow-card: 0 14px 28px -18px rgba(21, 17, 46, 0.45);
  --shadow-chip: 0 8px 18px -14px rgba(21, 17, 46, 0.5);
  --r-card: 24px;
  --r-field: 16px;
  --r-icon: 14px;
  --gutter: 16px;
  --gap: 12px;
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 600 15px/1.4 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

h1,
h2,
p {
  margin: 0;
}

a {
  color: var(--violet-deep);
}

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

.booting {
  padding: 40px var(--gutter);
  color: var(--muted);
}

.skip {
  position: absolute;
  left: -999px;
  top: 8px;
  z-index: 10;
  background: var(--white);
  color: var(--ink);
  padding: 10px 14px;
  border-radius: var(--r-icon);
}
.skip:focus {
  left: 8px;
}

/* ── The band ─────────────────────────────────────────────────────────────── */

.band {
  background: var(--violet);
  color: var(--white);
  padding: 14px var(--gutter) 0;
}
.band-inner,
.page,
.foot {
  max-width: 1200px;
  margin: 0 auto;
}
.band-top {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}
.logo {
  border-radius: 11px;
  box-shadow: var(--shadow-chip);
}
.caps {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.spacer {
  flex: 1;
}
.who {
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 34vw;
}
.band h1 {
  margin-top: 14px;
  font-size: 34px;
  line-height: 1.05;
  font-weight: 800;
  letter-spacing: -0.045em;
}
.band-line {
  margin-top: 6px;
  font-size: 15px;
  font-weight: 700;
}
.fresh {
  white-space: nowrap;
}
.band-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  margin-top: 16px;
  padding-bottom: 14px;
}

/* Tabs: white words on the band; the chosen one a white pill in ink. */
.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 calc(-1 * var(--gutter));
  padding: 2px var(--gutter);
  max-width: calc(100% + 2 * var(--gutter));
}
.tabs::-webkit-scrollbar {
  display: none;
}
.tab {
  flex: none;
  color: var(--white);
  text-decoration: none;
  font-weight: 800;
  font-size: 15px;
  padding: 10px 16px;
  border-radius: 999px;
  /* Tinted with ink, not white: a lighter violet would take white text below
     4.5:1, and white is the only text the band may carry. */
  background: rgba(21, 17, 46, 0.16);
}
.tab:hover {
  background: rgba(21, 17, 46, 0.28);
}
.tab[aria-current='page'] {
  background: var(--white);
  color: var(--ink);
  box-shadow: var(--shadow-chip);
}

/* The period: a segmented chip. */
.range {
  display: flex;
  background: rgba(21, 17, 46, 0.22);
  border-radius: 999px;
  padding: 3px;
}
.range-btn {
  border: 0;
  background: transparent;
  color: var(--white);
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  min-height: 36px;
}
.range-btn[aria-pressed='true'] {
  background: var(--white);
  color: var(--ink);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 20px;
  background: var(--ink);
  color: var(--white);
  font: inherit;
  font-weight: 800;
  font-size: 14px;
  padding: 10px 16px;
  min-height: 44px;
  cursor: pointer;
}
.btn:disabled {
  opacity: 0.5;
  cursor: default;
}
.btn-on-band {
  background: rgba(21, 17, 46, 0.22);
  min-height: 40px;
  padding: 8px 14px;
}
.btn-on-band:hover {
  background: rgba(21, 17, 46, 0.34);
}
.btn-quiet {
  background: var(--tab-pill);
  color: var(--violet-deep);
}

/* ── Content ──────────────────────────────────────────────────────────────── */

.main {
  padding: 16px var(--gutter) 24px;
}
.main:focus {
  outline: none;
}
.page {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 176px), 1fr));
  gap: var(--gap);
  grid-column: 1 / -1;
}

.tile {
  background: var(--white);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  padding: 16px 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
/* Two lines kept for every tile's label, so the numbers in a row line up. */
.tile .label {
  min-height: 2.5em;
  line-height: 1.25;
}
.tile-value {
  font-size: 30px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.04em;
  overflow-wrap: anywhere;
}
.tile-spark {
  margin-top: 4px;
  height: 34px;
}

/* The change since last week: symbol, sign and colour, never colour alone. */
.delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  align-self: flex-start;
  font-size: 12px;
  font-weight: 700;
  border-radius: 999px;
  padding: 3px 8px 3px 6px;
  color: var(--ink);
}
.delta b {
  font-weight: 800;
}
.delta-up {
  background: var(--lime-soft);
}
.delta-down {
  background: var(--error-fill);
  color: #8f1735;
}
.delta-flat,
.delta-none {
  background: var(--soft);
  color: var(--muted);
  padding-left: 8px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--gap);
}

.card {
  background: var(--white);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  padding: 18px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.span-12 { grid-column: span 12; }
.span-8 { grid-column: span 8; }
.span-7 { grid-column: span 7; }
.span-6 { grid-column: span 6; }
.span-5 { grid-column: span 5; }
.span-4 { grid-column: span 4; }

.card-head h2 {
  font-size: 17px;
  line-height: 1.25;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.card-line {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}
.card-foot {
  margin-top: auto;
  padding-top: 4px;
}
.card-foot a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 800;
  font-size: 14px;
  text-decoration: none;
  min-height: 44px;
}
.more {
  align-self: flex-start;
}
.card-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: -6px;
}

/* ── Charts ───────────────────────────────────────────────────────────────── */

.chart-host {
  position: relative;
  width: 100%;
  min-width: 0;
}
.chart {
  border-radius: 12px;
}
.chart svg {
  display: block;
  touch-action: pan-y;
}
.axis {
  fill: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.chart-empty {
  color: var(--muted);
  font-size: 14px;
  padding: 18px 0;
}
.tip {
  position: absolute;
  z-index: 3;
  pointer-events: none;
  background: var(--ink);
  color: var(--white);
  border-radius: 12px;
  padding: 8px 10px;
  font-size: 12px;
  min-width: 150px;
  box-shadow: var(--shadow-card);
}
.tip-title {
  font-weight: 800;
  margin-bottom: 4px;
}
.tip-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.tip-row b {
  margin-left: auto;
  padding-left: 12px;
}
.tip-dot,
.dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex: none;
}

.legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
}
.legend li {
  display: flex;
  align-items: center;
  gap: 8px;
}
.legend b {
  margin-left: auto;
  font-weight: 800;
}
.legend-row {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 6px 16px;
  color: var(--muted);
  font-weight: 700;
}

.bars {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.bar-row {
  display: grid;
  grid-template-columns: minmax(90px, 38%) 1fr auto;
  align-items: center;
  gap: 4px 10px;
  font-size: 13px;
}
.bar-label {
  font-weight: 700;
  overflow-wrap: anywhere;
}
.bar-value {
  font-weight: 800;
  text-align: right;
  min-width: 3.5em;
}
.bar-note {
  grid-column: 2 / -1;
  color: var(--muted);
  font-size: 12px;
  margin-top: -4px;
}
.bar-track {
  height: 12px;
  border-radius: 999px;
  background: var(--soft);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--violet);
  min-width: 0;
}

.donut {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.donut svg {
  flex: none;
}
.donut .legend {
  flex: 1;
  min-width: 160px;
}
.donut-total {
  fill: var(--ink);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

/* ── Insights, checks, funnel, features ──────────────────────────────────── */

.insights,
.checks {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.insight {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 12px;
  border-radius: 18px;
  background: var(--soft);
}
.insight-icon {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  display: grid;
  place-items: center;
}
.insight-problem .insight-icon { background: var(--error-fill); color: var(--late); }
.insight-watch .insight-icon { background: var(--orange-soft); color: var(--orange-ink); }
.insight-idea .insight-icon { background: var(--sky-soft); color: var(--violet-deep); }
.insight-good .insight-icon { background: var(--lime-soft); color: var(--ink); }
.insight-body strong {
  display: block;
  font-weight: 800;
  font-size: 15px;
  line-height: 1.3;
}
.insight-body p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}
.insight-link {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
  padding: 6px 4px;
  min-height: 32px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 800;
  border-radius: 999px;
  padding: 4px 10px 4px 7px;
  flex: none;
}
.pill-ok { background: var(--teal-soft); color: var(--teal-ink); }
.pill-watch { background: var(--orange-soft); color: var(--orange-ink); }
.pill-problem { background: var(--error-fill); color: #8f1735; }

.checks-compact li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 14px;
}
.checks-compact .pill {
  min-width: 92px;
}
.check {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px;
  border-radius: 18px;
  background: var(--soft);
}
.check .pill {
  min-width: 92px;
  margin-top: 1px;
}
.check strong {
  font-weight: 800;
}
.check p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}
.check-problem { background: var(--error-fill); }
.check-problem p, .check-watch p { color: var(--ink); }
.check-watch { background: var(--orange-soft); }

.funnel {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.funnel-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.funnel-step {
  width: 26px;
  height: 26px;
  border-radius: 9px;
  background: var(--tab-pill);
  color: var(--violet-deep);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 800;
  flex: none;
}
.funnel-top strong {
  font-weight: 800;
}
.funnel-n {
  margin-left: auto;
  font-weight: 800;
}
.funnel-pct {
  min-width: 4em;
  text-align: right;
  color: var(--muted);
  font-weight: 800;
}
.funnel .bar-track {
  height: 14px;
}
.funnel-hint {
  margin-top: 5px;
  font-size: 12px;
  color: var(--muted);
}

.features {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: 16px 24px;
}
.feature-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.feature-top strong {
  font-weight: 800;
}
.feature p {
  margin-top: 5px;
  font-size: 12px;
  color: var(--muted);
}

/* ── Tables ───────────────────────────────────────────────────────────────── */

.table-wrap {
  overflow-x: auto;
  margin: 0 -18px;
  padding: 0 18px;
  /* Scroll shadows: a soft edge appears on the side there is more to see,
     and only while there is (the white covers it once scrolled to the end). */
  background:
    linear-gradient(to right, var(--white) 30%, rgba(255, 255, 255, 0)) left / 40px 100% no-repeat local,
    linear-gradient(to left, var(--white) 30%, rgba(255, 255, 255, 0)) right / 40px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgba(21, 17, 46, 0.16), transparent) left / 14px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, rgba(21, 17, 46, 0.16), transparent) right / 14px 100% no-repeat scroll;
}
.card-tall .table-wrap {
  max-height: 520px;
  overflow-y: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th {
  text-align: left;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0 10px 10px 0;
  white-space: nowrap;
  position: sticky;
  top: 0;
  background: var(--white);
}
td {
  padding: 11px 10px 11px 0;
  border-top: 1px solid var(--soft);
  white-space: nowrap;
}
.num {
  text-align: right;
}
.heat {
  display: inline-block;
  min-width: 58px;
  padding: 4px 8px;
  border-radius: 8px;
  text-align: right;
  font-weight: 800;
  background: color-mix(in srgb, var(--violet) calc(var(--heat) * 55%), var(--white));
  color: var(--ink);
}
.heat-none {
  background: transparent;
  color: var(--placeholder);
  text-align: center;
}

/* ── States ───────────────────────────────────────────────────────────────── */

.skeleton {
  min-height: 112px;
  background: linear-gradient(90deg, var(--white) 0%, var(--soft) 50%, var(--white) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}
.skeleton-card {
  min-height: 260px;
}
@keyframes shimmer {
  to { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
}
.error-card h2 {
  font-size: 20px;
  font-weight: 800;
}
.error-card .btn {
  align-self: flex-start;
}

.foot {
  padding: 4px var(--gutter) 32px;
  color: var(--muted);
  font-size: 12px;
}

/* ── Sign-in ──────────────────────────────────────────────────────────────── */

.signin {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px var(--gutter);
}
.signin-card {
  background: var(--white);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  padding: 32px;
  width: min(100%, 400px);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
}
.logo-lg {
  border-radius: 18px;
  box-shadow: var(--shadow-chip);
  margin-bottom: 8px;
}
.caps-ink {
  color: var(--muted);
}
.signin h1 {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: 1.05;
}
.signin-line {
  color: var(--muted);
}
.signin-google {
  margin-top: 10px;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.signin-local:empty {
  display: none;
}
.signin-status {
  font-size: 14px;
  color: var(--late);
}
.signin-status:empty {
  display: none;
}

/* ── Smaller screens ──────────────────────────────────────────────────────── */

@media (max-width: 1000px) {
  .span-8, .span-7, .span-6, .span-5, .span-4 { grid-column: span 12; }
}
@media (min-width: 680px) and (max-width: 1000px) {
  .span-6, .span-5, .span-4 { grid-column: span 6; }
  /* A narrow card whose desktop partner is wide would sit alone at half width,
     beside a hole: it takes the row, as its partner already does. So does the
     third of three. */
  .span-7 + .span-5, .span-8 + .span-4, .span-4 + .span-4 + .span-4 { grid-column: span 12; }
}
@media (min-width: 521px) and (max-width: 1000px) {
  /* Headline tiles in even rows: six as 3 + 3, four as 2 + 2, never 4 + 2. */
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tiles:not(:has(> :nth-child(5))) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 760px) {
  :root { --gutter: 24px; --gap: 16px; }
  .band h1 { font-size: 44px; }
  .card { padding: 20px 22px; }
  .table-wrap { margin: 0 -22px; padding: 0 22px; }
}
@media (max-width: 520px) {
  .who { display: none; }
  .band h1 { font-size: 30px; }
  /* All five tabs in view, on two rows if they must: a row that scrolls
     sideways hides the last tab behind the edge. */
  .tabs { flex-wrap: wrap; overflow-x: visible; margin: 0; padding: 2px 0; max-width: none; }
  .tab { flex: 1 1 auto; text-align: center; font-size: 14px; padding: 9px 12px; }
  .band-controls { flex-direction: column; align-items: stretch; }
  .range { justify-content: space-between; }
  .range-btn { flex: 1; padding: 8px 6px; }
  /* Two headline tiles a row: the page's first screen holds all six. */
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile { padding: 14px 14px 12px; }
  .tile-value { font-size: 24px; }
  .delta { font-size: 11.5px; padding: 3px 7px 3px 5px; }
  .insight { grid-template-columns: auto 1fr; }
  .insight-link { grid-column: 2; padding-left: 0; }
}
