/* Service Panel: dark grayscale with cerulean accents. Square, blocky. */
:root {
  color-scheme: dark;
  --bg: #0b0b0b;
  --surface-1: #141414;
  --surface-2: #1c1c1c;
  --surface-3: #262626;
  --line: #2e2e2e;
  --line-strong: #3d3d3d;
  --text: #f2f2f2;
  --text-2: #b3b3b3;
  --text-3: #7a7a7a;

  --cer-900: #06293a;
  --cer-800: #0a3b53;
  --cer-700: #045a7c;
  --cer-600: #006d95;
  --cer-500: #007ba7;   /* cerulean */
  --cer-400: #1d97c9;
  --cer-300: #4fb6e3;
  --cer-200: #8fd3f2;

  --ok: #3ccf8e;
  --warn: #e3b341;
  --danger: #ef5b5b;

  --radius: 4px;
  --gap: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
a { color: var(--cer-300); text-decoration: none; }
a:hover { color: var(--cer-200); }
h1 { font-size: 1.6rem; margin: 0; letter-spacing: -0.01em; font-weight: 800; }
h2 { font-size: 1.05rem; margin: 0 0 4px; font-weight: 700; }
h3 { font-size: .95rem; margin: 0; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: .08em; }
main h2 { margin-top: 8px; }
code, .mono { font-family: var(--mono); font-size: .88em; }
.muted { color: var(--text-2); }
.small { font-size: .85rem; }
.hint { color: var(--text-3); font-size: .85rem; margin: 0; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------- layout ---------- */
.wrap { max-width: 1120px; margin: 0 auto; padding: 24px 16px 48px; display: flex; flex-direction: column; gap: var(--gap); }
.narrow { max-width: 460px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: var(--gap); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.stack { display: flex; flex-direction: column; gap: 14px; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  background: #000;
  border-bottom: 3px solid var(--cer-700);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 800; letter-spacing: .02em; }
.brand:hover { color: var(--text); }
.brand-mark { width: 18px; height: 18px; background: var(--cer-500); box-shadow: 6px 6px 0 var(--cer-800); display: inline-block; }
.brand-mark.big { width: 34px; height: 34px; box-shadow: 10px 10px 0 var(--cer-800); }
.nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.nav a {
  color: var(--text-2); padding: 6px 12px; border-radius: var(--radius); font-weight: 600; font-size: .92rem;
}
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a.on { color: var(--text); background: var(--surface-3); box-shadow: inset 0 -3px 0 var(--cer-500); }
.logout { display: flex; align-items: center; gap: 10px; margin: 0; }
.whoami { color: var(--text-2); font-size: .9rem; }

/* ---------- surfaces ---------- */
.panel {
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}
.panel.empty { text-align: center; color: var(--text-2); }
.danger-zone { border-color: #4a2424; }

.alert { padding: 12px 16px; border-radius: var(--radius); border-left: 4px solid; font-weight: 600; }
.alert.error { background: #2a1414; border-color: var(--danger); color: #ffd0d0; }
.alert.ok { background: var(--cer-900); border-color: var(--cer-400); color: var(--cer-200); }
.alert.warn { background: #2a2210; border-color: var(--warn); color: #f5dea0; }

.tag {
  display: inline-block; padding: 1px 8px; border-radius: 2px;
  background: var(--surface-3); color: var(--text-2);
  font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; vertical-align: middle;
}
.tag.accent { background: var(--cer-800); color: var(--cer-200); }
.tag.ok { background: #10301f; color: var(--ok); }
.tag.warn { background: #33280c; color: var(--warn); }
.tag.danger { background: #3a1616; color: var(--danger); }

/* ---------- forms ---------- */
label { display: flex; flex-direction: column; gap: 6px; font-size: .85rem; font-weight: 700; color: var(--text-2); letter-spacing: .02em; }
input, select {
  font: inherit; font-size: 1rem; color: var(--text);
  background: var(--surface-2); border: 2px solid var(--line-strong); border-radius: var(--radius);
  padding: 10px 12px; width: 100%; min-height: 44px;
}
input:focus, select:focus { outline: none; border-color: var(--cer-400); background: var(--surface-3); }
label.check { flex-direction: row; align-items: center; gap: 10px; font-weight: 600; color: var(--text); font-size: .95rem; cursor: pointer; }
label.check input { width: 20px; height: 20px; min-height: 0; accent-color: var(--cer-500); flex: none; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.checks .check { background: var(--surface-2); padding: 10px 12px; border-radius: var(--radius); border: 1px solid var(--line); }
.row-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row-form .grow { flex: 1 1 200px; }

/* ---------- buttons ---------- */
.btn {
  font: inherit; font-weight: 700; font-size: .92rem; letter-spacing: .02em;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 8px 18px;
  color: var(--text); background: var(--surface-3);
  border: 2px solid var(--line-strong); border-radius: var(--radius);
  cursor: pointer; transition: background .12s, border-color .12s, transform .05s;
}
.btn:hover { background: #303030; border-color: #4a4a4a; color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: progress; }
.btn:focus-visible { outline: 3px solid var(--cer-300); outline-offset: 2px; }
.btn.primary { background: var(--cer-500); border-color: var(--cer-500); color: #fff; }
.btn.primary:hover { background: var(--cer-400); border-color: var(--cer-400); }
.btn.ghost { background: transparent; border-color: var(--line-strong); color: var(--text-2); }
.btn.ghost:hover { color: var(--text); border-color: var(--cer-600); }
.btn.danger { background: #5a1d1d; border-color: #7a2727; }
.btn.danger:hover { background: #7a2727; }
.btn.small { min-height: 34px; padding: 4px 12px; font-size: .82rem; }
.btn.block { width: 100%; }

/* ---------- login ---------- */
body.bare { display: flex; align-items: center; justify-content: center; background: radial-gradient(1200px 600px at 50% -10%, var(--cer-900), var(--bg) 70%); }
body.bare .wrap { width: 100%; max-width: 420px; }
.login { display: flex; flex-direction: column; gap: 24px; }
.login-brand { display: flex; align-items: center; gap: 22px; padding-left: 4px; }
.login .panel { padding: 24px; border-top: 4px solid var(--cer-500); }

/* ---------- dashboard ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: var(--gap); align-items: start; }
.card {
  background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--radius);
  border-left: 6px solid var(--surface-3);
  padding: 18px; display: flex; flex-direction: column; gap: 12px;
  transition: border-color .2s;
}
.card[data-status="running"] { border-left-color: var(--cer-500); }
.card[data-status="partial"] { border-left-color: var(--warn); }
.card[data-status="stopped"] { border-left-color: #444; }
.card[data-status="error"] { border-left-color: var(--danger); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.card-head h2 { font-size: 1.15rem; margin: 0 0 6px; }
.meta { display: flex; gap: 6px; flex-wrap: wrap; }
.desc { margin: 0; color: var(--text-2); font-size: .92rem; }
.state {
  font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; white-space: nowrap;
  padding: 4px 10px; background: var(--surface-3); color: var(--text-2); border-radius: 2px;
}
.card[data-status="running"] .state { background: var(--cer-800); color: var(--cer-200); }
.card[data-status="partial"] .state { background: #33280c; color: var(--warn); }
.card[data-status="error"] .state { background: #3a1616; color: var(--danger); }
.containers { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.containers li { display: flex; justify-content: space-between; gap: 10px; font-size: .82rem; background: var(--surface-2); padding: 6px 10px; border-radius: 2px; }
.containers .name { font-family: var(--mono); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.containers .st { color: var(--text-3); white-space: nowrap; }
.containers .st.up { color: var(--cer-300); }
.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.actions .btn { padding: 8px 6px; }
.confirm { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: var(--surface-2); padding: 10px 12px; border-left: 4px solid var(--danger); border-radius: 2px; }
.confirm span { flex: 1; font-weight: 600; }
.console { border: 1px solid var(--line); border-radius: var(--radius); background: #050505; overflow: hidden; }
.console-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 6px 6px 12px; background: var(--surface-2); font-size: .8rem; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: .06em; }
.console pre {
  margin: 0; padding: 12px; max-height: 360px; overflow: auto;
  font: 12px/1.5 var(--mono); color: #d6d6d6; white-space: pre-wrap; word-break: break-all;
}
.console .l-info { color: var(--cer-300); }
.console .l-error { color: var(--danger); font-weight: 700; }
.console .l-compose { color: var(--text-2); }
.console .l-done { color: var(--ok); font-weight: 700; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-1); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); padding: 12px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #181818; }
tr.bad td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.audit td { font-size: .85rem; }
.secret { display: block; font-size: 1.25rem; padding: 14px; background: #050505; border: 2px dashed var(--cer-600); color: var(--cer-200); text-align: center; letter-spacing: .05em; user-select: all; word-break: break-all; }
.found { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.found li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 12px; background: var(--surface-2); border-radius: 2px; }
.found form { margin: 0; }
.pager { justify-content: flex-end; }

/* ---------- mobile ---------- */
@media (max-width: 640px) {
  .wrap { padding: 16px 12px 40px; }
  h1 { font-size: 1.35rem; }
  .topbar { gap: 8px; }
  .nav { order: 3; flex-basis: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .logout { margin-left: auto; }
  .whoami { display: none; }
  .grid { grid-template-columns: 1fr; }
  .actions { grid-template-columns: repeat(2, 1fr); }
  .actions .btn { min-height: 48px; }
  .panel { padding: 16px; }
  th, td { padding: 8px 10px; }
}
