:root {
  color-scheme: dark;
  --bg: #10161f;
  --bg-soft: #151d27;
  --panel: #1a2430;
  --panel-strong: #202d3a;
  --line: #2d3b49;
  --text: #eef3f7;
  --muted: #91a1b1;
  --cyan: #4fd1c5;
  --cyan-dark: #163d3d;
  --amber: #f3bd67;
  --amber-dark: #49361f;
  --red: #f17c83;
  --red-dark: #4b262d;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.22);
  font-family: Inter, Pretendard, "Noto Sans KR", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--text); }
button, a { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .38; }
button:disabled:hover { border-color: var(--line); color: inherit; background: inherit; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }
.app-shell { min-height: 100vh; }
.topbar { height: 72px; display: flex; align-items: center; justify-content: space-between; padding: 0 5vw; border-bottom: 1px solid var(--line); background: rgba(16, 22, 31, 0.94); }
.brand { display: inline-flex; align-items: center; gap: 11px; font-size: 15px; font-weight: 750; letter-spacing: .01em; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid var(--cyan); color: var(--cyan); font-size: 11px; letter-spacing: .08em; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.user-chip { padding: 8px 11px; border: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.icon-button { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 21px; }
.icon-button:hover { border-color: var(--cyan); color: var(--text); }
main { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }
.login-view { min-height: calc(100vh - 72px); display: grid; place-items: center; padding: 48px 0; }
.login-panel { width: min(500px, 100%); padding: 38px; border: 1px solid var(--line); background: var(--panel); box-shadow: var(--shadow); }
.section-kicker { margin: 0 0 12px; color: var(--cyan); font-size: 11px; font-weight: 800; letter-spacing: .16em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 12px; font-size: clamp(28px, 4vw, 46px); line-height: 1.1; letter-spacing: 0; }
h2 { margin-bottom: 0; font-size: 21px; }
.muted { color: var(--muted); line-height: 1.65; }
.login-button { width: 100%; margin-top: 25px; }
.primary-button, .secondary-button, .danger-button, .ghost-button { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; padding: 0 15px; font-weight: 750; transition: border-color .2s, background .2s, color .2s; }
.primary-button { background: var(--cyan); color: #102022; }
.primary-button:hover { background: #7be2d8; }
.secondary-button { border-color: var(--line); background: var(--panel); color: var(--text); }
.secondary-button:hover { border-color: var(--cyan); }
.danger-button { border-color: #6b353c; background: var(--red-dark); color: #ffd9dc; }
.danger-button:hover { background: #64323a; }
.ghost-button { border-color: var(--line); background: transparent; color: var(--muted); }
.ghost-button:hover { color: var(--text); border-color: var(--cyan); }
.login-note { margin: 20px 0 0; color: var(--muted); font-size: 13px; }
.error-text { margin: 16px 0 0; color: var(--red); line-height: 1.5; }
.dashboard-view { padding: 46px 0 70px; }
.dashboard-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.dashboard-heading h1 { margin-bottom: 8px; }
.overview-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 28px; }
.overview-item { min-height: 130px; display: flex; flex-direction: column; justify-content: space-between; padding: 20px; border: 1px solid var(--line); background: var(--panel); }
.overview-label { color: var(--muted); font-size: 13px; }
.overview-item strong { font-size: 32px; line-height: 1; }
.overview-caption { color: var(--muted); font-size: 12px; }
.automation-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.automation-card { display: flex; flex-direction: column; min-height: 355px; border: 1px solid var(--line); background: var(--panel); box-shadow: 0 10px 30px rgba(0, 0, 0, .12); }
.automation-card.is-live { border-top: 2px solid var(--cyan); }
.automation-card.is-stopped { border-top: 2px solid var(--red); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 20px 20px 15px; }
.card-title { margin: 0 0 6px; font-size: 19px; }
.card-category { margin: 0; color: var(--muted); font-size: 12px; }
.status-badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 8px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.status-badge::before { width: 7px; height: 7px; border-radius: 50%; background: currentColor; content: ""; }
.status-live { color: var(--cyan); background: var(--cyan-dark); }
.status-stopped { color: var(--red); background: var(--red-dark); }
.status-unknown { color: var(--amber); background: var(--amber-dark); }
.card-body { flex: 1; padding: 0 20px; }
.card-description { min-height: 44px; margin: 0 0 17px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.meta-list { display: grid; gap: 10px; margin: 0; }
.meta-row { display: flex; justify-content: space-between; gap: 14px; padding-bottom: 9px; border-bottom: 1px solid rgba(45, 59, 73, .7); font-size: 12px; }
.meta-row dt { color: var(--muted); }
.meta-row dd { max-width: 65%; margin: 0; color: var(--text); text-align: right; overflow-wrap: anywhere; }
.session-value { color: var(--amber) !important; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 10px; }
.card-actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 7px; padding: 18px 20px 20px; }
.card-actions button { min-width: 0; padding: 0 8px; font-size: 12px; }
.heartbeat-note { margin-top: 20px; color: var(--muted); font-size: 12px; }
.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: rgba(4, 8, 12, .78); }
.modal-panel { width: min(850px, 100%); max-height: min(720px, 90vh); display: flex; flex-direction: column; border: 1px solid var(--line); background: var(--panel); box-shadow: var(--shadow); }
.modal-header { display: flex; justify-content: space-between; gap: 20px; padding: 20px; border-bottom: 1px solid var(--line); }
.log-content { overflow: auto; padding: 18px 20px 24px; }
.log-block + .log-block { margin-top: 20px; }
.log-file { margin-bottom: 8px; color: var(--amber); font: 12px ui-monospace, SFMono-Regular, Consolas, monospace; }
pre { margin: 0; padding: 14px; overflow: auto; border: 1px solid var(--line); background: #0d131a; color: #cbd6df; font: 11px/1.65 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }

@media (max-width: 900px) {
  .automation-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .topbar { height: 64px; padding: 0 18px; }
  .brand { font-size: 13px; }
  main { width: min(100% - 28px, 520px); }
  .login-view { min-height: calc(100vh - 64px); }
  .login-panel { padding: 26px 22px; }
  .dashboard-view { padding: 30px 0 45px; }
  .dashboard-heading { align-items: flex-start; flex-direction: column; margin-bottom: 22px; }
  .dashboard-heading h1 { font-size: 34px; }
  .overview-grid { grid-template-columns: 1fr 1fr; }
  .heartbeat-item { grid-column: 1 / -1; min-height: 105px; }
  .automation-grid { grid-template-columns: 1fr; }
  .automation-card { min-height: 0; }
  .card-actions { position: sticky; bottom: 0; background: var(--panel); }
  .user-chip { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
