/* Quack Rise owner panel. Same dark teal world as the extension popup;
   one system sans family, restrained accents for actions and states. */
:root {
  --bg: #041213;
  --surface: #071a1d;
  --surface-2: #0a2226;
  --line: rgba(159, 238, 224, 0.14);
  --line-strong: rgba(159, 238, 224, 0.3);
  --text: #f0fbf8;
  --muted: #9fbfbd;
  --mint: #5ff7dc;
  --emerald: #17c995;
  --on-accent: #031312;
  --danger: #ff9e94;
  --danger-bg: rgba(255, 120, 108, 0.12);
  --trial: #9fd8ff;
  --trial-bg: rgba(110, 190, 255, 0.12);
  --active-bg: rgba(23, 201, 149, 0.14);
  --expired-bg: rgba(159, 191, 189, 0.1);
  --radius: 10px;
  --focus: 0 0 0 2px var(--bg), 0 0 0 4px var(--mint);
  color-scheme: dark;
  accent-color: var(--emerald);
  scrollbar-color: rgba(159, 238, 224, 0.28) transparent;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  caret-color: var(--mint);
}

::selection { background: rgba(95, 247, 220, 0.28); color: var(--text); }

[hidden] { display: none !important; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

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

h1, h2 { margin: 0; line-height: 1.25; text-wrap: balance; }
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.0625rem; font-weight: 650; }
p { margin: 0; }

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

.icon {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
}

.brand {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 700; letter-spacing: -0.01em;
}
.brand__sub { color: var(--muted); font-weight: 500; }

/* Controls */
label, legend { font-size: 0.8125rem; font-weight: 600; color: var(--muted); }

input[type="email"], input[type="text"], input[type="search"], input[type="date"] {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  transition: border-color 160ms ease-out, box-shadow 160ms ease-out;
}
input::placeholder { color: #7f9e9c; }
input:hover { border-color: rgba(159, 238, 224, 0.45); }
input:focus-visible { outline: none; border-color: var(--mint); box-shadow: 0 0 0 3px rgba(95, 247, 220, 0.18); }
input[aria-invalid="true"] { border-color: var(--danger); }

.code-input { font-variant-numeric: tabular-nums; font-size: 1.375rem; letter-spacing: 0.3em; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 6px 14px;
  border: 1px solid var(--line-strong); border-radius: 8px;
  background: transparent; color: var(--text);
  font: inherit; font-size: 0.875rem; font-weight: 600;
  cursor: pointer;
  transition: background-color 160ms ease-out, border-color 160ms ease-out, color 160ms ease-out;
}
.btn:hover { background: rgba(95, 247, 220, 0.08); border-color: rgba(159, 238, 224, 0.5); }
.btn:focus-visible, .link:focus-visible, .segmented button:focus-visible { outline: none; box-shadow: var(--focus); }
.btn:disabled { opacity: 0.55; cursor: default; background: transparent; }

.btn--primary {
  min-height: 40px;
  background: var(--emerald); border-color: var(--emerald); color: var(--on-accent);
}
.btn--primary:hover { background: #2bd9a6; border-color: #2bd9a6; }
.btn--primary:disabled { background: var(--emerald); }

.btn--quiet { border-color: transparent; color: var(--muted); }
.btn--quiet:hover { color: var(--text); border-color: transparent; }

.btn--small { min-height: 30px; padding: 4px 10px; font-size: 0.8125rem; }
.btn--danger { color: var(--danger); border-color: rgba(255, 158, 148, 0.35); }
.btn--danger:hover { background: var(--danger-bg); border-color: rgba(255, 158, 148, 0.6); }
.btn--danger[data-confirm="1"] { background: var(--danger-bg); border-color: var(--danger); }

.link {
  padding: 2px 0; border: 0; background: none; color: var(--mint);
  font: inherit; font-size: 0.875rem; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(95, 247, 220, 0.45);
}
.link:hover { text-decoration-color: var(--mint); }
.link:disabled { color: var(--muted); text-decoration: none; cursor: default; }

.stack { display: grid; gap: 8px; }
.stack > label { margin-top: 6px; }
.stack > .btn { margin-top: 8px; }
.links { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 4px; }

.status { min-height: 1.5em; margin-top: 10px; font-size: 0.875rem; color: var(--muted); }
.status:empty { min-height: 0; margin: 0; }
.status[data-tone="error"] { color: var(--danger); }
.status[data-tone="ok"] { color: var(--mint); }

/* Sign-in */
.signin { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.signin__panel {
  width: min(400px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}
.signin__panel .brand { margin-bottom: 20px; }
.signin__panel h1 { margin-bottom: 6px; }
.signin__panel > .muted { margin-bottom: 14px; }

/* Dashboard */
.topbar {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px max(16px, calc((100vw - 1240px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(4, 18, 19, 0.94);
}
.topbar__right { display: flex; align-items: center; gap: 4px; font-size: 0.875rem; }
.topbar__right .muted { margin-right: 8px; }

.content { max-width: 1240px; margin: 0 auto; padding: 20px 16px 48px; }

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  margin: 0 0 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.summary > div { padding: 12px 16px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-right: -1px; margin-bottom: -1px; }
.summary dt { font-size: 0.75rem; color: var(--muted); }
.summary dd {
  margin: 2px 0 0; min-height: 1.75rem;
  font-size: 1.375rem; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -0.01em;
}
.summary__revenue dd { font-size: 0.875rem; font-weight: 500; color: var(--muted); padding-top: 6px; }
.summary[aria-busy="true"] dd { border-radius: 6px; background: rgba(159, 238, 224, 0.07); width: 3.5em; animation: pulse 1.2s ease-in-out infinite; }

.columns { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: start; }
@media (min-width: 1040px) { .columns { grid-template-columns: minmax(0, 1fr) 360px; } }
.side { display: grid; gap: 20px; min-width: 0; }

.panel {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.panel > h2 { margin-bottom: 6px; }
.panel > .muted { font-size: 0.875rem; margin-bottom: 4px; }
.panel__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.search { position: relative; display: block; width: 240px; max-width: 100%; }
.search .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { padding-left: 36px; min-height: 36px; }

.segmented {
  display: inline-flex; padding: 3px; gap: 2px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2);
}
.segmented button, .segmented label span {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 30px; padding: 4px 10px;
  border: 0; border-radius: 6px; background: transparent; color: var(--muted);
  font: inherit; font-size: 0.8125rem; font-weight: 600; white-space: nowrap; cursor: pointer;
  transition: background-color 160ms ease-out, color 160ms ease-out;
}
.segmented button:hover, .segmented label:hover span { color: var(--text); }
.segmented button[aria-pressed="true"], .segmented input:checked + span { background: rgba(95, 247, 220, 0.14); color: var(--text); }
.segmented label { position: relative; margin: 0; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented input:focus-visible + span { box-shadow: var(--focus); }
.segmented--wide { display: grid; grid-template-columns: repeat(4, 1fr); width: 100%; }
.segmented--wide span { width: 100%; }

.term { margin: 6px 0 0; padding: 0; border: 0; display: grid; gap: 8px; }

.table-wrap { position: relative; overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table { width: 100%; min-width: 720px; border-collapse: collapse; font-size: 0.875rem; }
th {
  padding: 8px 10px; text-align: left; white-space: nowrap;
  font-size: 0.75rem; font-weight: 600; color: var(--muted);
  border-bottom: 1px solid var(--line);
}
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(159, 238, 224, 0.03); }
td.email { min-width: 15rem; font-weight: 600; overflow-wrap: anywhere; }
td.date { white-space: nowrap; color: var(--muted); }
td.actions { white-space: nowrap; text-align: right; }
td.actions .btn + .btn { margin-left: 6px; }
.email small { display: block; font-weight: 400; color: var(--muted); font-size: 0.8125rem; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px;
  border-radius: 999px; font-size: 0.75rem; font-weight: 600; white-space: nowrap;
}
.chip--active { background: var(--active-bg); color: var(--mint); }
.chip--trial { background: var(--trial-bg); color: var(--trial); }
.chip--expired { background: var(--expired-bg); color: var(--muted); }
.chip-detail { display: block; margin-top: 3px; font-size: 0.8125rem; color: var(--muted); white-space: nowrap; }

.skeleton td span { display: block; height: 12px; border-radius: 6px; background: rgba(159, 238, 224, 0.07); animation: pulse 1.2s ease-in-out infinite; }

.empty { padding: 20px 4px 8px; color: var(--muted); font-size: 0.875rem; max-width: 60ch; }

.pager { display: flex; align-items: center; justify-content: flex-end; gap: 6px; margin-top: 12px; font-size: 0.875rem; }
.pager .muted { margin-right: auto; font-variant-numeric: tabular-nums; }

.hint { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 0.8125rem; color: var(--muted); }

.events { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 0; }
.events li { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 0.875rem; }
.events li:last-child { border-bottom: 0; }
.events time { display: block; font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.events strong { font-weight: 600; overflow-wrap: anywhere; }
.events .extra { display: block; color: var(--muted); font-size: 0.8125rem; overflow-wrap: anywhere; }
.events[aria-busy="true"] li { height: 44px; border-radius: 6px; background: rgba(159, 238, 224, 0.05); border: 0; margin-bottom: 8px; animation: pulse 1.2s ease-in-out infinite; }

@keyframes pulse { 50% { opacity: 0.45; } }

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; }
  .topbar__right .muted { display: none; }
  .search { width: 100%; }
  .filters, .segmented:not(.segmented--wide) { width: 100%; }
  .segmented:not(.segmented--wide) button { flex: 1 1 auto; padding: 4px 6px; font-size: 0.75rem; }
  .signin__panel { padding: 22px; }
}

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