:root {
  color-scheme: light;
  --paper: #f1f3ee;
  --surface: #fbfcf8;
  --ink: #18221d;
  --muted: #69736d;
  --line: #d9ded7;
  --green: #145c43;
  --green-bright: #d8f065;
  --rust: #a3482f;
  --shadow: 0 18px 50px rgba(24, 34, 29, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 8% 3%, rgba(216, 240, 101, 0.23), transparent 30rem),
    var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select { font: inherit; }

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0 32px;
}

.masthead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  margin-bottom: 34px;
}
.masthead-actions { display: grid; justify-items: end; gap: 8px; }
.logout-button { padding: 4px 2px; }

.eyebrow, .section-number {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1 {
  max-width: 700px;
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(3.4rem, 8vw, 6.8rem);
  font-weight: 500;
  letter-spacing: -0.065em;
  line-height: 0.9;
}

.lede { margin: 18px 0 0; color: var(--muted); font-size: 1rem; }

.status-cluster {
  display: flex;
  align-items: center;
  min-width: 220px;
  gap: 12px;
  padding: 15px 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(251, 252, 248, 0.78);
}

.status-cluster strong, .status-cluster span { display: block; }
.status-cluster span { color: var(--muted); font-size: 0.8rem; margin-top: 3px; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: #a5ada8; box-shadow: 0 0 0 5px rgba(165, 173, 168, 0.14); }
.status-dot.running { background: #2c9b65; box-shadow: 0 0 0 5px rgba(44, 155, 101, 0.14); }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(300px, 0.75fr);
  gap: 20px;
  align-items: start;
}

.panel {
  border: 1px solid rgba(24, 34, 29, 0.1);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.form-panel { padding: clamp(22px, 4vw, 38px); }
.panel-heading { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; margin-bottom: 26px; }
.panel-heading.compact { margin-bottom: 18px; }
h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 1.7rem; font-weight: 500; }

.text-button, .icon-button {
  border: 0;
  background: transparent;
  color: var(--green);
  cursor: pointer;
  font-weight: 750;
}

.text-button { padding: 8px 0; font-size: 0.82rem; }
.icon-button { display: grid; width: 34px; height: 34px; place-items: center; border: 1px solid var(--line); border-radius: 50%; font-size: 1.15rem; }

.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.mode-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 24px;
  padding: 0;
  border: 0;
}
.mode-switch legend { margin-bottom: 10px; font-size: 0.82rem; font-weight: 750; }
.mode-option {
  position: relative;
  display: block;
  cursor: pointer;
}
.mode-option input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.mode-option > span {
  display: flex;
  min-height: 86px;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  transition: border-color 160ms, box-shadow 160ms, background 160ms;
}
.mode-option strong { font-size: 0.92rem; }
.mode-option small { color: var(--muted); font-size: 0.74rem; line-height: 1.4; }
.mode-option input:checked + span {
  border-color: var(--green);
  background: #edf3d9;
  box-shadow: 0 0 0 3px rgba(20, 92, 67, 0.08);
}
.mode-option input:focus-visible + span { outline: 2px solid var(--green); outline-offset: 2px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field > span { font-size: 0.82rem; font-weight: 750; }
.field small { color: var(--muted); font-size: 0.74rem; line-height: 1.45; }
.field small.error-hint { color: var(--rust); }
.span-2 { grid-column: span 2; }

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

input:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(20, 92, 67, 0.1); }
.upload-control { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
.upload-control .button { min-height: 48px; white-space: nowrap; }
.cookie-toolbar { display: flex; align-items: center; gap: 14px; }
.cookie-toolbar p { margin: 0; color: var(--green); font-size: 0.8rem; }
.cookie-toolbar p.error { color: var(--rust); }
.cookie-list { display: grid; gap: 9px; }
.cookie-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
}
.cookie-item > div:first-child { display: grid; gap: 4px; min-width: 0; }
.cookie-item strong { overflow: hidden; font-size: 0.84rem; text-overflow: ellipsis; white-space: nowrap; }
.cookie-item small { color: var(--muted); font-size: 0.7rem; }
.cookie-item > div:last-child { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.cookie-badge { padding: 5px 8px; border-radius: 999px; background: #eef1ed; color: var(--muted); font-size: 0.68rem; font-weight: 800; }
.status-valid .cookie-badge { background: #e3f4e9; color: var(--green); }
.status-expired .cookie-badge, .status-invalid .cookie-badge { background: #fff0ec; color: var(--rust); }
.empty-state { margin: 0; padding: 14px; border: 1px dashed var(--line); border-radius: 13px; color: var(--muted); font-size: 0.78rem; }
.rule { height: 1px; margin: 32px 0; background: var(--line); }
.emphasis-field { padding: 16px; border-radius: 16px; background: #edf3d9; }
.unit-input { display: flex; align-items: center; gap: 10px; }
.unit-input input { font-size: 1.4rem; font-weight: 760; }
.unit-input > span { color: var(--green); font-weight: 760; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
.button { min-height: 46px; border: 1px solid transparent; border-radius: 12px; padding: 0 18px; cursor: pointer; font-weight: 760; }
.button:disabled { cursor: not-allowed; opacity: 0.45; }
.button.primary { background: var(--green); color: #fff; }
.button.secondary { border-color: var(--line); background: #fff; color: var(--ink); }
.button.danger { margin-left: auto; border-color: rgba(163, 72, 47, 0.22); background: #fff6f3; color: var(--rust); }
.form-message { min-height: 1.25rem; margin: 13px 0 0; color: var(--green); font-size: 0.82rem; }
.form-message.error { color: var(--rust); }

.side-stack { display: grid; gap: 20px; }
.log-card { padding: 24px; }
.run-history { display: grid; gap: 8px; }
.history-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}
.history-row:hover { border-color: var(--green); }
.history-row > strong { font: 800 0.88rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.history-row > span:nth-child(2) { display: grid; gap: 3px; }
.history-row b { font-size: 0.78rem; }
.history-row small { color: var(--muted); font-size: 0.68rem; }
.history-running small, .history-scheduled small, .history-queued small { color: var(--green); }
.history-failed small, .history-cancelled small { color: var(--rust); }
.history-arrow { color: var(--green); font-size: 1.35rem; }

.task-dialog {
  width: min(760px, calc(100% - 28px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 26px;
  border: 1px solid rgba(24, 34, 29, 0.12);
  border-radius: 20px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 80px rgba(24, 34, 29, 0.25);
}
.task-dialog::backdrop { background: rgba(10, 18, 14, 0.54); backdrop-filter: blur(3px); }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-top: 20px; }
.detail-grid > div { display: grid; gap: 5px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.detail-grid span { color: var(--muted); font-size: 0.68rem; }
.detail-grid strong { font-size: 0.78rem; overflow-wrap: anywhere; }
.detail-log-heading { margin: 22px 0 9px; font-size: 0.8rem; }
.task-dialog pre { max-height: 360px; overflow: auto; margin: 0; padding: 16px; border-radius: 14px; background: #111a16; color: #cde7d8; font: 0.74rem/1.65 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; word-break: break-word; }

.task-panel { margin-top: 20px; padding: clamp(22px, 4vw, 34px); }
.task-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.task-item { padding: 17px; border: 1px solid var(--line); border-radius: 16px; background: #fff; }
.task-item-top { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.task-item-top strong { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 1rem; }
.task-status { padding: 6px 9px; border-radius: 999px; background: #eef1ed; color: var(--muted); font-size: 0.68rem; font-weight: 800; }
.task-running .task-status, .task-scheduled .task-status, .task-queued .task-status { background: #e3f4e9; color: var(--green); }
.task-failed .task-status, .task-cancelled .task-status { background: #fff0ec; color: var(--rust); }
.task-item dl { display: grid; gap: 7px; margin: 0; }
.task-item dl div { display: flex; justify-content: space-between; gap: 18px; }
.task-item dt { color: var(--muted); font-size: 0.74rem; }
.task-item dd { margin: 0; font-size: 0.76rem; font-weight: 700; text-align: right; }
.task-item-footer { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.task-item-footer small { color: var(--muted); font-size: 0.72rem; }
.button.task-cancel { min-height: 34px; padding: 0 11px; border-color: rgba(163, 72, 47, 0.2); background: #fff6f3; color: var(--rust); font-size: 0.72rem; }

footer { display: flex; justify-content: space-between; gap: 20px; padding: 24px 4px 0; color: var(--muted); font-size: 0.76rem; }

.login-page { min-height: 100vh; }
.login-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 430px);
  align-items: center;
  gap: clamp(38px, 8vw, 110px);
  width: min(1050px, calc(100% - 36px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 36px 0;
}
.login-copy h1 { max-width: 650px; }
.login-copy > p:last-child { max-width: 440px; margin: 22px 0 0; color: var(--muted); line-height: 1.7; }
.login-panel { display: grid; gap: 20px; padding: clamp(26px, 5vw, 38px); }
.login-panel .button { width: 100%; margin-top: 4px; }

@media (max-width: 850px) {
  .shell { padding-top: 28px; }
  .masthead { align-items: stretch; flex-direction: column; }
  .masthead-actions { justify-items: start; }
  .status-cluster { width: fit-content; }
  .layout { grid-template-columns: 1fr; }
  .task-list { grid-template-columns: 1fr; }
  .login-shell { grid-template-columns: 1fr; align-content: center; }
  .login-copy h1 { font-size: clamp(3.2rem, 14vw, 5.5rem); }
}

@media (max-width: 560px) {
  .shell { width: min(100% - 20px, 1180px); }
  h1 { font-size: 3.35rem; }
  .field-grid { grid-template-columns: 1fr; }
  .mode-switch { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .upload-control { grid-template-columns: 1fr; }
  .cookie-toolbar, .cookie-item { align-items: stretch; flex-direction: column; }
  .cookie-item > div:last-child { justify-content: space-between; }
  .button { width: 100%; }
  .button.danger { margin-left: 0; }
  .detail-grid { grid-template-columns: 1fr; }
  footer { flex-direction: column; }
}

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