:root {
  --bg: #f6f7fb; --card: #fff; --text: #1f2333; --muted: #6b7088; --line: #e3e5ee;
  --primary: #4f46e5; --primary-dark: #3f37c9; --danger: #dc2626; --ok: #059669;
  --radius: 12px; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #11131b; --card: #1a1d29; --text: #e8e9f1; --muted: #9a9eb5; --line: #2b2f40; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.5; }
a { color: var(--primary); }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 20px; }
.center { text-align: center; padding-top: 80px; }

.topbar { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 1.25rem; text-decoration: none; color: var(--text); font-weight: 600; }
.brand b { color: var(--primary); }
#nav { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
#nav a, #nav button { padding: 6px 10px; border-radius: 8px; text-decoration: none; color: var(--text); font-size: .92rem; }
#nav a.active { background: var(--bg); color: var(--primary); }
.badge { font-size: .72rem; padding: 2px 8px; border-radius: 99px; background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.badge.admin { color: #b45309; } .badge.editor { color: var(--primary); } .badge.viewer { color: var(--muted); } .badge.user { color: var(--ok); }

main { padding: 32px 20px 60px; min-height: 70vh; outline: none; }
h1 { font-size: 1.9rem; margin: 0 0 8px; }
h2 { font-size: 1.25rem; margin: 32px 0 12px; }
.lead { color: var(--muted); margin-top: 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.narrow { max-width: 420px; margin: 0 auto; }
form .row { display: flex; gap: 10px; flex-wrap: wrap; }
label { display: block; font-size: .85rem; color: var(--muted); margin: 12px 0 4px; }
input, select { font: inherit; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); width: 100%; }
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
.check input { width: auto; }

button, .btn { font: inherit; cursor: pointer; border: 1px solid transparent; border-radius: 8px; padding: 10px 16px; background: var(--primary); color: #fff; font-weight: 500; }
button:hover { background: var(--primary-dark); }
button.ghost { background: transparent; color: var(--text); border-color: var(--line); }
button.ghost:hover { background: var(--bg); }
button.danger { background: transparent; color: var(--danger); border-color: var(--line); }
button.small { padding: 4px 10px; font-size: .85rem; }
button:disabled { opacity: .5; cursor: not-allowed; }
#nav button { background: none; border: none; cursor: pointer; font: inherit; }

.shorten { display: flex; gap: 10px; flex-wrap: wrap; }
.shorten input[type=url] { flex: 1 1 320px; }
.result { margin-top: 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.result code { font-size: 1.05rem; padding: 6px 10px; background: var(--bg); border-radius: 8px; }
.error { color: var(--danger); font-size: .9rem; min-height: 1.2em; margin: 8px 0 0; }
.muted { color: var(--muted); }

table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { text-align: left; color: var(--muted); font-weight: 500; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
td.src { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.actions { white-space: nowrap; text-align: right; }
td.actions button { margin-left: 4px; }
.table-wrap { overflow-x: auto; }
.toolbar { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar input { max-width: 280px; }
.tabs { display: flex; gap: 6px; }
.tabs button { background: transparent; color: var(--text); border-color: var(--line); }
.tabs button.on { background: var(--primary); color: #fff; }
.pager { display: flex; gap: 8px; justify-content: flex-end; align-items: center; margin-top: 12px; }
tr.editing td { background: var(--bg); }
.edit-grid { display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: 8px; align-items: end; }
@media (max-width: 720px) { .edit-grid { grid-template-columns: 1fr; } }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 99px; opacity: 0; transition: opacity .2s; pointer-events: none; }
#toast.show { opacity: .95; }
.footer { display: flex; justify-content: center; padding-bottom: 30px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 720px) { .grid2 { grid-template-columns: 1fr; } }
