/*
 * MONO 제어 센터 — standalone shell.
 *
 * Mobile first: one column from 360px, two columns from 760px. Every control
 * is at least 44px on its short edge, nothing scrolls sideways, and state is
 * carried by an icon and a word as well as by colour.
 * No @import, no url() to anywhere off this origin, no web font.
 */

:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #14181d;
  --muted: #5b6672;
  --line: #d9dee5;
  --accent: #1b5fbe;
  --accent-ink: #ffffff;
  --danger: #a3231f;
  --warn-bg: #fff5e5;
  --warn-line: #d99a2b;
  --ok: #1c6b3f;
  --run: #1b5fbe;
  --wait: #6a5a1f;
  --fail: #a3231f;
  --tap: 44px;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --panel: #171c22;
    --ink: #e8edf3;
    --muted: #9aa6b3;
    --line: #2b333c;
    --accent: #5b9dff;
    --accent-ink: #0b0f14;
    --danger: #ff8a84;
    --warn-bg: #2e2410;
    --warn-line: #d99a2b;
    --ok: #6fd39b;
    --run: #7fb2ff;
    --wait: #e0c46a;
    --fail: #ff8a84;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
  overflow-wrap: anywhere;
  word-break: break-word;
}

body {
  padding:
    env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.view { max-width: 1200px; margin: 0 auto; padding: 12px; }

.brand { font-size: 1.15rem; margin: 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 4px 0 12px;
}

.columns { display: flex; flex-direction: column; gap: 12px; }
.col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  min-width: 0;
}

.card h2 { font-size: 1rem; margin: 0 0 10px; }
.card h3 { font-size: .92rem; margin: 14px 0 6px; }

.muted { color: var(--muted); font-size: .86rem; margin: 4px 0; }
.error { color: var(--fail); font-size: .88rem; margin: 6px 0; }
.warn {
  background: var(--warn-bg); border-left: 4px solid var(--warn-line);
  padding: 8px 10px; border-radius: 4px; font-size: .88rem; margin: 6px 0;
}

/* ------------------------------------------------------------- controls */
.btn {
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 10px 14px;
  font: inherit;
  font-size: .92rem;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.ghost { background: transparent; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }

.field { display: flex; flex-direction: column; gap: 4px; margin: 0 0 12px; border: 0; padding: 0; }
.field > span, .field > legend { font-size: .86rem; color: var(--muted); padding: 0; }
.field.inline { flex: 1 1 130px; margin-bottom: 8px; }

input[type="text"], input[type="password"], input[type="number"],
select, textarea {
  min-height: var(--tap);
  width: 100%;
  padding: 10px;
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
textarea { min-height: 132px; resize: vertical; }

.radio, .check {
  display: flex; align-items: center; gap: 10px;
  min-height: var(--tap); font-size: .9rem; cursor: pointer;
}
.radio input, .check input { width: 22px; height: 22px; min-height: 22px; flex: none; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.filters .btn { margin-bottom: 8px; }

.guard {
  border: 1px solid var(--warn-line); background: var(--warn-bg);
  border-radius: var(--radius); padding: 10px; margin: 0 0 12px;
}
.guard h3 { margin-top: 0; }

.disabled-card { opacity: .72; }

/* ----------------------------------------------------------------- data */
.kv { display: grid; grid-template-columns: minmax(88px, 40%) 1fr; gap: 4px 10px; margin: 0; }
.kv dt { color: var(--muted); font-size: .84rem; }
.kv dd { margin: 0; font-size: .9rem; }

.list { list-style: none; margin: 0; padding: 0; }
.list > li {
  border-top: 1px solid var(--line); padding: 10px 0;
  display: flex; flex-direction: column; gap: 4px;
}
.list > li:first-child { border-top: 0; }

.jobs > li { cursor: pointer; min-height: var(--tap); }
.jobs > li[aria-selected="true"] { outline: 2px solid var(--accent); outline-offset: 2px; }

.job-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.job-title { font-size: .92rem; font-weight: 600; }
.job-meta { color: var(--muted); font-size: .8rem; }

/* State is a shape, a word and a colour — never colour alone. */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: .78rem;
  border: 1px solid currentColor; white-space: nowrap;
}
.badge .glyph { font-weight: 700; }
.badge.s-running { color: var(--run); }
.badge.s-queued { color: var(--wait); }
.badge.s-succeeded { color: var(--ok); }
.badge.s-failed, .badge.s-cancelled, .badge.s-interrupted { color: var(--fail); }
.badge.s-timeout { color: var(--fail); }
.badge.s-unknown { color: var(--muted); }

.pre {
  white-space: pre-wrap; overflow-wrap: anywhere; margin: 0;
  padding: 10px; background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius); font-size: .85rem; max-height: 50vh; overflow-y: auto;
}

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline > li { border-top: 1px solid var(--line); padding: 8px 0; font-size: .86rem; }
.timeline > li:first-child { border-top: 0; }
.ev-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.ev-seq { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .78rem; }
.ev-type { font-weight: 600; }
.ev-time { color: var(--muted); font-size: .78rem; }
.ev-body { color: var(--muted); font-size: .82rem; white-space: pre-wrap; }
.ev-flag { color: var(--wait); font-size: .78rem; }

.copybar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.copybar .btn { flex: 1 1 auto; }
.detail-actions { margin-top: 10px; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 20; max-width: min(92vw, 460px);
  padding: 12px 16px; border-radius: var(--radius);
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); box-shadow: 0 6px 24px rgba(0, 0, 0, .28);
  font-size: .9rem;
}
.toast.bad { border-color: var(--fail); color: var(--fail); }

.offscreen {
  position: fixed; left: -9999px; top: 0; width: 1px; height: 1px;
  opacity: 0; pointer-events: none;
}

.login { max-width: 420px; padding-top: 12vh; }

/* -------------------------------------------------------- two columns */
@media (min-width: 760px) {
  .columns { flex-direction: row; align-items: flex-start; }
  .col { flex: 1 1 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
