:root {
  --green-950: #082617;
  --green-900: #0e3b24;
  --green-800: #0f4a2c;
  --green-700: #15663a;
  --green-600: #1e8a4c;
  --green-500: #27a45c;
  --green-300: #86d3a6;
  --green-100: #dcf2e4;
  --signal: #f2c230;
  --signal-ink: #4f3c05;
  --brick: #c23b2e;
  --ink: #0b1f15;
  --ink-soft: #4a5f53;
  --paper: #f1f6f0;
  --white: #ffffff;
  --line: #d7e2d8;
  --radius-s: 8px;
  --radius-m: 14px;
  --radius-l: 22px;
  --shadow: 0 18px 40px -28px rgba(8, 38, 23, 0.55);
  --display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --body: "Schibsted Grotesk", "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--body);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
.brand-name {
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: -0.015em;
  margin: 0;
}

.muted {
  color: var(--ink-soft);
}

/* ------------------------------------------------------------------ login */

.login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
}

.login-field {
  position: relative;
  overflow: hidden;
  background: radial-gradient(120% 120% at 12% 8%, var(--green-700) 0%, var(--green-900) 55%, var(--green-950) 100%);
  color: var(--green-100);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 56px 60px;
}

.login-field .wordmark {
  font-family: var(--display);
  font-size: clamp(40px, 5vw, 68px);
  line-height: 0.98;
  color: var(--white);
  max-width: 12ch;
}

.login-field .wordmark em {
  font-style: normal;
  color: var(--green-300);
}

.login-field .tagline {
  max-width: 34ch;
  font-size: 16px;
  line-height: 1.6;
  color: rgba(220, 242, 228, 0.82);
  margin-top: 20px;
}

.field-art {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.5;
}

.field-foot {
  font-size: 13px;
  letter-spacing: 0.01em;
  color: rgba(220, 242, 228, 0.6);
}

.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: var(--paper);
}

.login-card {
  width: min(380px, 100%);
}

.login-card h2 {
  font-size: 26px;
  margin-bottom: 6px;
}

.login-card p.sub {
  color: var(--ink-soft);
  margin: 0 0 28px;
  font-size: 14px;
}

.field {
  display: block;
  margin-bottom: 16px;
}

.field span {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 7px;
  color: var(--ink-soft);
}

input {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 11px 13px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus-visible {
  outline: none;
  border-color: var(--green-500);
  box-shadow: 0 0 0 3px rgba(39, 164, 92, 0.18);
}

.login-error {
  color: var(--brick);
  font-size: 13px;
  min-height: 18px;
  margin: 4px 0 12px;
}

/* ------------------------------------------------------------- shared ui */

.btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: var(--radius-s);
  padding: 10px 16px;
  cursor: pointer;
  background: var(--white);
  color: var(--ink);
  border-color: var(--line);
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--green-500);
  color: var(--white);
  border-color: var(--green-600);
}

.btn-primary:hover {
  background: var(--green-600);
}

.btn-danger {
  color: var(--brick);
  border-color: rgba(194, 59, 46, 0.35);
  background: rgba(194, 59, 46, 0.06);
}

.btn-amber {
  background: var(--signal);
  color: var(--signal-ink);
  border-color: #d9a900;
}

.btn-ghost {
  background: transparent;
}

.btn-sm {
  padding: 6px 11px;
  font-size: 13px;
}

/* ------------------------------------------------------------- dashboard */

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

.rail {
  background: linear-gradient(180deg, var(--green-900), #0a2f1d);
  color: var(--green-100);
  padding: 26px 22px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--green-500);
  display: grid;
  place-items: center;
  color: var(--white);
  font-family: var(--display);
  font-weight: 800;
  font-size: 18px;
}

.brand-name {
  font-size: 18px;
  color: var(--white);
}

.brand-sub {
  font-size: 12px;
  color: rgba(220, 242, 228, 0.6);
  margin: 2px 0 0;
}

.panel {
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-m);
  padding: 16px;
}

.panel-title {
  font-size: 14px;
  font-weight: 600;
  font-family: var(--body);
  color: var(--white);
  margin-bottom: 12px;
}

.hint {
  font-size: 12.5px;
  line-height: 1.55;
  color: rgba(220, 242, 228, 0.62);
  margin: 0 0 12px;
}

.qr-box {
  width: 100%;
  aspect-ratio: 1;
  background: var(--white);
  border-radius: var(--radius-m);
  display: grid;
  place-items: center;
  padding: 12px;
  margin-bottom: 12px;
}

.qr-box img {
  width: 100%;
  height: auto;
  display: block;
}

.qr-wait {
  color: var(--ink-soft);
  font-size: 13px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 999px;
}

.chip-ok {
  background: rgba(39, 164, 92, 0.18);
  color: var(--green-300);
}

.stats-line {
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--green-100);
  background: rgba(0, 0, 0, 0.18);
  border-radius: var(--radius-s);
  padding: 10px 12px;
  margin-bottom: 12px;
}

.stats-line b {
  color: var(--white);
  font-variant-numeric: tabular-nums;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.field-row label {
  font-size: 11.5px;
  color: rgba(220, 242, 228, 0.7);
  display: block;
}

.field-row input {
  margin-top: 5px;
  padding: 8px 10px;
  font-size: 13px;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.actions .btn-primary,
.actions .btn-ghost:last-child {
  grid-column: span 2;
}

/* ---------------------------------------------------------------- main */

.main {
  padding: 22px 30px 50px;
  overflow-y: auto;
  max-height: 100vh;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.status-pill {
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--green-100);
  color: var(--green-700);
}

.status-pill.is-running {
  background: rgba(39, 164, 92, 0.16);
  color: var(--green-700);
}

.status-pill.is-paused,
.status-pill.is-auto_paused {
  background: rgba(242, 194, 48, 0.22);
  color: var(--signal-ink);
}

.status-pill.is-done {
  background: var(--green-600);
  color: var(--white);
}

.status-pill.is-stopped {
  background: rgba(194, 59, 46, 0.14);
  color: var(--brick);
}

.who {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--ink-soft);
}

.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-radius: var(--radius-m);
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.banner-limit {
  background: var(--signal);
  color: var(--signal-ink);
  border: 1px solid #d9a900;
}

.banner-limit strong {
  display: block;
  font-size: 14px;
}

.banner-limit span {
  font-size: 13px;
}

.banner-resume {
  background: var(--white);
  border: 1px solid var(--line);
}

.banner-schedule {
  background: var(--green-100);
  border: 1px solid var(--green-300);
  color: var(--green-700);
}

.banner-schedule strong {
  display: block;
  font-size: 14px;
}

.banner-schedule span {
  font-size: 13px;
}

.banner-actions {
  display: flex;
  gap: 8px;
}

/* ------------------------------------------------------------ progress */

.progress-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow);
  padding: 26px 30px;
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 30px;
  align-items: center;
  margin-bottom: 18px;
}

.arc {
  width: 220px;
  height: 220px;
}

.arc-track {
  fill: none;
  stroke: var(--green-100);
  stroke-width: 16;
}

.arc-value {
  fill: none;
  stroke: var(--green-500);
  stroke-width: 16;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 110px 110px;
  transition: stroke-dashoffset 0.5s ease;
}

.arc-percent {
  font-family: var(--display);
  font-size: 40px;
  font-weight: 700;
  fill: var(--ink);
  text-anchor: middle;
}

.arc-caption {
  font-size: 12px;
  fill: var(--ink-soft);
  text-anchor: middle;
}

.progress-headline {
  font-family: var(--display);
  font-size: 24px;
  font-weight: 600;
  margin: 0 0 14px;
}

.progress-headline .num {
  font-size: 32px;
  font-variant-numeric: tabular-nums;
}

.legend {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
}

.legend li {
  font-size: 13.5px;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 7px;
}

.legend b {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}

.dot-ok {
  background: var(--green-500);
}
.dot-fail {
  background: var(--brick);
}
.dot-pending {
  background: var(--line);
}

.current,
.eta {
  font-size: 13.5px;
  margin: 4px 0;
  color: var(--ink-soft);
}

.quota {
  font-size: 13px;
  margin: 6px 0 0;
  color: var(--green-700);
  font-variant-numeric: tabular-nums;
}

.current b {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* -------------------------------------------------------- last sent strip */

.last-sent {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 16px;
}

.last-chip {
  flex: 0 0 auto;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 9px 13px;
  font-size: 12.5px;
  min-width: 150px;
}

.last-chip .ph {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.last-chip .st {
  color: var(--ink-soft);
  font-size: 11.5px;
}

.last-chip.is-failed .st {
  color: var(--brick);
}

/* -------------------------------------------------------------- feed */

.feed-wrap {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  overflow: hidden;
  min-width: 0;
}

.feed-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.tabs {
  display: flex;
  gap: 4px;
}

.tab {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  padding: 7px 13px;
  border-radius: 999px;
  cursor: pointer;
}

.tab.is-active {
  background: var(--green-100);
  color: var(--green-700);
}

.search {
  max-width: 220px;
  padding: 8px 12px;
  font-size: 13px;
}

.feed {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 46vh;
  overflow-y: auto;
  overflow-x: hidden;
}

.feed-row {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  padding: 11px 18px;
  border-bottom: 1px solid #eef4ee;
  font-size: 13.5px;
  animation: row-in 0.28s ease both;
}

.feed-row:last-child {
  border-bottom: none;
}

.feed-row .ph {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feed-row .err {
  color: var(--brick);
  font-size: 12px;
  max-width: 340px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feed-row .time {
  color: var(--ink-soft);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.tick {
  font-size: 15px;
  line-height: 1;
  text-align: center;
}

.tick-sent {
  color: var(--ink-soft);
}
.tick-delivered {
  color: var(--ink-soft);
}
.tick-read {
  color: #2f7fd0;
}
.tick-failed {
  color: var(--brick);
}
.tick-pending {
  color: var(--line);
}

.feed-empty {
  padding: 40px 18px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 13.5px;
}

@keyframes row-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* -------------------------------------------------------------- toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--white);
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 13.5px;
  box-shadow: var(--shadow);
  z-index: 40;
}

.toast.is-error {
  background: var(--brick);
}

/* -------------------------------------------------------------- mobile */

@media (max-width: 1040px) {
  .app {
    grid-template-columns: 1fr;
  }
  .rail {
    max-height: none;
  }
  .main {
    max-height: none;
    padding: 16px 14px 40px;
  }
  .login {
    grid-template-columns: 1fr;
  }
  .login-field {
    min-height: 44vh;
    padding: 40px 32px;
  }
  .progress-card {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
    padding: 20px;
  }
}

@media (max-width: 640px) {
  .search {
    max-width: none;
    width: 100%;
  }
  .feed-toolbar {
    gap: 10px;
  }
  .progress-card {
    padding: 18px 14px;
  }
  .arc {
    width: 180px;
    height: 180px;
  }
  .banner-actions {
    width: 100%;
  }
  .banner-actions .btn {
    flex: 1;
  }
  .feed-row {
    grid-template-columns: 22px minmax(0, 1fr) auto;
    grid-template-areas:
      "tick phone time"
      "tick err err";
    column-gap: 10px;
    row-gap: 2px;
    padding: 10px 14px;
  }
  .feed-row .tick {
    grid-area: tick;
  }
  .feed-row .ph {
    grid-area: phone;
  }
  .feed-row .err {
    grid-area: err;
    max-width: none;
    white-space: normal;
  }
  .feed-row .time {
    grid-area: time;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

:focus-visible {
  outline: 3px solid rgba(39, 164, 92, 0.45);
  outline-offset: 2px;
}
