@import url("https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700;900&display=swap");

/* ============================================================
   Tokens. Copied from the shared brand palette — the two accent
   hues (#147ac1 blue, #16b978 green) are the only colors in the
   system; everything else is a neutral.
   ============================================================ */
:root {
  --radius: 0.625rem;
  --background: oklch(1 0 0);
  --foreground: oklch(0.129 0.042 264.695);
  --muted: oklch(0.968 0.007 247.896);
  --muted-foreground: oklch(0.554 0.046 257.417);
  --border: oklch(0.929 0.013 255.508);
  --input: oklch(0.929 0.013 255.508);
  --ring: oklch(0.704 0.04 256.788);
  --destructive: oklch(0.577 0.245 27.325);

  --brand-blue: #147ac1;
  --brand-green: #16b978;
  --brand-gradient: linear-gradient(135deg, #147ac1, #16b978);

  --glass: rgba(255, 255, 255, 0.66);
  --glass-border: rgba(255, 255, 255, 0.78);
  --glass-shadow: 0 24px 70px rgba(13, 34, 51, 0.12);
  --glass-soft: rgba(255, 255, 255, 0.45);
  --glass-strong: rgba(255, 255, 255, 0.86);
  --glass-tile-shadow: 0 10px 32px rgba(13, 34, 51, 0.09);

  --ambient-a: rgba(20, 122, 193, 0.14);
  --ambient-b: rgba(22, 185, 120, 0.12);

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

:root[data-theme="dark"] {
  --background: oklch(0.129 0.042 264.695);
  --foreground: oklch(0.984 0.003 247.858);
  --muted: oklch(0.279 0.041 260.031);
  --muted-foreground: oklch(0.704 0.04 256.788);
  --border: oklch(1 0 0 / 10%);
  --input: oklch(1 0 0 / 15%);
  --ring: oklch(0.551 0.027 264.364);
  --destructive: oklch(0.704 0.191 22.216);

  --glass: rgba(15, 23, 42, 0.55);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
  --glass-soft: rgba(15, 23, 42, 0.38);
  --glass-strong: rgba(15, 23, 42, 0.82);
  --glass-tile-shadow: 0 10px 32px rgba(0, 0, 0, 0.35);

  --ambient-a: rgba(20, 122, 193, 0.2);
  --ambient-b: rgba(22, 185, 120, 0.14);
}

* {
  box-sizing: border-box;
}

/* Inline icons carry a viewBox but no intrinsic size, so without a default
   they expand to fill their container. Every icon gets a sane size here and
   the few larger ones opt in below. */
svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: "Cairo", Tahoma, Arial, sans-serif;
  background: var(--background);
  color: var(--foreground);
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ---------------- ambient backdrop ---------------- */
.ambient-backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  background: linear-gradient(
    135deg,
    var(--background) 0%,
    color-mix(in oklab, var(--background) 88%, var(--foreground)) 100%
  );
}
.ambient-backdrop::before,
.ambient-backdrop::after {
  content: "";
  position: absolute;
  border-radius: 9999px;
  filter: blur(90px);
  will-change: transform;
}
.ambient-backdrop::before {
  width: 46vw;
  height: 46vw;
  min-width: 420px;
  min-height: 420px;
  top: -14%;
  inset-inline-start: -8%;
  background: radial-gradient(circle at center, var(--ambient-a), transparent 65%);
  animation: ambient-drift-a 26s ease-in-out infinite alternate;
}
.ambient-backdrop::after {
  width: 42vw;
  height: 42vw;
  min-width: 380px;
  min-height: 380px;
  bottom: -18%;
  inset-inline-end: -6%;
  background: radial-gradient(circle at center, var(--ambient-b), transparent 65%);
  animation: ambient-drift-b 32s ease-in-out infinite alternate;
}
@keyframes ambient-drift-a {
  from {
    transform: translate3d(0, 0, 0) scale(1);
  }
  to {
    transform: translate3d(8vw, 6vh, 0) scale(1.15);
  }
}
@keyframes ambient-drift-b {
  from {
    transform: translate3d(0, 0, 0) scale(1.1);
  }
  to {
    transform: translate3d(-7vw, -5vh, 0) scale(0.95);
  }
}

/* ---------------- glass tiers ---------------- */
.glass-panel {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(28px) saturate(1.4);
  -webkit-backdrop-filter: blur(28px) saturate(1.4);
  border-radius: calc(var(--radius) + 8px);
}
.glass-tile {
  background: var(--glass-soft);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-tile-shadow);
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  border-radius: calc(var(--radius) + 4px);
}
.glass-overlay {
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(32px) saturate(1.5);
  -webkit-backdrop-filter: blur(32px) saturate(1.5);
  border-radius: calc(var(--radius) + 8px);
}
.glass-inset {
  background: color-mix(in oklab, var(--background) 42%, transparent);
  border: 1px solid color-mix(in oklab, var(--border) 70%, transparent);
  border-radius: calc(var(--radius) + 2px);
}

/* ---------------- layout ---------------- */
.app-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
@media (min-width: 640px) {
  .app-shell {
    padding: 1.5rem;
  }
}

.topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.9rem;
  position: sticky;
  top: 0.75rem;
  z-index: 30;
}
.topbar .brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: var(--brand-gradient);
  display: grid;
  place-items: center;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 8px 20px rgba(20, 122, 193, 0.35);
}
.brand-mark svg,
.panel-head .icon svg,
.empty .bubble svg,
.dropzone .bubble svg {
  width: 19px;
  height: 19px;
}
.brand-name {
  font-weight: 900;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.topbar .spacer {
  margin-inline-start: auto;
}

.nav {
  display: flex;
  gap: 0.35rem;
  padding: 0.35rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav::-webkit-scrollbar {
  display: none;
}
.nav button {
  border: 0;
  background: transparent;
  color: var(--muted-foreground);
  font-family: inherit;
  font-weight: 700;
  font-size: 0.82rem;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s var(--ease-out);
}
.nav button:hover {
  background: color-mix(in oklab, var(--brand-blue) 10%, transparent);
  color: var(--brand-blue);
  transform: translateY(-1px);
}
.nav button[aria-selected="true"] {
  background: var(--brand-gradient);
  color: #fff;
  box-shadow: 0 10px 24px rgba(20, 122, 193, 0.35);
}

.view {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.view[hidden] {
  display: none;
}

.panel {
  padding: 1.15rem;
}
.panel-head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.9rem;
  flex-wrap: wrap;
}
.panel-head .icon {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: var(--brand-blue);
  background: color-mix(in oklab, var(--brand-blue) 12%, transparent);
  flex-shrink: 0;
}
.panel-head h2 {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 900;
  letter-spacing: -0.01em;
}
.panel-head p {
  margin: 0.1rem 0 0;
  font-size: 0.76rem;
  color: var(--muted-foreground);
  font-weight: 400;
}
.panel-head .actions {
  margin-inline-start: auto;
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

/* ---------------- stat tiles ---------------- */
.stat-row {
  display: flex;
  gap: 0.6rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  scrollbar-width: thin;
}
.stat-tile {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.85rem;
  min-width: 8.5rem;
  flex-shrink: 0;
  transition: transform 0.2s var(--ease-out);
}
.stat-tile:hover {
  transform: translateY(-3px);
}
.stat-tile .bubble {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: color-mix(in oklab, var(--brand-blue) 12%, transparent);
  color: var(--brand-blue);
  flex-shrink: 0;
}
.stat-tile .bubble svg {
  width: 15px;
  height: 15px;
}
.stat-tile .label {
  font-size: 0.68rem;
  color: var(--muted-foreground);
  font-weight: 600;
  display: block;
}
.stat-tile .value {
  font-size: 1.15rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.tile-green .bubble {
  background: color-mix(in oklab, var(--brand-green) 14%, transparent);
  color: var(--brand-green);
}
.tile-red .bubble {
  background: color-mix(in oklab, var(--destructive) 14%, transparent);
  color: var(--destructive);
}
.tile-muted .bubble {
  background: color-mix(in oklab, var(--muted-foreground) 14%, transparent);
  color: var(--muted-foreground);
}

/* ---------------- controls ---------------- */
.btn {
  font-family: inherit;
  font-weight: 700;
  font-size: 0.8rem;
  padding: 0.5rem 0.95rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: color-mix(in oklab, var(--background) 60%, transparent);
  color: var(--foreground);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s var(--ease-out);
  white-space: nowrap;
}
.btn:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: color-mix(in oklab, var(--brand-blue) 40%, var(--border));
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn svg {
  width: 15px;
  height: 15px;
}
.btn-primary {
  background: var(--brand-gradient);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 10px 24px rgba(20, 122, 193, 0.3);
}
.btn-primary:hover:not(:disabled) {
  box-shadow: 0 14px 30px rgba(20, 122, 193, 0.4);
}
.btn-danger {
  color: var(--destructive);
  border-color: color-mix(in oklab, var(--destructive) 35%, var(--border));
}
.btn-danger:hover:not(:disabled) {
  background: color-mix(in oklab, var(--destructive) 10%, transparent);
  border-color: var(--destructive);
}
.btn-sm {
  font-size: 0.72rem;
  padding: 0.35rem 0.65rem;
}
.btn-icon {
  padding: 0.45rem;
  border-radius: 10px;
}

label.field {
  display: block;
  margin-bottom: 0.85rem;
}
label.field > span.lbl {
  display: block;
  font-size: 0.76rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
}
label.field > span.hint {
  display: block;
  font-size: 0.7rem;
  color: var(--muted-foreground);
  font-weight: 400;
  margin-top: 0.25rem;
  line-height: 1.5;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="datetime-local"],
input[type="time"],
input[type="search"],
select,
textarea {
  width: 100%;
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius);
  border: 1px solid var(--input);
  background: color-mix(in oklab, var(--background) 70%, transparent);
  color: var(--foreground);
  transition: border-color 0.2s var(--ease-out);
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--brand-blue) 18%, transparent);
}
textarea {
  min-height: 130px;
  resize: vertical;
  line-height: 1.7;
}

.grid-2 {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 1fr;
}
@media (min-width: 640px) {
  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}
.grid-3 {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 1fr;
}
@media (min-width: 720px) {
  .grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ---------------- badges ---------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: currentColor;
}
.badge-running,
.badge-connected,
.badge-sent {
  color: var(--brand-green);
  background: color-mix(in oklab, var(--brand-green) 12%, transparent);
  border-color: color-mix(in oklab, var(--brand-green) 30%, transparent);
}
.badge-scheduled,
.badge-pairing,
.badge-connecting,
.badge-pending {
  color: var(--brand-blue);
  background: color-mix(in oklab, var(--brand-blue) 12%, transparent);
  border-color: color-mix(in oklab, var(--brand-blue) 30%, transparent);
}
.badge-paused,
.badge-draft,
.badge-skipped,
.badge-disconnected,
.badge-cancelled,
.badge-completed {
  color: var(--muted-foreground);
  background: color-mix(in oklab, var(--muted-foreground) 12%, transparent);
  border-color: color-mix(in oklab, var(--muted-foreground) 25%, transparent);
}
.badge-failed {
  color: var(--destructive);
  background: color-mix(in oklab, var(--destructive) 12%, transparent);
  border-color: color-mix(in oklab, var(--destructive) 30%, transparent);
}

/* ---------------- progress ---------------- */
.progress {
  height: 7px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--muted-foreground) 18%, transparent);
  overflow: hidden;
}
.progress > i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--brand-gradient);
  transition: width 0.6s var(--ease-out);
}

/* ---------------- lists ---------------- */
.rows {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.row {
  padding: 0.75rem 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: transform 0.2s var(--ease-out);
}
.row:hover {
  transform: translateY(-2px);
}
.row .grow {
  flex: 1;
  min-width: 0;
}
.row .title {
  font-weight: 700;
  font-size: 0.85rem;
  margin: 0 0 0.15rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row .sub {
  font-size: 0.72rem;
  color: var(--muted-foreground);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 2.5rem 1.5rem;
  text-align: center;
  border: 1px dashed color-mix(in oklab, var(--border) 90%, transparent);
  border-radius: calc(var(--radius) + 4px);
}
.empty .bubble {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: var(--muted-foreground);
  background: var(--glass-soft);
}
.empty strong {
  font-size: 0.85rem;
}
.empty span {
  font-size: 0.75rem;
  color: var(--muted-foreground);
  max-width: 34ch;
}

/* ---------------- QR ---------------- */
.qr-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem;
  text-align: center;
}
.qr-frame {
  padding: 0.8rem;
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--glass-tile-shadow);
  line-height: 0;
}
.qr-frame img {
  width: 250px;
  height: 250px;
  display: block;
}
.qr-steps {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  text-align: start;
  font-size: 0.78rem;
  counter-reset: step;
  max-width: 340px;
}
.qr-steps li {
  list-style: none;
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  line-height: 1.6;
}
.qr-steps li::before {
  counter-increment: step;
  content: counter(step);
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: var(--brand-gradient);
  color: #fff;
  font-size: 0.66rem;
  font-weight: 900;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  margin-top: 0.15rem;
}

/* ---------------- wizard ---------------- */
.steps {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.step {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted-foreground);
}
.step .num {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 0.68rem;
  background: color-mix(in oklab, var(--muted-foreground) 15%, transparent);
}
.step.active {
  color: var(--foreground);
}
.step.active .num {
  background: var(--brand-gradient);
  color: #fff;
}
.step.done .num {
  background: color-mix(in oklab, var(--brand-green) 20%, transparent);
  color: var(--brand-green);
}
.step-sep {
  width: 18px;
  height: 1px;
  background: var(--border);
}

.dropzone {
  border: 2px dashed color-mix(in oklab, var(--brand-blue) 35%, var(--border));
  border-radius: calc(var(--radius) + 6px);
  padding: 2rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}
.dropzone:hover,
.dropzone.dragover {
  background: color-mix(in oklab, var(--brand-blue) 7%, transparent);
  border-color: var(--brand-blue);
}
.dropzone .bubble {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: color-mix(in oklab, var(--brand-blue) 12%, transparent);
  color: var(--brand-blue);
}
.dropzone strong {
  font-size: 0.88rem;
}
.dropzone span {
  font-size: 0.75rem;
  color: var(--muted-foreground);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.4rem;
}
.chip {
  font-family: inherit;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  border: 1px solid color-mix(in oklab, var(--brand-blue) 30%, transparent);
  background: color-mix(in oklab, var(--brand-blue) 8%, transparent);
  color: var(--brand-blue);
  cursor: pointer;
  transition: all 0.15s var(--ease-out);
}
.chip:hover {
  background: color-mix(in oklab, var(--brand-blue) 16%, transparent);
  transform: translateY(-1px);
}

.preview-bubble {
  padding: 0.75rem 0.9rem;
  border-radius: 14px;
  border-start-end-radius: 4px;
  background: color-mix(in oklab, var(--brand-green) 12%, transparent);
  border: 1px solid color-mix(in oklab, var(--brand-green) 25%, transparent);
  font-size: 0.82rem;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

.estimate {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.9rem;
}
.estimate-line {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  font-size: 0.8rem;
  flex-wrap: wrap;
}
.estimate-line b {
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.day-bars {
  display: flex;
  gap: 0.4rem;
  align-items: flex-end;
  padding-top: 0.25rem;
  overflow-x: auto;
}
/* Fixed-width columns rather than flex-grow: three days stretched across a
   full-width panel stop reading as a bar chart. A long spread scrolls instead. */
.day-bar {
  flex: 0 0 58px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}
/* Fixed-height track so every bar grows from the same baseline. */
.day-bar .track {
  width: 100%;
  height: 46px;
  display: flex;
  align-items: flex-end;
}
.day-bar .bar {
  width: 100%;
  border-radius: 6px 6px 2px 2px;
  background: var(--brand-gradient);
  min-height: 4px;
  transition: height 0.5s var(--ease-out);
}
.day-bar .n {
  font-size: 0.66rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.day-bar .d {
  font-size: 0.6rem;
  color: var(--muted-foreground);
  white-space: nowrap;
}

.notice {
  display: flex;
  gap: 0.55rem;
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius);
  font-size: 0.76rem;
  line-height: 1.6;
  align-items: flex-start;
}
.notice svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-top: 0.15rem;
}
.notice-warn {
  background: color-mix(in oklab, #f59e0b 12%, transparent);
  border: 1px solid color-mix(in oklab, #f59e0b 30%, transparent);
  color: color-mix(in oklab, #b45309 90%, var(--foreground));
}
:root[data-theme="dark"] .notice-warn {
  color: #fbbf24;
}
.notice-info {
  background: color-mix(in oklab, var(--brand-blue) 10%, transparent);
  border: 1px solid color-mix(in oklab, var(--brand-blue) 25%, transparent);
}

/* ---------------- table ---------------- */
.table-wrap {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}
th {
  text-align: start;
  font-weight: 700;
  font-size: 0.7rem;
  color: var(--muted-foreground);
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid color-mix(in oklab, var(--border) 60%, transparent);
  vertical-align: middle;
}
tr:last-child td {
  border-bottom: 0;
}
.num {
  font-variant-numeric: tabular-nums;
}
.ltr {
  direction: ltr;
  unicode-bidi: isolate;
  text-align: start;
}
.msg-cell {
  max-width: 30ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted-foreground);
}

/* ---------------- login ---------------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.login-card {
  width: 100%;
  max-width: 380px;
  padding: 1.75rem;
  text-align: center;
}
.login-card .brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  margin: 0 auto 0.9rem;
}
.login-card .brand-mark svg {
  width: 26px;
  height: 26px;
}
.login-card h1 {
  font-size: 1.15rem;
  font-weight: 900;
  margin: 0 0 0.25rem;
}
.login-card p {
  font-size: 0.78rem;
  color: var(--muted-foreground);
  margin: 0 0 1.25rem;
}

/* ---------------- toasts ---------------- */
.toasts {
  position: fixed;
  bottom: 1rem;
  inset-inline-start: 1rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 340px;
}
.toast {
  padding: 0.7rem 0.9rem;
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  animation: toast-in 0.35s var(--ease-out);
}
.toast svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-top: 0.1rem;
}
.toast-success {
  color: var(--brand-green);
}
.toast-error {
  color: var(--destructive);
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------------- modal ---------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(8, 15, 26, 0.45);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: 1rem;
  animation: fade-in 0.2s var(--ease-out);
}
.modal {
  width: 100%;
  max-width: 440px;
  padding: 1.25rem;
  animation: scale-in 0.3s var(--ease-out);
}
.modal h3 {
  margin: 0 0 0.4rem;
  font-size: 0.95rem;
  font-weight: 900;
}
.modal p {
  margin: 0 0 1rem;
  font-size: 0.8rem;
  color: var(--muted-foreground);
  line-height: 1.6;
}
.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}
@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes scale-in {
  from {
    opacity: 0;
    transform: scale(0.94);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ---------------- entrance motion ---------------- */
.enter {
  animation: enter 0.4s var(--ease-out) both;
}
@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.stagger > * {
  animation: enter 0.4s var(--ease-out) both;
}
.stagger > *:nth-child(1) {
  animation-delay: 0.03s;
}
.stagger > *:nth-child(2) {
  animation-delay: 0.09s;
}
.stagger > *:nth-child(3) {
  animation-delay: 0.15s;
}
.stagger > *:nth-child(4) {
  animation-delay: 0.21s;
}
.stagger > *:nth-child(5) {
  animation-delay: 0.27s;
}
.stagger > *:nth-child(n + 6) {
  animation-delay: 0.33s;
}

.spin {
  animation: spin 1s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.muted {
  color: var(--muted-foreground);
}
.small {
  font-size: 0.72rem;
}
.mono-num {
  font-variant-numeric: tabular-nums;
}
.flex {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.wrap {
  flex-wrap: wrap;
}
.mt {
  margin-top: 0.85rem;
}
.hidden {
  display: none !important;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .row:hover,
  .stat-tile:hover,
  .btn:hover:not(:disabled) {
    transform: none;
  }
}

/* ============================================================
   Dashboard
   ============================================================ */

.hero {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 1.35rem;
  flex-wrap: wrap;
}
.hero-main {
  min-width: 0;
  flex: 1;
}
.hero-label {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--muted-foreground);
}
.hero-value {
  font-size: 2.6rem;
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -0.02em;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-sub {
  font-size: 0.76rem;
  color: var(--muted-foreground);
  margin-top: 0.15rem;
}
.hero-cta {
  flex-shrink: 0;
}

/* ---- 7-day activity chart ---- */
.chart {
  position: relative;
  padding-top: 0.25rem;
}
/* Recessive gridlines: present enough to read heights against, never
   competing with the bars themselves. */
.chart-grid {
  position: absolute;
  inset: 1.4rem 0 1.6rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
}
.chart-grid span {
  display: block;
  height: 1px;
  background: color-mix(in oklab, var(--border) 70%, transparent);
}
.chart-bars {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
}
.chart-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}
.chart-val {
  font-size: 0.72rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.chart-val.is-zero {
  color: var(--muted-foreground);
  font-weight: 600;
}
.chart-track {
  width: 100%;
  height: 110px;
  display: flex;
  align-items: flex-end;
}
.chart-bar {
  width: 100%;
  /* 4px rounded data-end, square where it meets the baseline. */
  border-radius: 4px 4px 2px 2px;
  background: var(--brand-gradient);
  transition:
    height 0.5s var(--ease-out),
    filter 0.2s var(--ease-out);
}
/* A day with nothing sent gets a flat neutral rule, not a brand-coloured
   sliver — otherwise an entirely empty week reads as seven bars of data. */
.chart-bar.is-zero {
  background: color-mix(in oklab, var(--muted-foreground) 30%, transparent);
  border-radius: 2px;
}
.chart-col:hover .chart-bar:not(.is-zero) {
  filter: brightness(1.08);
}
.chart-day {
  font-size: 0.66rem;
  color: var(--muted-foreground);
  white-space: nowrap;
}
.chart-empty {
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted-foreground);
  margin: 0.75rem 0 0;
}

/* ---- status breakdown ---- */
.breakdown {
  margin-top: 1.1rem;
  padding-top: 0.9rem;
  border-top: 1px solid color-mix(in oklab, var(--border) 70%, transparent);
}
.breakdown-bar {
  display: flex;
  /* 2px of surface between segments, so adjacent fills stay separable
     without relying on the colours differing enough. */
  gap: 2px;
  height: 10px;
  margin-bottom: 0.6rem;
}
.breakdown-bar .seg {
  min-width: 3px;
  border-radius: 3px;
}
.seg-sent,
.dot-sent {
  background: var(--brand-green);
}
.seg-pending,
.dot-pending {
  background: var(--brand-blue);
}
.seg-failed,
.dot-failed {
  background: var(--destructive);
}
.seg-skipped,
.dot-skipped {
  background: color-mix(in oklab, var(--muted-foreground) 55%, transparent);
}
.breakdown-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  color: var(--muted-foreground);
}
.legend-item b {
  color: var(--foreground);
  font-weight: 900;
}
.dot {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  display: inline-block;
}

/* ---- template download call-out ---- */
.template-cta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 0.95rem;
  flex-wrap: wrap;
}
.template-cta .bubble {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: color-mix(in oklab, var(--brand-green) 14%, transparent);
  color: var(--brand-green);
  flex-shrink: 0;
}
.template-cta .grow {
  flex: 1;
  min-width: 12rem;
}
.template-cta .title {
  margin: 0 0 0.1rem;
  font-size: 0.82rem;
  font-weight: 700;
}
.template-cta .sub {
  margin: 0;
  font-size: 0.72rem;
  color: var(--muted-foreground);
  line-height: 1.6;
}

@media (max-width: 520px) {
  .hero-value {
    font-size: 2.1rem;
  }
  .hero-cta {
    width: 100%;
    justify-content: center;
  }
  .chart-track {
    height: 84px;
  }
}
