@font-face { font-family: "Rubik"; src: url("fonts/Rubik.woff2") format("woff2"); font-weight: 300 900; font-display: swap; }
:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f0f2f8;
  --ink: #141826;
  --ink-2: #4a5168;
  --muted: #646b82;
  --line: #e2e5ee;
  --brand: #4338ca;
  --brand-ink: #ffffff;
  --brand-soft: #eceafd;
  --accent: #0ea5a4;
  --ok-bg: #e7f7ef; --ok-ink: #116a3d;
  --err-bg: #fdecec; --err-ink: #a12323;
  --warn-bg: #fff5e0; --warn-ink: #8a5a00;
  --bar: #4338ca;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20,24,38,.05), 0 8px 24px rgba(20,24,38,.06);
  --font: "Rubik", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e111a; --surface: #161a26; --surface-2: #1d2231; --ink: #eef0f6; --ink-2: #b7bdd0;
    --muted: #8a91a8; --line: #2a3043; --brand: #8b85ff; --brand-ink: #0e111a; --brand-soft: #24224a;
    --ok-bg: #12301f; --ok-ink: #8ee0b2; --err-bg: #3a1717; --err-ink: #ffb1b1;
    --warn-bg: #3a2c0d; --warn-ink: #ffd88a; --bar: #8b85ff;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--font);
  font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased;
  min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: clamp(1.8rem, 4vw + .6rem, 3rem); font-weight: 700; letter-spacing: -.02em; }
h2 { font-size: 1.35rem; font-weight: 600; }
h3 { font-size: 1.05rem; font-weight: 600; }
.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.break { overflow-wrap: anywhere; word-break: break-word; }

/* header */
.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.top .wrap { display: flex; align-items: center; gap: 12px; min-height: 64px; flex-wrap: wrap; }
.logo { min-height: 44px; font-weight: 700; font-size: 1.35rem; color: var(--ink); letter-spacing: -.02em; display: inline-flex; align-items: center; gap: 8px; }
.logo:hover { text-decoration: none; }
.logo-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--brand); color: var(--brand-ink); display: inline-grid; place-items: center; font-size: .9rem; }
.nav { display: flex; align-items: center; gap: 4px; margin-inline-start: auto; flex-wrap: wrap; }
.nav a, .nav button.linklike { color: var(--ink-2); padding: 10px 12px; border-radius: 10px; min-height: 44px; display: inline-flex; align-items: center; }
.nav a:hover, .nav button.linklike:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { color: var(--ink); background: var(--surface-2); }
.nav a.btn, .nav a.btn:hover { color: var(--brand-ink); background: var(--brand); padding: 0 16px; }
.nav form { margin: 0; }
button.linklike { background: none; border: 0; font: inherit; cursor: pointer; }

.lang-select { position: relative; }
.lang-select select {
  appearance: none; font: inherit; font-size: .9rem; color: var(--ink-2); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 10px; padding: 0 30px 0 12px; min-height: 44px; cursor: pointer;
}
[dir="rtl"] .lang-select select { padding: 0 12px 0 30px; }
.lang-select::after { content: "▾"; position: absolute; inset-inline-end: 11px; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--muted); font-size: .8rem; }

main { flex: 1; padding: 32px 0 56px; }
.footer { border-top: 1px solid var(--line); padding: 20px 0; color: var(--muted); font-size: .875rem; }
.footer a { display: inline-flex; align-items: center; min-height: 44px; }
.footer .wrap { display: flex; gap: 16px; flex-wrap: wrap; justify-content: space-between; align-items: center; }

/* cards & forms */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.card + .card { margin-top: 20px; }
.stack > * + * { margin-top: 16px; }
label { display: block; font-weight: 500; font-size: .92rem; margin-bottom: 6px; color: var(--ink-2); }
input[type=text], input[type=url], input[type=email], input[type=password], input[type=search], input[type=datetime-local], select.input {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 11px 14px; min-height: 46px; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, button:focus-visible, a:focus-visible { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent); }
.check { display: flex; gap: 10px; align-items: center; font-weight: 400; min-height: 44px; margin: 0; }
.check input { width: 20px; height: 20px; accent-color: var(--brand); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 600;
  background: var(--brand); color: var(--brand-ink); border: 0; border-radius: 10px; padding: 0 20px; min-height: 46px;
  cursor: pointer; white-space: nowrap; transition: filter .15s, transform .05s;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: var(--err-bg); color: var(--err-ink); }
.btn.sm { min-height: 44px; padding: 0 14px; font-size: .875rem; font-weight: 500; }
.btn.block { width: 100%; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 200px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }

.alert { border-radius: 10px; padding: 12px 16px; font-size: .95rem; }
.alert.ok { background: var(--ok-bg); color: var(--ok-ink); }
.alert.err { background: var(--err-bg); color: var(--err-ink); }
.alert.warn { background: var(--warn-bg); color: var(--warn-ink); }

/* home */
.hero { text-align: center; max-width: 760px; margin: 12px auto 28px; }
.hero p { color: var(--ink-2); font-size: 1.1rem; margin: 0; }
.hero .accent { color: var(--brand); }
.shorten { max-width: 760px; margin: 0 auto; }
.shorten .main-row { display: flex; gap: 10px; }
.shorten .main-row input { flex: 1; font-size: 1.05rem; min-height: 54px; }
.shorten .main-row .btn { min-height: 54px; padding: 0 26px; font-size: 1.02rem; }
details.opts { margin-top: 14px; }
details.opts summary { cursor: pointer; color: var(--ink-2); font-weight: 500; min-height: 44px; display: inline-flex; align-items: center; gap: 6px; list-style: none; }
details.opts summary::-webkit-details-marker { display: none; }
details.opts summary::before { content: "+"; display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: var(--surface-2); font-weight: 600; }
details.opts[open] summary::before { content: "−"; }
.prefix-input { display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); direction: ltr; }
.prefix-input span { background: var(--surface-2); color: var(--muted); padding: 0 12px; display: flex; align-items: center; font-size: .92rem; white-space: nowrap; border-inline-end: 1px solid var(--line); }
.prefix-input input { border: 0; border-radius: 0; min-width: 0; }
.prefix-input:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent); }
.prefix-input input:focus { box-shadow: none; }

.result { max-width: 760px; margin: 0 auto 20px; border: 2px solid var(--brand); }
.result-body { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.result-main { flex: 1 1 280px; min-width: 0; }
.short-link { font-size: 1.5rem; font-weight: 700; color: var(--brand); direction: ltr; display: inline-block; overflow-wrap: anywhere; }
.qr { background: #fff; padding: 8px; border-radius: 12px; border: 1px solid var(--line); line-height: 0; }
.result .row > * { flex: 1 1 140px; }
.qr img, .qr svg { width: 132px; height: 132px; display: block; image-rendering: pixelated; }

.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; max-width: 1080px; margin: 48px auto 0; }
.feature { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.feature .ico { width: 40px; height: 40px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; margin-bottom: 12px; }
.feature .ico svg { width: 22px; height: 22px; }
.feature p { color: var(--ink-2); margin: 0; font-size: .95rem; }

/* auth */
.auth { max-width: 440px; margin: 0 auto; }

/* dashboard */
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: space-between; margin-bottom: 20px; }
.page-head > a { min-height: 44px; display: inline-flex; align-items: center; }
.page-head h1 { font-size: 1.7rem; margin: 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.kpi .v { font-size: 1.7rem; font-weight: 700; letter-spacing: -.02em; }
.kpi .l { color: var(--muted); font-size: .875rem; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 14px; align-items: center; padding: 14px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.list li:first-child { border-top: 0; }
.list .info { flex: 1 1 260px; min-width: 0; }
.list .code { font-weight: 600; direction: ltr; unicode-bidi: isolate; }
.list .dest { color: var(--muted); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; direction: ltr; text-align: start; }
.list .meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: .78rem; font-weight: 500; background: var(--surface-2); color: var(--ink-2); }
.badge.off { background: var(--err-bg); color: var(--err-ink); }
.badge.lock { background: var(--warn-bg); color: var(--warn-ink); }
.badge.adm { background: var(--brand-soft); color: var(--brand); }
.clicks { font-weight: 600; min-width: 64px; text-align: end; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.toolbar input[type=search] { flex: 1 1 160px; }
.toolbar select.input { flex: 0 0 auto; width: auto; }
.pager { display: flex; gap: 8px; justify-content: center; margin-top: 18px; align-items: center; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: start; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: .82rem; }
td.ltr, td.num { white-space: nowrap; }
td.num, th.num { text-align: end; font-variant-numeric: tabular-nums; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.actions form { margin: 0; }
td .actions { flex-wrap: nowrap; }
td .btn.danger { background: transparent; border: 1px solid var(--line); }
td .btn.danger:hover { background: var(--err-bg); }
td > a:first-child { display: inline-flex; align-items: center; min-height: 44px; }

/* stats */
.chart { display: flex; align-items: flex-end; gap: 2px; height: 160px; padding-top: 8px; border-bottom: 1px solid var(--line); direction: ltr; }
.chart .b { flex: 1; display: flex; align-items: flex-end; height: 100%; position: relative; cursor: default; }
.chart .b i { display: block; width: 100%; background: var(--bar); border-radius: 4px 4px 0 0; min-height: 0; }
.chart .b.zero i { background: var(--line); height: 2px !important; border-radius: 1px; }
.chart .b:hover i { filter: brightness(1.15); }
.chart .b .tip { position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--surface); padding: 4px 8px; border-radius: 6px; font-size: .78rem; white-space: nowrap; display: none; pointer-events: none; z-index: 2; }
.chart .b:hover .tip, .chart .b:focus .tip { display: block; }
.chart .b:nth-child(-n+4) .tip { left: 0; transform: none; }
.chart .b:nth-last-child(-n+4) .tip { left: auto; right: 0; transform: none; }
.chart-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: .78rem; margin-top: 6px; direction: ltr; }
.hbars { list-style: none; padding: 0; margin: 0; }
.hbars li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; padding: 6px 0; font-size: .92rem; }
.hbars .track { grid-column: 1 / -1; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.hbars .track i { display: block; height: 100%; background: var(--bar); border-radius: 3px; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg a { padding: 0 12px; min-height: 44px; display: inline-flex; align-items: center; border-radius: 8px; color: var(--ink-2); font-size: .9rem; }
.seg a.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.seg a:hover { text-decoration: none; }

.codebox { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; direction: ltr; text-align: left; overflow-x: auto; white-space: pre; }

/* admin */
.admin-shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 24px; }
.side { display: flex; flex-direction: column; gap: 4px; }
.side a { color: var(--ink-2); padding: 0 14px; min-height: 44px; display: flex; align-items: center; gap: 10px; border-radius: 10px; }
.side a:hover { background: var(--surface); text-decoration: none; }
.side a.active { border-inline-start: 3px solid var(--brand); background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }
.side svg { width: 18px; height: 18px; flex: 0 0 auto; }
.admin-tag { font-size: .75rem; background: var(--brand); color: var(--brand-ink); padding: 2px 8px; border-radius: 999px; font-weight: 600; }

@media (max-width: 760px) {
  main { padding: 20px 0 40px; }
  .card { padding: 18px; }
  .shorten .main-row { flex-direction: column; }
  .admin-shell { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .nav a, .nav button.linklike { padding: 10px; }
  .side { flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .side a { white-space: nowrap; }
  .nav { width: 100%; margin-inline-start: 0; justify-content: flex-start; }
  .top .wrap { padding-top: 8px; padding-bottom: 8px; }
  .hide-sm { display: none; }
  .result-body { flex-direction: column; align-items: stretch; }
  .qr { align-self: center; }
  .qr img, .qr svg { width: 112px; height: 112px; }
}
