:root {
  color-scheme: dark;
  --bg: #071019;
  --surface: #0c1722;
  --surface-2: #101e2b;
  --line: #1c2b39;
  --text: #f2f6f8;
  --muted: #8393a1;
  --blue: #39a9ff;
  --violet: #8b7cff;
  --orange: #ff9850;
  --green: #42d392;
  --radius: 16px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 16px; }
button, input, select { font: inherit; }
button, a, input, select { outline-color: var(--blue); }
.shell { min-height: 100vh; display: grid; grid-template-columns: 232px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 28px 20px 22px; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: #08131d; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; background: linear-gradient(135deg, #39a9ff, #786cff); color: white; font-weight: 900; box-shadow: 0 8px 28px rgba(57,169,255,.22); }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 17px; letter-spacing: -.02em; }
.brand small { margin-top: 1px; color: var(--muted); font-size: 12px; }
nav { margin-top: 44px; display: grid; gap: 7px; }
.nav-item { display: flex; align-items: center; gap: 11px; min-height: 46px; padding: 0 12px; border-radius: 10px; color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 650; }
.nav-item:hover, .nav-item.active { background: #112333; color: var(--text); }
.nav-glyph { width: 22px; color: var(--blue); font-size: 19px; text-align: center; }
.side-foot { margin-top: auto; }
.system-state { display: flex; gap: 10px; padding: 14px 10px; border-top: 1px solid var(--line); }
.system-state > span, .live-pill > span { width: 8px; height: 8px; margin-top: 5px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 5px rgba(66,211,146,.08); }
.system-state strong, .system-state small { display: block; }
.system-state strong { font-size: 12px; }
.system-state small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.signout { display: block; margin: 8px 10px 0; color: var(--muted); font-size: 12px; text-decoration: none; }
main { width: min(1500px, 100%); margin: 0 auto; padding: 34px 38px 64px; overflow: hidden; }
.topbar, .panel-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.eyebrow { margin: 0 0 7px; color: #6f8291; font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
h1, h2 { margin: 0; letter-spacing: -.035em; }
h1 { font-size: clamp(28px, 3vw, 38px); }
h2 { font-size: 21px; }
.live-pill { display: grid; grid-template-columns: auto auto; column-gap: 9px; align-items: center; min-width: 150px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.live-pill > span { grid-row: 1 / 3; margin: 0; }
.live-pill strong { font-size: 12px; }
.live-pill small { color: var(--muted); font-size: 10px; }
.filters { margin: 28px 0 18px; display: grid; grid-template-columns: minmax(180px, 1fr) 165px 165px auto; gap: 10px; align-items: end; }
label > span { display: block; margin: 0 0 7px; color: var(--muted); font-size: 12px; font-weight: 650; }
input, select { width: 100%; height: 44px; padding: 0 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); }
input::placeholder { color: #536474; }
.button { min-height: 44px; padding: 0 17px; border: 1px solid #258de0; border-radius: 10px; background: var(--blue); color: #03111d; cursor: pointer; font-size: 13px; font-weight: 800; }
.button:hover { filter: brightness(1.08); }
.button.secondary { border-color: var(--line); background: var(--surface); color: var(--text); }
.error-banner { margin: 12px 0; padding: 13px 15px; border: 1px solid #7a3940; border-radius: 10px; background: #28151a; color: #ffb9c0; font-size: 13px; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.metric, .panel { border: 1px solid var(--line); background: linear-gradient(145deg, rgba(17,31,44,.96), rgba(10,21,31,.98)); box-shadow: 0 16px 40px rgba(0,0,0,.13); }
.metric { position: relative; min-height: 152px; padding: 20px; border-radius: var(--radius); overflow: hidden; }
.metric::after { content: ""; position: absolute; inset: auto -35px -55px auto; width: 120px; height: 120px; border-radius: 50%; background: currentColor; opacity: .055; }
.metric-head { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12px; font-weight: 700; }
.metric-head em { color: currentColor; font-size: 11px; font-style: normal; }
.metric > strong { display: block; margin-top: 22px; color: var(--text); font-size: 34px; letter-spacing: -.04em; }
.metric > small { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
.accent-blue { color: var(--blue); border-top-color: var(--blue); }
.accent-violet { color: var(--violet); border-top-color: var(--violet); }
.accent-orange { color: var(--orange); border-top-color: var(--orange); }
.accent-green { color: var(--green); border-top-color: var(--green); }
.panel { margin-top: 14px; padding: 22px; border-radius: var(--radius); }
.panel-note { color: var(--muted); font-size: 12px; }
.legend { display: flex; gap: 18px; color: var(--muted); font-size: 11px; }
.legend span::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; }
.legend-clicks::before { background: var(--blue); }
.legend-vsl::before { background: var(--orange); }
.chart-wrap { margin-top: 20px; min-height: 260px; overflow: hidden; }
#trendChart { display: block; width: 100%; height: 260px; }
.grid-line { stroke: #1b2c3a; stroke-width: 1; }
.axis-label { fill: #6f8291; font-size: 11px; }
.line-clicks, .line-vsl { fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.line-clicks { stroke: var(--blue); }
.line-vsl { stroke: var(--orange); }
.chart-area { fill: url(#clickGradient); }
.table-wrap { margin: 18px -22px -22px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 880px; }
th, td { padding: 15px 22px; border-top: 1px solid var(--line); text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { color: #718392; background: rgba(6,15,23,.36); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
td { color: #cdd6dc; font-size: 13px; }
.page-cell strong { display: block; color: var(--text); font-size: 13px; }
.page-cell small { color: var(--muted); font-size: 10px; }
.rate { color: var(--green); font-variant-numeric: tabular-nums; }
.empty { padding: 35px; color: var(--muted); text-align: center !important; }
.shortlinks-panel { scroll-margin-top: 20px; }
.link-form { margin-top: 20px; padding: 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; border: 1px solid var(--line); border-radius: 12px; background: #09141e; }
.link-form[hidden] { display: none; }
.destination, .form-actions { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }
.slug-input { display: flex; align-items: center; height: 44px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); overflow: hidden; }
.slug-input span { padding-left: 13px; color: var(--muted); font-size: 13px; }
.slug-input input { height: 42px; border: 0; background: transparent; }
.links-list { margin-top: 18px; display: grid; gap: 8px; }
.link-row { display: grid; grid-template-columns: minmax(130px,.7fr) minmax(210px,1.7fr) auto; gap: 18px; align-items: center; padding: 14px 16px; border: 1px solid var(--line); border-radius: 11px; background: rgba(8,19,29,.58); }
.link-row strong, .link-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-row strong { font-size: 13px; }
.link-row small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.link-url { color: var(--blue); font-size: 12px; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copy-button { min-height: 34px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); color: var(--text); cursor: pointer; font-size: 11px; font-weight: 700; }
.empty-card { padding: 28px; border: 1px dashed #283b4b; border-radius: 11px; color: var(--muted); text-align: center; font-size: 13px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 20; padding: 12px 16px; border: 1px solid #275f54; border-radius: 10px; background: #0d2c25; color: #b8f5dd; opacity: 0; transform: translateY(10px); pointer-events: none; transition: .2s ease; font-size: 13px; }
.toast.show { opacity: 1; transform: translateY(0); }
@media (max-width: 1050px) { .metrics { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 760px) {
  .shell { display: block; }
  .sidebar { position: static; width: auto; height: auto; padding: 16px; flex-direction: row; align-items: center; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar nav { margin: 0 0 0 auto; display: flex; }
  .nav-item { min-height: 40px; padding: 0 9px; }
  .nav-glyph, .side-foot, .brand small { display: none; }
  main { padding: 24px 15px 50px; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters label:first-child { grid-column: 1 / -1; }
  .filters .button { grid-column: 1 / -1; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metric { min-height: 138px; padding: 16px; }
  .metric > strong { font-size: 29px; }
  .panel { padding: 17px; }
  .table-wrap { margin: 16px -17px -17px; }
  .link-form { grid-template-columns: 1fr; }
  .destination, .form-actions { grid-column: auto; }
  .link-row { grid-template-columns: 1fr auto; }
  .link-url { grid-column: 1 / -1; grid-row: 2; }
}
@media (max-width: 480px) {
  .brand span:last-child { display: none; }
  .topbar { align-items: flex-start; }
  .live-pill { min-width: auto; }
  .metrics { grid-template-columns: 1fr; }
  .panel-head { align-items: flex-start; }
  .legend { display: none; }
}

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 0, #102c42 0, var(--bg) 42%); }
.login-card { width: min(440px, 100%); padding: 34px; border: 1px solid var(--line); border-radius: 20px; background: linear-gradient(145deg, rgba(17,31,44,.98), rgba(10,21,31,.99)); box-shadow: 0 28px 80px rgba(0,0,0,.32); }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 38px; }
.login-brand strong, .login-brand small { display: block; }
.login-brand small { margin-top: 2px; color: var(--muted); font-size: 12px; }
.login-card h1 { font-size: 31px; }
.login-copy { margin: 10px 0 25px; color: var(--muted); line-height: 1.55; }
.login-card form { display: grid; gap: 15px; }
.login-card .button { width: 100%; margin-top: 3px; }
.login-error { margin: 0 0 16px; padding: 12px 14px; border: 1px solid #7a3940; border-radius: 10px; background: #28151a; color: #ffb9c0; font-size: 13px; }
.login-note { display: block; margin-top: 22px; color: #637584; line-height: 1.5; text-align: center; }
