/* Trobbu Link — tokens de marca: azul marino + dorado del ícono */
:root {
  --navy-950: #060e1b;
  --navy-900: #0a1628;
  --navy-800: #11213a;
  --navy-700: #1b3150;
  --gold-500: #c4963a;
  --gold-400: #d6ac55;
  --gold-600: #9e7522;
  --gold-100: #f6ecd7;
  --paper: #f4f5f7;
  --surface: #ffffff;
  --line: #dfe3ea;
  --ink: #0a1628;
  --ink-2: #4a5568;
  --ink-3: #6b7689;
  --ok: #1d7a4d;
  --danger: #b3261e;
  --danger-bg: #fdeceb;
  --radius: 12px;
  --font: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "Cascadia Code", Menlo, monospace;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.5;
  color: var(--ink); background: var(--paper);
}
img { max-width: 100%; display: block; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { line-height: 1.2; text-wrap: balance; margin: 0; }
a { color: inherit; }

:focus-visible { outline: 3px solid var(--gold-500); outline-offset: 2px; border-radius: 6px; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 44px; padding: 0 1.25rem; border-radius: 10px; border: 1px solid transparent;
  font-weight: 700; text-decoration: none; transition: background-color .15s, border-color .15s, transform .1s;
}
.btn:active { transform: translateY(1px); }
.btn-gold { background: var(--gold-500); color: var(--navy-900); }
.btn-gold:hover { background: var(--gold-400); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { background: var(--paper); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #8f1d17; }
.btn[disabled] { opacity: .6; cursor: progress; }

.icon-btn {
  display: inline-grid; place-items: center; min-width: 44px; min-height: 44px; padding: 0;
  background: transparent; border: 0; border-radius: 10px; color: var(--ink-2);
  transition: background-color .15s, color .15s;
}
.icon-btn:hover { background: var(--paper); color: var(--ink); }
.icon-btn svg, .btn svg { width: 20px; height: 20px; flex: none; }

/* ---------- campos ---------- */
.field { display: grid; gap: .4rem; }
.field > label { font-weight: 700; font-size: .9rem; }
.field .hint { font-size: .85rem; color: var(--ink-3); min-height: 1.3em; }
.field .hint.err { color: var(--danger); }
.field .hint.ok { color: var(--ok); }
.input {
  width: 100%; min-height: 48px; padding: 0 .9rem; background: var(--surface);
  color: var(--ink); caret-color: var(--ink);
  border: 1.5px solid var(--line); border-radius: 10px; transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--ink-3); opacity: 1; }
.input:hover { border-color: #c3cad6; }
.input:focus { outline: none; border-color: var(--gold-500); box-shadow: 0 0 0 3px rgba(196, 150, 58, .25); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.prefixed { display: flex; align-items: center; gap: .5rem; }
.prefixed .pre { flex: none; color: var(--ink-3); white-space: nowrap; user-select: none; font-size: .95rem; cursor: text; }
.prefixed .input { flex: 1; min-width: 0; }
.prefixed.invalid .input { border-color: var(--danger); }
.create .prefixed .pre { color: #9fb0c9; }

/* ---------- login ---------- */
.login-page {
  min-height: 100dvh; display: grid; place-items: center; padding: 1.5rem;
  background:
    radial-gradient(60rem 40rem at 85% -10%, rgba(196, 150, 58, .22), transparent 60%),
    var(--navy-900);
}
.login-card { width: min(100%, 400px); display: grid; gap: 1.75rem; }
.login-card .logo { width: 120px; height: auto; aspect-ratio: 300 / 199; margin-inline: auto; }
.login-panel { background: var(--surface); border-radius: 16px; padding: 1.75rem; display: grid; gap: 1.1rem; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.login-panel h1 { font-size: 1.4rem; }
.login-panel p { margin: 0; color: var(--ink-2); font-size: .95rem; }
.login-foot { text-align: center; color: #8ea0bb; font-size: .85rem; }
.form-error { background: var(--danger-bg); color: var(--danger); border-radius: 10px; padding: .7rem .9rem; font-size: .92rem; font-weight: 600; }

/* ---------- app ---------- */
.topbar { background: var(--navy-900); color: #fff; position: sticky; top: 0; z-index: 5; }
.topbar-in { max-width: 1080px; margin: 0 auto; padding: .6rem 1.25rem; display: flex; align-items: center; gap: 1rem; }
.topbar .logo { height: 40px; width: auto; }
.topbar .spacer { flex: 1; }
.topbar .who { color: #9fb0c9; font-size: .9rem; }
.topbar .icon-btn { color: #c9d4e6; }
.topbar .icon-btn:hover { background: var(--navy-700); color: #fff; }

main { max-width: 1080px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.5rem; }
.create .row > *, .stats > * { min-width: 0; }

.create { background: var(--navy-900); color: #fff; border-radius: 16px; padding: 1.75rem; display: grid; gap: 1.1rem; position: relative; overflow: hidden; }
.create::after {
  content: ""; position: absolute; right: -60px; top: -60px; width: 240px; height: 240px; pointer-events: none;
  background: url("/static/img/icon-512.png") center/contain no-repeat; opacity: .12;
}
.create h1 { font-size: 1.5rem; }
.create p { margin: .25rem 0 0; color: #9fb0c9; }
.create .field > label { color: #dbe4f3; }
.create .field .hint { color: #8ea0bb; }
.create .field .hint.err { color: #ff9c94; }
.create .field .hint.ok { color: #7fd6a4; }
.create .row { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); position: relative; z-index: 1; }
@media (min-width: 760px) { .create .row { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto; align-items: start; } .create .row .btn { margin-top: 1.7rem; } }
.create .form-error { position: relative; z-index: 1; }

.result { display: none; align-items: center; gap: .75rem; background: var(--gold-100); border: 1px solid #ead7ab; border-radius: 12px; padding: .75rem .75rem .75rem 1rem; position: relative; z-index: 1; color: var(--ink); animation: pop .35s cubic-bezier(.2, .9, .3, 1.2); }
.result.show { display: flex; }
.result .label { font-size: .8rem; color: var(--gold-600); font-weight: 700; }
.result a { font-weight: 800; font-size: 1.1rem; text-decoration: none; overflow-wrap: anywhere; }
.result a:hover { text-decoration: underline; }
.result .grow { flex: 1; min-width: 0; }
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; }
.stat b { display: block; font-size: 1.9rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { color: var(--ink-2); font-size: .9rem; }
@media (max-width: 520px) { .stat b { font-size: 1.4rem; } .stat { padding: .8rem; } .stat span { font-size: .8rem; } }

.list-head { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.list-head h2 { font-size: 1.15rem; flex: 1; }
.search { max-width: 280px; min-height: 44px; flex: 1 1 200px; }

.links { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.link { display: grid; grid-template-columns: 1fr auto; gap: .25rem 1rem; align-items: center; padding: .9rem 1.1rem; border-top: 1px solid var(--line); }
.link:first-child { border-top: 0; }
.link .main { min-width: 0; }
.link .short { display: flex; align-items: center; gap: .25rem; flex-wrap: wrap; }
.link .short a { font-weight: 800; text-decoration: none; overflow-wrap: anywhere; }
.link .short a:hover { text-decoration: underline; }
.link .dest { color: var(--ink-3); font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link .meta { color: var(--ink-3); font-size: .8rem; }
.link .count { text-align: right; font-variant-numeric: tabular-nums; }
.link .count b { font-size: 1.35rem; font-weight: 800; display: block; line-height: 1.1; }
.link .count span { font-size: .78rem; color: var(--ink-3); }
.link .actions { grid-column: 1 / -1; display: flex; gap: .25rem; flex-wrap: wrap; margin-top: .2rem; }
.link .actions .icon-btn, .link .actions .btn { min-height: 40px; min-width: 40px; }
.link.off .short a, .link.off .dest { opacity: .5; text-decoration: line-through; }
.badge { font-size: .72rem; font-weight: 700; padding: .1rem .5rem; border-radius: 99px; background: var(--paper); color: var(--ink-2); border: 1px solid var(--line); }
.badge.paused { background: #fff4e0; color: #8a5a00; border-color: #f1d9a8; }
.copy-btn[data-copied] { color: var(--ok); }
.empty { padding: 2.5rem 1.25rem; text-align: center; color: var(--ink-2); }
.empty img { width: 64px; margin: 0 auto 1rem; opacity: .9; }
.empty b { display: block; color: var(--ink); font-size: 1.05rem; margin-bottom: .25rem; }

@media (min-width: 760px) {
  .link { grid-template-columns: 1fr 90px auto; padding-block: .8rem; }
  .link .actions { grid-column: auto; margin: 0; flex-wrap: nowrap; }
}

/* ---------- diálogos ---------- */
dialog { border: 0; padding: 0; border-radius: 16px; width: min(94vw, 640px); max-height: 92dvh; background: var(--surface); color: var(--ink); box-shadow: 0 30px 80px rgba(6, 14, 27, .45); }
dialog::backdrop { background: rgba(6, 14, 27, .6); overflow: hidden; overscroll-behavior: contain; }
dialog:modal { overscroll-behavior: contain; }
.dlg { padding: 1.4rem; display: grid; gap: 1.1rem; }
.dlg-head { display: flex; align-items: flex-start; gap: .75rem; }
.dlg-head h1 { font-size: 1.2rem; flex: 1; overflow-wrap: anywhere; }
.dlg-foot { display: flex; gap: .6rem; justify-content: flex-end; flex-wrap: wrap; }
.dlg p { margin: 0; color: var(--ink-2); }

.chart { width: 100%; height: 160px; display: block; }
.chart .bar { fill: var(--gold-500); }
.chart .bar:hover { fill: var(--navy-900); }
.chart .axis { stroke: var(--line); }
.chart text { fill: var(--ink-3); font-size: 10px; font-family: var(--font); }
.mini-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; }
.breakdowns { display: grid; gap: 1.1rem; grid-template-columns: 1fr; }
@media (min-width: 560px) { .breakdowns { grid-template-columns: 1fr 1fr; } }
.bd h3 { font-size: .9rem; margin-bottom: .5rem; }
.bd ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .45rem; }
.bd li { display: grid; grid-template-columns: 1fr auto; gap: .15rem .5rem; font-size: .88rem; }
.bd li i { grid-column: 1 / -1; height: 5px; border-radius: 3px; background: var(--paper); overflow: hidden; display: block; }
.bd li i::after { content: ""; display: block; height: 100%; width: var(--w); background: var(--navy-700); border-radius: 3px; }
.bd .none { color: var(--ink-3); font-size: .88rem; }
.recent { font-size: .85rem; border-collapse: collapse; width: 100%; }
.recent td { padding: .4rem .25rem; border-top: 1px solid var(--line); color: var(--ink-2); }
.recent td:first-child { color: var(--ink); white-space: nowrap; }
.table-wrap { overflow-x: auto; }

.toast { position: fixed; left: 50%; bottom: 1.25rem; transform: translate(-50%, 1rem); background: var(--navy-900); color: #fff; padding: .7rem 1.1rem; border-radius: 10px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; max-width: 92vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- usuarios ---------- */
.filter { max-width: 220px; min-height: 44px; flex: 0 1 220px; }
.filter[hidden] { display: none; }
.utable { width: 100%; border-collapse: collapse; font-size: .88rem; }
.utable th { text-align: left; font-weight: 700; color: var(--ink-3); padding: .4rem .5rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.utable td { padding: .55rem .5rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.utable td:first-child { font-weight: 700; }
.utable .role { margin-left: .35rem; }
.uform { display: grid; gap: .8rem; border-top: 1px solid var(--line); padding-top: 1rem; }
.uform-row { display: grid; gap: .8rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 560px) { .uform-row { grid-template-columns: 1fr 1fr; } }
.check { display: flex; align-items: center; gap: .6rem; min-height: 44px; font-size: .95rem; }
.check input { width: 20px; height: 20px; accent-color: var(--gold-500); }
.link .by { color: var(--ink-2); font-weight: 600; }
.badge.admin { background: var(--gold-100); color: var(--gold-600); border-color: #ead7ab; }
