:root {
  --bg: #f3f5f8; --card: #fff; --ink: #18202b; --muted: #5f6b7d; --line: #dfe4ec;
  --accent: #1f6feb; --accent-ink: #fff; --ok: #1a7f4b; --warn: #a15c00; --bad: #c5303b;
  --okbg: #e6f5ec; --badbg: #fde8ea; --hover: #f6f8fb;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c; --card: #1b212a; --ink: #e7ecf3; --muted: #9aa6b8; --line: #2c3542;
    --accent: #4c8dff; --accent-ink: #0b1220; --ok: #5fd08f; --warn: #f0b354; --bad: #ff7b85;
    --okbg: #16301f; --badbg: #3a1a1e; --hover: #222a35;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 "Segoe UI", system-ui, -apple-system, sans-serif; }
a { color: var(--accent); }
h1 { font-size: 24px; margin: 0 0 8px; }
h2 { font-size: 17px; margin: 0 0 6px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.warn-text { color: var(--warn); }

.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 24px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; color: var(--ink); text-decoration: none; }
.logo { width: 22px; height: 22px; border-radius: 6px; background: linear-gradient(135deg, var(--accent), #7b5cff); }
.nav { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.nav a { color: var(--ink); text-decoration: none; font-weight: 500; }
.nav a:hover { color: var(--accent); }

main { margin: 0 auto; padding: 8px 16px 48px; }
main.narrow { max-width: 440px; margin-top: 4vh; }
main.wide { max-width: 980px; }
.org { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 6px 0 14px; flex-wrap: wrap; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 22px; margin-bottom: 18px; }
.note { padding: 10px 14px; border-radius: 10px; font-size: 14px; }
.note.ok { background: var(--okbg); color: var(--ok); }
.note.bad { background: var(--badbg); color: var(--bad); }
.empty { padding: 22px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 12px; }

input, select, button, .button { font: inherit; color: inherit; }
input, select { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg); min-width: 0; }
input:focus, select:focus, button:focus-visible, .button:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button, .button { display: inline-block; padding: 10px 16px; border: 1px solid var(--line); border-radius: 9px; background: var(--card); cursor: pointer; white-space: nowrap; text-decoration: none; text-align: center; }
button:hover, .button:hover { border-color: var(--accent); }
.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.danger { color: var(--bad); border-color: var(--bad); background: transparent; }
button.link { border: 0; background: none; padding: 0; color: var(--ink); font-weight: 500; }
button.link:hover { color: var(--accent); }
form.inline { display: inline; margin: 0; }

.stack { display: flex; flex-direction: column; gap: 14px; margin: 14px 0; }
.stack label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; }
.stack label small { font-weight: 400; }
.stack label.check { flex-direction: row; align-items: flex-start; gap: 10px; font-weight: 400; }
.stack label.check input { width: auto; margin-top: 3px; }
.row-form { display: flex; gap: 10px; align-items: center; margin: 8px 0; }
.links { margin-top: 16px; font-size: 14px; text-align: center; }
.or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; margin: 16px 0; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.button.google { display: block; width: 100%; font-weight: 600; }

.table { background: var(--card); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 18px; }
.row { display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.grow { flex: 1; min-width: 0; }
.name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.sub { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.on { background: var(--ok); }
.tag { font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 99px; background: var(--okbg); color: var(--ok); }

.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; padding: 7px 12px; border: 1px solid var(--line); border-radius: 9px; font-size: 14px; user-select: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu[open] summary { border-color: var(--accent); }
.menu .pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 5; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; width: min(340px, 86vw); box-shadow: 0 10px 30px rgba(0,0,0,.15); display: flex; flex-direction: column; gap: 8px; }
.menu .pop form { margin: 0; }
.menu .pop .row-form { margin: 0; }
.menu .pop .danger { width: 100%; }

/* Registro de actividad */
.row.audit .when { flex: none; width: 128px; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) { .row.audit .when { width: 100%; } }

/* Plan y facturación */
.note.warn { background: #fff3dc; color: #8a4f00; }
@media (prefers-color-scheme: dark) { .note.warn { background: #33270f; color: var(--warn); } }
.banner a { color: inherit; font-weight: 600; }
.plan-now { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.plan-name { font-size: 22px; font-weight: 700; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.badge { font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 99px; background: var(--hover); color: var(--muted); }
.badge.active { background: var(--okbg); color: var(--ok); }
.badge.trialing { background: #e3edff; color: #1f4fa3; }
.badge.past_due, .badge.canceled { background: var(--badbg); color: var(--bad); }
@media (prefers-color-scheme: dark) { .badge.trialing { background: #1a2a48; color: #8fb4ff; } }
.usage { display: flex; gap: 28px; margin-top: 16px; flex-wrap: wrap; }
.usage div { display: flex; flex-direction: column; }
.usage .n { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.usage .l { font-size: 13px; color: var(--muted); }
.plans { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; margin-bottom: 14px; }
.plan { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px; display: flex; flex-direction: column; }
.plan.current { border-color: var(--accent); }
.plan h3 { margin: 0 0 6px; font-size: 18px; }
.plan .amount { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 6px; }
.plan .amount span { font-size: 14px; font-weight: 400; color: var(--muted); }
.plan ul { padding-left: 18px; margin: 4px 0 16px; flex: 1; }
.plan form button { width: 100%; }
.plan .tag { align-self: flex-start; }

/* Banner de modo soporte y administración */
.imp { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; padding: 8px 16px; background: #a15c00; color: #fff; font-size: 14px; }
.imp button { padding: 4px 12px; background: #fff; color: #5a3300; border: 0; font-weight: 600; }
.nav a.admin-link { color: var(--accent); }
.subnav { display: flex; gap: 6px; margin: 4px 0 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.subnav a { padding: 8px 14px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.subnav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; display: flex; flex-direction: column; }
.stat .n { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-size: 13px; }
.link-row { color: inherit; text-decoration: none; }
.link-row:hover { background: var(--hover); }
.link-row.archived { opacity: .6; }
.nums { display: flex; flex-direction: column; align-items: flex-end; font-size: 13px; color: var(--muted); white-space: nowrap; }
.price { font-weight: 700; font-size: 18px; white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
.price small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.tag.muted-tag { background: var(--hover); color: var(--muted); }
.tag.warn-tag { background: #fff3dc; color: #8a4f00; }
@media (prefers-color-scheme: dark) { .tag.warn-tag { background: #33270f; color: var(--warn); } }
code { font-family: ui-monospace, Consolas, monospace; font-size: 13px; background: var(--hover); padding: 2px 6px; border-radius: 6px; overflow-wrap: anywhere; }
.spaced { margin-top: 18px; }
.search { margin: 0; }
.search input { width: 260px; }
.head form { margin: 0; }

@media (max-width: 640px) {
  .stats, .grid3 { grid-template-columns: 1fr; }
  .search input { width: 100%; }
  .top { padding: 12px 16px; }
  .row-form { flex-direction: column; align-items: stretch; }
  .row { flex-wrap: wrap; }
}
