:root {
  --bg: #f5f6f4;
  --surface: #ffffff;
  --surface-2: #f0f2ee;
  --border: #dde1da;
  --text: #1c211b;
  --muted: #5d665a;
  --accent: #3f7d1f;
  --accent-hover: #346a19;
  --accent-text: #ffffff;
  --ok: #2f7d32;
  --ok-bg: #e5f3e3;
  --warn: #8a5a00;
  --warn-bg: #fff3d6;
  --bad: #b3261e;
  --bad-bg: #fde7e5;
  --info: #1d5fa8;
  --info-bg: #e3eefb;
  --radius: 10px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111410;
    --surface: #191d18;
    --surface-2: #222821;
    --border: #2f362d;
    --text: #e8ece6;
    --muted: #9aa496;
    --accent: #6fb43f;
    --accent-hover: #82c552;
    --accent-text: #0e130c;
    --ok: #7fcf7a;
    --ok-bg: #1e3320;
    --warn: #f0c060;
    --warn-bg: #3a2f14;
    --bad: #ff8a80;
    --bad-bg: #3d1d1a;
    --info: #8ab8f0;
    --info-bg: #1a2a3d;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--info); }
h1, h2 { margin: 0; }
h1 { font-size: 20px; }
h2 { font-size: 15px; }
pre { white-space: pre-wrap; overflow-wrap: anywhere; }
[hidden] { display: none !important; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand, .user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo { width: 18px; height: 18px; border-radius: 5px; background: var(--accent); flex: none; }
.user img { border-radius: 50%; }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  padding: 20px 24px 40px;
  max-width: 1280px;
  margin: 0 auto;
}
.wide { grid-column: 1 / -1; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  min-width: 0;
}
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; }

.table-wrap { overflow-x: auto; }
table.status { width: 100%; border-collapse: collapse; }
.status th, .status td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.status th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.status tbody tr:last-child td { border-bottom: none; }
.status .app-name { font-weight: 600; }
.status .app-key { color: var(--muted); font-size: 12px; font-family: ui-monospace, Menlo, monospace; }
.status .row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.version { font-family: ui-monospace, Menlo, monospace; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot.ok { background: var(--ok); }
.dot.behind { background: var(--warn); }
.dot.newer { background: var(--info); }
.dot.bad { background: var(--bad); }
.legend { margin: 10px 0 0; color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.legend .dot + * { margin-right: 10px; }
.legend-note { margin: 2px 0 0; color: var(--muted); font-size: 12px; }

.form { display: grid; gap: 12px; }
.form p { margin: 0; }
.form label { display: grid; gap: 4px; font-weight: 600; }
.form label.check { display: flex; gap: 8px; align-items: flex-start; font-weight: normal; }
.form label.check input { margin-top: 3px; }
select, input[type=text], input[type=password] {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}
.inline-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inline-form select { width: auto; }

button, .button {
  display: inline-block;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
button:hover, .button:hover { background: var(--accent-hover); }
button:disabled { opacity: .6; cursor: progress; }
button.secondary, button.small { background: var(--surface-2); color: var(--text); border-color: var(--border); }
button.secondary:hover, button.small:hover { background: var(--border); }
button.small { padding: 3px 10px; font-size: 12px; font-weight: 500; }
button.link { background: none; border: none; color: var(--info); padding: 0; font-weight: 500; }
.actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.hint { padding: 8px 12px; border-radius: 8px; font-size: 13px; }
.hint + .hint { margin-top: 8px; }
.hint.warn { background: var(--warn-bg); color: var(--warn); }
.hint.info { background: var(--info-bg); color: var(--info); }
#deploy-result:empty { display: none; }
.result { padding: 8px 12px; border-radius: 8px; display: grid; gap: 2px; overflow-wrap: anywhere; }
.result.ok { background: var(--ok-bg); color: var(--ok); }
.result.info { background: var(--info-bg); color: var(--info); }
.result.error { background: var(--bad-bg); color: var(--bad); }


.runs { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.runs li { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 10px; align-items: center; padding: 10px; border: 1px solid var(--border); border-radius: 8px; }
.runs li.muted { display: block; border: none; padding: 0; }
.run-title { font-weight: 600; overflow-wrap: anywhere; }
.run-meta { grid-column: 2; color: var(--muted); font-size: 12px; }
.run-error { grid-column: 2; color: var(--bad); font-size: 12px; overflow-wrap: anywhere; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--muted); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge-demo { background: var(--warn-bg); color: var(--warn); }

.demo-tools { border-style: dashed; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.login { display: grid; place-items: center; min-height: calc(100vh - 60px); padding: 16px; }
.login-card { max-width: 380px; width: 100%; display: grid; gap: 12px; }
.login-card p { margin: 0; color: var(--muted); }

.message { max-width: 760px; margin: 40px auto; padding: 0 16px; display: grid; gap: 12px; }
.message h1 { overflow-wrap: anywhere; }

@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding: 16px; }
  .topbar { padding: 12px 16px; }
  .user #user-name { display: none; }
}
