:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #eef3f2;
  --border: #d9dee5;
  --border-strong: #b9c2cd;
  --text: #26231f;
  --muted: #64707d;
  --accent: #e85d48;
  --accent-dark: #bb3f30;
  --green: #287b5f;
  --blue: #2d6cdf;
  --yellow: #b26a00;
  --shadow: 0 14px 36px rgba(34, 43, 52, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: Aptos, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  font-weight: 400;
}

body.auth-locked .app-shell {
  filter: blur(4px);
  pointer-events: none;
  user-select: none;
}

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

button {
  cursor: pointer;
}

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

.sidebar,
.detail-panel {
  background: #fbfcfd;
  border-color: var(--border);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding: 22px 16px;
  border-right: 1px solid var(--border);
}

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

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  color: #fff;
  background: var(--accent);
  border-radius: 8px;
  font-weight: 700;
}

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

.brand span,
.eyebrow,
.summary-label,
.task-meta,
.empty-detail span {
  color: var(--muted);
  font-size: 12px;
}

.nav-section,
.project-list,
.team-list {
  display: grid;
  gap: 6px;
}

.empty-sidebar {
  padding: 8px 10px;
  color: var(--muted);
  font-size: 13px;
}

.nav-item,
.project-item,
.member-item {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 38px;
  gap: 10px;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  color: var(--text);
  background: transparent;
  text-align: left;
}

.nav-item.active,
.project-item.active {
  background: #e8edf3;
  font-weight: 700;
}

.sidebar-heading,
.view-toolbar,
.topbar,
.detail-header,
.detail-actions,
.comment-box,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sidebar-heading {
  margin-bottom: 8px;
  padding: 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.avatar {
  display: grid;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  place-items: center;
  color: #fff;
  background: #335c67;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
}

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

.topbar {
  align-items: flex-start;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 4px;
  text-transform: uppercase;
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 42px);
  font-family: Avenir, Aptos, "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
  font-weight: 750;
  line-height: 1.05;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

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

.search {
  display: flex;
  align-items: center;
  min-width: min(320px, 100%);
  gap: 8px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.search input {
  width: 100%;
  height: 40px;
  border: 0;
  outline: 0;
  background: transparent;
}

.primary-button,
.secondary-button,
.danger-button,
.icon-button,
.segment,
select,
input,
textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
}

.primary-button,
.secondary-button,
.danger-button,
.segment {
  min-height: 40px;
  padding: 0 14px;
  font-weight: 700;
}

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

.secondary-button,
.segment,
select,
input,
textarea {
  color: var(--text);
  background: var(--surface);
}

.danger-button {
  color: #9d2f26;
  background: #fff4f0;
  border-color: #f0c4b8;
}

.icon-button {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  background: transparent;
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
}

.icon-button.danger {
  color: #8d271f;
}

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

.project-summary > div {
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.section-panel {
  min-width: 0;
}

.project-summary strong,
.summary-label {
  display: block;
}

.project-summary strong {
  margin-top: 4px;
  font-size: 22px;
}

.view-toolbar {
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.segmented-control {
  display: inline-flex;
  padding: 3px;
  background: #e7ecf1;
  border-radius: 8px;
}

.segment {
  min-height: 34px;
  border-color: transparent;
  background: transparent;
}

.segment.active {
  background: var(--surface);
  border-color: var(--border);
  box-shadow: 0 2px 8px rgba(44, 39, 31, 0.08);
}

.view-toolbar select {
  min-height: 40px;
  padding: 0 34px 0 12px;
}

.view-panel {
  min-height: 520px;
}

.board-view {
  display: grid;
  grid-template-columns: repeat(4, minmax(230px, 1fr));
  gap: 14px;
  align-items: start;
  overflow-x: auto;
  padding-bottom: 8px;
}

.column {
  min-width: 230px;
  background: #e9eef2;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  font-weight: 700;
}

.column-body {
  display: grid;
  min-height: 360px;
  align-content: start;
  gap: 10px;
  padding: 0 10px 10px;
}

.column-body.drag-over {
  outline: 2px solid var(--accent);
  outline-offset: -4px;
}

.task-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(44, 39, 31, 0.05);
}

.task-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}

.task-card.selected {
  border-color: var(--accent);
}

.task-title-row,
.task-footer,
.list-row,
.timeline-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.task-title-row {
  align-items: flex-start;
  justify-content: space-between;
  font-weight: 700;
}

.task-meta,
.task-footer {
  justify-content: space-between;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.priority-High {
  color: #9d2f26;
  background: #ffe2dc;
}

.priority-Medium {
  color: #835000;
  background: #ffe6ba;
}

.priority-Low {
  color: #1e6a51;
  background: #dff3e9;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  color: #31556c;
  background: #e0edf4;
}

.list-view {
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.list-header,
.list-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) 130px 140px 120px 120px 100px;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
}

.list-header {
  color: var(--muted);
  background: #eef2f6;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.list-row {
  width: 100%;
  border: 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
  text-align: left;
}

.timeline-view {
  display: grid;
  gap: 12px;
}

.timeline-scale {
  display: grid;
  grid-template-columns: repeat(8, minmax(70px, 1fr));
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.timeline-lanes {
  display: grid;
  gap: 8px;
}

.timeline-lane {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 130px minmax(260px, 2fr) 150px;
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-align: left;
}

.timeline-task-name {
  font-weight: 700;
}

.timeline-owner {
  color: var(--muted);
}

.timeline-rail {
  position: relative;
  height: 18px;
  background: #e6ebf0;
  border-radius: 999px;
}

.timeline-bar {
  position: absolute;
  height: 18px;
  background: var(--blue);
  border-radius: 999px;
}

.timeline-bar.priority-High {
  background: var(--accent);
}

.timeline-bar.priority-Medium {
  background: var(--yellow);
}

.timeline-bar.priority-Low {
  background: var(--green);
}

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

.permission-summary {
  grid-template-columns: repeat(3, minmax(150px, 1fr));
}

.metric-card,
.report-card,
.table-card,
.inbox-item,
.empty-state {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.metric-card {
  padding: 14px;
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric-card strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
}

.inbox-layout,
.report-grid {
  display: grid;
  gap: 14px;
}

.inbox-list,
.compact-list {
  display: grid;
  gap: 10px;
}

.inbox-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 14px;
}

.inbox-item.unread {
  border-color: var(--accent);
  box-shadow: inset 4px 0 0 var(--accent);
}

.inbox-item h3 {
  margin: 8px 0 4px;
  font-size: 18px;
}

.inbox-item p {
  margin: 0 0 6px;
  color: var(--muted);
}

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

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

.report-card {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.report-card h2 {
  margin: 0;
  font-size: 18px;
}

.bar-row {
  display: grid;
  gap: 6px;
}

.bar-row > div,
.management-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.progress {
  display: block;
  height: 10px;
  overflow: hidden;
  background: #e6ebf0;
  border-radius: 999px;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--blue);
  border-radius: inherit;
}

.compact-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 100px 90px;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 10px 0;
  border: 0;
  border-top: 1px solid var(--border);
  background: transparent;
  text-align: left;
}

.management-toolbar {
  margin-bottom: 14px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.management-toolbar > div {
  display: grid;
  gap: 4px;
}

.table-card {
  overflow-x: auto;
}

.member-row,
.access-row {
  display: grid;
  gap: 12px;
  align-items: center;
  min-width: 940px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
}

.member-row {
  grid-template-columns: minmax(220px, 1.2fr) 150px 140px 160px 130px 100px;
}

.access-row {
  grid-template-columns: minmax(220px, 1.2fr) 140px repeat(3, 150px);
}

.table-head {
  color: var(--muted);
  background: #eef2f6;
  border-top: 0;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.member-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.member-cell strong,
.member-cell small {
  display: block;
}

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

.member-row input,
.member-row select,
.access-row select,
.inline-select select {
  min-height: 38px;
  padding: 0 10px;
}

.capacity-cell {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 10px;
  align-items: center;
}

.capacity-cell input {
  width: 58px;
}

.inline-select {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

.access-warning {
  color: #8d271f;
  background: #fff4f0;
  border: 1px solid #f0c4b8;
  border-radius: 8px;
  padding: 12px;
}

.empty-state {
  padding: 18px;
}

.empty-state strong,
.empty-state span {
  display: block;
}

.empty-state span {
  margin-top: 4px;
  color: var(--muted);
}

.setup-state {
  grid-column: 1 / -1;
}

.detail-panel {
  position: fixed;
  right: 0;
  top: 0;
  z-index: 4;
  width: min(380px, 100vw);
  height: 100vh;
  overflow-y: auto;
  padding: 22px;
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  transform: translateX(100%);
  transition: transform 180ms ease;
}

.detail-panel.open {
  transform: translateX(0);
}

.empty-detail {
  display: grid;
  place-items: center;
  align-content: center;
  height: 100%;
  gap: 8px;
  text-align: center;
}

.task-form {
  display: grid;
  gap: 16px;
}

.task-form label,
.dialog-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.task-form input,
.task-form select,
.task-form textarea,
.dialog-form input {
  width: 100%;
  min-height: 40px;
  padding: 9px 10px;
  color: var(--text);
  text-transform: none;
}

.task-form textarea {
  resize: vertical;
}

.title-input {
  min-width: 0;
  border: 0;
  padding: 0;
  background: transparent;
  font-size: 22px;
  font-weight: 700;
  outline: 0;
}

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

.section-title {
  margin-bottom: 10px;
  font-weight: 700;
}

.comments {
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.comment {
  display: grid;
  gap: 4px;
  margin-bottom: 10px;
  padding: 10px;
  background: var(--surface-soft);
  border-radius: 8px;
}

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

.comment-box input {
  flex: 1;
}

dialog {
  width: min(420px, calc(100vw - 32px));
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(38, 35, 31, 0.38);
}

.dialog-form {
  display: grid;
  gap: 16px;
}

.dialog-form h2 {
  margin: 0;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(244, 246, 248, 0.82);
}

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

.auth-brand {
  padding: 0;
}

.auth-card h2,
.auth-card p {
  margin: 0;
}

.auth-card p {
  color: var(--muted);
}

.auth-card label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.auth-card input {
  min-height: 42px;
  padding: 9px 10px;
}

.auth-message {
  min-height: 20px;
  color: #9d2f26;
  font-size: 13px;
}

.auth-actions {
  display: flex;
  gap: 10px;
}

.hidden {
  display: none !important;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }
}

@media (max-width: 820px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .workspace {
    padding: 18px;
  }

  .topbar {
    display: grid;
  }

  .topbar-actions,
  .search {
    width: 100%;
  }

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

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

  .list-header,
  .list-row {
    min-width: 720px;
  }
}

@media (max-width: 520px) {
  .project-summary {
    grid-template-columns: 1fr;
  }

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