@font-face {
  font-family: "Manrope";
  src: url("fonts/manrope-latin.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
}

:root {
  --ink: #18201d;
  --ink-soft: #45514c;
  --muted: #6d7773;
  --canvas: #f4f6f5;
  --surface: #ffffff;
  --surface-muted: #eef1ef;
  --border: #dce2df;
  --border-strong: #c5cec9;
  --sidebar: #17231e;
  --sidebar-muted: #9caaa3;
  --accent: #147451;
  --accent-strong: #0d5d40;
  --accent-soft: #e2f2eb;
  --positive: #087a50;
  --positive-soft: #dcf3e9;
  --negative: #b33a42;
  --negative-soft: #fbe6e8;
  --warning: #9c5c00;
  --warning-soft: #fff0ce;
  --focus: #2f7de1;
  --radius: 6px;
  --shadow-modal: 0 20px 60px rgba(15, 26, 21, 0.22);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--canvas);
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: "Manrope", "Avenir Next", "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

button,
input,
select,
textarea {
  color: inherit;
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

a {
  color: inherit;
  text-decoration: none;
}

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

h1,
h2,
h3,
strong {
  font-weight: 700;
}

h1 {
  margin-bottom: 0;
  font-size: 22px;
  line-height: 1.25;
}

h2 {
  margin-bottom: 0;
  font-size: 17px;
  line-height: 1.35;
}

h3 {
  font-size: 15px;
}

svg {
  display: block;
}

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 55%, transparent);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

.sidebar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  height: 100vh;
  color: #f6faf8;
  background: var(--sidebar);
  border-right: 1px solid #2b3a33;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  min-height: 76px;
  padding: 16px;
  border-bottom: 1px solid #2b3a33;
  gap: 11px;
}

.brand-mark {
  display: grid;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  color: #d6f2e6;
  background: #225d47;
  border: 1px solid #34795e;
  border-radius: var(--radius);
  place-items: center;
}

.brand-mark svg {
  width: 19px;
  height: 19px;
}

.brand-mark-large {
  width: 44px;
  height: 44px;
  margin-bottom: 16px;
}

.product-name {
  margin-bottom: 1px;
  font-size: 15px;
  font-weight: 800;
}

.product-meta,
.topbar-context,
.section-context {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
}

.sidebar .product-meta {
  color: var(--sidebar-muted);
}

.app-nav {
  min-height: 0;
  padding: 18px 10px;
  overflow-y: auto;
}

.nav-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px 9px;
  color: var(--sidebar-muted);
  font-size: 12px;
  font-weight: 700;
}

.sidebar .icon-button {
  color: var(--sidebar-muted);
}

.sidebar .icon-button:hover {
  color: #ffffff;
  background: #2b3a33;
}

.nav-empty {
  padding: 10px 6px;
  color: var(--sidebar-muted);
  font-size: 13px;
}

.app-nav-item {
  display: flex;
  align-items: center;
  min-height: 52px;
  padding: 8px;
  border-radius: var(--radius);
  gap: 10px;
}

.app-nav-item:hover {
  background: #203129;
}

.app-nav-item.is-active {
  background: #284338;
  box-shadow: inset 3px 0 #64c49e;
}

.app-nav-item img,
.app-fallback {
  width: 32px;
  height: 32px;
  border-radius: 7px;
}

.app-fallback {
  display: grid;
  color: #aac6b9;
  background: #31443b;
  place-items: center;
}

.app-fallback svg {
  width: 16px;
}

.app-nav-item > span:last-child {
  min-width: 0;
}

.app-nav-item strong,
.app-nav-item small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-nav-item strong {
  font-size: 12px;
}

.app-nav-item small {
  margin-top: 2px;
  color: var(--sidebar-muted);
  font-size: 11px;
}

.sidebar-footer {
  padding: 10px;
  margin-top: auto;
  border-top: 1px solid #2b3a33;
}

.sidebar-footer form {
  margin: 0;
}

.sidebar-link {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 38px;
  padding: 8px;
  color: var(--sidebar-muted);
  background: transparent;
  border: 0;
  border-radius: var(--radius);
  gap: 9px;
  text-align: left;
}

.sidebar-link:hover {
  color: #ffffff;
  background: #203129;
}

.sidebar-link svg {
  width: 16px;
  height: 16px;
}

.main-content {
  min-width: 0;
  padding: 0 32px 40px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  min-height: 76px;
  margin: 0 -32px;
  padding: 12px 32px;
  background: color-mix(in srgb, var(--canvas) 92%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.topbar > div:nth-child(2) {
  min-width: 0;
}

.topbar h1 {
  max-width: 640px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  margin-left: auto;
  gap: 8px;
}

.button,
.icon-button,
.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
}

.button {
  min-height: 38px;
  padding: 8px 13px;
  border-radius: var(--radius);
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
}

.button svg {
  width: 16px;
  height: 16px;
}

.button-primary {
  color: #ffffff;
  background: var(--accent);
  border: 1px solid var(--accent);
}

.button-primary:hover:not(:disabled) {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.button-secondary {
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--border-strong);
}

.button-secondary:hover:not(:disabled) {
  color: var(--ink);
  background: var(--surface-muted);
}

.button-wide {
  width: 100%;
}

.icon-button {
  width: 34px;
  height: 34px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border-radius: var(--radius);
}

.icon-button:hover {
  color: var(--ink);
  background: var(--surface-muted);
}

.icon-button svg {
  width: 17px;
  height: 17px;
}

.sidebar-close,
.mobile-menu {
  display: none;
}

.icon-danger:hover {
  color: var(--negative);
  background: var(--negative-soft);
}

.text-button {
  padding: 4px;
  background: transparent;
  font-size: 12px;
  font-weight: 700;
}

.text-danger {
  color: var(--negative);
}

.page-alert {
  margin-top: 20px;
}

.alert {
  display: flex;
  align-items: flex-start;
  padding: 11px 13px;
  border: 1px solid;
  border-radius: var(--radius);
  gap: 9px;
  font-size: 13px;
}

.alert p {
  margin: 0;
}

.alert svg {
  flex: 0 0 17px;
  width: 17px;
  height: 17px;
  margin-top: 1px;
}

.alert-success {
  color: #075c3d;
  background: var(--positive-soft);
  border-color: #a5dcc6;
}

.alert-error {
  color: #8d2830;
  background: var(--negative-soft);
  border-color: #efb9bd;
}

.alert-warning {
  color: #7b4900;
  background: var(--warning-soft);
  border-color: #edcd88;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-top: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.metric-strip > div {
  min-width: 0;
  padding: 17px 19px;
  border-right: 1px solid var(--border);
}

.metric-strip > div:last-child {
  border-right: 0;
}

.metric-strip span,
.metric-strip small {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.metric-strip strong {
  display: block;
  margin: 4px 0 1px;
  font-size: 24px;
  line-height: 1.2;
}

.trend-section,
.rankings-section {
  margin-top: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.section-heading {
  display: flex;
  align-items: center;
  min-height: 68px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  gap: 20px;
}

.section-heading > div:first-child {
  min-width: 0;
}

.section-heading h2 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.select-label {
  display: flex;
  align-items: center;
  margin-left: auto;
  color: var(--muted);
  font-size: 11px;
  gap: 8px;
}

select,
input,
textarea {
  width: 100%;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}

input,
select {
  min-height: 39px;
  padding: 8px 10px;
}

textarea {
  min-height: 150px;
  padding: 10px;
  line-height: 1.5;
  resize: vertical;
}

.select-label select {
  width: min(260px, 42vw);
  min-height: 36px;
}

label {
  display: grid;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
  gap: 6px;
}

.field-help {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

.chart-wrap {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  height: 220px;
  padding: 20px 20px 8px 10px;
}

.chart-axis {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 3px 8px 15px 0;
  color: var(--muted);
  font-size: 10px;
  text-align: right;
}

.rank-chart {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.chart-grid {
  stroke: #e5e9e7;
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.chart-line {
  fill: none;
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
}

.chart-dot {
  fill: var(--surface);
  stroke: var(--accent);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.chart-footer {
  display: flex;
  justify-content: space-between;
  padding: 0 20px 13px 52px;
  color: var(--muted);
  font-size: 10px;
}

.chart-empty {
  display: grid;
  height: 220px;
  color: var(--muted);
  place-content: center;
  text-align: center;
}

.chart-empty svg {
  width: 25px;
  height: 25px;
  margin: 0 auto 8px;
}

.chart-empty p {
  margin: 0;
}

.rankings-heading {
  justify-content: space-between;
}

.table-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-field {
  position: relative;
  display: block;
}

.search-field svg {
  position: absolute;
  top: 11px;
  left: 10px;
  width: 16px;
  height: 16px;
  color: var(--muted);
}

.search-field input {
  width: 210px;
  padding-left: 33px;
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  height: 54px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

thead th {
  height: 41px;
  color: var(--muted);
  background: #fafbfa;
  font-size: 11px;
  font-weight: 700;
}

tbody th {
  min-width: 220px;
  font-weight: 700;
}

tbody th a:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

tbody tr:hover {
  background: #fafcfb;
}

tbody tr:last-child th,
tbody tr:last-child td {
  border-bottom: 0;
}

td:last-child {
  width: 50px;
  text-align: right;
}

td:last-child form {
  display: inline-block;
}

.rank-value {
  font-size: 15px;
}

.status,
.change {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 2px 7px;
  border-radius: 999px;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
}

.status svg,
.change svg {
  width: 12px;
  height: 12px;
}

.status-unranked {
  color: var(--warning);
  background: var(--warning-soft);
}

.status-error,
.change-down {
  color: var(--negative);
  background: var(--negative-soft);
}

.change-up {
  color: var(--positive);
  background: var(--positive-soft);
}

.change-flat {
  color: var(--muted);
  background: var(--surface-muted);
}

.checked-time {
  color: var(--muted);
}

.table-footer {
  display: flex;
  justify-content: space-between;
  min-height: 42px;
  padding: 12px 14px;
  color: var(--muted);
  background: #fafbfa;
  border-top: 1px solid var(--border);
  font-size: 11px;
}

.table-empty,
.empty-state {
  display: grid;
  color: var(--muted);
  place-items: center;
  text-align: center;
}

.table-empty {
  min-height: 270px;
  padding: 28px;
}

.table-empty > svg {
  width: 30px;
  height: 30px;
  margin-bottom: 10px;
}

.table-empty h3,
.empty-state h2 {
  margin-bottom: 5px;
  color: var(--ink);
}

.table-empty p,
.empty-state p {
  max-width: 440px;
  margin-bottom: 17px;
}

.empty-state {
  min-height: calc(100vh - 150px);
}

.empty-visual {
  display: grid;
  width: 58px;
  height: 58px;
  margin-bottom: 16px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid #b9dfcf;
  border-radius: var(--radius);
  place-items: center;
}

.empty-visual svg {
  width: 27px;
  height: 27px;
}

.method-note {
  display: flex;
  align-items: flex-start;
  padding: 16px 2px;
  color: var(--muted);
  gap: 9px;
  font-size: 11px;
}

.method-note > svg {
  flex: 0 0 15px;
  width: 15px;
  height: 15px;
  margin-top: 1px;
}

.method-note p {
  max-width: 760px;
  margin: 0;
}

.method-note form {
  margin-left: auto;
}

.modal {
  width: min(480px, calc(100vw - 32px));
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
}

.modal::backdrop {
  background: rgba(17, 29, 24, 0.56);
  backdrop-filter: blur(3px);
}

.modal-content {
  display: grid;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-modal);
  gap: 16px;
}

.modal-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.modal-heading h2 {
  margin-bottom: 3px;
}

.modal-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 3px;
  gap: 8px;
}

.sidebar-backdrop {
  display: none;
}

.auth-body {
  display: grid;
  min-height: 100vh;
  padding: 32px 18px;
  background:
    linear-gradient(90deg, transparent calc(50% - 1px), rgba(24, 32, 29, 0.035) 50%, transparent calc(50% + 1px)),
    var(--canvas);
  place-items: center;
}

.login-shell,
.setup-shell {
  width: min(100%, 420px);
}

.login-shell h1 {
  max-width: 360px;
  margin-bottom: 8px;
  font-size: 31px;
}

.login-intro {
  max-width: 380px;
  margin-bottom: 24px;
  color: var(--muted);
}

.login-shell .alert {
  margin-bottom: 14px;
}

.login-form,
.setup-form {
  display: grid;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  gap: 16px;
}

.setup-shell {
  width: min(100%, 680px);
  padding: 30px 0;
}

.setup-heading {
  display: flex;
  align-items: flex-start;
  margin-bottom: 20px;
  gap: 14px;
}

.setup-heading h1 {
  margin-bottom: 4px;
  font-size: 25px;
}

.setup-heading p:last-child {
  margin: 0;
  color: var(--muted);
}

.setup-shell > .alert {
  margin-bottom: 12px;
}

fieldset {
  display: grid;
  padding: 0;
  border: 0;
  gap: 13px;
}

fieldset + fieldset {
  padding-top: 17px;
  border-top: 1px solid var(--border);
}

legend {
  padding: 0;
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 800;
}

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

.form-span {
  grid-column: 1 / -1;
}

.segmented-control {
  display: inline-grid;
  grid-template-columns: repeat(2, 1fr);
  width: 250px;
  padding: 3px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.segmented-control label {
  display: block;
}

.segmented-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented-control span {
  display: block;
  min-height: 31px;
  padding: 6px 12px;
  border-radius: 4px;
  text-align: center;
}

.segmented-control input:checked + span {
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(24, 32, 29, 0.12);
}

.segmented-control input:focus-visible + span {
  outline: 3px solid color-mix(in srgb, var(--focus) 55%, transparent);
}

.is-hidden {
  display: none !important;
}

@media (max-width: 900px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    left: 0;
    width: min(290px, 86vw);
    transform: translateX(-102%);
    transition: transform 180ms ease;
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .sidebar-close,
  .mobile-menu {
    display: inline-flex;
  }

  .sidebar-close {
    margin-left: auto;
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 15;
    background: rgba(17, 29, 24, 0.48);
  }

  .sidebar-backdrop.is-open {
    display: block;
  }

  .main-content {
    padding-right: 20px;
    padding-left: 20px;
  }

  .topbar {
    margin-right: -20px;
    margin-left: -20px;
    padding-right: 20px;
    padding-left: 20px;
    gap: 10px;
  }

  .metric-strip {
    grid-template-columns: repeat(3, 1fr);
  }

  .metric-strip > div:nth-child(3) {
    border-right: 0;
  }

  .metric-strip > div:nth-child(n + 4) {
    border-top: 1px solid var(--border);
  }
}

@media (max-width: 640px) {
  .main-content {
    padding-right: 12px;
    padding-bottom: 24px;
    padding-left: 12px;
  }

  .topbar {
    min-height: 66px;
    margin-right: -12px;
    margin-left: -12px;
    padding-right: 12px;
    padding-left: 12px;
  }

  .topbar h1 {
    max-width: 38vw;
    font-size: 16px;
  }

  .topbar-context {
    display: none;
  }

  .topbar-actions {
    gap: 5px;
  }

  .export-button span,
  .topbar-actions .button-primary span {
    display: none;
  }

  .topbar-actions .button {
    width: 38px;
    padding: 0;
  }

  .metric-strip {
    grid-template-columns: repeat(2, 1fr);
  }

  .metric-strip > div,
  .metric-strip > div:nth-child(3) {
    border-right: 1px solid var(--border);
  }

  .metric-strip > div:nth-child(even) {
    border-right: 0;
  }

  .metric-strip > div:last-child {
    grid-column: 1 / -1;
    border-right: 0;
  }

  .metric-strip > div:nth-child(n + 3) {
    border-top: 1px solid var(--border);
  }

  .section-heading,
  .rankings-heading {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .select-label {
    align-items: stretch;
    flex-direction: column;
    margin-left: 0;
  }

  .select-label select,
  .search-field input {
    width: 100%;
  }

  .table-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .table-tools .button {
    width: 100%;
  }

  .chart-wrap {
    height: 190px;
    padding-right: 10px;
  }

  .chart-footer {
    padding-right: 10px;
    padding-left: 47px;
  }

  .method-note {
    flex-wrap: wrap;
  }

  .method-note form {
    width: 100%;
    margin-left: 24px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-span {
    grid-column: auto;
  }

  .setup-form,
  .login-form {
    padding: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
