:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-2: #eef3f1;
  --ink: #17201f;
  --muted: #66736f;
  --line: #d9e0dd;
  --green: #1f9d69;
  --green-soft: #dff5ea;
  --blue: #2f6fe4;
  --blue-soft: #dfe9ff;
  --purple: #8a4bd1;
  --purple-soft: #efe3ff;
  --coral: #d9634a;
  --coral-soft: #ffe6de;
  --amber: #c98914;
  --amber-soft: #fff2cf;
  --shadow: 0 18px 48px rgba(28, 42, 38, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(246, 247, 244, 0.96)),
    linear-gradient(135deg, rgba(31, 157, 105, 0.08), rgba(47, 111, 228, 0.06) 42%, rgba(217, 99, 74, 0.06)),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

.login-page {
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(31, 157, 105, 0.1), rgba(47, 111, 228, 0.08) 48%, rgba(217, 99, 74, 0.08)),
    var(--bg);
}

.login-shell {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(320px, 440px);
  gap: clamp(32px, 8vw, 120px);
  align-items: center;
  width: min(1040px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.login-brand .brand-mark {
  width: 58px;
  height: 58px;
  font-size: 18px;
}

.login-brand h1 {
  margin-bottom: 8px;
}

.login-brand p,
.login-panel > div p {
  color: var(--muted);
  line-height: 1.5;
}

.login-panel {
  display: grid;
  gap: 24px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow);
}

.login-panel h2 {
  margin-bottom: 6px;
  font-size: 24px;
}

.login-panel form {
  display: grid;
  gap: 16px;
}

.password-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 8px;
}

.password-field .icon-button {
  height: 38px;
}

.login-button {
  width: 100%;
  min-height: 44px;
}

.form-status {
  min-height: 20px;
  color: var(--coral);
  font-size: 13px;
}

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

button {
  cursor: pointer;
}

.app-shell {
  width: min(1880px, 100%);
  margin: 0 auto;
  padding: 20px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

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

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  background: #15251f;
  color: #eaf7f1;
  font-weight: 850;
  box-shadow: var(--shadow);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1;
  letter-spacing: 0;
}

.brand p,
.scenario-head p,
.microcopy {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.topbar-actions,
.segmented,
.status-tabs,
.panel-heading,
.toolbar {
  display: flex;
  align-items: center;
}

.topbar-actions {
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.system-status {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.system-status.is-online {
  border-color: #b9dfcd;
  background: var(--green-soft);
  color: #12643f;
}

.icon-button,
.text-button,
.primary-button,
.segmented button,
.status-tabs button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

.icon-button {
  display: grid;
  width: 40px;
  place-items: center;
  color: inherit;
  text-decoration: none;
}

.icon-button svg,
.text-button svg,
.primary-button svg {
  width: 18px;
  height: 18px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric-card {
  min-height: 112px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(28, 42, 38, 0.08);
}

.metric-card strong {
  display: block;
  margin: 10px 0 6px;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 0.92;
}

.metric-label,
.field span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0;
  text-transform: uppercase;
}

.accent-green {
  border-top: 4px solid var(--green);
}

.accent-blue {
  border-top: 4px solid var(--blue);
}

.accent-purple {
  border-top: 4px solid var(--purple);
}

.accent-coral {
  border-top: 4px solid var(--coral);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr) minmax(280px, 380px);
  gap: 14px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 12px 36px rgba(28, 42, 38, 0.08);
}

.team-panel,
.scenario-panel,
.inspector-panel,
.import-panel,
.timeline-panel {
  padding: 14px;
}

.panel-heading {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-actions {
  display: flex;
  gap: 6px;
}

.panel-heading h2,
.scenario-head h2 {
  font-size: 18px;
  line-height: 1.2;
}

.panel-heading span:not(.status-pill) {
  color: var(--muted);
  font-size: 13px;
}

.team-list,
.timeline-list {
  display: grid;
  gap: 10px;
}

.team-item {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--surface-2);
}

.avatar {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: #17201f;
  color: white;
  font-size: 14px;
  font-weight: 800;
}

.team-meta {
  min-width: 0;
}

.team-name {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 14px;
  font-weight: 780;
}

.team-name span:last-child {
  color: var(--muted);
  font-weight: 650;
}

.bar {
  overflow: hidden;
  height: 7px;
  margin-top: 8px;
  border-radius: 999px;
  background: #d8e0dd;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--blue));
}

.scenario-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.segmented,
.status-tabs {
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border-radius: 8px;
  background: var(--surface-2);
}

.segmented button,
.status-tabs button {
  min-height: 32px;
  padding: 0 11px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 780;
}

.segmented button.is-active,
.status-tabs button.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 4px 14px rgba(28, 42, 38, 0.08);
}

.toolbar {
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fafbf9;
}

.field {
  display: grid;
  gap: 5px;
}

.field.compact {
  width: min(180px, 100%);
}

.field.grow {
  flex: 1 1 220px;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
}

select,
input {
  min-height: 38px;
  padding: 0 10px;
}

textarea {
  min-height: 150px;
  padding: 10px;
  resize: vertical;
  line-height: 1.42;
}

select:focus,
input:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 111, 228, 0.16);
  outline: none;
}

.script-board {
  display: grid;
  gap: 14px;
  max-height: calc(100vh - 256px);
  min-height: 560px;
  overflow: auto;
  padding-right: 4px;
}

.part-block {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.part-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
}

.part-title {
  min-width: 0;
  font-weight: 820;
}

.part-title span {
  color: var(--muted);
  font-weight: 700;
}

.part-count {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 13px;
}

.line-row {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid #edf1ef;
  border-radius: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.line-row:hover,
.line-row.is-selected {
  background: #f6faf8;
}

.line-row:last-child {
  border-bottom: 0;
}

.line-no {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 30px;
  border-radius: 8px;
  background: #edf1ef;
  color: var(--muted);
  font-size: 12px;
  font-weight: 820;
}

.line-text {
  min-width: 0;
  font-size: 15px;
  line-height: 1.42;
}

.line-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 118px;
  justify-content: flex-end;
}

.line-row.status-done {
  background: linear-gradient(90deg, rgba(31, 157, 105, 0.16), transparent 70%);
}

.line-row.status-in_progress {
  background: linear-gradient(90deg, rgba(47, 111, 228, 0.15), transparent 70%);
}

.line-row.status-review {
  background: linear-gradient(90deg, rgba(138, 75, 209, 0.16), transparent 70%);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 74px;
  min-height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 820;
  white-space: nowrap;
}

.status-pill.done {
  background: var(--green-soft);
  color: #12643f;
}

.status-pill.in_progress {
  background: var(--blue-soft);
  color: #1e4c9c;
}

.status-pill.review {
  background: var(--purple-soft);
  color: #5b2f8d;
}

.status-pill.todo {
  background: #edf1ef;
  color: var(--muted);
}

.assignees {
  display: flex;
  gap: 4px;
}

.assignee-dot {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 7px;
  background: #17201f;
  color: white;
  font-size: 10px;
  font-weight: 850;
}

.side-stack {
  display: grid;
  gap: 14px;
  position: sticky;
  top: 14px;
}

.other-tasks-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.other-tasks-section .panel-heading p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.other-tasks-list,
.insights-list {
  display: grid;
  gap: 8px;
  max-height: 420px;
  overflow: auto;
}

.other-task-item,
.insight-item {
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fafbf9;
}

.other-task-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.other-task-head strong {
  font-size: 14px;
  line-height: 1.4;
}

.other-task-meta,
.insight-kpis {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.other-task-meta span,
.insight-kpis span {
  padding: 4px 7px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 720;
}

.blocker {
  margin-top: 8px;
  color: var(--coral);
  font-size: 12px;
}

.insight-item p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.line-inspector {
  display: grid;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.line-inspector strong {
  color: var(--ink);
}

.inspector-text {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fafbf9;
  color: var(--ink);
}

.assignment-list {
  display: grid;
  gap: 8px;
}

.assignment-item,
.timeline-item {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fafbf9;
}

.assignment-item strong,
.timeline-item strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
}

.timeline-item {
  position: relative;
  padding-left: 16px;
}

.timeline-item::before {
  content: "";
  position: absolute;
  top: 14px;
  left: 0;
  width: 5px;
  height: calc(100% - 28px);
  border-radius: 999px;
  background: var(--blue);
}

.timeline-item.status-fallback::before {
  background: var(--amber);
}

.timeline-item.status-seed::before {
  background: var(--green);
}

.timeline-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.timeline-summary {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.import-panel form {
  display: grid;
  gap: 10px;
}

.text-button,
.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 12px;
  font-weight: 820;
}

.text-button {
  min-height: 34px;
  background: var(--surface-2);
}

.primary-button {
  border-color: #15251f;
  background: #15251f;
  color: white;
}

.empty-state {
  display: grid;
  min-height: 140px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .side-stack {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .timeline-panel {
    grid-column: 1 / -1;
  }

  .script-board {
    max-height: none;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 12px;
  }

  .topbar {
    align-items: flex-start;
  }

  .metric-grid,
  .side-stack {
    grid-template-columns: 1fr;
  }

  .scenario-head {
    display: grid;
  }

  .line-row {
    grid-template-columns: 44px minmax(0, 1fr);
  }

  .line-meta {
    grid-column: 2;
    justify-content: flex-start;
  }

  .login-shell {
    grid-template-columns: 1fr;
    align-content: center;
    gap: 28px;
    padding: 28px 0;
  }

  .login-brand {
    align-items: flex-start;
  }
}
