/*
  Aloft founder dashboard (dash.aloftcode.com). The design language of the
  app and aloftcode.com: the same tokens (src/agent-platform/platform.css,
  site/public/styles.css), Geist, white panes on the soft rail color,
  hairlines, quiet shadows, small pill buttons. Light and dark follow the
  system. The only sky is the sunset inside the cloud mark.
*/

@font-face {
  font-family: 'Geist';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/assets/fonts/geist-latin-wght.woff2') format('woff2');
  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+2122, U+2191, U+2193, U+2212, U+2215,
    U+FEFF, U+FFFD;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  color-scheme: light;
  /* App tokens (light). */
  --bg: #ffffff;
  --rail: #edf1f7;
  --side: #f7f8fb;
  --fg: #1b1b1f;
  --surface: #fafafa;
  --soft: #ececef;
  --hover: #f3f3f5;
  --muted: #8a8a91;
  --t2: #5c5c63;
  --t4: #b4b4ba;
  --line: #ededf0;
  --line-2: #e2e2e6;
  --btn-strong-bg: #1b1b1f;
  --btn-strong-fg: #ffffff;
  --btn-strong-hover: #2e2e33;
  --tonal: #ececef;
  --tonal-hover: #e2e2e6;
  --acc: #3b5bdb;
  --ok: #2f8a4f;
  --danger: #c93c47;
  --danger-bg: #fbf1f2;

  /* Chart series. Windows and Mac keep their color everywhere. Checked with
     the dataviz validator (CVD and contrast) on both surfaces. */
  --series-win: #3b5bdb;
  --series-mac: #d97a2b;
  --bar: #6d849c;
  --bar-soft: rgb(109 132 156 / 0.18);
  --track: var(--hover);

  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-full: 999px;

  --shadow-xs: 0 1px 2px rgb(20 22 34 / 0.05);
  --shadow-sm: 0 1px 2px rgb(20 22 34 / 0.04), 0 2px 10px rgb(20 22 34 / 0.05);

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font: 'Geist', 'Geist Variable', 'Segoe UI', system-ui, -apple-system, sans-serif;

  --mark: url('/assets/aloft-cloud.svg');
  --sunset:
    linear-gradient(180deg, transparent 40%, rgb(27 27 31 / 0.06)),
    url('/assets/sky-2.webp') center 40% / cover no-repeat;

  --measure: 1200px;
  --nav-h: 60px;
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #18181a;
  --rail: #1c1d1f;
  --side: #212224;
  --fg: #e6e6e8;
  --surface: #1e1e21;
  --soft: #2a2a2e;
  --hover: #222225;
  --muted: #6e6e74;
  --t2: #a1a1a6;
  --t4: #4a4a50;
  --line: #26262a;
  --line-2: #303035;
  --btn-strong-bg: #4e4e51;
  --btn-strong-fg: #e6e6e8;
  --btn-strong-hover: #59595c;
  --tonal: #2a2a2e;
  --tonal-hover: #333337;
  --acc: #7c9cff;
  --ok: #5fbf7f;
  --danger: #e5727a;
  --danger-bg: #291d1f;
  --series-win: #6d8cf0;
  --series-mac: #c97632;
  --bar: #7f93a8;
  --bar-soft: rgb(127 147 168 / 0.2);
  --track: var(--soft);
  --shadow-xs: 0 1px 2px rgb(0 0 0 / 0.3);
  --shadow-sm: 0 0 0 1px rgb(255 255 255 / 0.04), 0 2px 10px rgb(0 0 0 / 0.3);
  --sunset:
    linear-gradient(180deg, transparent 40%, rgb(230 230 232 / 0.06)),
    url('/assets/sky-2.webp') center 40% / cover no-repeat;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --bg: #18181a;
    --rail: #1c1d1f;
    --side: #212224;
    --fg: #e6e6e8;
    --surface: #1e1e21;
    --soft: #2a2a2e;
    --hover: #222225;
    --muted: #6e6e74;
    --t2: #a1a1a6;
    --t4: #4a4a50;
    --line: #26262a;
    --line-2: #303035;
    --btn-strong-bg: #4e4e51;
    --btn-strong-fg: #e6e6e8;
    --btn-strong-hover: #59595c;
    --tonal: #2a2a2e;
    --tonal-hover: #333337;
    --acc: #7c9cff;
    --ok: #5fbf7f;
    --danger: #e5727a;
    --danger-bg: #291d1f;
    --series-win: #6d8cf0;
    --series-mac: #c97632;
    --bar: #7f93a8;
    --bar-soft: rgb(127 147 168 / 0.2);
    --track: var(--soft);
    --shadow-xs: 0 1px 2px rgb(0 0 0 / 0.3);
    --shadow-sm: 0 0 0 1px rgb(255 255 255 / 0.04), 0 2px 10px rgb(0 0 0 / 0.3);
    --sunset:
      linear-gradient(180deg, transparent 40%, rgb(230 230 232 / 0.06)),
      url('/assets/sky-2.webp') center 40% / cover no-repeat;
  }
}

@media (prefers-contrast: more) {
  :root {
    --line: var(--t2);
    --line-2: var(--t2);
  }
}

html {
  background: var(--bg);
  scroll-padding-top: 84px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  font-feature-settings: 'cv11', 'ss01';
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button,
a,
input {
  font: inherit;
  color: inherit;
}

::selection {
  background: var(--soft);
  color: var(--fg);
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 13px;
}

/* Views */
body.dash[data-view='loading'] .login,
body.dash[data-view='loading'] .dash-nav,
body.dash[data-view='loading'] .board,
body.dash[data-view='login'] .dash-nav,
body.dash[data-view='login'] .board,
body.dash[data-view='board'] .login {
  display: none;
}

body.dash[data-view='board'] {
  padding-top: var(--nav-h);
}

/* ---- The cloud mark, filled with the sunset ---- */

.sky-mark {
  display: inline-block;
  flex: none;
  aspect-ratio: 1866.7 / 1249.1;
  background: var(--sunset);
  -webkit-mask: var(--mark) center / contain no-repeat;
  mask: var(--mark) center / contain no-repeat;
}

/* ---- Buttons: small pills, as in the app ---- */

.btn-nav,
.btn-primary,
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: var(--r-full);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  transition:
    background-color 150ms var(--ease),
    color 150ms var(--ease);
}

.btn-nav,
.nav-actions .btn-ghost {
  height: 34px;
  padding: 0 16px;
  font-size: 13.5px;
}

.btn-primary {
  height: 40px;
  padding: 0 20px;
  font-size: 14px;
}

.btn-nav,
.btn-primary {
  background: var(--btn-strong-bg);
  color: var(--btn-strong-fg);
}

.btn-nav:hover,
.btn-primary:hover {
  background: var(--btn-strong-hover);
}

.btn-ghost {
  background: var(--tonal);
  color: var(--fg);
}

.btn-ghost:hover {
  background: var(--tonal-hover);
}

.btn-primary[disabled] {
  opacity: 0.6;
  cursor: progress;
}

.btn-nav:focus-visible,
.btn-primary:focus-visible,
.btn-ghost:focus-visible,
.nav-links a:focus-visible,
.card-head a:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--acc) 70%, transparent);
  outline-offset: 2px;
}

.pill,
.tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 26px;
  padding: 0 11px;
  border-radius: var(--r-full);
  background: var(--tonal);
  color: var(--t2);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.pill.is-live::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
}

/* ---- Login: the first-run screen, a white pane inside the rail ---- */

.login {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 8px;
  background: var(--rail);
}

.login-pane {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
  padding: 48px 24px 32px;
  border-radius: var(--r-lg);
  background: var(--bg);
  box-shadow: var(--shadow-xs);
}

.login-form {
  display: grid;
  justify-items: start;
  gap: 14px;
  width: 100%;
  max-width: 360px;
}

.login-mark {
  width: 64px;
  margin-bottom: 6px;
}

.login-form h1 {
  margin: 0;
  font-size: 30px;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.login-form > p {
  margin: -8px 0 8px;
  font-size: 15px;
}

.login-foot {
  margin: 0;
}

.field {
  display: grid;
  gap: 6px;
  width: 100%;
}

.field span {
  color: var(--t2);
  font-size: 13px;
  font-weight: 500;
}

.field input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  outline: none;
  background: var(--bg);
  color: var(--fg);
  font-size: 15px;
  transition:
    border-color 150ms var(--ease),
    outline-color 150ms var(--ease);
}

.field input:hover {
  border-color: var(--t4);
}

.field input:focus-visible {
  border-color: color-mix(in srgb, var(--acc) 60%, transparent);
  outline: 3px solid color-mix(in srgb, var(--acc) 16%, transparent);
}

.form-error {
  width: 100%;
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 13.5px;
}

.btn-block {
  width: 100%;
  margin-top: 6px;
}

/* ---- Header: as on aloftcode.com ---- */

.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  height: var(--nav-h);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}

.nav-inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  column-gap: 28px;
  height: 100%;
  padding-inline: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  text-decoration: none;
}

.logo {
  display: block;
  height: 22px;
  width: auto;
}

.logo-dark {
  display: none;
}

:root[data-theme='dark'] .logo-light {
  display: none;
}

:root[data-theme='dark'] .logo-dark {
  display: block;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .logo-light {
    display: none;
  }

  :root:not([data-theme='light']) .logo-dark {
    display: block;
  }
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  color: var(--t2);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  transition: color 150ms var(--ease);
}

.nav-links a:hover {
  color: var(--fg);
}

.nav-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-self: end;
}

/* ---- Board ---- */

.board {
  display: grid;
  gap: 16px;
  width: min(var(--measure), calc(100% - 48px));
  margin: 0 auto;
  padding: 40px 0 56px;
}

.board-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}

.board-head h1 {
  margin: 0;
  font-size: clamp(28px, 3.2vw, 40px);
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 1.1;
}

.board-head p {
  margin: 6px 0 0;
  font-size: 14px;
}

.section {
  display: grid;
  gap: 12px;
  margin-top: 28px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 16px;
}

.section-title {
  margin: 0;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

/* The rail frame, white panes inside (the app window). */
.frame {
  display: grid;
  gap: 8px;
  padding: 8px;
  border-radius: var(--r-xl);
  background: var(--rail);
}

.pane,
.kpi {
  min-width: 0;
  border-radius: var(--r-lg);
  background: var(--bg);
  box-shadow: var(--shadow-xs);
}

.pane {
  padding: 20px 22px;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.kpis-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.kpi {
  display: grid;
  align-content: start;
  gap: 4px;
  padding: 18px 20px;
}

.kpi-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--t2);
  font-size: 13px;
  font-weight: 500;
}

.kpi-value {
  font-size: 34px;
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.kpi-value.is-empty {
  color: var(--t4);
}

.kpi-note {
  color: var(--muted);
  font-size: 12.5px;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-bottom: 16px;
}

.card-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.card-head a {
  text-decoration: none;
}

.card-head a:hover {
  color: var(--fg);
}

/* Series keys: a small square per OS, always with its name. */
.key {
  display: inline-block;
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.key-win {
  background: var(--series-win);
}

.key-mac {
  background: var(--series-mac);
}

.legend {
  display: inline-flex;
  gap: 14px;
  color: var(--t2);
  font-size: 12.5px;
}

.legend > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ---- Charts ---- */

.chart {
  position: relative;
  height: 220px;
  padding-left: 32px;
}

/* The downloads chart fills its pane next to the taller country list. */
.grid-wide .pane:first-child {
  display: flex;
  flex-direction: column;
}

.grid-wide .pane:first-child .chart {
  flex: 1;
  min-height: 220px;
}

.chart svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.chart .grid {
  stroke: var(--line);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.chart .bar {
  fill: var(--bar);
}

.chart .bar-empty {
  fill: var(--bar-soft);
}

.chart .seg-win {
  fill: var(--series-win);
}

.chart .seg-mac {
  fill: var(--series-mac);
}

.chart .hit {
  fill: transparent;
}

.chart .col:hover .hit {
  fill: var(--hover);
}

.chart-axis {
  position: absolute;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.chart-tip {
  position: absolute;
  z-index: 2;
  top: 0;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  background: var(--bg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--line);
  font-size: 12.5px;
  line-height: 1.5;
  white-space: nowrap;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}

.chart-tip b {
  display: block;
  font-weight: 600;
}

.chart-tip span {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--t2);
}

.chart-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 4px;
  text-align: center;
  pointer-events: none;
}

.chart-empty strong {
  font-size: 15px;
  font-weight: 600;
}

.chart-empty span {
  max-width: 46ch;
  color: var(--muted);
  font-size: 13.5px;
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 8px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

/* ---- Tables and bar rows ---- */

.table-wrap {
  overflow-x: auto;
}

table.rel {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}

table.rel th {
  padding: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  text-align: left;
}

table.rel td {
  padding: 9px 0;
  border-top: 1px solid var(--line);
}

table.rel th:not(:first-child),
table.rel td:not(:first-child) {
  padding-left: 12px;
  text-align: right;
}

table.rel td:first-child {
  font-weight: 500;
}

table.rel .date {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

table.rel tfoot td {
  border-top: 1px solid var(--line-2);
  font-weight: 600;
}

/* Error tables: the message column reads left and wraps. */
table.errs td:first-child {
  max-width: 0;
  width: 60%;
  font-weight: 400;
}

table.errs .err-kind {
  display: block;
  font-weight: 500;
}

table.errs .err-msg {
  display: block;
  color: var(--t2);
  font-size: 12.5px;
  overflow-wrap: anywhere;
}

table.errs td:not(:first-child) {
  white-space: nowrap;
  vertical-align: top;
}

.rows {
  display: grid;
  gap: 12px;
}

.row {
  display: grid;
  gap: 6px;
}

.row-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}

.row-top span:first-child {
  font-weight: 500;
}

.track {
  display: flex;
  gap: 2px;
  height: 8px;
  border-radius: var(--r-full);
  background: var(--track);
  overflow: hidden;
}

.track i {
  display: block;
  height: 100%;
  border-radius: var(--r-full);
  background: var(--bar);
}

.track i.seg-win {
  background: var(--series-win);
}

.track i.seg-mac {
  background: var(--series-mac);
}

.note {
  margin: 14px 0 0;
}

.stat-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stat-pair div {
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--line);
}

.stat-pair b {
  display: block;
  font-size: 24px;
  font-weight: 500;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.stat-pair span {
  color: var(--muted);
  font-size: 12.5px;
}

.stat-pair + .stat-pair {
  margin-top: 8px;
}

.empty {
  display: grid;
  gap: 4px;
  padding: 16px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px dashed var(--line-2);
}

.empty strong {
  font-size: 13.5px;
  font-weight: 600;
}

.empty span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.foot {
  margin: 20px 0 0;
  text-align: center;
}

@media (max-width: 1080px) {
  .kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .kpis-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid-2,
  .grid-3 {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 760px) {
  .dash-nav .nav-links {
    display: none;
  }

  .nav-inner {
    grid-template-columns: 1fr auto;
    padding-inline: 16px;
  }

  .board {
    width: calc(100% - 32px);
    padding-top: 28px;
  }

  .board-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .kpis,
  .kpis-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kpi-value {
    font-size: 28px;
  }

  .kpis > .kpi:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  .pane {
    padding: 16px;
  }

  .chart {
    height: 180px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
