:root {
  --bg: #0b0f14;
  --panel: #121821;
  --panel-2: #18202b;
  --line: #232d3b;
  --text: #e6edf3;
  --muted: #8b9bb0;
  --accent: #f5b400;
  --accent-ink: #1a1200;
  --danger: #f87171;
  --warn: #fbbf24;
  --ok: #34d399;
  --radius: 12px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 80% -10%, #16323a 0%, var(--bg) 55%) fixed;
  color: var(--text);
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, sans-serif;
  min-height: 100vh;
}

a { color: var(--accent); }

button, input, select, textarea { font: inherit; color: inherit; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  border-radius: 9px; padding: 8px 14px; cursor: pointer;
  transition: border-color .15s, background .15s, transform .05s;
}
.btn:hover { border-color: #33475e; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

input[type=text], input[type=password], input[type=number], select {
  background: #0d131a; border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 11px; color: var(--text); width: 100%;
}
input:focus, select:focus, .btn:focus-visible { outline: 2px solid #2dd4bf55; outline-offset: 1px; }

.hidden { display: none !important; }

/* ---------- login ---------- */
#login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
#login .box {
  width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 28px; box-shadow: 0 20px 60px #0008;
}
#login h1 { margin: 0 0 4px; font-size: 22px; letter-spacing: -.3px; }
#login p.sub { margin: 0 0 22px; color: var(--muted); font-size: 13px; }
#login label { display: block; margin: 12px 0 6px; font-size: 13px; color: var(--muted); }
#login .btn { width: 100%; justify-content: center; margin-top: 18px; }

/* ---------- shell ---------- */
header {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 14px 22px; background: #0b0f14e6; backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
header .brand { font-weight: 700; letter-spacing: -.2px; display: flex; align-items: center; gap: 10px; }
header .brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.brand-mini { height: 28px; width: auto; display: block; }
.brand-logo { width: 100%; max-width: 240px; display: block; margin: 0 auto 14px; }
header .spacer { flex: 1; }
header .where { color: var(--muted); font-size: 12.5px; font-family: ui-monospace, Consolas, monospace; }

nav.tabs { display: flex; gap: 6px; padding: 0 22px; border-bottom: 1px solid var(--line); background: #0b0f14; }
nav.tabs button {
  background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted);
  padding: 12px 14px; cursor: pointer; font-size: 14px;
}
nav.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }

main { padding: 22px; max-width: 1180px; margin: 0 auto; }

.section-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.section-head h2 { margin: 0; font-size: 17px; font-weight: 600; }
.section-head .spacer { flex: 1; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px;
}

/* ---------- apps ---------- */
.app-row {
  display: grid; grid-template-columns: 52px minmax(0,1.6fr) minmax(0,1.4fr) auto auto;
  gap: 14px; align-items: center;
  padding: 12px 14px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); margin-bottom: 10px;
}
.app-row.disabled { opacity: .5; }
.app-icon {
  width: 52px; height: 52px; border-radius: 12px; background: var(--panel-2);
  display: grid; place-items: center; overflow: hidden; border: 1px solid var(--line);
  font-weight: 700; color: var(--muted);
}
.app-icon img { width: 100%; height: 100%; object-fit: cover; }
.app-name { font-weight: 600; }
.app-pkg { color: var(--muted); font-size: 12.5px; font-family: ui-monospace, Consolas, monospace; word-break: break-all; }
.pill {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px;
  background: #1d2836; color: var(--muted); border: 1px solid var(--line);
}
.pill.ok { background: #0f2e26; color: var(--ok); border-color: #1c5747; }
.pill.warn { background: #33290f; color: var(--warn); border-color: #5c4715; }
.pill.muted { opacity: .7; }
.app-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.empty { color: var(--muted); text-align: center; padding: 34px 12px; border: 1px dashed var(--line); border-radius: var(--radius); }

/* ---------- modal ---------- */
#modal { position: fixed; inset: 0; background: #000a; display: grid; place-items: center; z-index: 50; padding: 20px; }
#modal .box {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  width: min(620px, 100%); max-height: 88vh; overflow: auto; padding: 22px;
  box-shadow: 0 30px 80px #000b;
}
#modal h3 { margin: 0 0 14px; font-size: 17px; }
#modal .row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.hint { color: var(--muted); font-size: 12.5px; }
code, pre {
  font-family: ui-monospace, Consolas, monospace; font-size: 12.5px;
  background: #0a0e13; border: 1px solid var(--line); border-radius: 8px;
}
code { padding: 2px 6px; }
pre { padding: 12px; overflow: auto; white-space: pre-wrap; word-break: break-all; margin: 10px 0; }

/* ---------- toast ---------- */
#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast {
  background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  padding: 11px 15px; border-radius: 10px; box-shadow: 0 12px 30px #0008; max-width: 380px;
  animation: slideIn .18s ease-out;
}
.toast.err { border-left-color: var(--danger); }
@keyframes slideIn { from { opacity: 0; transform: translateY(8px); } }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
th { color: var(--muted); font-weight: 500; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; }
td.mono, .mono { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }

.drag-over { outline: 2px dashed var(--accent); outline-offset: -6px; }
