:root {
  color-scheme: light;
  --bg: #f3f5f7;
  --panel: #ffffff;
  --panel-soft: #f8fafb;
  --line: #d7dee6;
  --line-strong: #b8c4d0;
  --text: #19212b;
  --muted: #627083;
  --accent: #0f766e;
  --accent-dark: #0b5f59;
  --blue: #2c5f8f;
  --amber: #8a5a00;
  --green: #2f7d52;
  --danger: #b42318;
  --shadow: 0 1px 2px rgba(17, 24, 39, 0.08);
  --shadow-pop: 0 12px 28px rgba(17, 24, 39, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  min-height: 36px;
  border: 1px solid var(--accent-dark);
  border-radius: 7px;
  background: var(--accent);
  color: #ffffff;
  padding: 7px 13px;
  font-weight: 650;
  letter-spacing: 0;
  cursor: pointer;
  transition:
    background-color 0.12s ease,
    border-color 0.12s ease,
    box-shadow 0.12s ease,
    transform 0.12s ease;
}

button:hover {
  background: var(--accent-dark);
}

button:active {
  transform: translateY(1px);
}

button.secondary {
  border-color: var(--line);
  background: #ffffff;
  color: var(--text);
}

button.secondary:hover {
  border-color: var(--line-strong);
  background: var(--panel-soft);
}

button.danger {
  border-color: #992018;
  background: var(--danger);
}

button.danger:hover {
  background: #912018;
}

.hidden {
  display: none !important;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 74px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid #0a625c;
  border-radius: 8px;
  background: #0f766e;
  color: #ffffff;
  font-size: 18px;
  font-weight: 800;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

#session-user {
  min-height: 22px;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.2;
}

h2 {
  font-size: 16px;
  line-height: 1.3;
}

h3 {
  font-size: 14px;
  line-height: 1.35;
}

.topbar p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.tabs {
  position: sticky;
  top: 74px;
  z-index: 9;
  display: flex;
  gap: 4px;
  padding: 8px 28px 0;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  overflow-x: auto;
}

.tab {
  min-width: 92px;
  min-height: 42px;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
}

.tab:hover {
  background: var(--panel-soft);
  color: var(--text);
}

.tab.active {
  border-bottom-color: var(--accent);
  background: #ffffff;
  color: var(--text);
}

main {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 20px 28px 36px;
}

.login-view {
  display: grid;
  min-height: calc(100vh - 74px);
  place-items: center;
  padding: 24px;
}

.login-panel {
  display: grid;
  width: min(390px, 100%);
  gap: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 20px;
  box-shadow: var(--shadow-pop);
}

#login-error {
  min-height: 21px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.metric {
  min-height: 96px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--blue);
  border-radius: 8px;
  background: var(--panel);
  padding: 15px 16px;
  box-shadow: var(--shadow);
}

.metric-task {
  border-top-color: var(--amber);
}

.metric-schedule {
  border-top-color: var(--green);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 4px;
  font-size: 30px;
  line-height: 1;
}

.split {
  display: grid;
  grid-template-columns: minmax(300px, 0.92fr) minmax(420px, 1.35fr);
  gap: 16px;
  align-items: start;
}

.schedule-layout {
  grid-template-columns: minmax(320px, 0.88fr) minmax(480px, 1.4fr);
}

.surface {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 15px;
  box-shadow: var(--shadow);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.list {
  display: grid;
  gap: 9px;
}

.item {
  display: block;
  width: 100%;
  min-height: 72px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  padding: 11px 12px;
  text-align: left;
  box-shadow: none;
  cursor: pointer;
}

.item:hover {
  border-color: var(--line-strong);
  border-left-color: var(--accent);
  background: var(--panel-soft);
}

.item.good {
  border-left-color: var(--green);
}

.item.off {
  border-left-color: var(--muted);
}

.item-row {
  display: flex;
  min-width: 0;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}

.item-row h3 {
  min-width: 0;
  overflow-wrap: anywhere;
}

.badge {
  flex: 0 0 auto;
  max-width: 48%;
  border: 1px solid #c8d6dc;
  border-radius: 999px;
  background: #eef6f5;
  color: #0c5f59;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meta {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.empty {
  min-height: 78px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--muted);
  padding: 14px;
  text-align: center;
}

.form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

label.inline,
.checks label {
  display: flex;
  align-items: center;
  gap: 8px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--text);
  padding: 8px 10px;
  font-weight: 400;
  outline: none;
  transition:
    border-color 0.12s ease,
    box-shadow 0.12s ease,
    background-color 0.12s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

input[type="checkbox"] {
  width: 16px;
  min-width: 16px;
  height: 16px;
  min-height: 16px;
  accent-color: var(--accent);
}

textarea {
  resize: vertical;
}

#agent-persona,
#task-body,
#schedule-prompt,
#schedule-script-body,
#setting-value {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.55;
}

.grid2,
.grid3 {
  display: grid;
  gap: 11px;
}

.grid2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.toggle-row {
  display: flex;
  min-height: 38px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  padding: 8px 10px;
  color: var(--text);
  font-weight: 500;
}

.report {
  min-height: 300px;
  max-height: 56vh;
  margin: 0;
  border: 1px solid #111827;
  border-radius: 8px;
  background: #111827;
  color: #f8fafc;
  padding: 15px;
  overflow: auto;
  white-space: pre-wrap;
  font: 12px/1.55 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

.kv {
  display: grid;
  grid-template-columns: minmax(135px, 0.38fr) minmax(0, 1fr);
  gap: 7px 12px;
  margin: 12px 0 0;
}

.kv dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.kv dd {
  margin: 0;
  color: var(--text);
  overflow-wrap: anywhere;
}

#toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 36px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow-pop);
  padding: 11px 13px;
  color: var(--text);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition:
    opacity 0.15s ease,
    transform 0.15s ease;
}

#toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 980px) {
  .topbar {
    position: static;
    align-items: flex-start;
    padding: 14px 16px;
  }

  .tabs {
    position: static;
    padding: 8px 16px 0;
  }

  main {
    padding: 14px 16px 28px;
  }

  .split,
  .schedule-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .topbar {
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
    justify-content: space-between;
  }

  #session-user {
    width: 100%;
  }

  .metrics,
  .grid2,
  .grid3 {
    grid-template-columns: 1fr;
  }

  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .section-head button {
    width: 100%;
  }

  .item-row {
    flex-direction: column;
  }

  .badge {
    max-width: 100%;
  }

  .actions button {
    flex: 1 1 150px;
  }
}
