:root {
  color-scheme: light;
  --bg: #f7f8f5;
  --ink: #20231f;
  --muted: #687066;
  --line: #d9ddd4;
  --panel: #ffffff;
  --accent: #236967;
  --accent-2: #b5402f;
  --accent-3: #c99b2e;
  --accent-soft: #e5f0ee;
  --shadow: 0 18px 45px rgba(39, 44, 37, 0.08);
  --timeline-label-width: min(720px, calc(100vw - 240px));
  --timeline-gap: 12px;
  --topbar-height: 124px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.auth-pending .topbar,
body.auth-pending main,
body.auth-pending dialog {
  display: none;
}

.auth-screen {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
  z-index: 100;
}

body.auth-pending .auth-screen {
  display: flex;
}

.auth-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-card h1 {
  margin-bottom: 8px;
}

.auth-error {
  min-height: 20px;
  margin: 0;
  color: var(--accent-2);
  font-size: 13px;
}

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

button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

button:hover {
  border-color: #aeb7aa;
}

.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  padding: 0 14px;
}

.danger {
  border-color: #e4beb8;
  color: var(--accent-2);
}

.icon-button {
  width: 38px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  padding: 22px 28px;
  background: rgba(247, 248, 245, 0.92);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.1;
}

h2 {
  font-size: 18px;
}

.actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

main {
  width: min(1480px, calc(100vw - 32px));
  margin: 18px auto 42px;
}

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

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

.metric strong {
  display: block;
  font-size: 28px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.controls {
  display: grid;
  grid-template-columns: 2fr repeat(4, 1fr);
  gap: 10px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 9px 10px;
}

textarea {
  resize: vertical;
}

.view-switch {
  display: flex;
  gap: 6px;
  margin: 14px 0;
  border-bottom: 1px solid var(--line);
}

.tab {
  min-width: 112px;
  border-bottom: 0;
  border-radius: 7px 7px 0 0;
  background: transparent;
}

.tab.active {
  background: var(--panel);
  border-color: var(--line);
  color: var(--accent);
  font-weight: 700;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.table-wrap {
  overflow-x: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  min-width: 1040px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.task-title {
  font-weight: 700;
}

.task-description {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.pill.priority-high {
  background: #f8e3df;
  color: var(--accent-2);
}

.pill.priority-medium {
  background: #fff1cc;
  color: #8b6412;
}

.progress {
  width: 120px;
  height: 8px;
  margin-top: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #ecefe9;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 12px;
}

.lane {
  min-height: 280px;
  padding: 12px;
  background: #eef1ec;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.lane h2 {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
}

.card {
  margin-bottom: 10px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(39, 44, 37, 0.06);
}

.card footer {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

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

.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.segmented button {
  min-height: 30px;
  border: 0;
  padding: 0 12px;
  background: transparent;
}

.segmented button.active {
  background: var(--accent);
  color: #fff;
}

.file-status {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.timeline {
  overflow: visible;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 100%;
  padding: 0;
}

.timeline-shell {
  width: 100%;
}

.timeline-header {
  position: sticky;
  top: var(--topbar-height);
  z-index: 20;
  width: calc(100% - var(--timeline-label-width) - var(--timeline-gap) - 32px);
  min-width: min(var(--timeline-width), calc(100% - var(--timeline-label-width) - var(--timeline-gap) - 32px));
  margin-left: calc(var(--timeline-label-width) + var(--timeline-gap) + 16px);
  padding: 0 0 8px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  border-radius: 8px 8px 0 0;
}

.timeline-header-scroll {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}

.timeline-header-scroll::-webkit-scrollbar {
  display: none;
}

.timeline-body {
  overflow-x: auto;
  overflow-y: visible;
  padding: 0 16px 16px;
}

.timeline-content {
  min-width: calc(var(--timeline-label-width) + var(--timeline-gap) + var(--timeline-width));
}

.days {
  position: relative;
  z-index: 20;
  display: flex;
  flex-wrap: nowrap;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.day-cell {
  display: grid;
  place-items: center;
  flex: 0 0 var(--unit-width);
  min-height: 44px;
  border-right: 1px solid var(--line);
  background: #fbfcfa;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  white-space: nowrap;
}

.day-cell:last-child {
  border-right: 0;
}

.day-cell strong {
  color: var(--ink);
  font-size: 12px;
}

.day-cell.weekend {
  background: #f8eee9;
}

.day-cell.active-bound {
  background: #dcebe8;
  box-shadow: inset 0 0 0 2px var(--accent);
  color: var(--accent);
}

.timeline-group {
  margin-top: 6px;
  border-top: 1px solid var(--line);
}

.group-toggle {
  position: sticky;
  left: 0;
  z-index: 8;
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: var(--timeline-label-width);
  margin: 10px 0 4px;
  padding: 8px 10px;
  background: #eef1ec;
  border-color: var(--line);
  font-weight: 700;
  text-align: left;
  box-shadow: var(--timeline-gap) 0 0 var(--panel);
}

.timeline-row {
  display: grid;
  grid-template-columns: var(--timeline-label-width) var(--timeline-width);
  gap: var(--timeline-gap);
  align-items: center;
  min-height: 58px;
  border-bottom: 1px solid var(--line);
}

.timeline-task-info {
  position: sticky;
  left: 0;
  z-index: 8;
  align-self: stretch;
  width: var(--timeline-label-width);
  min-width: var(--timeline-label-width);
  padding: 8px 8px 8px 0;
  background: var(--panel);
  box-shadow: var(--timeline-gap) 0 0 var(--panel);
}

.timeline-task-info::after {
  position: absolute;
  top: 0;
  right: calc(-1 * var(--timeline-gap));
  bottom: 0;
  width: var(--timeline-gap);
  content: "";
  background: var(--panel);
  border-right: 1px solid var(--line);
}

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

.bar-track {
  position: relative;
  z-index: 0;
  height: 24px;
  border-radius: 999px;
  background:
    repeating-linear-gradient(
      to right,
      transparent 0,
      transparent calc(var(--unit-width) - 1px),
      rgba(104, 112, 102, 0.2) calc(var(--unit-width) - 1px),
      rgba(104, 112, 102, 0.2) var(--unit-width)
    ),
    #ecefe9;
}

.bar {
  position: absolute;
  top: 3px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  height: 18px;
  min-width: 8px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.bar:active {
  cursor: grabbing;
}

.bar-label {
  min-width: 0;
  overflow: hidden;
  padding: 0 2px;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.resize-handle {
  flex: 0 0 8px;
  height: 18px;
  cursor: ew-resize;
}

.resize-handle.left {
  border-radius: 999px 0 0 999px;
}

.resize-handle.right {
  border-radius: 0 999px 999px 0;
}

.bar.done {
  background: #4c7b3e;
}

.bar.blocked {
  background: var(--accent-2);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 12px;
}

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

.settings-row {
  display: grid;
  grid-template-columns: 1fr 38px;
  gap: 8px;
  margin-bottom: 8px;
}

dialog {
  width: min(760px, calc(100vw - 24px));
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 30px 80px rgba(28, 33, 26, 0.28);
}

dialog::backdrop {
  background: rgba(32, 35, 31, 0.42);
}

.dialog-head,
.dialog-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.dialog-actions {
  grid-template-columns: auto 1fr auto auto;
  margin-top: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.subtasks-editor {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.subtasks-details {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.subtasks-details summary {
  width: fit-content;
  cursor: pointer;
  font-weight: 700;
}

.subtasks-details ul {
  display: grid;
  gap: 5px;
  margin: 7px 0 0;
  padding: 0;
  list-style: none;
}

.subtasks-details li {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  justify-content: space-between;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfa;
}

.subtask-check {
  display: flex;
  grid-template-columns: auto 1fr;
  gap: 7px;
  align-items: center;
  color: var(--ink);
  font-size: 13px;
}

.subtask-check input {
  width: 16px;
  height: 16px;
  padding: 0;
  accent-color: var(--accent);
}

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

.subtasks-head h3 {
  margin: 0;
  font-size: 15px;
}

.subtask-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 150px 38px;
  gap: 8px;
  margin-bottom: 8px;
}

@media (max-width: 860px) {
  :root {
    --timeline-label-width: min(720px, calc(100vw - 96px));
  }

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

  .topbar {
    flex-direction: column;
  }

  .summary,
  .controls,
  .settings-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .view-switch {
    overflow-x: auto;
  }

  .timeline-row {
    grid-template-columns: 1fr;
    padding: 12px 0;
  }

  .timeline-header {
    top: 0;
    width: calc(100% - var(--timeline-label-width) - var(--timeline-gap) - 32px);
    min-width: 260px;
    margin-left: calc(var(--timeline-label-width) + var(--timeline-gap) + 16px);
  }

  .group-toggle,
  .timeline-task-info {
    position: sticky;
    width: var(--timeline-label-width);
  }

  .subtask-row {
    grid-template-columns: 1fr;
  }
}
