:root {
  color-scheme: dark;
  --bg: #080d16;
  --surface: #111927;
  --surface-2: #162132;
  --line: #26354a;
  --text: #eef4ff;
  --muted: #91a1b8;
  --green: #4ade80;
  --green-dark: #166534;
  --blue: #60a5fa;
  --red: #fb7185;
  --amber: #fbbf24;
  --shadow: 0 20px 50px rgba(0, 0, 0, .28);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 10% 0%, rgba(34, 197, 94, .12), transparent 28rem),
    radial-gradient(circle at 90% 30%, rgba(37, 99, 235, .10), transparent 32rem),
    var(--bg);
}
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgba(96, 165, 250, .48); outline-offset: 2px; }
a { color: inherit; text-decoration: none; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: .35rem; font-size: clamp(1.75rem, 3vw, 2.35rem); letter-spacing: -.04em; }
h2 { margin-bottom: .8rem; font-size: 1.05rem; letter-spacing: -.015em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.5rem 0; }
[hidden], #login[hidden], #app[hidden], #app > section[hidden], .content-shell > section[hidden] { display: none !important; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.login-card {
  width: min(100%, 410px);
  padding: 2.2rem;
  border: 1px solid rgba(74, 222, 128, .24);
  border-radius: 24px;
  background: linear-gradient(150deg, rgba(22, 33, 50, .98), rgba(11, 18, 30, .98));
  box-shadow: var(--shadow), 0 0 0 1px rgba(255, 255, 255, .025) inset;
}
.login-card h1 { font-size: 2.6rem; }
.brand-mark {
  width: 54px; height: 54px; display: grid; place-items: center;
  margin-bottom: 1.25rem; border-radius: 15px;
  background: linear-gradient(135deg, #4ade80, #22c55e 55%, #15803d);
  color: #041008; font-weight: 950; letter-spacing: -.08em; box-shadow: 0 12px 30px rgba(34, 197, 94, .22);
}
.brand-mark.small { width: 38px; height: 38px; margin: 0; border-radius: 11px; font-size: .85rem; }
.eyebrow { margin: 0 0 .3rem; color: var(--green); font-size: .72rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.muted, .help { color: var(--muted); }
.help { margin: .2rem 0 .8rem; font-size: .84rem; line-height: 1.5; }
.warning-text { color: var(--amber); font-size: .82rem; }
.error { min-height: 1.2rem; margin: 0; color: #fda4af; font-size: .88rem; }

.topbar {
  min-height: 68px; padding: .8rem clamp(1rem, 4vw, 3rem);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  background: rgba(8, 13, 22, .84); border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px); position: sticky; top: 0; z-index: 20;
}
.brand { display: inline-flex; align-items: center; gap: .75rem; }
.brand > span:last-child { display: grid; line-height: 1.1; }
.brand strong { font-size: 1.05rem; }
.brand small { color: var(--muted); font-size: .72rem; margin-top: .2rem; }
.topbar-status { display: flex; align-items: center; gap: .7rem; }
.status-pill, .user-chip, .tag {
  display: inline-flex; align-items: center; gap: .4rem; border: 1px solid var(--line);
  border-radius: 999px; background: var(--surface); padding: .38rem .7rem; color: var(--muted); font-size: .76rem; font-weight: 750;
}
.status-pill.online { color: #86efac; border-color: rgba(74, 222, 128, .35); background: rgba(22, 101, 52, .2); }
.status-pill.offline { color: #fda4af; border-color: rgba(251, 113, 133, .35); background: rgba(159, 18, 57, .18); }
.status-pill.online::before, .status-pill.offline::before, .status-pill.pending::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 10px currentColor; }
.user-chip { color: var(--text); }

.main-nav {
  padding: .7rem clamp(1rem, 4vw, 3rem); display: flex; align-items: center; gap: .35rem; overflow-x: auto;
  background: rgba(13, 20, 32, .94); border-bottom: 1px solid var(--line); position: sticky; top: 68px; z-index: 19;
  scrollbar-width: none;
}
.main-nav::-webkit-scrollbar { display: none; }
.main-nav a, .nav-logout { flex: 0 0 auto; padding: .58rem .82rem; border-radius: 9px; color: var(--muted); font-size: .84rem; font-weight: 700; }
.main-nav a:hover, .main-nav a.active { background: var(--surface-2); color: var(--text); }
.main-nav a.active { box-shadow: 0 -2px 0 var(--green) inset; }
.nav-logout { margin-left: auto; }

.content-shell { width: min(1280px, calc(100% - 2rem)); margin: 0 auto; padding: 2.1rem 0 4rem; }
.content-shell > section { animation: section-in .22s ease-out; }
@keyframes section-in { from { opacity: 0; transform: translateY(5px); } }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.section-heading.compact { margin-top: 2rem; margin-bottom: .9rem; }
.section-heading h1, .section-heading h2, .panel-heading h2 { margin-bottom: 0; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }

.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); gap: .85rem; }
.metric-card, .panel {
  border: 1px solid var(--line); border-radius: 16px; background: linear-gradient(145deg, rgba(22, 33, 50, .94), rgba(14, 23, 37, .96));
  box-shadow: 0 12px 28px rgba(0, 0, 0, .14);
}
.metric-card { min-height: 112px; padding: 1rem; position: relative; overflow: hidden; }
.metric-card::after { content: ""; position: absolute; width: 48px; height: 48px; right: -22px; top: -22px; border-radius: 50%; background: rgba(74, 222, 128, .18); filter: blur(7px); }
.metric-card small { display: block; margin-bottom: .75rem; color: var(--muted); font-size: .72rem; font-weight: 750; text-transform: uppercase; letter-spacing: .07em; }
.metric { font-size: 1.35rem; line-height: 1.2; font-weight: 850; letter-spacing: -.035em; overflow-wrap: anywhere; }
.metric-note { margin-top: .35rem; color: var(--muted); font-size: .72rem; }
.panel-grid { display: grid; gap: 1rem; }
.panel-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.panel { padding: 1.15rem; margin-bottom: 1rem; }
.log-panel, .table-panel { margin-top: 1.2rem; }
.danger-panel { border-color: rgba(251, 113, 133, .28); }

form { margin: 0; }
.stacked-form { display: grid; gap: 1rem; margin-top: 1.5rem; }
label { display: grid; gap: .42rem; color: #c8d3e3; font-size: .8rem; font-weight: 700; }
input, select {
  width: 100%; min-width: 0; padding: .72rem .8rem; color: var(--text); background: #0b1320;
  border: 1px solid #34455d; border-radius: 10px; transition: border-color .16s, box-shadow .16s;
}
input:hover, select:hover { border-color: #49617f; }
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(96, 165, 250, .12); outline: none; }
button {
  min-height: 40px; padding: .62rem .9rem; border: 1px solid transparent; border-radius: 10px;
  background: linear-gradient(135deg, #22c55e, #16a34a); color: #031109; cursor: pointer; font-weight: 800;
  box-shadow: 0 7px 18px rgba(34, 197, 94, .14); transition: transform .14s, filter .14s, opacity .14s;
}
button:hover:not(:disabled) { filter: brightness(1.09); transform: translateY(-1px); }
button:active:not(:disabled) { transform: translateY(0); }
button:disabled, button.busy { opacity: .55; cursor: wait; }
button.secondary { color: #dbeafe; background: #1e3a5f; border-color: #2f5583; box-shadow: none; }
button.danger { color: #fff1f2; background: #9f1239; border-color: #be123c; box-shadow: none; }
button.ghost { min-height: auto; color: var(--muted); background: transparent; border-color: var(--line); box-shadow: none; }
button.wide { width: 100%; }
.inline-form { display: flex; align-items: end; gap: .55rem; flex-wrap: wrap; margin: .75rem 0; }
.inline-form input, .inline-form select { flex: 1 1 130px; width: auto; }
.button-row, .command-grid { display: flex; gap: .55rem; flex-wrap: wrap; }
.command-grid button { flex: 1 1 145px; }
.announce-form { margin-top: 1rem; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .85rem; }
.settings-grid .full { grid-column: 1 / -1; }
.search { margin: .4rem 0; }

.result-box { margin-top: 1rem; padding: .8rem .9rem; border: 1px solid var(--line); border-radius: 10px; background: #0a111d; color: #b9c7d9; font-size: .84rem; line-height: 1.45; }
.result-box.success { color: #bbf7d0; border-color: rgba(74, 222, 128, .32); }
.result-box.failure { color: #fecdd3; border-color: rgba(251, 113, 133, .35); }
.item-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.item-list li { padding: .7rem .78rem; border: 1px solid var(--line); border-radius: 10px; background: rgba(8, 13, 22, .42); }
.compact-list { max-height: 245px; overflow: auto; }
.backup-list code { color: #a7f3d0; }
pre { max-height: 380px; overflow: auto; margin: 0; padding: 1rem; border: 1px solid #1d2a3b; border-radius: 11px; background: #060a11; color: #b8c5d8; white-space: pre-wrap; font: .76rem/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .84rem; }
th { color: var(--muted); font-size: .7rem; letter-spacing: .06em; text-transform: uppercase; }
td, th { padding: .78rem .7rem; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
tbody tr:hover { background: rgba(96, 165, 250, .04); }
.plugin-card { display: grid; gap: .85rem; }
.plugin-title { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.plugin-title h2 { margin: 0; }
.plugin-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; }
.plugin-meta div { padding: .7rem; border-radius: 10px; background: rgba(8, 13, 22, .48); }
.plugin-meta small { display: block; margin-bottom: .25rem; color: var(--muted); }
.hash { display: block; overflow: hidden; color: var(--muted); font: .7rem/1.4 ui-monospace, monospace; text-overflow: ellipsis; white-space: nowrap; }
.source-link { color: #93c5fd; font-size: .82rem; }
.source-link:hover { text-decoration: underline; }

#notice {
  display: none; position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 50; max-width: min(420px, calc(100vw - 2.5rem));
  padding: .85rem 1rem; border: 1px solid rgba(74, 222, 128, .38); border-radius: 12px; background: #10251a; color: #bbf7d0; box-shadow: var(--shadow);
}
#notice.error-notice { border-color: rgba(251, 113, 133, .42); background: #30131b; color: #fecdd3; }

@media (max-width: 880px) {
  .panel-grid.two { grid-template-columns: 1fr; }
  .topbar { position: relative; }
  .main-nav { top: 0; }
}

@media (max-width: 620px) {
  .content-shell { width: min(100% - 1.1rem, 1280px); padding-top: 1.2rem; }
  .topbar { padding: .75rem; }
  .user-chip { display: none; }
  .main-nav { padding-inline: .55rem; }
  .section-heading { align-items: flex-start; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric { font-size: 1.05rem; }
  .settings-grid { grid-template-columns: 1fr; }
  .settings-grid .full { grid-column: auto; }
  .inline-form { align-items: stretch; }
  .inline-form button { flex: 1 1 auto; }
  .plugin-meta { grid-template-columns: 1fr; }
  .login-card { padding: 1.5rem; }
}
