:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef2f6;
  --ink: #16181d;
  --muted: #6e7784;
  --line: #e3e7ed;
  --blue: #2672ff;
  --blue-soft: #e9f1ff;
  --green: #11a36a;
  --green-soft: #e8f7ef;
  --amber: #d98d12;
  --amber-soft: #fff4da;
  --red: #e84c4f;
  --red-soft: #ffecee;
  --shadow: 0 18px 60px rgba(22, 24, 29, 0.08);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.app-shell {
  display: grid;
  grid-template-columns: 304px minmax(0, 1fr);
  min-height: 100vh;
}

.side-rail {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(24px);
}

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

.brand strong,
.brand small {
  display: block;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
}

.brand-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: #111827;
  overflow: hidden;
}

.brand-mark span:first-child {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
}

.brand-mark span:last-child {
  position: absolute;
  right: 9px;
  bottom: 9px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #53d28f;
}

.nav-stack {
  display: grid;
  gap: 6px;
}

.nav-item,
.ghost-button,
.primary-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border-radius: var(--radius);
  transition: transform 140ms ease, background 140ms ease, color 140ms ease, box-shadow 140ms ease;
}

.nav-item {
  justify-content: flex-start;
  width: 100%;
  padding: 10px 12px;
  color: var(--muted);
  background: transparent;
}

.nav-item:hover,
.nav-item.is-active {
  color: var(--ink);
  background: var(--surface-2);
}

.nav-item b {
  margin-left: auto;
  min-width: 26px;
  padding: 2px 7px;
  border-radius: 999px;
  text-align: center;
  color: var(--muted);
  background: #ffffff;
  font-size: 12px;
}

.icon {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.calendar-panel {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 10px 30px rgba(22, 24, 29, 0.04);
}

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

.weekday-row,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.weekday-row span {
  padding: 4px 0 8px;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

.day-cell {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 9px;
  color: var(--ink);
  background: transparent;
}

.day-cell.is-muted {
  color: #b8c0ca;
}

.day-cell.is-today {
  color: var(--blue);
  background: var(--blue-soft);
}

.day-cell.is-selected {
  color: #ffffff;
  background: var(--ink);
}

.day-cell span {
  line-height: 1;
  transform: translateY(4px);
}

.day-dot {
  position: absolute;
  top: 4px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--blue);
}

.main {
  min-width: 0;
  padding: 28px 32px;
}

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

.eyebrow {
  margin: 0 0 5px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
}

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

h1 {
  font-size: clamp(28px, 3vw, 42px);
  line-height: 1.08;
}

h2 {
  font-size: 24px;
}

.top-actions {
  display: flex;
  gap: 8px;
}

.ghost-button {
  padding: 0 14px;
  color: var(--ink);
  border: 1px solid var(--line);
  background: #ffffff;
}

.ghost-button:hover {
  background: var(--surface-2);
}

.ghost-button.danger {
  color: var(--red);
}

.primary-button {
  padding: 0 16px;
  color: #ffffff;
  background: var(--blue);
  box-shadow: 0 10px 24px rgba(38, 114, 255, 0.24);
}

.primary-button:hover {
  transform: translateY(-1px);
}

.icon-button {
  width: 40px;
  min-height: 40px;
  color: var(--muted);
  background: transparent;
}

.icon-button:hover {
  color: var(--ink);
  background: var(--surface-2);
}

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

.metric {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}

.metric span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  overflow: hidden;
  font-size: 28px;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.task-zone,
.smart-add,
.quick-add,
.report-panel {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.task-zone {
  min-width: 0;
  padding: 14px;
}

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

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

.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: var(--surface-2);
}

.segmented button {
  min-width: 70px;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
}

.segmented button.is-active {
  color: var(--ink);
  background: #ffffff;
  box-shadow: 0 3px 10px rgba(22, 24, 29, 0.08);
}

.select-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.select-wrap select {
  min-width: 116px;
}

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

select,
input {
  min-height: 40px;
  padding: 0 11px;
}

textarea {
  resize: vertical;
  padding: 11px;
}

select:focus,
input:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(38, 114, 255, 0.12);
}

.bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--ink);
  background: var(--blue-soft);
}

.bulk-bar div {
  display: flex;
  gap: 6px;
}

.task-list {
  display: grid;
  gap: 18px;
}

.task-group {
  display: grid;
  gap: 10px;
}

.task-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 2px;
}

.task-group-head strong,
.task-group-head span {
  display: block;
}

.task-group-head strong {
  font-size: 14px;
}

.task-group-head span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.task-group-head b {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 12px;
}

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

.task-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #ffffff;
}

.task-card.is-manual {
  border-color: #bfe9d2;
  background: #f7fcf9;
}

.task-card.is-ai {
  border-color: #cfe0ff;
  background: #f8fbff;
}

.task-card.is-overdue {
  border-color: #ffc8cd;
  background: #fff8f8;
}

.task-card.is-suggested {
  border-color: #cfe0ff;
  background: #f8fbff;
}

.task-card.is-selectable {
  cursor: pointer;
}

.task-card.is-selectable:hover {
  border-color: #9fc0ff;
  background: #f3f8ff;
}

.task-card.is-selected {
  border-color: var(--blue);
  background: var(--blue-soft);
  box-shadow: 0 0 0 3px rgba(38, 114, 255, 0.12);
}

.task-check {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  background: #ffffff;
}

.task-check.is-done {
  color: #ffffff;
  border-color: var(--green);
  background: var(--green);
}

.suggest-select {
  width: 22px;
  height: 22px;
  accent-color: var(--blue);
}

.task-main {
  min-width: 0;
}

.task-title-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.task-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
  font-weight: 750;
}

.priority-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber);
}

.priority-dot.high {
  background: var(--red);
}

.priority-dot.low {
  background: var(--green);
}

.task-notes {
  display: -webkit-box;
  margin: 5px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.latest-progress {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: start;
  gap: 6px;
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  color: #324153;
  background: rgba(255, 255, 255, 0.72);
}

.latest-progress .icon {
  margin-top: 1px;
  color: var(--blue);
}

.latest-progress p {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 12px;
}

.pill.deadline {
  color: #1258c8;
  background: var(--blue-soft);
}

.pill.overdue {
  color: #c33135;
  background: var(--red-soft);
}

.pill.done {
  color: #08734b;
  background: var(--green-soft);
}

.pill.origin-manual {
  color: #08734b;
  background: var(--green-soft);
}

.pill.origin-ai {
  color: #1258c8;
  background: var(--blue-soft);
}

.task-actions {
  display: flex;
  gap: 4px;
}

.right-stack {
  display: grid;
  gap: 14px;
}

.smart-add,
.quick-add,
.report-panel {
  padding: 16px;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

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

label + label,
.form-row + label,
label + .form-row {
  margin-top: 12px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.form-row.compact-3 {
  grid-template-columns: 1fr 0.82fr 0.9fr;
}

.form-row.compact-4 {
  grid-template-columns: 1fr 0.82fr 0.9fr 0.95fr;
}

.full {
  width: 100%;
  margin-top: 14px;
}

.smart-actions {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 8px;
  margin-top: 12px;
}

.smart-preview {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.smart-preview-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px;
  gap: 8px;
  padding: 10px 10px 10px 12px;
  border: 1px solid #cfe0ff;
  border-radius: 12px;
  background: #f8fbff;
}

.smart-preview-item strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.smart-preview-item p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.smart-preview-item .meta-row {
  margin-top: 7px;
}

.smart-preview-empty {
  padding: 11px 12px;
  border-radius: 12px;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 13px;
  line-height: 1.45;
}

.summary-list {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
}

.summary-item {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.summary-item strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-item span,
.summary-item p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 220px;
  color: var(--muted);
  text-align: center;
}

dialog {
  width: min(540px, calc(100vw - 28px));
  padding: 0;
  border: 0;
  border-radius: 22px;
  box-shadow: 0 28px 90px rgba(22, 24, 29, 0.24);
}

#editDialog {
  width: min(680px, calc(100vw - 28px));
}

dialog::backdrop {
  background: rgba(22, 24, 29, 0.32);
}

.settings-panel {
  padding: 20px;
}

.dialog-head,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog-head {
  margin-bottom: 18px;
}

.dialog-actions {
  margin-top: 18px;
}

.compact-title {
  margin: 18px 0 10px;
}

.progress-panel {
  margin-top: 14px;
  padding-top: 2px;
}

.progress-list {
  display: grid;
  gap: 8px;
  max-height: 220px;
  margin-bottom: 12px;
  overflow: auto;
}

.progress-item {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
}

.progress-item time {
  display: block;
  margin-bottom: 4px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
}

.progress-item p,
.progress-empty {
  margin: 0;
  color: #3b4554;
  font-size: 13px;
  line-height: 1.45;
}

.progress-empty {
  padding: 12px;
  border-radius: 12px;
  color: var(--muted);
  background: var(--surface-2);
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 44px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .side-rail {
    position: sticky;
    top: 0;
    z-index: 5;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 14px;
    padding: 14px 18px;
  }

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

  .nav-stack {
    grid-auto-flow: column;
    overflow: auto;
  }

  .nav-item {
    min-width: 130px;
  }

  .content-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1280px) and (min-width: 1121px) {
  .content-grid {
    grid-template-columns: 1fr;
  }

  .right-stack {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

@media (max-width: 720px) {
  .side-rail {
    position: static;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 18px 14px;
  }

  .nav-stack {
    grid-auto-flow: row;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
  }

  .nav-item {
    min-width: 0;
  }

  .main {
    padding: 18px 14px 28px;
  }

  .topbar,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .filter-controls {
    justify-content: stretch;
  }

  .select-wrap {
    flex: 1;
  }

  .top-actions,
  .segmented {
    width: 100%;
  }

  .top-actions > *,
  .segmented button {
    flex: 1;
  }

  .segmented {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-auto-flow: row;
  }

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

  .task-card {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .task-actions {
    grid-column: 2;
    justify-content: flex-start;
  }

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

  .form-row.compact-3 {
    grid-template-columns: 1fr;
  }

  .form-row.compact-4 {
    grid-template-columns: 1fr;
  }
}
