:root {
  --bg: #f6fbff;
  --surface: #ffffff;
  --surface-2: #eef7ff;
  --surface-3: #eaf8f0;
  --line: #c8d9ea;
  --line-strong: #3f8fdb;
  --ink: #102638;
  --muted: #5f7184;
  --green: #19a66a;
  --green-2: #0b7d57;
  --accent-muted: #2563eb;
  --green-soft: rgba(25, 166, 106, 0.13);
  --red: #df6b63;
  --amber: #b47a18;
  --blue: #2777c9;
  --todo: #87a0b8;
  --status-empty: rgba(16, 38, 56, 0.08);
  --shadow: 0 18px 44px rgba(35, 75, 112, 0.13);
  --field: rgba(255, 255, 255, 0.84);
  --field-strong: #ffffff;
  --subtle: rgba(39, 119, 201, 0.06);
  --success-ink: #07543a;
  --dark-ink: #ffffff;
  --status-todo: var(--todo);
  --status-doing: var(--amber);
  --status-done: var(--green);
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #f6fbff 0%, #eef8f3 52%, #ffffff 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button,
a,
summary {
  -webkit-tap-highlight-color: transparent;
}

button,
summary {
  cursor: pointer;
}

svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.5rem, 2.4vw, 2.2rem);
  line-height: 1;
}

h2 {
  margin-bottom: 0;
  font-size: 0.98rem;
}

h3,
h4 {
  margin-bottom: 0;
  font-size: 0.86rem;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 70px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  padding: 14px clamp(14px, 2.4vw, 28px);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(14px);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-muted);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.header-actions,
.panel-heading,
.board-toolbar,
.filters,
.filter-control,
.card-kicker,
.card-meta,
.detail-link-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status-pill,
.user-pill,
.status-token,
.priority {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.72rem;
  font-weight: 800;
}

.status-pill.ready,
.status-token {
  border-color: rgba(92, 160, 255, 0.34);
  background: var(--green-soft);
  color: var(--success-ink);
}

.status-pill.muted {
  color: var(--muted);
}

.user-pill {
  border-color: rgba(142, 172, 224, 0.28);
  background: rgba(142, 172, 224, 0.08);
  color: var(--ink);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(230px, 0.68fr) minmax(680px, 2fr) minmax(280px, 0.82fr);
  grid-template-areas:
    "projects board insights"
    "calendar calendar calendar";
  gap: 12px;
  width: min(1840px, calc(100% - 24px));
  margin: 12px auto 28px;
}

.project-sidebar,
.board-workspace,
.insight-card,
.calendar-panel,
.modal {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(239, 248, 255, 0.98));
  box-shadow: var(--shadow);
}

.project-sidebar {
  grid-area: projects;
  padding: 12px;
}

.board-workspace {
  grid-area: board;
  min-width: 0;
  padding: 12px;
}

.insight-sidebar {
  grid-area: insights;
  display: grid;
  gap: 12px;
  align-content: start;
}

.calendar-panel {
  grid-area: calendar;
  padding: 12px;
}

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

.panel-heading > svg {
  color: var(--green);
}

.portfolio-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.portfolio-metrics div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  padding: 10px;
}

.portfolio-metrics span {
  display: block;
  color: var(--green);
  font-size: 1.15rem;
  font-weight: 900;
}

.portfolio-metrics small {
  color: var(--muted);
  font-size: 0.72rem;
}

.project-list,
.user-list,
.task-stack,
.meeting-list,
.task-legend,
.calendar-events {
  display: grid;
  gap: 8px;
}

.project-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 56px;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  padding: 9px;
  text-align: left;
}

.project-row.active,
.project-row:hover {
  border-color: rgba(92, 160, 255, 0.44);
  background: rgba(92, 160, 255, 0.08);
}

.project-row-main {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.project-row-main strong,
.project-row-main small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-row-main small,
.muted-text {
  color: var(--muted);
}

.mini-progress {
  height: 7px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--green) var(--progress), rgba(16, 38, 56, 0.1) 0);
}

.team-panel {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.compact-heading {
  margin-bottom: 0;
}

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

.user-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  padding: 8px;
}

.user-row summary {
  display: flex;
  justify-content: space-between;
  width: 100%;
  color: var(--ink);
}

.user-row summary span {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.user-row summary small {
  color: var(--muted);
  font-size: 0.7rem;
}

.board-toolbar {
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.filters {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.filter-control {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  padding: 0 9px;
}

.filter-control input,
.filter-control select {
  border: 0;
  background: transparent;
  padding: 7px 0;
}

.filter-control input {
  min-width: 180px;
}

.kanban-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(210px, 1fr));
  gap: 10px;
  overflow-x: auto;
  min-height: 620px;
  padding-bottom: 2px;
}

.kanban-column {
  min-width: 210px;
  border: 1px solid rgba(63, 143, 219, 0.3);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  padding: 8px;
}

.kanban-column.drag-over {
  border-color: rgba(25, 166, 106, 0.52);
  background: rgba(25, 166, 106, 0.08);
}

.column-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding: 3px 2px;
}

.column-heading div {
  display: flex;
  align-items: center;
  gap: 7px;
}

.status-dot,
.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.status-dot.todo,
.legend-dot.todo {
  background: var(--status-todo);
}

.status-dot.doing,
.legend-dot.doing {
  background: var(--status-doing);
}

.status-dot.done,
.legend-dot.done {
  background: var(--status-done);
}

.column-count {
  min-width: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  color: var(--muted);
  text-align: center;
  font-size: 0.72rem;
  font-weight: 900;
}

.kanban-card {
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-strong);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #f4f9ff);
  min-width: 0;
  padding: 10px;
  box-shadow: 0 10px 24px rgba(35, 75, 112, 0.11);
}

.kanban-card:hover {
  border-color: rgba(25, 166, 106, 0.42);
}

.kanban-card.dragging {
  opacity: 0.45;
}

.priority-high,
.priority-critical {
  border-left-color: var(--amber);
}

.priority-critical {
  border-left-color: var(--red);
}

.card-kicker {
  justify-content: space-between;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
}

.kanban-card h4 {
  margin-bottom: 6px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.kanban-card p {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.card-notes {
  border-top: 1px solid var(--line);
  padding-top: 8px;
  line-height: 1.35;
  white-space: pre-wrap;
}

.priority {
  min-height: 22px;
  border-color: rgba(92, 160, 255, 0.28);
  color: var(--success-ink);
  font-size: 0.62rem;
}

.priority.high,
.priority.critical {
  border-color: rgba(196, 154, 69, 0.38);
  color: var(--amber);
}

.priority.critical {
  border-color: rgba(223, 107, 99, 0.42);
  color: var(--red);
}

.card-meta {
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.72rem;
}

.card-meta span,
.card-meta a,
.text-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.card-meta a,
.text-link {
  color: var(--green);
  font-weight: 800;
  text-decoration: none;
}

.insight-card {
  padding: 12px;
}

.detail-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.detail-top h2 {
  margin-bottom: 8px;
  font-size: 1.08rem;
}

.pie,
.task-pie {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 50%;
  position: relative;
}

.pie {
  width: 84px;
  background: conic-gradient(var(--green) var(--value), rgba(16, 38, 56, 0.08) 0);
}

.task-pie {
  width: 132px;
}

.pie::after,
.task-pie::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: var(--surface);
}

.pie::after {
  inset: 10px;
}

.task-pie::after {
  inset: 16px;
}

.pie span,
.task-pie span,
.task-pie small {
  position: relative;
  z-index: 1;
}

.pie span,
.task-pie span {
  color: var(--green);
  font-size: 1.05rem;
  font-weight: 900;
}

.task-pie small {
  margin-top: 28px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  position: absolute;
}

.task-pie-wrap {
  display: grid;
  justify-items: center;
  gap: 12px;
}

.task-legend {
  width: 100%;
  color: var(--muted);
  font-size: 0.76rem;
}

.task-legend span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  background: rgba(255, 255, 255, 0.82);
}

.legend-dot {
  margin-right: auto;
}

.detail-description {
  margin: 10px 0;
  color: #355169;
  font-size: 0.84rem;
  line-height: 1.4;
}

.detail-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 10px;
}

.detail-stats span {
  display: grid;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px;
  color: var(--muted);
  font-size: 0.66rem;
}

.detail-stats strong {
  color: var(--ink);
  font-size: 0.9rem;
}

.meeting-pill {
  display: grid;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  padding: 9px;
}

.meeting-pill span,
.meeting-pill small {
  color: var(--muted);
  font-size: 0.72rem;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(128px, 1fr));
  gap: 7px;
  overflow-x: auto;
}

.calendar-weekday {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
  padding: 0 2px 2px;
}

.calendar-day {
  min-height: 112px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  padding: 7px;
}

.calendar-day.outside-month {
  opacity: 0.42;
}

.calendar-day.today {
  border-color: rgba(92, 160, 255, 0.62);
  box-shadow: inset 0 0 0 1px rgba(92, 160, 255, 0.18);
}

.calendar-day-number {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 900;
}

.calendar-day.today .calendar-day-number {
  background: var(--green);
  color: var(--dark-ink);
}

.calendar-events {
  margin-top: 6px;
}

.calendar-meeting {
  border: 1px solid rgba(92, 160, 255, 0.28);
  border-radius: 8px;
  background: rgba(92, 160, 255, 0.08);
  padding: 6px;
}

.calendar-meeting summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  width: 100%;
  gap: 6px;
  color: var(--ink);
}

.calendar-meeting summary span {
  color: var(--green);
  font-size: 0.68rem;
  font-weight: 900;
}

.calendar-meeting summary strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.76rem;
}

.calendar-meeting p {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.74rem;
}

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

details {
  margin-top: 8px;
}

summary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--green);
  font-weight: 800;
  list-style: none;
}

summary::-webkit-details-marker {
  display: none;
}

.empty-state,
.empty-column {
  margin: 0;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 10px;
  color: var(--muted);
  background: var(--subtle);
  font-size: 0.76rem;
}

.empty-column {
  display: none;
}

.task-stack:empty + .empty-column,
.task-stack .empty-column:only-child {
  display: block;
}

button,
.primary,
.secondary,
.danger,
.ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 8px 11px;
  color: inherit;
  font-weight: 900;
}

.primary {
  border-color: rgba(92, 160, 255, 0.62);
  background: linear-gradient(135deg, var(--green), var(--green-2));
  color: var(--dark-ink);
}

.secondary {
  border-color: var(--line-strong);
  background: rgba(92, 160, 255, 0.1);
  color: var(--success-ink);
}

.ghost {
  border-color: var(--line);
  background: var(--subtle);
  color: var(--ink);
}

.danger {
  border-color: rgba(223, 107, 99, 0.34);
  background: rgba(223, 107, 99, 0.12);
  color: #f1b8b3;
}

.icon-button {
  width: 36px;
  min-width: 36px;
  padding: 0;
}

.full,
.full-width {
  width: 100%;
}

.flash-stack {
  display: grid;
  gap: 8px;
  width: min(920px, calc(100% - 24px));
  margin: 10px auto 0;
}

.flash {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(92, 160, 255, 0.1);
  color: var(--success-ink);
  font-weight: 800;
}

.flash.warning {
  background: rgba(196, 154, 69, 0.12);
  color: var(--amber);
}

.flash.error {
  background: rgba(223, 107, 99, 0.12);
  color: #f1b8b3;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field-strong);
  color: var(--ink);
  padding: 9px 10px;
}

input[type="range"] {
  accent-color: var(--green);
}

textarea {
  resize: vertical;
}

label {
  display: grid;
  min-width: 0;
  gap: 5px;
}

label span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  outline: 3px solid rgba(92, 160, 255, 0.14);
}

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

.compact-form .full,
.modal-form .full,
.team-form .full,
.single-column {
  grid-column: 1 / -1;
}

.single-column {
  grid-template-columns: 1fr;
}

.modal {
  width: min(620px, calc(100% - 24px));
  max-height: min(730px, calc(100vh - 24px));
  overflow: auto;
  color: var(--ink);
  padding: 14px;
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.76);
}

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

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  padding: 5px;
}

.segment {
  min-height: 34px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.segment.active {
  background: var(--green-soft);
  color: var(--green);
}

.segmented-control:has(.segment:only-child) {
  grid-template-columns: 1fr;
}

.modal-form {
  display: none;
}

.modal-form.active {
  display: grid;
}

[hidden] {
  display: none !important;
}

.auth-body {
  display: grid;
  place-items: center;
  padding: 18px;
}

.auth-shell {
  width: min(440px, 100%);
}

.auth-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(239, 248, 255, 0.98));
  box-shadow: var(--shadow);
  padding: 18px;
}

.auth-panel h1 {
  font-size: 1.55rem;
}

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

.inline-flashes {
  width: 100%;
  margin: 0 0 12px;
}

@media (max-width: 1360px) {
  .app-shell {
    grid-template-columns: minmax(230px, 0.7fr) minmax(620px, 2fr);
    grid-template-areas:
      "projects board"
      "insights insights"
      "calendar calendar";
  }

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

@media (max-width: 900px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions,
  .filters {
    justify-content: flex-start;
  }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "projects"
      "board"
      "insights"
      "calendar";
  }

  .insight-sidebar,
  .compact-form,
  .modal-form,
  .team-form,
  .detail-stats {
    grid-template-columns: 1fr;
  }

  .kanban-board {
    grid-template-columns: repeat(3, 82vw);
  }

  .calendar-grid {
    grid-template-columns: repeat(7, minmax(112px, 1fr));
  }

  .board-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .filter-control input {
    min-width: 0;
  }
}
