/* dodoer console. Tokens copied from dodoer's neutral theme
   (src/app/globals.css) and its shadcn radix-maia look: pill buttons and
   inputs, rounded-2xl cards with a 10% foreground ring, neutral surfaces. */

:root {
  --background: oklch(1 0 0);
  --foreground: oklch(0.145 0 0);
  --card: oklch(1 0 0);
  --primary: oklch(0.205 0 0);
  --primary-foreground: oklch(0.985 0 0);
  --secondary: oklch(0.97 0 0);
  --muted: oklch(0.97 0 0);
  --muted-foreground: oklch(0.556 0 0);
  --accent: oklch(0.97 0 0);
  --destructive: oklch(0.58 0.22 27);
  --success: oklch(0.6 0.13 155);
  --warning: oklch(0.7 0.14 70);
  --border: oklch(0.922 0 0);
  --input: oklch(0.922 0 0);
  --ring: oklch(0.708 0 0);
  --sidebar: oklch(0.985 0 0);
  --sidebar-accent: oklch(0.94 0 0);
  --ring-card: oklch(0.145 0 0 / 10%);
  --radius: 0.625rem;
  --font-sans:
    "Inter Variable", Inter, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono:
    "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}

:root.dark {
  --background: oklch(0.145 0 0);
  --foreground: oklch(0.985 0 0);
  --card: oklch(0.205 0 0);
  --primary: oklch(0.87 0 0);
  --primary-foreground: oklch(0.205 0 0);
  --secondary: oklch(0.269 0 0);
  --muted: oklch(0.269 0 0);
  --muted-foreground: oklch(0.708 0 0);
  --accent: oklch(0.371 0 0);
  --destructive: oklch(0.704 0.191 22.216);
  --success: oklch(0.72 0.14 155);
  --warning: oklch(0.8 0.13 75);
  --border: oklch(1 0 0 / 10%);
  --input: oklch(1 0 0 / 15%);
  --ring: oklch(0.556 0 0);
  --sidebar: oklch(0.205 0 0);
  --sidebar-accent: oklch(0.28 0 0);
  --ring-card: oklch(0.985 0 0 / 10%);
  color-scheme: dark;
}

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

[hidden] {
  display: none !important;
}

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

body {
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
}

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

.mono {
  font-family: var(--font-mono);
  font-size: 12px;
}

.muted {
  color: var(--muted-foreground);
}

.small {
  font-size: 12px;
}

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

svg.icon {
  width: 16px;
  height: 16px;
  flex: none;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- controls ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: 2rem;
  border: 1px solid transparent;
  background: var(--primary);
  color: var(--primary-foreground);
  font: inherit;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  transition:
    background-color 0.15s,
    opacity 0.15s;
  user-select: none;
}
.btn:hover {
  background: color-mix(in oklch, var(--primary) 80%, transparent);
}
.btn:active {
  transform: translateY(1px);
}
.btn:focus-visible,
.input:focus-visible,
.select:focus-visible,
.nav a:focus-visible {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--ring) 50%, transparent);
}
.btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}
.btn.outline {
  background: color-mix(in oklch, var(--input) 30%, transparent);
  border-color: var(--border);
  color: var(--foreground);
}
.btn.outline:hover {
  background: color-mix(in oklch, var(--input) 50%, transparent);
}
.btn.ghost {
  background: transparent;
  color: var(--foreground);
}
.btn.ghost:hover {
  background: var(--muted);
}
.btn.danger {
  background: color-mix(in oklch, var(--destructive) 10%, transparent);
  color: var(--destructive);
}
.btn.danger:hover {
  background: color-mix(in oklch, var(--destructive) 20%, transparent);
}
.btn.sm {
  height: 32px;
  padding: 0 12px;
}
.btn.xs {
  height: 26px;
  padding: 0 10px;
  font-size: 12px;
}
.btn.icon-only {
  width: 36px;
  padding: 0;
}
.btn.block {
  width: 100%;
}

.input,
.select {
  height: 36px;
  width: 100%;
  min-width: 0;
  padding: 0 12px;
  border-radius: 2rem;
  border: 1px solid var(--input);
  background: color-mix(in oklch, var(--input) 30%, transparent);
  color: var(--foreground);
  font: inherit;
  outline: none;
}
.input::placeholder {
  color: var(--muted-foreground);
}
.input[aria-invalid="true"] {
  border-color: var(--destructive);
}
.select {
  appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.select.sm {
  height: 30px;
  width: auto;
  font-size: 13px;
}

label.field {
  display: grid;
  gap: 6px;
  font-weight: 500;
}
label.field > span.hint {
  font-weight: 400;
  color: var(--muted-foreground);
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 8px;
  border-radius: 2rem;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  background: var(--secondary);
  color: var(--foreground);
}
.badge.outline {
  background: transparent;
  border: 1px solid var(--border);
}
.badge.ok {
  background: color-mix(in oklch, var(--success) 14%, transparent);
  color: var(--success);
}
.badge.warn {
  background: color-mix(in oklch, var(--warning) 18%, transparent);
  color: color-mix(in oklch, var(--warning) 70%, var(--foreground));
}
.badge.bad {
  background: color-mix(in oklch, var(--destructive) 12%, transparent);
  color: var(--destructive);
}
.badge.strong {
  background: var(--primary);
  color: var(--primary-foreground);
}

/* ---------- surfaces ---------- */

.card {
  background: var(--card);
  border-radius: 1rem;
  box-shadow: 0 0 0 1px var(--ring-card);
  overflow: hidden;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 18px 20px 14px;
}
.card-head h2 {
  font-size: 15px;
  font-weight: 600;
}
.card-head p {
  color: var(--muted-foreground);
  margin-top: 2px;
}
.card-body {
  padding: 0 20px 20px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.stat {
  padding: 16px 18px;
}
.stat .num {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat .lbl {
  color: var(--muted-foreground);
  font-size: 12px;
}
a.stat {
  text-decoration: none;
  transition: background-color 0.15s;
}
a.stat:hover {
  background: var(--muted);
}

.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: 0.75rem;
  background: var(--muted);
  color: var(--foreground);
}
.notice .icon {
  margin-top: 2px;
  color: var(--muted-foreground);
}
.notice.warn {
  background: color-mix(in oklch, var(--warning) 14%, transparent);
}
.notice.bad {
  background: color-mix(in oklch, var(--destructive) 10%, transparent);
}

/* ---------- tables (stack into cards on phones) ---------- */

.table-wrap {
  overflow-x: auto;
}
table.data {
  width: 100%;
  border-collapse: collapse;
}
table.data th {
  text-align: left;
  font-weight: 500;
  color: var(--muted-foreground);
  font-size: 12px;
  padding: 8px 20px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data td {
  height: 47px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data tr:last-child td {
  border-bottom: 0;
}
table.data td.actions {
  text-align: right;
  white-space: nowrap;
}
table.data td.actions .row-actions {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}
.who {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.who .avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex: none;
  display: grid;
  place-items: center;
  background: var(--secondary);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
}
.who .name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.empty {
  padding: 28px 20px;
  text-align: center;
  color: var(--muted-foreground);
}

/* ---------- shell ---------- */

.shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
  /* The sidebar is sticky; this paints its column below the fold too. */
  background: linear-gradient(
    to right,
    var(--sidebar) 247px,
    var(--border) 247px 248px,
    var(--background) 248px
  );
}
.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px;
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
}
.brand .logo {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--primary);
  color: var(--primary-foreground);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
}
.brand small {
  font-weight: 500;
  color: var(--muted-foreground);
  font-size: 12px;
}
.nav {
  display: grid;
  gap: 2px;
}
.nav .group {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted-foreground);
  padding: 10px 10px 4px;
}
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  padding: 0 10px;
  border-radius: 0.6rem;
  border: 1px solid transparent;
  text-decoration: none;
  color: var(--foreground);
  white-space: nowrap;
}
.nav a:hover {
  background: var(--sidebar-accent);
}
.nav a[aria-current="page"] {
  background: var(--sidebar-accent);
  font-weight: 500;
}
.nav a .count {
  margin-left: auto;
}
.sidebar .foot {
  margin-top: auto;
  display: grid;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.me-line {
  text-decoration: none;
  border-radius: 0.6rem;
  height: 32px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  min-width: 0;
}
.me-line:hover,
.me-line[aria-current="page"] {
  background: var(--sidebar-accent);
}
.me-line .email {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  min-width: 0;
  flex: 1;
}
.theme-switch {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 2rem;
  background: var(--muted);
}
.theme-switch button {
  flex: 1;
  height: 26px;
  border: 0;
  border-radius: 2rem;
  background: transparent;
  color: var(--muted-foreground);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.theme-switch button[aria-pressed="true"] {
  background: var(--card);
  color: var(--foreground);
  box-shadow: 0 0 0 1px var(--ring-card);
}

.main {
  min-width: 0;
  padding: 28px 36px 48px;
}
.page {
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 4px;
}
.page-head h1 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.page-head .crumb {
  color: var(--muted-foreground);
  font-size: 13px;
  margin-bottom: 2px;
}
.page-head .crumb .badge {
  margin-left: 6px;
}

.topbar,
.scrim {
  display: none;
}

/* ---------- sign-in ---------- */

.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.auth-box {
  width: 100%;
  max-width: 380px;
  padding: 28px;
  display: grid;
  gap: 18px;
}
.auth-box .brand {
  justify-content: center;
  padding: 0;
  font-size: 17px;
}
.auth-box h1 {
  font-size: 20px;
  font-weight: 600;
  text-align: center;
}
.auth-box .sub {
  text-align: center;
  color: var(--muted-foreground);
  margin-top: 4px;
}
.or {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted-foreground);
  font-size: 12px;
}
.or::before,
.or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}
.stack {
  display: grid;
  gap: 12px;
}
.row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.code-input {
  letter-spacing: 0.4em;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 18px;
  height: 44px;
}
.fineprint {
  text-align: center;
  font-size: 12px;
  color: var(--muted-foreground);
}

/* ---------- forms in cards ---------- */

.form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 160px auto;
  gap: 10px;
  align-items: end;
}
.radio-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.radio-card {
  display: flex;
  gap: 10px;
  padding: 14px;
  border-radius: 0.9rem;
  border: 1px solid var(--border);
  cursor: pointer;
}
.radio-card:has(input:checked) {
  border-color: var(--foreground);
  box-shadow: 0 0 0 1px var(--foreground);
}
.radio-card input {
  margin-top: 3px;
  accent-color: var(--primary);
}
.radio-card b {
  display: block;
  font-weight: 500;
}

.kv {
  margin: 0;
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 10px 16px;
}
.kv dt {
  color: var(--muted-foreground);
}
.kv dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

/* ---------- org picker ---------- */

.org-list {
  display: grid;
  gap: 10px;
}
.org-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  text-decoration: none;
}
.org-item:hover {
  background: var(--muted);
}
.org-item .mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--secondary);
  display: grid;
  place-items: center;
  font-weight: 600;
}
.org-item .grow {
  flex: 1;
  min-width: 0;
}

/* ---------- dialog & toasts ---------- */

dialog#dialog {
  border: 0;
  padding: 0;
  border-radius: 1rem;
  background: var(--card);
  color: var(--foreground);
  box-shadow:
    0 0 0 1px var(--ring-card),
    0 20px 50px -12px rgb(0 0 0 / 0.35);
  width: min(440px, calc(100vw - 32px));
}
dialog#dialog::backdrop {
  background: rgb(0 0 0 / 0.4);
}
.dlg {
  padding: 22px;
  display: grid;
  gap: 14px;
}
.dlg h2 {
  font-size: 16px;
  font-weight: 600;
}
.dlg .actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.secret {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 10px 12px;
  border-radius: 0.6rem;
  background: var(--muted);
  overflow-wrap: anywhere;
  user-select: all;
}

#toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: grid;
  gap: 8px;
  z-index: 50;
  max-width: calc(100vw - 32px);
}
.toast {
  padding: 10px 14px;
  border-radius: 0.75rem;
  background: var(--foreground);
  color: var(--background);
  box-shadow: 0 10px 30px -10px rgb(0 0 0 / 0.4);
  font-size: 13px;
}
.toast.bad {
  background: var(--destructive);
  color: white;
}

.loading {
  padding: 60px 0;
  text-align: center;
  color: var(--muted-foreground);
}

/* ---------- phone ---------- */

@media (max-width: 860px) {
  .shell {
    display: block;
    background: var(--background);
  }
  .topbar {
    display: flex;
    align-items: center;
    gap: 8px;
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 10px 16px;
    background: color-mix(in oklch, var(--background) 88%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
  }
  .topbar .brand {
    padding: 0;
    flex: 1;
    min-width: 0;
  }
  .topbar .brand span.t {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(300px, 86vw);
    z-index: 40;
    transform: translateX(-102%);
    visibility: hidden;
    transition:
      transform 0.2s ease,
      visibility 0s linear 0.2s;
  }
  .shell.nav-open .sidebar {
    transform: none;
    visibility: visible;
    transition: transform 0.2s ease;
    box-shadow: 0 0 40px rgb(0 0 0 / 0.25);
  }
  .shell.nav-open .scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgb(0 0 0 / 0.35);
  }
  .main {
    padding: 18px 16px 40px;
  }
  .page-head h1 {
    font-size: 20px;
  }
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .form-grid {
    grid-template-columns: 1fr 1fr;
  }
  .form-grid > :first-child {
    grid-column: 1 / -1;
  }
  .radio-cards {
    grid-template-columns: 1fr;
  }
  .kv {
    grid-template-columns: 1fr;
    gap: 2px;
  }
  .kv dd {
    margin-bottom: 10px;
  }
  .card-head {
    padding: 16px 16px 12px;
  }
  .card-body {
    padding: 0 16px 16px;
  }

  /* Rows become small cards: each cell shows its column name. */
  table.data thead {
    display: none;
  }
  table.data,
  table.data tbody,
  table.data tr,
  table.data td {
    display: block;
    width: 100%;
  }
  table.data tr {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
  }
  table.data tr:last-child {
    border-bottom: 0;
  }
  table.data td {
    height: auto;
    border: 0;
    padding: 3px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    min-width: 0;
  }
  table.data td[data-label]::before {
    content: attr(data-label);
    color: var(--muted-foreground);
    font-size: 12px;
    flex: none;
  }
  table.data td.primary-cell {
    padding-bottom: 6px;
  }
  table.data td.primary-cell::before {
    display: none;
  }
  table.data td.actions {
    justify-content: flex-end;
    padding-top: 8px;
  }
  table.data td.actions:has(.row-actions:empty) {
    display: none;
  }
  table.data td.actions .row-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  table.data td > .cell-val {
    min-width: 0;
    text-align: right;
    overflow-wrap: anywhere;
  }
  table.data td.primary-cell > .cell-val {
    text-align: left;
  }
}

/* ---------- small utilities (no inline styles, so a strict CSP works) ---------- */

.full,
.select.sm.full {
  width: 100%;
}
.grow-field {
  flex: 1;
  min-width: 180px;
}
.org-pick {
  padding: 0 2px 6px;
}
table.data th.ta-right {
  text-align: right;
}
.row.badges {
  gap: 4px;
  justify-content: flex-end;
}
.row.end {
  justify-content: flex-end;
}
.more-row {
  justify-content: center;
  padding-top: 12px;
}
.plain-link {
  text-decoration: none;
}
.mt-8 {
  margin-top: 8px;
}
.stack.gap-18 {
  gap: 18px;
}
.secret.codes {
  display: grid;
  gap: 4px;
}
.sidebar .foot > .btn {
  justify-content: flex-start;
}
