:root {
  color-scheme: light;
  --bg: #f4f6f2;
  --surface: #ffffff;
  --surface-soft: #eef5ef;
  --ink: #14201c;
  --muted: #68756f;
  --line: #dbe3dc;
  --accent: #176b4b;
  --accent-strong: #0d5037;
  --accent-soft: #dff3e8;
  --warning: #a55b13;
  --warning-soft: #fff0da;
  --danger: #aa342d;
  --danger-soft: #ffebe8;
  --shadow: 0 22px 65px rgba(29, 55, 43, 0.09);
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% -10%, rgba(129, 203, 157, 0.24), transparent 34rem),
    radial-gradient(circle at 92% 4%, rgba(228, 182, 117, 0.16), transparent 32rem),
    var(--bg);
}

button, input, textarea, select { font: inherit; }

button, .button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  color: var(--ink);
  background: var(--surface);
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms ease;
}

button:hover, .button:hover { border-color: #a9b9af; transform: translateY(-1px); }
button:disabled, .button[aria-disabled="true"] { opacity: 0.48; cursor: not-allowed; transform: none; }
button.primary, .button.primary { border-color: var(--accent); color: #fff; background: var(--accent); }
button.primary:hover, .button.primary:hover { border-color: var(--accent-strong); background: var(--accent-strong); }
button.danger, .button.danger { border-color: #efc2bc; color: var(--danger); background: var(--danger-soft); }
button.ghost, .button.ghost { background: transparent; }

input, textarea, select {
  width: 100%;
  border: 1px solid #cbd6ce;
  border-radius: 12px;
  padding: 12px 13px;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(23, 107, 75, 0.11);
}

textarea { min-height: 98px; resize: vertical; line-height: 1.5; }
label { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 800; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(27px, 3vw, 42px); line-height: 1.04; letter-spacing: -0.04em; }
h2 { margin-bottom: 5px; font-size: 19px; letter-spacing: -0.015em; }
h3 { margin-bottom: 6px; font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
[hidden] { display: none !important; }

.topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 68px;
  padding: 12px clamp(16px, 4vw, 44px);
  border-bottom: 1px solid rgba(210, 222, 213, 0.85);
  background: rgba(248, 250, 246, 0.88);
  backdrop-filter: blur(18px);
}

.brand { display: flex; align-items: center; gap: 11px; font-size: 17px; font-weight: 900; }
.brand::before { width: 13px; height: 13px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 6px var(--accent-soft); content: ""; }
.topbar .spacer { flex: 1; }

.layout {
  display: grid;
  grid-template-columns: minmax(290px, 370px) minmax(0, 1fr);
  gap: 20px;
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 24px clamp(16px, 4vw, 44px) 60px;
}

.sidebar, .main { display: grid; align-content: start; gap: 16px; min-width: 0; }
.sidebar { position: sticky; top: 92px; max-height: calc(100vh - 110px); overflow: auto; padding-right: 4px; }

.panel {
  border: 1px solid rgba(211, 221, 213, 0.95);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  padding: 20px;
}

.panel.hero { overflow: hidden; background: linear-gradient(135deg, #173d30, #0c211a); color: #f6fff9; }
.panel.hero .muted { color: #bed2c8; }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.section-head p { margin-bottom: 0; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.field { min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field + .field { margin-top: 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }
.field + .toolbar, .grid + .toolbar { margin-top: 16px; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: fit-content;
  border: 1px solid #c8e1d1;
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-size: 12px;
  font-weight: 850;
}
.status-pill::before { width: 7px; height: 7px; border-radius: 50%; background: currentColor; content: ""; }
.status-pill.offline, .status-pill.failed { border-color: #efd0ca; color: var(--danger); background: var(--danger-soft); }
.status-pill.waiting, .status-pill.review { border-color: #f0d4aa; color: var(--warning); background: var(--warning-soft); }

.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.metric { border: 1px solid var(--line); border-radius: 14px; padding: 13px; background: #fbfcfa; }
.metric strong { display: block; font-size: 22px; letter-spacing: -0.035em; }
.metric span { color: var(--muted); font-size: 11px; font-weight: 750; }

.task-list, .timeline { display: grid; gap: 10px; }
.task-card { border: 1px solid var(--line); border-radius: 15px; padding: 15px; background: #fff; }
.task-card.current { border-color: #9fcfb3; box-shadow: 0 0 0 3px rgba(23, 107, 75, 0.08); }
.task-card.completed, .task-card.skipped { opacity: 0.64; }
.task-card textarea { min-height: 112px; margin-top: 10px; }
.task-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-bottom: 8px; }
.task-meta .kind, .task-meta .risk, .task-meta .state {
  border-radius: 999px;
  padding: 4px 8px;
  background: var(--surface-soft);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.task-meta .risk.review { color: var(--warning); background: var(--warning-soft); }
.task-meta .risk.blocked { color: var(--danger); background: var(--danger-soft); }
.task-card .target { display: block; overflow: hidden; margin: 7px 0; color: var(--accent); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.task-card .toolbar { margin-top: 11px; }

.timeline-item { position: relative; padding: 2px 0 12px 24px; color: var(--muted); font-size: 13px; }
.timeline-item::before { position: absolute; top: 5px; left: 2px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); content: ""; }
.timeline-item:not(:last-child)::after { position: absolute; top: 16px; bottom: -3px; left: 6px; width: 1px; background: var(--line); content: ""; }
.timeline-item strong { display: block; margin-bottom: 3px; color: var(--ink); }

.notice, .empty { border: 1px dashed #c9d5cc; border-radius: 14px; padding: 15px; color: var(--muted); background: #fafcf9; line-height: 1.45; }
.notice.warning { border-style: solid; border-color: #eed2a9; color: #75430f; background: var(--warning-soft); }
.notice.error { border-style: solid; border-color: #edc4be; color: var(--danger); background: var(--danger-soft); }
.status-message { min-height: 20px; margin-top: 10px; color: var(--muted); font-size: 13px; }
.status-message.error { color: var(--danger); }
.status-message.success { color: var(--accent); }
#statusMessage { width: min(1480px, 100%); margin: 10px auto 0; padding: 0 clamp(16px, 4vw, 44px); }

.login-page { display: grid; min-height: 100vh; place-items: center; padding: 20px; }
.login-shell { width: min(430px, 100%); }
.login-panel { width: 100%; padding: 30px; }
.login-card { width: min(430px, 100%); border: 1px solid var(--line); border-radius: 24px; padding: 30px; background: rgba(255, 255, 255, 0.96); box-shadow: var(--shadow); }
.login-card .brand { margin-bottom: 28px; }
.login-card button { width: 100%; margin-top: 12px; }
.form-error { margin: 12px 0 0; color: var(--danger); }

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: none; overflow: visible; padding-right: 0; }
}

@media (max-width: 650px) {
  .topbar { align-items: flex-start; flex-wrap: wrap; }
  .topbar .spacer { display: none; }
  .layout { padding-top: 15px; }
  .grid, .metrics { grid-template-columns: 1fr; }
  .panel { border-radius: 15px; padding: 16px; }
  .section-head { flex-direction: column; }
  .toolbar > button, .toolbar > .button { flex: 1 1 145px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
