:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --text: #152033;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #0f172a;
  --requested: #dbeafe;
  --quoted: #ffedd5;
  --scheduled: #ede9fe;
  --confirmed: #d1fae5;
  --completed: #dcfce7;
  --danger: #b91c1c;
  --shadow: 0 10px 30px rgba(15, 23, 42, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
}

body {
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }
.screen { min-height: 100dvh; }

.center-card {
  max-width: 480px;
  margin: 0 auto;
  padding: max(48px, env(safe-area-inset-top)) 24px 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.brand-mark {
  width: 62px;
  height: 62px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: var(--brand);
  color: white;
  font-weight: 800;
  letter-spacing: -.03em;
  margin-bottom: 14px;
}

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

h1 {
  margin-bottom: 8px;
  font-size: clamp(28px, 7vw, 38px);
  letter-spacing: -.04em;
}

h2 { letter-spacing: -.03em; }

.muted { color: var(--muted); line-height: 1.5; }

.stack,
.dialog-form {
  display: grid;
  gap: 12px;
}

label {
  font-size: 13px;
  font-weight: 700;
  color: #334155;
}

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  background: white;
  color: var(--text);
  border-radius: 12px;
  padding: 13px 14px;
  outline: none;
}

input:focus, textarea:focus, select:focus {
  border-color: #94a3b8;
  box-shadow: 0 0 0 3px rgba(148, 163, 184, .2);
}

.btn {
  border: 0;
  border-radius: 12px;
  padding: 12px 15px;
  font-weight: 800;
  cursor: pointer;
}

.btn-primary {
  background: var(--brand);
  color: white;
}

.btn-secondary {
  background: #eef2f7;
  color: #253247;
}

.notice {
  margin-top: 16px;
  padding: 13px 14px;
  border-radius: 12px;
  background: #eef2ff;
  color: #3730a3;
  line-height: 1.45;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(246, 248, 251, .94);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: max(14px, env(safe-area-inset-top)) 18px 12px;
  border-bottom: 1px solid rgba(226, 232, 240, .85);
}

.topbar h1 {
  font-size: 26px;
  margin: 0;
}

.eyebrow {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .12em;
  color: #64748b;
  margin-bottom: 3px;
}

.avatar-btn, .avatar {
  border: 0;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  color: white;
  font-weight: 900;
}

.avatar-btn {
  width: 44px;
  height: 44px;
  cursor: pointer;
}

.avatar {
  width: 34px;
  height: 34px;
  font-size: 12px;
}

.content {
  max-width: 920px;
  margin: 0 auto;
  padding: 16px 14px calc(32px + env(safe-area-inset-bottom));
}

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

.summary-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 10px;
  box-shadow: 0 3px 15px rgba(15,23,42,.035);
}

.summary-number {
  display: block;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: -.04em;
}

.summary-label {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.toolbar {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  margin: 10px 0 20px;
}

.board-group { margin-bottom: 22px; }

.group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 2px 8px;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

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

.task-card {
  position: relative;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 15px;
  padding: 14px 14px 13px 17px;
  box-shadow: 0 3px 14px rgba(15,23,42,.04);
  cursor: pointer;
  overflow: hidden;
}

.task-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--person-color, #64748b);
}

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

.task-title {
  font-weight: 850;
  line-height: 1.32;
  letter-spacing: -.01em;
}

.task-meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 7px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
}

.priority-pill, .unread-pill {
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 10px;
  line-height: 1;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
}

.priority-priority { background: #fef3c7; color: #92400e; }
.priority-urgent { background: #fee2e2; color: #991b1b; }
.unread-pill { background: #0f172a; color: white; }

.empty-state {
  padding: 18px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed #cbd5e1;
  border-radius: 14px;
  background: rgba(255,255,255,.55);
}

.sheet-dialog {
  width: min(720px, calc(100% - 16px));
  max-height: calc(100dvh - 24px);
  border: 0;
  border-radius: 20px;
  padding: 0;
  box-shadow: var(--shadow);
  background: white;
}

.sheet-dialog::backdrop { background: rgba(15, 23, 42, .48); }

.dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 0;
  background: #eef2f7;
  color: #334155;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
}

.dialog-form,
#taskDialogBody { padding: 22px; }

.dialog-heading-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-right: 44px;
}

.task-detail-head { padding-right: 46px; }

.task-detail-title {
  font-size: 24px;
  margin-bottom: 8px;
}

.task-detail-text {
  color: #475569;
  line-height: 1.55;
  white-space: pre-wrap;
}

.status-actions {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin: 16px 0;
}

.status-action {
  border: 1px solid var(--line);
  background: white;
  border-radius: 999px;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  cursor: pointer;
}

.status-action.active {
  outline: 2px solid #0f172a;
  outline-offset: 1px;
}

.status-requested { background: var(--requested); color: #1d4ed8; }
.status-quoted { background: var(--quoted); color: #9a3412; }
.status-scheduled { background: var(--scheduled); color: #6d28d9; }
.status-confirmed { background: var(--confirmed); color: #047857; }
.status-completed { background: var(--completed); color: #166534; }
.status-gating { background: #f3f4f6; color: #374151; }

.task-secondary-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 14px 0;
  max-width: 360px;
}

.thread {
  border-top: 1px solid var(--line);
  padding-top: 16px;
  margin-top: 16px;
}

.message {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.message-body { min-width: 0; }

.message-head {
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 4px;
}

.message-author { font-weight: 900; }

.message-time {
  font-size: 11px;
  color: var(--muted);
}

.message-text {
  margin: 0;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message-compose {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
  margin-top: 14px;
}

.message-compose textarea {
  min-height: 70px;
  max-height: 170px;
  resize: vertical;
}

.activity-list {
  margin: 18px 0 0;
  padding: 0;
  background: #f8fafc;
  border-radius: 14px;
  overflow: hidden;
}

.activity-summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  cursor: pointer;
  user-select: none;
}

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

.activity-title {
  margin: 0;
}

.activity-chevron {
  font-size: 20px;
  line-height: 1;
  color: #64748b;
  transition: transform .18s ease;
}

.activity-disclosure[open] .activity-chevron {
  transform: rotate(180deg);
}

.activity-content {
  padding: 0 14px 14px;
}

.activity-row {
  font-size: 12px;
  color: #64748b;
  padding: 6px 0;
  border-bottom: 1px solid #e5e7eb;
}

.activity-row:last-child { border-bottom: 0; }

@media (max-width: 700px) {
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
  .toolbar { grid-template-columns: 1fr; }

  .sheet-dialog {
    width: 100%;
    max-width: none;
    max-height: 94dvh;
    margin: auto 0 0;
    border-radius: 20px 20px 0 0;
  }

  .dialog-form,
  #taskDialogBody {
    padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  }
}
