:root {
  font-family: "DM Sans", system-ui, sans-serif;
  color: #1b1830;
  background: #f7f7fc;
  --ink: #1b1830;
  --muted: #635e77;
  --border: #e5e2ee;
  --purple: #5c3bd3;
  --purple-dark: #4928bc;
  --sidebar: #211a3d;
  --white: #fff;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
h1, h2, p, dl, dd { margin: 0; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .62; cursor: wait; }
a { color: inherit; }
:focus-visible { outline: 3px solid #8065ef; outline-offset: 3px; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.startup { margin: 3rem auto; text-align: center; color: var(--muted); }

.brand { display: inline-flex; align-items: center; gap: .7rem; color: white; font-size: 1.25rem; font-weight: 850; letter-spacing: .035em; white-space: nowrap; }
.brand-mark { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: .58rem; background: #7857f2; position: relative; }
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; border: 2px solid #fff; width: 11px; height: 12px; border-radius: 4px; transform: rotate(35deg); }
.brand-mark::before { translate: -3px 3px; }
.brand-mark::after { translate: 3px -3px; }
.link-mark { display: inline-block; position: relative; width: 1.15rem; height: 1.15rem; flex: none; }
.link-mark::before, .link-mark::after { content: ""; position: absolute; border: 1.5px solid currentColor; width: 11px; height: 7px; border-radius: 5px; transform: rotate(-42deg); }
.link-mark::before { left: 1px; top: 9px; }
.link-mark::after { left: 7px; top: 3px; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 2.6rem; padding: .54rem .87rem; border: 1px solid transparent; border-radius: .62rem; background: none; color: var(--ink); font-size: .875rem; font-weight: 680; white-space: nowrap; }
.button.primary { background: var(--purple); color: var(--white); box-shadow: 0 2px 4px #4220a12e; }
.button.primary:hover { background: var(--purple-dark); }
.button.outline { border-color: var(--border); background: var(--white); }
.button.outline:hover, .button.subtle:hover { background: #f1edfc; }
.button.danger { background: #a42941; color: var(--white); }
.button.danger:hover { background: #8e2035; }
.plus { font-size: 1.3rem; line-height: .8; font-weight: 450; }

.dashboard { display: grid; grid-template-columns: 218px minmax(0, 1fr); min-height: 100dvh; }
.sidebar { background: var(--sidebar); color: #eeeafa; padding: 1.4rem 1rem; }
.sidebar .brand { margin-left: .5rem; }
.sidebar nav { margin-top: 2.25rem; }
.nav-link { display: flex; align-items: center; gap: .65rem; padding: .72rem .82rem; border-radius: .6rem; background: #403264; color: #fff; text-decoration: none; font-size: .9rem; font-weight: 680; }
.nav-link .link-mark { color: #d6c7ff; }
.workspace { min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 66px; padding: .6rem clamp(1.25rem, 3.6vw, 3rem); background: var(--white); border-bottom: 1px solid var(--border); }
.topbar-title { color: var(--muted); font-weight: 650; font-size: .875rem; }
.content { max-width: 1400px; margin: 0 auto; padding: clamp(1.25rem, 3.6vw, 3rem); }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 1.25rem; margin-bottom: 1.65rem; }
h1 { font-size: clamp(1.8rem, 3vw, 2.55rem); letter-spacing: -.05em; line-height: 1.1; }
.page-heading p { margin-top: .6rem; line-height: 1.5; }

.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.65rem; }
.metric, .links-panel { background: var(--white); border: 1px solid var(--border); border-radius: .9rem; box-shadow: 0 2px 5px #211a3d07; }
.metric { padding: clamp(.85rem, 2vw, 1.3rem); }
.metric dt { display: flex; align-items: center; gap: .65rem; color: var(--muted); font-weight: 650; font-size: .875rem; }
.metric-icon, .row-icon { display: grid; place-items: center; width: 2.1rem; height: 2.1rem; flex: none; border-radius: .6rem; font-size: 1.1rem; font-weight: 750; }
.violet, .row-icon { background: #f0eafe; color: var(--purple-dark); }
.green { background: #e4f8ee; color: #14674c; }
.blue { background: #e9effe; color: #3455ac; }
.metric dd { font-size: clamp(1.5rem, 3vw, 2.1rem); font-weight: 800; letter-spacing: -.04em; margin-top: .45rem; overflow-wrap: anywhere; }

.links-panel { overflow: hidden; }
.table-top { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .9rem; padding: 1rem 1.25rem; }
h2 { font-size: 1.15rem; letter-spacing: -.02em; }
.table-tools { display: flex; gap: .45rem; }
.search input { max-width: 15rem; min-height: 2.6rem; font-size: .875rem; }
#refresh { width: 2.6rem; padding: 0; font-size: 1.2rem; }
table { width: 100%; border-collapse: collapse; text-align: left; }
thead { background: #faf9fd; color: var(--muted); font-size: .78rem; }
th, td { padding: .8rem .6rem; border-top: 1px solid var(--border); }
th:first-child, td:first-child { padding-left: 1.25rem; }
th:last-child, td:last-child { padding-right: 1.25rem; }
tbody th, td { font-size: .875rem; }
.link-info { display: flex; gap: .68rem; align-items: center; overflow-wrap: anywhere; }
.slug { margin-top: .25rem; color: var(--purple-dark); font: .785rem ui-monospace, monospace; }
.number, [data-visits], dd { font-variant-numeric: tabular-nums; }
.number { overflow-wrap: anywhere; }
.row-actions { display: flex; flex-wrap: wrap; gap: .2rem; }
.button.compact { min-height: 2.2rem; padding: .33rem .55rem; font-size: .78rem; }
.button.remove { color: #982c46; }
.badge { display: inline-flex; align-items: center; gap: .32rem; border-radius: 1rem; padding: .22rem .55rem; font-size: .75rem; font-weight: 700; background: #efedf5; color: #514964; }
.badge::before { content: ""; width: .42rem; height: .42rem; border-radius: 50%; background: currentColor; }
.badge.is-active { color: #116145; background: #e4f7ed; }
.empty { padding: 1.5rem 1.25rem; color: var(--muted); border-top: 1px solid var(--border); font-size: .9rem; }
.mobile-visits { display: none; }

.login-layout { display: grid; grid-template-columns: minmax(0, .88fr) minmax(0, 1fr); min-height: 100dvh; }
.login-brand { display: flex; flex-direction: column; justify-content: space-between; gap: 3rem; padding: clamp(2rem, 6vw, 6rem); color: var(--white); background: radial-gradient(ellipse at 90% 90%, #53328d, transparent 69%), var(--sidebar); }
.login-brand h1 { font-size: clamp(2.7rem, 6.8vw, 6rem); }
.login-brand-content { margin-bottom: clamp(1rem, 8vh, 6rem); }
.login-brand p { color: #e2d9fa; margin-top: 1.25rem; line-height: 1.5; max-width: 25rem; }
.login-card { display: grid; align-content: center; justify-items: center; padding: clamp(1.3rem, 4vw, 3rem); }
.login-card form { width: min(100%, 25rem); padding: clamp(1rem, 4vw, 2.15rem); border: 1px solid var(--border); border-radius: 1rem; background: var(--white); box-shadow: 0 12px 30px #211a3d0e; }
.login-card h2 { font-size: 1.55rem; }
.login-card .muted { margin: .4rem 0 1.35rem; line-height: 1.5; }
.login-card .primary { width: 100%; justify-content: space-between; margin-top: 1.15rem; }

form label { display: block; margin: .85rem 0 .3rem; font-size: .875rem; font-weight: 660; }
input, textarea { width: 100%; border: 1px solid #dcd7e8; border-radius: .55rem; padding: .6rem .7rem; color: var(--ink); background: var(--white); }
input[readonly] { background: #f5f3f9; color: var(--muted); }
textarea { resize: vertical; min-height: 4rem; }
.path-field { display: flex; align-items: center; gap: .4rem; }
.path-field span { color: var(--muted); font: 1.1rem ui-monospace, monospace; }
.field-help { color: var(--muted); font-size: .785rem; margin: .32rem 0 0; line-height: 1.45; }
.check { display: flex; align-items: center; gap: .55rem; min-height: 2rem; }
.check input { width: 1.05rem; height: 1.05rem; accent-color: var(--purple); }
.notice { color: #1f5d46; background: #e8f7ef; border-radius: .5rem; margin: .75rem 0 1rem; padding: .7rem .8rem; font-size: .885rem; line-height: 1.4; }
.notice.error { color: #8e2338; background: #fcebf0; }

dialog { width: min(100% - 1.7rem, 32rem); max-height: calc(100dvh - 1.7rem); padding: 1.25rem; border: 1px solid var(--border); border-radius: .95rem; color: var(--ink); background: var(--white); box-shadow: 0 20px 60px #1b183040; }
dialog::backdrop { background: #211a3d99; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; }
.close-dialog { min-height: 2rem; width: 2rem; padding: 0; font-size: 1.3rem; }
.close-dialog:hover { background: #f1edfc; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }
#delete-form > p { line-height: 1.5; margin-top: .65rem; overflow-wrap: anywhere; }

@media (max-width: 1050px) {
  .dashboard { grid-template-columns: 155px minmax(0, 1fr); }
  .row-actions .button { min-height: 2.35rem; }
}
@media (max-width: 820px) {
  .dashboard { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .sidebar { display: flex; align-items: center; justify-content: space-between; padding: .65rem 1rem; }
  .sidebar .brand, .sidebar nav { margin: 0; }
  .nav-link { padding: .53rem .65rem; }
  .topbar { min-height: 3rem; padding-block: .15rem; }
}
@media (max-width: 610px) {
  .button { min-height: 2.75rem; }
  .page-heading { align-items: flex-start; flex-direction: column; gap: .9rem; }
  .metrics { gap: .4rem; }
  .metric { padding: .65rem .45rem; }
  .metric dt { flex-direction: column; align-items: flex-start; gap: .3rem; font-size: .75rem; }
  .table-top { padding-inline: .85rem; }
  .table-tools { flex: 1 1 auto; justify-content: flex-end; }
  .search { flex: 0 1 15rem; min-width: 0; }
  table, tbody { display: block; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; padding: .85rem; gap: .55rem; border-top: 1px solid var(--border); }
  tbody th, tbody td, tbody th:first-child, tbody td:last-child { padding: 0; border: 0; }
  tbody th { grid-column: 1 / -1; }
  tbody td:nth-child(4) { color: var(--muted); font-size: .8rem; }
  tbody td:last-child { grid-column: 1 / -1; }
  .mobile-visits { display: inline; }
  .row-actions .button { min-height: 2.75rem; }
  .login-layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .login-brand { gap: 1.1rem; padding: 1.35rem; }
  .login-brand-content { margin-bottom: 0; }
  .login-brand h1 { font-size: 2rem; }
  .login-brand br { display: none; }
  .login-brand p { margin-top: .45rem; }
}
