/* Werkbank – dark panel theme */
:root {
  --bg: #0e1115;
  --bg-elev: #13181e;
  --card: #181e25;
  --card-2: #1f2730;
  --border: #29323d;
  --border-strong: #36414e;
  --text: #e6e9ed;
  --muted: #8d99a7;
  --accent: #6cc24a;
  --accent-hover: #80d35e;
  --accent-ink: #0d1a08;
  --accent-soft: rgba(108, 194, 74, 0.12);
  --danger: #f0706a;
  --danger-solid: #d63a35;
  --danger-soft: rgba(240, 112, 106, 0.12);
  --warn: #e0a83a;
  --warn-soft: rgba(224, 168, 58, 0.12);
  --info: #6aa9ff;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --mono: ui-monospace, 'Cascadia Code', 'JetBrains Mono', Consolas, 'Liberation Mono', monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: 0.92em; background: var(--card-2); padding: 1px 6px; border-radius: 5px; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h2 { font-size: 15px; font-weight: 650; margin-bottom: 12px; }
h2.inline { display: inline; margin: 0; }
p { margin: 0 0 10px; }
[hidden] { display: none !important; }

.icon { width: 18px; height: 18px; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grow { flex: 1; min-width: 0; }
.spacer { flex: 1; }
.mt { margin-top: 16px; }
.mt-lg { margin-top: 28px; }
.mb { margin-bottom: 10px; }
.center { justify-content: center; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.nowrap { flex-wrap: nowrap; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack-lg { display: flex; flex-direction: column; gap: 16px; }

/* ---------- Layout ---------- */
.boot { min-height: 100vh; display: grid; place-items: center; color: var(--muted); }
.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 6px;
  padding: 18px 12px; background: var(--bg-elev); border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 18px; color: var(--text); font-weight: 700; font-size: 18px; letter-spacing: 0.01em; }
.brand:hover { text-decoration: none; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a, .account-link {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px;
  border-radius: var(--radius-sm); color: var(--muted); font-weight: 500;
}
.nav a:hover, .account-link:hover { background: var(--card); color: var(--text); text-decoration: none; }
.nav a.active, .account-link.active { background: var(--card-2); color: var(--text); }
.nav a.active .icon { color: var(--accent); }
.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 4px; border-top: 1px solid var(--border); padding-top: 12px; }
.sidebar-footer .btn { justify-content: flex-start; color: var(--muted); }
.content { min-width: 0; padding: 24px 32px 48px; max-width: 1240px; width: 100%; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-title { font-size: 23px; font-weight: 700; }
.loading { color: var(--muted); display: flex; gap: 10px; align-items: center; padding: 20px 0; }

/* ---------- Status ---------- */
.status-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 13px;
  border-radius: 999px; background: var(--card); border: 1px solid var(--border); font-size: 13px; font-weight: 500;
}
.dot { width: 9px; height: 9px; border-radius: 50%; background: #5a6573; flex: none; display: inline-block; }
.dot.running { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.dot.starting, .dot.stopping, .dot.installing, .dot.restoring { background: var(--warn); animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }

.banner {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; margin-bottom: 16px;
  border-radius: var(--radius-sm); background: var(--warn-soft); border: 1px solid rgba(224, 168, 58, 0.4); color: #f2c66d;
}
.note {
  padding: 10px 14px; border-radius: var(--radius-sm); background: var(--card-2);
  border: 1px solid var(--border); color: var(--muted); margin-bottom: 16px;
}

/* ---------- Cards & grids ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; min-width: 0; }
.card-label { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; margin-bottom: 10px; }
.card-label .icon { width: 15px; height: 15px; }
.grid { display: grid; gap: 16px; }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-2-1 { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); align-items: start; }
.hero { max-width: 860px; }
.hero h2 { font-size: 20px; }
.error-card { border-color: rgba(240, 112, 106, 0.5); color: var(--danger); }

.big-status { display: flex; align-items: center; gap: 10px; font-size: 24px; font-weight: 700; }
.big-number { font-size: 26px; font-weight: 700; margin-bottom: 8px; }
.address { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.address code { font-size: 17px; padding: 5px 10px; background: var(--bg); border: 1px solid var(--border); }
.motd { margin-top: 4px; }
.metric-value { font-size: 17px; font-weight: 650; margin-bottom: 8px; }
.metric-value .muted { font-size: 13px; font-weight: 500; }
.progress { height: 7px; background: var(--card-2); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.4s; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.warn-note {
  display: block; margin-top: 12px; padding: 9px 12px; border-radius: var(--radius-sm); font-size: 13px;
  background: var(--warn-soft); border: 1px solid rgba(224, 168, 58, 0.4); color: #f2c66d;
}
.warn-note:hover { text-decoration: none; border-color: var(--warn); }
.chip { padding: 3px 10px; border-radius: 999px; background: var(--card-2); border: 1px solid var(--border); font-size: 13px; }
.quick { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; padding: 10px; }
.quick-link { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: var(--radius-sm); color: var(--text); font-weight: 500; }
.quick-link:hover { background: var(--card-2); text-decoration: none; }
.quick-link .icon { color: var(--accent); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--card-2); color: var(--text); font: inherit; font-weight: 550; cursor: pointer;
  white-space: nowrap; transition: background 0.12s, border-color 0.12s; text-decoration: none !important;
}
.btn:hover { background: #28323e; border-color: #455262; }
.btn:focus-visible, .switch input:focus-visible + span, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn .icon { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); border-color: transparent; }
.btn-danger { background: transparent; border-color: rgba(240, 112, 106, 0.45); color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-danger-solid { background: var(--danger-solid); border-color: transparent; color: #fff; }
.btn-danger-solid:hover { background: #e2453f; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--card-2); border-color: transparent; }
.btn-ghost.danger:hover { color: var(--danger); background: var(--danger-soft); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-icon { padding: 6px; }
.btn-block { width: 100%; padding: 10px; }
.spinner {
  width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin 0.7s linear infinite; display: inline-block; flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Forms ---------- */
input, select, textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--border-strong); color: var(--text);
  border-radius: var(--radius-sm); padding: 8px 11px; font: inherit; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type='range'] { padding: 0; accent-color: var(--accent); box-shadow: none; border: none; background: none; }
input[type='checkbox'] { width: auto; accent-color: var(--accent); }
.w-num { width: 110px; flex: none; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-size: 13px; color: #b5bfca; font-weight: 550; }
.help { font-size: 12.5px; color: var(--muted); }
.form-grid { display: grid; gap: 16px 22px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.switch-field .switch-row label:first-child { font-size: 13px; color: #b5bfca; font-weight: 550; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #3a4552; border-radius: 999px; cursor: pointer; transition: background 0.15s; }
.switch span::after {
  content: ''; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px;
  background: #fff; border-radius: 50%; transition: transform 0.15s;
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:disabled + span { opacity: 0.5; cursor: wait; }
.save-bar {
  position: sticky; bottom: 12px; display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  background: rgba(24, 30, 37, 0.92); backdrop-filter: blur(6px); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.kv-grid { display: grid; grid-template-columns: minmax(160px, max-content) 1fr; gap: 8px 14px; align-items: center; }
details summary { cursor: pointer; list-style: none; }
details summary::-webkit-details-marker { display: none; }
details summary::before { content: '▸'; color: var(--muted); margin-right: 8px; display: inline-block; transition: transform 0.15s; }
details[open] summary::before { transform: rotate(90deg); }
details[open] summary { margin-bottom: 12px; }
.search-box { position: relative; }
.search-box .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; }
.search-box input { padding-left: 34px; }
.msg { padding: 9px 12px; border-radius: var(--radius-sm); font-size: 13.5px; }
.msg.error { background: var(--danger-soft); color: #ff9c97; border: 1px solid rgba(240, 112, 106, 0.35); }
.msg.success { background: var(--accent-soft); color: #9ae07c; border: 1px solid rgba(108, 194, 74, 0.35); }

/* ---------- Install picker ---------- */
.type-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.type-card {
  position: relative; display: flex; flex-direction: column; gap: 4px; padding: 14px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--bg); cursor: pointer;
}
.type-card:hover { border-color: #4a5868; }
.type-card input { position: absolute; opacity: 0; }
.type-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.type-card:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.type-name { font-weight: 650; }
.type-desc { font-size: 12.5px; color: var(--muted); }
.install-log {
  max-height: 220px; overflow: auto; margin: 0; padding: 10px 12px; background: #0a0d10;
  border: 1px solid var(--border); border-radius: var(--radius-sm); font: 12px/1.5 var(--mono); color: #b9c3cd; white-space: pre-wrap;
}

/* ---------- Lists & tables ---------- */
.list { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; gap: 13px; padding: 11px 2px; border-bottom: 1px solid var(--border); }
.item:last-child { border-bottom: none; }
.item.compact { padding: 8px 2px; }
.item.is-disabled { opacity: 0.55; }
.item .meta { flex: 1; min-width: 0; }
.item .title { font-weight: 600; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.item .title a { color: var(--text); }
.item .sub { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .sub.wrap { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.item .actions { display: flex; align-items: center; gap: 8px; flex: none; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.avatar { width: 42px; height: 42px; border-radius: 9px; object-fit: cover; background: var(--card-2); flex: none; }
.avatar.placeholder { display: grid; place-items: center; font-weight: 700; color: var(--muted); border: 1px solid var(--border); }
.avatar.small { width: 30px; height: 30px; border-radius: 7px; font-size: 13px; }
.add-form { margin-bottom: 8px; flex-wrap: nowrap; }
.empty { color: var(--muted); padding: 18px 0; text-align: center; }
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 550;
  background: var(--card-2); border: 1px solid var(--border); color: var(--muted);
}
.badge .icon { width: 12px; height: 12px; }
.badge.green { color: #94dc76; background: var(--accent-soft); border-color: rgba(108, 194, 74, 0.35); }
.badge.yellow { color: #efc263; background: var(--warn-soft); border-color: rgba(224, 168, 58, 0.35); }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: 11.5px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); font-weight: 650; }
.table th.right, .table td.right { text-align: right; }
.table tr:last-child td { border-bottom: none; }
.table td .btn + .btn, .table td .btn + a, .table td a + .btn { margin-left: 4px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

/* ---------- Console ---------- */
.console-card { display: flex; flex-direction: column; gap: 10px; }
.console-toolbar { gap: 14px; }
.console {
  height: calc(100vh - 290px); min-height: 320px; overflow: auto; padding: 12px 14px;
  background: #090c0f; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font: 12.5px/1.55 var(--mono); color: #c9d1d9; white-space: pre-wrap; word-break: break-word;
}
.console .l-warn { color: #e3b341; }
.console .l-error { color: #ff7b72; }
.console .l-panel { color: #8fdc6e; }
.console .l-cmd { color: #79c0ff; }
.console-input { display: flex; align-items: center; gap: 8px; }
.console-input .prompt { font: 600 15px var(--mono); color: var(--accent); }
.console-input input { font-family: var(--mono); }

/* ---------- Auth ---------- */
.auth-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(900px 500px at 50% -10%, rgba(108, 194, 74, 0.09), transparent 60%), var(--bg);
}
.auth-card { width: 100%; max-width: 410px; padding: 28px; box-shadow: var(--shadow); }
.auth-card h2 { font-size: 17px; margin: 22px 0 14px; }
.auth-brand { display: flex; align-items: center; gap: 14px; }
.auth-title { font-size: 22px; font-weight: 750; }
.auth-switch { margin-top: 18px; text-align: center; color: var(--muted); }
.auth-card .note { margin-bottom: 14px; }

/* ---------- Toasts & dialogs ---------- */
#toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 1000; }
.toast {
  max-width: 400px; padding: 11px 15px; border-radius: var(--radius-sm); background: var(--card-2);
  border: 1px solid var(--border-strong); border-left: 4px solid var(--accent); box-shadow: var(--shadow);
  animation: toast-in 0.2s ease-out;
}
.toast.error { border-left-color: var(--danger); }
.toast.info { border-left-color: var(--info); }
.toast.out { opacity: 0; transform: translateY(6px); transition: 0.25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
dialog.modal {
  width: min(460px, calc(100vw - 32px)); padding: 22px; border-radius: var(--radius); border: 1px solid var(--border-strong);
  background: var(--card); color: var(--text); box-shadow: var(--shadow);
}
dialog.modal::backdrop { background: rgba(5, 7, 10, 0.65); backdrop-filter: blur(2px); }
dialog.modal h3 { font-size: 17px; margin-bottom: 10px; }
dialog.modal p { color: #b5bfca; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .type-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quick { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky; top: 0; z-index: 20; height: auto; flex-direction: row; align-items: center;
    padding: 8px 10px; gap: 4px; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--border);
  }
  .brand { padding: 0 6px 0 2px; }
  .brand span { display: none; }
  .nav { flex-direction: row; }
  .nav a { padding: 8px 9px; }
  .nav a span { display: none; }
  .nav a.active span { display: inline; }
  .sidebar-footer { flex-direction: row; margin: 0 0 0 auto; border: none; padding: 0; }
  .sidebar-footer span { display: none; }
  .content { padding: 16px 14px 40px; }
  .grid.cols-3, .grid.cols-2, .grid.cols-2-1 { grid-template-columns: 1fr; }
  .console { height: calc(100vh - 300px); }
  .item { flex-wrap: wrap; }
  .item .actions { margin-left: auto; }
}
