:root {
    --bg: #07111f;
    --surface: #0d1a2b;
    --surface-2: #12233a;
    --line: #203653;
    --text: #edf5ff;
    --muted: #91a6bf;
    --primary: #4f8cff;
    --primary-2: #72a4ff;
    --green: #26d69b;
    --red: #ff647c;
    --amber: #f7bd56;
    --shadow: 0 18px 50px rgba(0,0,0,.24);
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 10% 0%, #112a4b 0, transparent 34%), var(--bg); color: var(--text); font: 15px/1.55 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
a { color: var(--primary-2); text-decoration: none; }
a:hover { color: #a7c5ff; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }

.topbar { height: 72px; display: flex; align-items: center; justify-content: space-between; padding: 0 max(24px, calc((100vw - 1280px)/2)); border-bottom: 1px solid rgba(255,255,255,.08); background: rgba(7,17,31,.88); backdrop-filter: blur(18px); position: sticky; top: 0; z-index: 20; }
.brand { color: var(--text); display: flex; align-items: center; gap: 12px; font-weight: 800; letter-spacing: -.02em; }
.brand:hover { color: white; }
.brand-mark, .auth-logo { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: white; font-weight: 900; background: linear-gradient(135deg, var(--primary), #7657ff); box-shadow: 0 8px 25px rgba(79,140,255,.35); }
nav { display: flex; align-items: center; gap: 5px; }
nav a { color: var(--muted); padding: 9px 13px; border-radius: 9px; font-weight: 650; }
nav a:hover, nav a.active { color: white; background: rgba(255,255,255,.07); }
.nav-toggle { display: none; border: 0; background: transparent; color: white; font-size: 24px; }

.container { width: min(1280px, calc(100% - 40px)); margin: 0 auto; padding: 38px 0 60px; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.page-heading h1, .panel h2, .auth-card h1, .link-card h3 { margin: 0; line-height: 1.2; letter-spacing: -.035em; }
.page-heading h1 { font-size: clamp(28px, 4vw, 40px); }
.panel h2 { font-size: 21px; }
.eyebrow { margin: 0 0 5px; color: var(--primary-2); font-size: 11px; font-weight: 850; letter-spacing: .16em; }
.user-chip { color: var(--muted); background: var(--surface); border: 1px solid var(--line); padding: 8px 12px; border-radius: 999px; }
.muted { color: var(--muted); }
.small-text { font-size: 12px; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
.stat, .panel, .status-strip { background: linear-gradient(145deg, rgba(18,35,58,.96), rgba(11,25,42,.96)); border: 1px solid var(--line); border-radius: 17px; box-shadow: var(--shadow); }
.stat { padding: 20px; position: relative; overflow: hidden; }
.stat::after { content: ''; position: absolute; width: 90px; height: 90px; border-radius: 50%; right: -35px; top: -35px; background: rgba(79,140,255,.13); }
.stat.success::after { background: rgba(38,214,155,.13); }
.stat.danger::after { background: rgba(255,100,124,.13); }
.stat span, .stat small { color: var(--muted); display: block; }
.stat strong { display: block; font-size: 34px; margin: 6px 0 1px; }
.stat small { font-size: 12px; }
.status-strip { display: flex; align-items: center; gap: 24px; padding: 13px 16px; margin-bottom: 18px; color: var(--muted); }
.status-strip form { margin-left: auto; }
.dot { width: 9px; height: 9px; display: inline-block; border-radius: 50%; margin-right: 8px; background: var(--muted); }
.dot.green { background: var(--green); box-shadow: 0 0 12px rgba(38,214,155,.7); }
.dot.red { background: var(--red); box-shadow: 0 0 12px rgba(255,100,124,.6); }
.dot.gray { background: #64748b; }

.content-grid { display: grid; grid-template-columns: 1.08fr .92fr; gap: 18px; align-items: start; }
.content-grid.links-layout { grid-template-columns: minmax(280px, .65fr) minmax(0, 1.35fr); }
.settings-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(300px, .7fr); gap: 18px; align-items: start; }
.panel { padding: 21px; min-width: 0; }
.sticky-panel { position: sticky; top: 92px; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.stack-list { display: grid; }
.stack-item { min-width: 0; display: flex; align-items: center; gap: 12px; padding: 13px 0; border-top: 1px solid rgba(255,255,255,.07); }
.stack-item:first-child { border-top: 0; }
.stack-item small { display: block; color: var(--muted); font-size: 12px; }
.stack-list.compact .stack-item { padding: 11px 0; }
.grow { min-width: 0; flex: 1; }
.right { text-align: right; flex-shrink: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.block { display: block; }

.status-icon { width: 34px; height: 34px; flex: 0 0 34px; border-radius: 10px; display: grid; place-items: center; font-weight: 900; background: rgba(145,166,191,.12); color: var(--muted); }
.status-icon.healthy { color: var(--green); background: rgba(38,214,155,.13); }
.status-icon.unhealthy { color: var(--red); background: rgba(255,100,124,.13); }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 9px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.badge-success { color: #58e9b7; background: rgba(38,214,155,.12); }
.badge-danger { color: #ff8295; background: rgba(255,100,124,.12); }
.badge-muted { color: #a9b8ca; background: rgba(145,166,191,.12); }

label { display: block; color: #c7d5e5; font-size: 13px; font-weight: 700; margin-bottom: 15px; }
input, select, textarea { width: 100%; color: var(--text); background: #091626; border: 1px solid #29425f; border-radius: 10px; padding: 11px 12px; outline: none; margin-top: 6px; transition: border-color .2s, box-shadow .2s; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,140,255,.15); }
textarea { resize: vertical; }
label small { color: var(--muted); display: block; font-weight: 500; margin-top: 5px; }
.check-row { display: flex; align-items: center; gap: 9px; }
.check-row input { width: 17px; height: 17px; margin: 0; }
.form-grid { display: grid; gap: 0 14px; }
.form-grid.two { grid-template-columns: 1fr 1fr; }
.span-two { grid-column: 1 / -1; }
hr { border: 0; border-top: 1px solid var(--line); margin: 23px 0; }
.button-row, .card-actions, .filter-row { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.button { display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 10px; padding: 10px 14px; color: white; background: linear-gradient(135deg, var(--primary), #6b64f4); font-weight: 800; box-shadow: 0 8px 20px rgba(79,140,255,.2); }
.button:hover { color: white; filter: brightness(1.08); }
.button:disabled { opacity: .6; cursor: wait; }
.button.small { padding: 7px 10px; font-size: 12px; border-radius: 8px; }
.button.secondary { color: #c9d8e9; background: rgba(255,255,255,.045); border-color: var(--line); box-shadow: none; }
.button.danger-button { color: #ff91a2; background: rgba(255,100,124,.08); border-color: rgba(255,100,124,.25); box-shadow: none; }
.button.full { width: 100%; }
.inline-form { display: inline-flex; margin-top: 9px; }

.link-cards { display: grid; gap: 12px; }
.link-card { min-width: 0; padding: 16px; border: 1px solid rgba(255,255,255,.08); background: rgba(5,15,27,.35); border-radius: 13px; }
.link-card-top { display: flex; align-items: flex-start; gap: 12px; }
.link-card h3 { font-size: 17px; margin: 2px 0 3px; }
.link-meta { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 13px 0 9px; }
.link-meta span { color: var(--muted); background: rgba(255,255,255,.035); padding: 7px 8px; border-radius: 8px; font-size: 11px; }
.link-meta strong { color: var(--text); display: block; font-size: 12px; }
.inline-error { color: #ff9bab; background: rgba(255,100,124,.08); border: 1px solid rgba(255,100,124,.18); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; font-size: 12px; }
.link-card > small { color: var(--muted); }
.card-actions { margin-top: 13px; }
.card-actions form { display: inline-flex; margin: 0; }

.alert { border-radius: 11px; padding: 11px 13px; margin-bottom: 16px; border: 1px solid; }
.alert-success { color: #7cebc4; border-color: rgba(38,214,155,.25); background: rgba(38,214,155,.09); }
.alert-danger { color: #ff9bad; border-color: rgba(255,100,124,.25); background: rgba(255,100,124,.09); }
.alert-info { color: #99bcff; border-color: rgba(79,140,255,.25); background: rgba(79,140,255,.09); }
.empty { text-align: center; color: var(--muted); padding: 30px 12px; }
.note { color: var(--muted); background: rgba(247,189,86,.07); border: 1px solid rgba(247,189,86,.18); border-radius: 10px; padding: 12px; margin-top: 24px; font-size: 13px; }

.filter-row { align-items: end; margin-bottom: 17px; }
.filter-row label { min-width: 190px; margin: 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 11px 10px; text-align: left; border-bottom: 1px solid rgba(255,255,255,.07); vertical-align: top; }
th { color: var(--muted); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
td { font-size: 13px; }

.auth-page { display: grid; place-items: center; padding: 28px; }
.auth-card { width: min(420px, 100%); background: linear-gradient(145deg, rgba(18,35,58,.98), rgba(10,23,39,.98)); border: 1px solid var(--line); border-radius: 20px; padding: 30px; box-shadow: 0 30px 80px rgba(0,0,0,.38); }
.auth-card.install-card { width: min(780px, 100%); }
.auth-logo { margin-bottom: 20px; }
.auth-card h1 { font-size: 30px; margin-bottom: 5px; }
.auth-card form { margin-top: 22px; }

footer { color: #667c95; text-align: center; font-size: 12px; padding: 0 20px 30px; }

@media (max-width: 980px) {
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .content-grid, .content-grid.links-layout, .settings-grid { grid-template-columns: 1fr; }
    .sticky-panel { position: static; }
}

@media (max-width: 720px) {
    .topbar { padding: 0 20px; }
    .brand span:last-child { max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .nav-toggle { display: block; }
    nav { display: none; position: absolute; top: 64px; left: 14px; right: 14px; padding: 10px; flex-direction: column; align-items: stretch; background: #0c1b2e; border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow); }
    nav.open { display: flex; }
    .container { width: min(100% - 24px, 1280px); padding-top: 25px; }
    .page-heading { align-items: flex-end; }
    .user-chip { display: none; }
    .status-strip { align-items: flex-start; flex-direction: column; gap: 10px; }
    .status-strip form { margin: 0; width: 100%; }
    .status-strip .button { width: 100%; }
    .form-grid.two, .link-meta { grid-template-columns: 1fr 1fr; }
    .panel { padding: 16px; }
}

@media (max-width: 460px) {
    .stats-grid { grid-template-columns: 1fr; }
    .form-grid.two, .link-meta { grid-template-columns: 1fr; }
    .span-two { grid-column: auto; }
    .link-card-top { flex-wrap: wrap; }
    .link-card-top .badge { margin-left: 46px; }
    .auth-page { padding: 14px; }
    .auth-card { padding: 22px; }
}
