:root {
  --bg: #f3f5f8;
  --panel: #ffffff;
  --panel-soft: #f9fafc;
  --text: #17202a;
  --muted: #657386;
  --line: #e2e7ef;
  --shadow: 0 18px 55px rgba(23, 32, 42, 0.10);
  --radius: 24px;
  --task-width: 360px;
  --day-width: 24px;
  --row-height: 102px;
  --critical: #d93933;
  --high: #e48214;
  --normal: #2563eb;
  --low: #6b7280;
  --ok: #11845b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.10), transparent 34rem),
    linear-gradient(180deg, #f7f9fc 0%, var(--bg) 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  cursor: pointer;
}

.app-shell {
  width: min(1680px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: stretch;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--normal);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.05;
  letter-spacing: -0.04em;
}

h1 {
  font-size: clamp(2.2rem, 5vw, 5rem);
}

h2 {
  font-size: clamp(1.25rem, 2vw, 1.8rem);
}

p {
  margin: 0;
}

.hero-copy,
.panel-title-row p,
.timeline-heading p,
.muted {
  color: var(--muted);
  line-height: 1.55;
}

.hero-copy {
  max-width: 760px;
  margin-top: 12px;
  font-size: 1.06rem;
}

.today-card,
.panel,
.toolbar,
.timeline-panel,
.summary-card {
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid rgba(226, 231, 239, 0.95);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.today-card {
  display: grid;
  align-content: center;
  min-width: 260px;
  padding: 24px;
  border-radius: var(--radius);
}

.today-card span,
.summary-card span,
label span {
  color: var(--muted);
}

.today-card strong {
  display: block;
  margin: 4px 0;
  font-size: 1.3rem;
}

.today-card small,
.summary-card small,
.next-due,
.mini-card small {
  color: var(--muted);
}

main {
  display: grid;
  gap: 18px;
}

.panel,
.timeline-panel {
  border-radius: var(--radius);
  padding: 22px;
}

.panel-title-row,
.timeline-heading {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
}

.panel-title-row.compact {
  margin-bottom: 14px;
}

.button-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.button-row.end {
  justify-content: flex-end;
}

.button-row.between {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
}

.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 999px;
  padding: 0.72rem 1rem;
  font-weight: 800;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(23, 32, 42, 0.12);
}

.btn.primary {
  border-color: #1d4ed8;
  background: #1d4ed8;
  color: #fff;
}

.btn.ghost {
  background: #f8fafc;
}

.btn.danger,
.btn.danger.ghost {
  color: #b42318;
}

.btn.tiny {
  padding: 0.48rem 0.72rem;
  font-size: 0.82rem;
  white-space: nowrap;
}

.settings-grid,
.toolbar,
.form-grid {
  display: grid;
  gap: 12px;
}

.settings-grid {
  grid-template-columns: repeat(6, minmax(120px, 1fr)) auto;
  align-items: end;
  margin-top: 18px;
}

.toolbar {
  grid-template-columns: minmax(260px, 1fr) 210px 180px auto auto;
  align-items: end;
  padding: 16px;
  border-radius: 20px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  padding: 0.78rem 0.88rem;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(37, 99, 235, 0.72);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

textarea {
  resize: vertical;
}

.toggle-line {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
}

.toggle-line input {
  width: 18px;
  height: 18px;
}

.toggle-line.in-form {
  justify-content: flex-start;
  margin: 2px 0 4px;
}

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

.summary-card {
  display: grid;
  gap: 6px;
  padding: 18px;
  border-radius: 20px;
}

.summary-card strong {
  font-size: 2.2rem;
  letter-spacing: -0.05em;
}

.timeline-heading {
  margin-bottom: 18px;
}

.legend {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--normal);
}

.dot.critical { background: var(--critical); }
.dot.high { background: var(--high); }
.dot.normal { background: var(--normal); }
.dot.low { background: var(--low); }

.timeline-scroll {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fff;
  max-height: 72vh;
}

.timeline-grid {
  --day-count: 365;
  display: grid;
  grid-template-columns: var(--task-width) calc(var(--day-count) * var(--day-width));
  min-width: calc(var(--task-width) + var(--day-count) * var(--day-width));
}

.timeline-sticky {
  position: sticky;
  left: 0;
  z-index: 4;
  background: #fff;
  border-right: 1px solid var(--line);
}

.timeline-corner,
.day-label-title {
  display: flex;
  align-items: center;
  padding: 0 18px;
  min-height: 46px;
  color: var(--muted);
  font-weight: 900;
  border-bottom: 1px solid var(--line);
}

.timeline-corner {
  top: 0;
  z-index: 8;
  background: #f8fafc;
}

.day-label-title {
  top: 46px;
  z-index: 7;
  background: #fff;
}

.month-header,
.day-header,
.timeline-row {
  display: grid;
  grid-template-columns: repeat(var(--day-count), var(--day-width));
}

.month-header {
  position: sticky;
  top: 0;
  z-index: 6;
  min-height: 46px;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
}

.month-header > div {
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 900;
}

.day-header {
  position: sticky;
  top: 46px;
  z-index: 5;
  min-height: 46px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.day-head {
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid #eef2f7;
  color: #7b8797;
  font-size: 0.72rem;
  font-weight: 800;
}

.day-head.weekend,
.timeline-cell.weekend {
  background: #f8fafc;
}

.day-head.today,
.timeline-cell.today {
  background: #eff6ff;
}

.task-info {
  min-height: var(--row-height);
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: grid;
  align-content: center;
  gap: 8px;
}

.task-info::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--normal);
}

.task-info.priority-critical::before { background: var(--critical); }
.task-info.priority-high::before { background: var(--high); }
.task-info.priority-normal::before { background: var(--normal); }
.task-info.priority-low::before { background: var(--low); }

.task-topline {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: start;
}

.task-topline strong {
  line-height: 1.25;
}

.task-edit-btn {
  border: 0;
  background: #eef2ff;
  color: #1d4ed8;
  border-radius: 999px;
  padding: 0.34rem 0.56rem;
  font-size: 0.72rem;
  font-weight: 900;
}

.task-meta,
.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.task-meta span,
.mini-badge {
  border-radius: 999px;
  padding: 0.22rem 0.48rem;
  font-size: 0.72rem;
  font-weight: 900;
  background: #f1f5f9;
  color: #475569;
}

.mini-badge.critical { background: rgba(217, 57, 51, 0.12); color: #a51610; }
.mini-badge.high { background: rgba(228, 130, 20, 0.16); color: #9a4f00; }
.mini-badge.normal { background: rgba(37, 99, 235, 0.12); color: #1d4ed8; }
.mini-badge.low { background: rgba(107, 114, 128, 0.14); color: #4b5563; }
.muted-badge { opacity: 0.75; }

.timeline-row {
  position: relative;
  min-height: var(--row-height);
  border-bottom: 1px solid var(--line);
}

.timeline-cell {
  display: block;
  border-right: 1px solid #eef2f7;
  min-height: var(--row-height);
}

.marker {
  align-self: center;
  justify-self: center;
  z-index: 2;
  width: 22px;
  height: 22px;
  border: 2px solid #fff;
  border-radius: 999px;
  color: #fff;
  font-size: 0.66rem;
  font-weight: 1000;
  line-height: 1;
  box-shadow: 0 6px 14px rgba(23, 32, 42, 0.22);
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.marker:hover {
  transform: scale(1.18);
  box-shadow: 0 10px 20px rgba(23, 32, 42, 0.30);
}

.marker.critical { background: var(--critical); }
.marker.high { background: var(--high); }
.marker.normal { background: var(--normal); }
.marker.low { background: var(--low); }
.marker.overdue { outline: 3px solid rgba(217, 57, 51, 0.18); }
.marker.due-today { width: 28px; height: 28px; }

.split-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}

.card-list {
  display: grid;
  gap: 10px;
}

.mini-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel-soft);
}

.mini-card strong {
  display: block;
  margin-bottom: 3px;
}

.mini-card p {
  color: var(--muted);
  font-size: 0.9rem;
}

.mini-card.priority-critical { border-left: 5px solid var(--critical); }
.mini-card.priority-high { border-left: 5px solid var(--high); }
.mini-card.priority-normal { border-left: 5px solid var(--normal); }
.mini-card.priority-low { border-left: 5px solid var(--low); }

.loading-state,
.error-state,
.empty-state {
  grid-column: 1 / -1;
  padding: 28px;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.error-state {
  color: #b42318;
}

.empty-state.slim {
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  background: #fff;
}

.modal {
  border: 0;
  padding: 0;
  width: min(560px, calc(100% - 24px));
  background: transparent;
}

.wide-modal {
  width: min(880px, calc(100% - 24px));
}

.modal::backdrop {
  background: rgba(15, 23, 42, 0.52);
  backdrop-filter: blur(8px);
}

.modal-card {
  position: relative;
  display: grid;
  gap: 14px;
  padding: 24px;
  border-radius: 28px;
  background: #fff;
  box-shadow: var(--shadow);
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 999px;
  background: #f1f5f9;
  color: var(--text);
  font-size: 1.35rem;
  font-weight: 900;
}

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

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: min(420px, calc(100% - 44px));
  padding: 0.9rem 1rem;
  border-radius: 18px;
  color: #fff;
  background: #111827;
  box-shadow: var(--shadow);
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  font-weight: 800;
}

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

.toast.error {
  background: #b42318;
}

@media (max-width: 1120px) {
  .settings-grid,
  .toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 760px) {
  :root {
    --task-width: 290px;
    --day-width: 22px;
    --row-height: 118px;
  }

  .app-shell {
    width: min(100% - 18px, 1680px);
    padding-top: 14px;
  }

  .hero,
  .panel-title-row,
  .timeline-heading,
  .summary-grid,
  .split-panel,
  .settings-grid,
  .toolbar,
  .form-grid.two-cols {
    grid-template-columns: 1fr;
  }

  .hero {
    display: grid;
  }

  .today-card {
    min-width: 0;
  }

  .panel,
  .timeline-panel {
    padding: 16px;
    border-radius: 20px;
  }

  .toolbar {
    display: grid;
  }

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

  .mini-card {
    align-items: flex-start;
    flex-direction: column;
  }
}
