/* statusboard — dark wall dashboard, iPad 6th gen 1024×768 landscape first (DESIGN §5).
 * Burn-in policy (DESIGN §5-1): text ≤ #d6dee6, backgrounds ≤ #10151b,
 * saturated colors only on small status dots. */

:root {
  --bg: #0a0e13;        /* ≤ #10151b */
  --panel: #0e1319;     /* ≤ #10151b */
  --panel-2: #10151b;
  --border: #1f2831;
  --text: #d6dee6;      /* max allowed text brightness */
  --muted: #8b98a5;
  --faint: #5c6873;
  /* desaturated status text tones (dots below stay saturated but small) */
  --ok-text: #7fbf8c;
  --warn-text: #c2a65a;
  --err-text: #d98878;
  /* saturated dot colors — small elements only */
  --ok: #3fb950;
  --warn: #d29922;
  --err: #f85149;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  overflow: hidden; /* wall display: fixed viewport, table scrolls internally */
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh; /* iPad Safari address-bar safe (vh fallback above) */
  padding: 12px 16px 10px;
  gap: 10px;
}

/* main must be a flex child of #app, or .services/.main-cols height
 * constraints are void and the cron-table scroll chain breaks */
main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---- pixel shift (burn-in, DESIGN §5-1): instant swap, no transition ---- */
#app.shift-0 { transform: translate(0, 0); }
#app.shift-1 { transform: translate(3px, 2px); }
#app.shift-2 { transform: translate(-2px, 3px); }
#app.shift-3 { transform: translate(3px, -2px); }

/* ---- night dimming overlay (23:00–07:00 KST) ---- */
.night-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.25);
  pointer-events: none;
  z-index: 999;
}
.night-overlay.hidden { display: none; }

.hidden { display: none !important; }

/* ---- header ---- */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex: none;
}
.head-left { display: flex; align-items: baseline; gap: 14px; }
.clock { font-size: 44px; font-weight: 700; letter-spacing: 1px; }
.date { font-size: 16px; color: var(--muted); }
.head-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.meta-line { font-size: 13px; color: var(--muted); }
#mac-freshness.stale { color: var(--err-text); font-weight: 600; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  font-size: 17px;
  font-weight: 600;
}
.badge .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--faint); }
.badge.ok .dot { background: var(--ok); }
.badge.warn .dot { background: var(--warn); }
.badge.err .dot { background: var(--err); }
.badge.ok { color: var(--ok-text); }
.badge.warn { color: var(--warn-text); }
.badge.err { color: var(--err-text); }

/* ---- banner ---- */
.banner {
  flex: none;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--warn-text);
  font-size: 14px;
}

/* ---- row 2: service tiles (one row of 4) ---- */
.services {
  flex: none;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.tile {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
}
.tile .tile-top { display: flex; align-items: center; gap: 10px; }
.tile .dot { width: 13px; height: 13px; border-radius: 50%; flex: none; }
.tile.ok .dot { background: var(--ok); }
.tile.err .dot { background: var(--err); }
.tile .svc-name { font-size: 19px; font-weight: 600; }
.tile .tile-bottom { display: flex; justify-content: space-between; align-items: baseline; }
.tile .code { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile.err .code { color: var(--err-text); }
.tile .lat { font-size: 14px; color: var(--muted); max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- row 3: two-column main area (left 2/3, right 1/3) ---- */
.main-cols {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 10px;
}
.col-left, .col-right { min-height: 0; display: flex; flex-direction: column; gap: 10px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px 12px;
}
.card h2 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}
.cnt { color: var(--faint); font-weight: 400; margin-left: 6px; }
.cron-stale { color: var(--warn-text); font-weight: 500; margin-left: 10px; font-size: 12.5px; }

/* mac summary strip above the cron table */
.mac-strip { font-size: 14.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px 18px; }
.mac-strip .seg { display: inline-flex; align-items: center; gap: 7px; }
.mac-strip .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.mac-strip .dot.ok { background: var(--ok); }
.mac-strip .dot.err { background: var(--err); }
.mac-strip .up-ok { color: var(--ok-text); }
.mac-strip .up-err { color: var(--err-text); }

/* cron table (compact 13–14px so 23 rows fit 768px when possible) */
.cron-card { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.tbl-wrap { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
thead th {
  position: sticky;
  top: 0;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  z-index: 1;
}
tbody td { padding: 5.5px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody td.name { font-weight: 550; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
td.mono, .mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); font-size: 12.5px; }
tr.overdue td { background: rgba(248, 81, 73, 0.10); }
tr.overdue td.name { color: var(--err-text); }
tr.dim td { opacity: 0.5; }
td.empty { color: var(--faint); text-align: center; padding: 18px 0; }

.pill {
  display: inline-block;
  padding: 1px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
}
.pill.ok { color: var(--ok-text); }
.pill.err { color: var(--err-text); }
.pill.warn { color: var(--warn-text); }
.err-text { color: var(--err-text); }
.bold { font-weight: 700; }

/* right column detail card */
.detail-card { flex: none; }
#mac-detail .d-block { padding: 7px 0; border-bottom: 1px solid var(--border); }
#mac-detail .d-block:last-child { border-bottom: none; }
#mac-detail .lbl { font-size: 12px; color: var(--faint); margin-bottom: 3px; }
#mac-detail .val { font-size: 15px; font-weight: 550; }
#mac-detail .channels { display: flex; flex-direction: column; gap: 4px; }
#mac-detail .channel { display: flex; justify-content: space-between; gap: 8px; font-size: 13.5px; }
#mac-detail .channel .st-ok { color: var(--ok-text); }
#mac-detail .channel .st-err { color: var(--err-text); }
#mac-detail .empty { color: var(--faint); font-size: 13.5px; }

/* ---- below 900px: single column (DESIGN §5) ---- */
@media (max-width: 899px) {
  body { overflow: auto; }
  #app { height: auto; min-height: 100vh; }
  .main-cols { grid-template-columns: 1fr; }
  .tbl-wrap { overflow-y: visible; }
  .services { grid-template-columns: repeat(2, 1fr); }
  .clock { font-size: 34px; }
}

@media (max-width: 560px) {
  .services { grid-template-columns: 1fr; }
  header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .head-right { align-items: flex-start; }
}
