:root {
  --ink: #17233b;
  --muted: #71809b;
  --line: #e5eaf2;
  --bg: #f6f8fc;
  --card: #fff;
  --primary: #5268dc;
  --primary-dark: #4054c3;
  --mint: #e4f7ef;
  --mint-ink: #2f9d73;
  --orange: #fff0dd;
  --orange-ink: #c87828;
  --lavender: #eeedff;
  --lavender-ink: #7469d4;
}

* {
  box-sizing: border-box;
}

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

html:not(.auth-ready) body[data-page] { visibility: hidden; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #f6f8fc 0%, #eef0ff 100%);
}

.login-card {
  width: min(430px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 38px;
  box-shadow: 0 20px 60px #263e7814;
}

.login-brand { margin-bottom: 46px; }
.login-card h1 { margin: 0 0 8px; font-size: 30px; letter-spacing: -0.04em; }
.login-button { width: 100%; justify-content: center; gap: 10px; margin-top: 22px; }
.google-g { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: #fff; color: #4285f4; font-weight: 800; }
.auth-message { min-height: 20px; margin: 14px 0 0; text-align: center; color: var(--muted); font-size: 13px; }
.login-note { margin: 30px 0 0; color: var(--muted); font-size: 12px; text-align: center; }

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

button {
  cursor: pointer;
  border: 0;
}

/* Layout shells */
.topbar {
  height: 72px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
}

.brand {
  font-weight: 800;
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
}

.topbar-actions,
.sidebar-footer,
.page-heading,
.panel-heading,
.calendar-header,
.pipeline-summary,
.board-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.save-status {
  color: var(--muted);
  font-size: 12px;
}

.app-shell {
  display: flex;
  min-height: calc(100vh - 72px);
}

.sidebar {
  width: 230px;
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 30px 18px;
  display: flex;
  flex-direction: column;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 11px;
  font-weight: 800;
  color: #9aa6bb;
  margin: 0 0 8px;
}

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

.nav-link {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  border-radius: 10px;
  font-weight: 600;
  text-decoration: none;
}

.nav-link:hover,
.nav-link.active {
  background: #eef0ff;
  color: var(--primary);
}

.nav-count {
  margin-left: auto;
  background: #eef0ff;
  border-radius: 9px;
  padding: 2px 7px;
  font-size: 11px;
}

.sidebar-footer {
  margin-top: auto;
  justify-content: flex-start;
  padding: 15px 5px;
  border-top: 1px solid var(--line);
  font-size: 12px;
}

.sidebar-footer small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}

.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--lavender);
  color: var(--lavender-ink);
  font-weight: 800;
}

.main-content {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 38px 44px 60px;
}

.view {
  display: none;
}

.active-view {
  display: block;
}

/* Headings and buttons */
.page-heading {
  align-items: flex-end;
  margin-bottom: 30px;
}

.page-heading h1 {
  font-size: 30px;
  letter-spacing: -0.04em;
  margin: 0 0 5px;
}

.muted,
small {
  color: var(--muted);
}

.button {
  display: inline-flex;
  align-items: center;
  border-radius: 9px;
  padding: 11px 17px;
  font-weight: 700;
  text-decoration: none;
}

.button-primary {
  background: var(--primary);
  color: #fff;
}

.button-primary:hover {
  background: var(--primary-dark);
}

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

.text-button {
  color: var(--primary);
  background: none;
  font-weight: 700;
  text-decoration: none;
}

/* Cards and dashboard */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 22px;
}

.stat-card,
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 21px;
}

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

.stat-card strong {
  display: block;
  font-size: 28px;
  margin: 10px 0 8px;
  letter-spacing: -0.04em;
}

.progress-track {
  height: 7px;
  background: #edf0f6;
  border-radius: 99px;
  overflow: hidden;
  margin: 9px 0 8px;
}

.progress-track i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 99px;
  background: var(--primary);
  transition: width 0.25s;
}

.progress-track.large {
  height: 10px;
  margin: 20px 0 27px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 22px;
  margin-bottom: 22px;
}

.panel h2 {
  font-size: 17px;
  margin: 0;
}

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

.task-list,
.event-list,
.file-list {
  display: grid;
  gap: 10px;
}

.task-row,
.event-row,
.file-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.task-row:last-child,
.event-row:last-child,
.file-row:last-child {
  border-bottom: 0;
}

.task-row-main,
.event-row-main,
.file-row-main {
  min-width: 0;
  flex: 1;
}

.task-row strong,
.event-row strong,
.file-row strong {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-row small,
.event-row small,
.file-row small {
  display: block;
  margin-top: 4px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #bec7d8;
  flex: 0 0 auto;
}

.status-dot.IN-PROGRESS {
  background: #efaa55;
}

.status-dot.COMPLETE {
  background: #4bb488;
}

.badge {
  padding: 4px 8px;
  border-radius: 7px;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.TO-DO {
  background: #eef1f6;
  color: #687891;
}

.badge.IN-PROGRESS {
  background: var(--orange);
  color: var(--orange-ink);
}

.badge.COMPLETE {
  background: var(--mint);
  color: var(--mint-ink);
}

.board-copy {
  min-height: 48px;
  margin: 0;
  line-height: 1.7;
  white-space: pre-wrap;
  color: #53617a;
}

/* Toolbar and forms */
.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 7px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0 12px;
  color: var(--muted);
  flex: 1;
}

.search-box input {
  border: 0;
  outline: 0;
  padding: 11px 0;
  width: 100%;
}

select,
input,
textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
  color: var(--ink);
  outline-color: var(--primary);
}

.toolbar select {
  min-width: 160px;
}

/* Kanban board */
.task-columns {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.task-column {
  background: #eef1f7;
  border-radius: 13px;
  padding: 14px;
  min-height: 250px;
}

.column-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-weight: 800;
}

.column-heading span {
  font-size: 12px;
  background: #fff;
  border-radius: 8px;
  padding: 3px 7px;
  color: var(--muted);
}

.column-task {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 9px;
  box-shadow: 0 2px 5px #263e7808;
}

.column-task h3 {
  font-size: 14px;
  margin: 0 0 8px;
}

.column-task p {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 12px;
}

.column-task footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--muted);
}

/* Calendar and pipeline */
.calendar-layout {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 22px;
}

.calendar-header {
  justify-content: flex-start;
  margin-bottom: 20px;
}

.calendar-header h2 {
  flex: 1;
  text-align: center;
  font-size: 18px;
}

.icon-button {
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  padding: 2px 8px;
}

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

.calendar-day-name {
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  padding: 7px;
}

.calendar-day {
  min-height: 86px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
}

.calendar-day:hover,
.calendar-day.selected {
  border-color: var(--primary);
  background: #f7f8ff;
}

.calendar-day.today .day-number {
  background: var(--primary);
  color: #fff;
}

.day-number {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-weight: 700;
  font-size: 12px;
}

.day-event {
  font-size: 10px;
  color: var(--primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 7px;
}

.pipeline-summary strong {
  font-size: 32px;
  color: var(--primary);
}

.pipeline-stages {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}

.stage-card {
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 15px;
  cursor: pointer;
}

.stage-card:hover,
.stage-card.current {
  border-color: var(--primary);
  background: #f9f9ff;
}

.stage-marker {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.stage-marker i {
  display: grid;
  place-items: center;
  width: 23px;
  height: 23px;
  border-radius: 50%;
  background: #edf0f6;
  font-style: normal;
}

.stage-card.done .stage-marker i,
.stage-card.current .stage-marker i {
  background: var(--primary);
  color: #fff;
}

.stage-card h3 {
  font-size: 14px;
  margin: 14px 0 8px;
}

.stage-card small {
  display: block;
}

/* File upload and board note */
.drop-zone {
  text-align: center;
  border: 2px dashed #cbd3e4;
  margin-bottom: 22px;
  padding: 38px;
}

.drop-zone.dragging {
  border-color: var(--primary);
  background: #f4f5ff;
}

.drop-icon {
  display: grid;
  place-items: center;
  margin: 0 auto 10px;
  width: 45px;
  height: 45px;
  border-radius: 50%;
  background: #eef0ff;
  color: var(--primary);
  font-size: 25px;
}

.drop-zone h2 {
  margin: 0 0 6px;
}

.drop-zone input {
  display: none;
}

.file-icon {
  font-size: 23px;
}

.file-actions button {
  background: none;
  color: #9aa6bb;
}

.board-panel {
  padding: 0;
  overflow: hidden;
}

.board-panel textarea {
  display: block;
  width: 100%;
  min-height: 430px;
  border: 0;
  border-radius: 0;
  padding: 26px;
  font-size: 17px;
  line-height: 1.7;
  resize: vertical;
}

.board-footer {
  padding: 13px 20px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
}

.whiteboard-frame {
  display: block;
  width: 100%;
  height: min(720px, 75vh);
  border: 0;
  background: #fff;
}

/* Modal */
dialog {
  border: 0;
  border-radius: 14px;
  box-shadow: 0 18px 80px #17233b33;
  padding: 0;
  width: min(480px, calc(100% - 32px));
}

dialog::backdrop {
  background: #15213b66;
}

.dialog-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
}

.dialog-heading h2 {
  margin: 0;
}

dialog form {
  padding: 25px;
  display: grid;
  gap: 15px;
}

dialog label {
  display: grid;
  gap: 7px;
  font-weight: 700;
  font-size: 13px;
}

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

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 8px;
}

/* Responsive */
@media (max-width: 900px) {
  .sidebar {
    width: 72px;
    padding: 22px 10px;
  }

  .sidebar .eyebrow,
  .nav-link span:not(.nav-count),
  .sidebar-footer div {
    display: none;
  }

  .nav-link {
    justify-content: center;
    padding: 13px;
  }

  .main-content {
    padding: 28px 20px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .pipeline-stages {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 0 16px;
  }

  .topbar-actions .button {
    display: none;
  }

  .main-content {
    padding: 24px 14px;
  }

  .page-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .dashboard-grid,
  .calendar-layout,
  .task-columns {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    gap: 9px;
  }

  .stat-card {
    padding: 15px;
  }

  .stat-card strong {
    font-size: 23px;
  }

  .calendar-day {
    min-height: 65px;
  }

  .day-event {
    display: none;
  }

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