/* Sign-in, account and admin pages. Colours, radius and fonts come from the
 * shared tweakcn tokens (https://cowbloke.com/theme/tweakcn.css); only the
 * cowbloke accent palette is defined here. */

:root {
  --ink: #17130f;
  --coral: #ff6b6b;
  --amber: #ffc844;
  --teal: #4ecdc4;
  --violet: #b69cff;
  --blue: #69a7ff;
  --green: #72d39a;
  --ok: oklch(0.72 0.14 155);
  --warn: oklch(0.8 0.14 80);
  --surface: color-mix(in oklch, var(--card) 92%, transparent);
  --hairline: color-mix(in oklch, var(--border) 80%, transparent);
  --soft: color-mix(in oklch, var(--foreground) 5%, transparent);
  --r: calc(var(--radius) + 4px);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  color: var(--foreground);
  background: var(--background);
  font: 500 15px/1.5 "DM Sans", var(--font-sans);
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(circle at 8% 0%, rgba(255, 200, 68, .10), transparent 32%),
    radial-gradient(circle at 96% 8%, rgba(255, 107, 107, .09), transparent 34%),
    radial-gradient(circle at 85% 100%, rgba(78, 205, 196, .08), transparent 36%);
}

a { color: inherit; text-underline-offset: 3px; }
a:hover { color: var(--foreground); }
code { font-family: var(--font-mono); font-size: .88em; }
h1, h2, h3 { margin: 0; letter-spacing: -.02em; line-height: 1.15; }
h1 { font: 700 clamp(1.7rem, 4vw, 2.2rem)/1.05 "Space Grotesk", var(--font-sans); letter-spacing: -.04em; }
h2 { font-size: 1.05rem; font-weight: 700; }
h3 { font-size: .92rem; font-weight: 700; }
p { margin: 0; }
svg { flex: none; }

.muted { color: var(--muted-foreground); }
.small { font-size: .84rem; }
.eyebrow {
  margin-bottom: 6px;
  color: var(--muted-foreground);
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.dot { color: var(--coral); }

/* ---- layout ------------------------------------------------------------- */

.shell {
  width: min(100%, var(--w, 1080px));
  margin: 0 auto;
  padding: clamp(20px, 4vw, 40px) clamp(14px, 4vw, 28px) max(48px, env(safe-area-inset-bottom));
}
.shell-narrow { --w: 460px; padding-top: clamp(28px, 9vh, 90px); }
.shell-medium { --w: 760px; }
.shell-wide { --w: 1080px; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: calc(var(--r) + 6px);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 12px 32px -18px rgba(0, 0, 0, .35);
}
.section { padding: clamp(18px, 3vw, 26px); margin-bottom: 16px; display: grid; gap: 16px; }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.section-head p { margin-top: 3px; }

.split { display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---- auth card ---------------------------------------------------------- */

.auth-card { padding: clamp(22px, 5vw, 34px); display: grid; gap: 18px; }
.auth-head { display: grid; gap: 4px; }
.auth-head h1 { font-size: clamp(1.9rem, 6vw, 2.4rem); }
.auth-head .eyebrow { text-transform: none; letter-spacing: 0; font-family: "Space Grotesk", var(--font-sans); font-size: .95rem; color: var(--foreground); }
.auth-head .muted { margin-top: 6px; }
.auth-foot { color: var(--muted-foreground); font-size: .9rem; text-align: center; }
.auth-foot a { color: var(--foreground); font-weight: 700; }
.hint { text-align: left; }
.hint summary { cursor: pointer; text-align: center; }
.hint p { margin-top: 8px; }

/* ---- forms -------------------------------------------------------------- */

.form { display: grid; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); align-items: start; gap: 14px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; grid-column: 1 / -1; }
.field { display: grid; gap: 6px; }
.field > span:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .84rem;
  font-weight: 700;
}
.field small { color: var(--muted-foreground); font-size: .8rem; }

input:not([type=checkbox]):not([type=hidden]),
select {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  color: var(--foreground);
  background: var(--background);
  border: 1px solid var(--input);
  border-radius: var(--r);
  font: inherit;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: color-mix(in oklch, var(--muted-foreground) 70%, transparent); }
input:focus-visible,
select:focus-visible {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--ring) 30%, transparent);
}
.code-input { max-width: 11ch; font-family: var(--font-mono) !important; font-size: 1.1rem !important; letter-spacing: .18em; text-align: center; }
.auth-card .code-input { max-width: none; font-size: 1.5rem !important; }

.inline-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inline-form input,
.inline-form select { flex: 1 1 180px; width: auto; }
.inline-form .code-input { flex: 0 0 11ch; }

/* ---- buttons ------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  padding: 8px 15px;
  color: var(--foreground);
  background: var(--soft);
  border: 1px solid var(--hairline);
  border-radius: var(--r);
  font: 700 .9rem/1 "DM Sans", var(--font-sans);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { background: color-mix(in oklch, var(--foreground) 10%, transparent); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .icon-btn:focus-visible, .tab:focus-visible, .switch:focus-visible, .chip:focus-within {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.btn-primary { color: var(--primary-foreground); background: var(--primary); border-color: transparent; }
.btn-primary:hover { background: color-mix(in oklch, var(--primary) 88%, var(--foreground)); color: var(--primary-foreground); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-danger { color: #fff; background: var(--destructive); border-color: transparent; }
.btn-danger:hover { background: color-mix(in oklch, var(--destructive) 85%, black); color: #fff; }
.btn-danger-ghost { color: var(--destructive); background: transparent; }
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: .84rem; }
.btn-block { width: 100%; min-height: 46px; font-size: .98rem; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-left: auto;
  color: var(--muted-foreground);
  background: transparent;
  border: 0;
  border-radius: 999px;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}
.icon-btn:hover { color: var(--foreground); background: var(--soft); }
.link-btn { padding: 0; color: var(--muted-foreground); background: none; border: 0; font: inherit; font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* ---- feedback ----------------------------------------------------------- */

.alert { padding: 11px 14px; border-radius: var(--r); border: 1px solid; font-weight: 600; font-size: .92rem; }
.alert-error { color: var(--foreground); background: color-mix(in oklch, var(--destructive) 16%, transparent); border-color: color-mix(in oklch, var(--destructive) 45%, transparent); }
.alert-warn { margin-bottom: 16px; background: color-mix(in oklch, var(--warn) 18%, transparent); border-color: color-mix(in oklch, var(--warn) 50%, transparent); }

.toasts {
  position: fixed;
  z-index: 60;
  right: 16px;
  bottom: max(16px, env(safe-area-inset-bottom));
  display: grid;
  gap: 8px;
  width: min(380px, calc(100vw - 32px));
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 12px 12px 16px;
  color: var(--popover-foreground);
  background: var(--popover);
  border: 1px solid var(--hairline);
  border-left: 4px solid var(--ok);
  border-radius: var(--r);
  box-shadow: 0 18px 40px -16px rgba(0, 0, 0, .45);
  font-size: .9rem;
  font-weight: 600;
  animation: toast-in .22s ease-out;
  transition: opacity .2s, transform .2s;
}
.toast span { flex: 1; }
.toast-error { border-left-color: var(--destructive); }
.toast.is-leaving { opacity: 0; transform: translateY(6px); }
.toast-close { padding: 0 4px; color: var(--muted-foreground); background: none; border: 0; font-size: 1.2rem; line-height: 1; cursor: pointer; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---- badges, chips, avatars ---------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  color: var(--muted-foreground);
  background: var(--soft);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .02em;
  white-space: nowrap;
}
.badge-accent { color: var(--ink); background: var(--amber); border-color: transparent; }
.badge-ok { color: var(--ink); background: var(--green); border-color: transparent; }
.badge-danger { color: #fff; background: var(--destructive); border-color: transparent; }

.avatar {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 12px;
  font: 700 1rem/1 "Space Grotesk", var(--font-sans);
  box-shadow: 2px 2px 0 var(--ink);
}
.avatar-0 { background: var(--amber); }
.avatar-1 { background: var(--coral); }
.avatar-2 { background: var(--teal); }
.avatar-3 { background: var(--violet); }
.avatar-4 { background: var(--blue); }
.avatar-5 { background: var(--green); }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 6px 12px;
  background: var(--soft);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  font-size: .85rem;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  transition: background .15s, border-color .15s, color .15s;
}
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip-mark { display: none; }
.chip-mark svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.chip:has(input:checked) { color: var(--ink); background: var(--amber); border-color: var(--ink); }
.chip:has(input:checked) .chip-mark { display: inline-flex; }
.chip-paused { opacity: .6; }
.chip-static { min-height: 26px; padding: 2px 10px; font-size: .76rem; cursor: default; }

/* ---- tabs --------------------------------------------------------------- */

.tabs {
  display: flex;
  gap: 4px;
  width: max-content;
  max-width: 100%;
  margin-bottom: 18px;
  padding: 4px;
  overflow-x: auto;
  background: var(--soft);
  border: 1px solid var(--hairline);
  border-radius: calc(var(--r) + 4px);
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  color: var(--muted-foreground);
  background: transparent;
  border: 0;
  border-radius: var(--r);
  font: 700 .92rem/1 "DM Sans", var(--font-sans);
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { color: var(--foreground); }
.tab[aria-selected="true"] { color: var(--foreground); background: var(--card); box-shadow: 0 1px 3px rgba(0, 0, 0, .18); }
.tab-count { padding: 2px 7px; background: var(--soft); border-radius: 999px; font-size: .74rem; }
.tab-count-alert { color: #fff; background: var(--coral); }

/* ---- toolbar + lists ------------------------------------------------------ */

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar > .muted { flex: 1 1 280px; font-size: .9rem; }
.search { position: relative; flex: 1 1 260px; max-width: 380px; }
.search svg { position: absolute; left: 12px; top: 50%; width: 17px; height: 17px; transform: translateY(-50%); fill: none; stroke: var(--muted-foreground); stroke-width: 2; stroke-linecap: round; }
.search input { padding-left: 38px !important; }

.list {
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: calc(var(--r) + 6px);
}
.row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px 16px;
  padding: 14px 18px;
}
.row + .row, .row + dialog + .row { border-top: 1px solid var(--hairline); }
.row.is-muted .row-main, .row.is-muted .avatar { opacity: .55; }
.row-main { min-width: 0; }
.row-title { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.row-title strong { font-size: 1rem; }
.row-meta { margin-top: 2px; overflow: hidden; color: var(--muted-foreground); font-size: .84rem; text-overflow: ellipsis; white-space: nowrap; }
.row-meta a { text-decoration: none; }
.row-meta a:hover { text-decoration: underline; }
.row-chips { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; max-width: 420px; }
.row-stat { color: var(--muted-foreground); font-size: .84rem; font-weight: 600; white-space: nowrap; }

.person { grid-template-columns: auto minmax(0, 1fr) auto auto; }
.service { grid-template-columns: auto minmax(0, 1fr) auto auto auto; }
.request { grid-template-columns: auto minmax(0, 1fr); }
.request-form { grid-column: 2 / -1; display: grid; gap: 12px; }
.request-form .button-row { justify-content: flex-end; }
.request-form > .btn { justify-self: end; }
.feedback { grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; }
.feedback-message { margin: 6px 0 4px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }

.empty { padding: 26px; color: var(--muted-foreground); text-align: center; }
.empty-state { display: grid; justify-items: center; gap: 6px; padding: 48px 20px; text-align: center; }
.empty-state svg { width: 38px; height: 38px; margin-bottom: 4px; fill: none; stroke: var(--muted-foreground); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.switch {
  position: relative;
  width: 44px;
  height: 26px;
  padding: 0;
  background: color-mix(in oklch, var(--foreground) 18%, transparent);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: background .18s;
}
.switch span {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
  transition: transform .18s;
}
.switch[aria-checked="true"] { background: var(--ok); }
.switch[aria-checked="true"] span { transform: translateX(18px); }

/* ---- dialogs ------------------------------------------------------------ */

.dialog {
  width: min(560px, calc(100vw - 24px));
  max-height: min(88dvh, 820px);
  padding: 0;
  color: var(--foreground);
  background: var(--popover);
  border: 1px solid var(--hairline);
  border-radius: calc(var(--r) + 8px);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .6);
}
.dialog[open] { animation: dialog-in .18s ease-out; }
.dialog::backdrop { background: rgba(10, 8, 6, .55); backdrop-filter: blur(3px); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.dialog-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px 14px;
  background: var(--popover);
  border-bottom: 1px solid var(--hairline);
}
.dialog-head h2 { font-size: 1.2rem; }
.dialog-body { padding: 18px 20px 20px; }
.dialog-section { display: grid; gap: 10px; padding: 16px 20px; }
.dialog-section + .dialog-section { border-top: 1px solid var(--hairline); }
.dialog-danger { background: color-mix(in oklch, var(--destructive) 7%, transparent); border-top: 1px solid var(--hairline); }

/* ---- account -------------------------------------------------------------- */

.steps { display: grid; gap: 20px; margin: 0; padding: 0; list-style: none; counter-reset: step; }
.steps > li { position: relative; display: grid; gap: 8px; padding-left: 42px; counter-increment: step; }
.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: -2px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  color: var(--ink);
  background: var(--amber);
  border: 2px solid var(--ink);
  border-radius: 9px;
  font-weight: 700;
  font-size: .85rem;
}
.qr-wrap { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; margin-top: 4px; }
.qr { width: 180px; padding: 10px; background: #fff; border-radius: var(--r); }
.qr svg { display: block; width: 100%; height: auto; }
.qr-manual { display: grid; justify-items: start; gap: 8px; }
.secret { padding: 8px 10px; background: var(--soft); border-radius: var(--r); font-size: .95rem; letter-spacing: .06em; word-break: break-all; }
.only-mobile { display: none; }
@media (hover: none) and (pointer: coarse) { .only-mobile { display: inline-flex; } }

.facts { display: flex; gap: 28px; margin: 0; }
.facts dt { color: var(--muted-foreground); font-size: .8rem; font-weight: 700; }
.facts dd { margin: 2px 0 0; font-size: 1.05rem; font-weight: 700; }

.recovery-codes {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px 18px;
  margin: 0;
  padding: 16px 16px 16px 40px;
  background: var(--soft);
  border-radius: var(--r);
  font-size: 1.02rem;
}
.recovery-codes code { letter-spacing: .06em; }

/* ---- small screens ---------------------------------------------------------- */

@media (max-width: 720px) {
  .page-head { align-items: flex-start; flex-direction: column; }
  .row, .person, .service { grid-template-columns: auto minmax(0, 1fr) auto; }
  .row-chips { grid-column: 2 / -1; grid-row: 2; justify-content: flex-start; }
  .person > .btn { grid-column: 3; grid-row: 1; }
  .service { grid-template-columns: auto minmax(0, 1fr) auto auto; }
  .service .row-stat { display: none; }
  .feedback { grid-template-columns: auto minmax(0, 1fr); }
  .feedback > form { grid-column: 2; }
  .search { max-width: none; }
  .tabs { width: 100%; }
  .tab { flex: 1; justify-content: center; padding: 8px 10px; }
  .toolbar .btn-primary { flex: 1 1 auto; }
  .recovery-codes { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
