:root {
  color-scheme: light;
  --bg: #eef1f5;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --ink: #111827;
  --muted: #667085;
  --line: #dfe5ee;
  --line-strong: #c8d1df;
  --accent: #2563eb;
  --accent-2: #b7791f;
  --danger: #b42318;
  --shadow: 0 22px 70px rgba(15, 23, 42, 0.14);
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.14), transparent 32rem),
    linear-gradient(135deg, #f6f7fb 0%, #edf1f6 48%, #f8f3eb 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

body.login-locked {
  overflow: hidden;
}

body.login-locked .app-shell {
  display: none;
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: 100vh;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    linear-gradient(135deg, rgba(15, 23, 42, 0.88), rgba(37, 99, 235, 0.74)),
    radial-gradient(circle at 70% 20%, rgba(255, 255, 255, 0.22), transparent 22rem);
}

.login-card {
  display: grid;
  gap: 16px;
  width: min(100%, 440px);
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.login-card h1 {
  font-size: 42px;
}

.login-brand {
  margin-bottom: 0;
}

.form-error {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(180, 35, 24, 0.22);
  border-radius: 10px;
  background: #fff4f2;
  color: var(--danger);
  font-size: 13px;
  font-weight: 800;
}

.login-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px;
  background: rgba(255, 255, 255, 0.78);
  border-right: 1px solid rgba(203, 213, 225, 0.8);
  backdrop-filter: blur(18px);
  overflow-y: auto;
}

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

.brand-logo {
  display: block;
  width: min(100%, 180px);
  height: auto;
  object-fit: contain;
}

.login-logo {
  width: min(100%, 220px);
}

.sidebar-logo {
  width: min(100%, 150px);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #111827;
  color: #fff;
  font-weight: 900;
}

.brand-title {
  font-size: 18px;
  font-weight: 900;
}

.brand-subtitle,
.eyebrow,
.archive-header p,
.task-header p {
  color: var(--muted);
  font-size: 12px;
  margin: 0;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
}

.nav-tabs {
  display: grid;
  gap: 8px;
  margin-bottom: 22px;
}

.nav-tab,
.ghost-button,
.secondary-button,
.primary-button,
.icon-button {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  min-height: 40px;
  padding: 10px 13px;
  font-weight: 800;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.nav-tab {
  text-align: left;
}

.nav-tab.active {
  background: #111827;
  color: #fff;
  border-color: #111827;
}

.sidebar-panel {
  display: grid;
  gap: 12px;
  padding: 16px;
  margin-bottom: 16px;
  background: rgba(248, 250, 252, 0.88);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.panel-title {
  font-weight: 900;
}

label {
  display: grid;
  gap: 7px;
  font-size: 13px;
  font-weight: 800;
  color: #344054;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
  min-height: 42px;
}

textarea {
  resize: vertical;
}

select[multiple] {
  min-height: 120px;
}

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

.topbar,
.archive-header,
.task-header,
.modal-header,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

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

h1 {
  font-size: clamp(30px, 4vw, 52px);
  line-height: 1.02;
}

h2 {
  font-size: 24px;
}

h3 {
  font-size: 16px;
}

.topbar-actions {
  display: grid;
  grid-template-columns: minmax(220px, 320px) auto;
  align-items: center;
  gap: 10px;
  justify-content: end;
}

.global-search {
  width: 100%;
}

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

.secondary-button:hover,
.ghost-button:hover,
.nav-tab:hover {
  border-color: #111827;
}

.danger {
  color: var(--danger);
}

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

.pipeline-controls {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(120px, 180px) minmax(160px, 1fr);
  gap: 12px;
  align-items: end;
  margin: 18px 0 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.86);
}

.search-results-panel {
  display: grid;
  gap: 12px;
  margin: 0 0 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-left: 5px solid #2563eb;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

.search-result-header,
.conversion-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.search-result-header span,
.conversion-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.search-result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}

.search-result-card {
  display: grid;
  gap: 7px;
  text-align: left;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.search-result-card small {
  color: var(--muted);
  font-weight: 800;
}

.metric {
  min-height: 86px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

.metric span {
  display: block;
  font-size: 28px;
  font-weight: 950;
}

.metric label {
  margin-top: 4px;
  color: var(--muted);
}

.metric.accent {
  background: #111827;
  color: #fff;
}

.metric.accent label {
  color: #cbd5e1;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.kanban {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(280px, 320px);
  gap: 14px;
  overflow-x: auto;
  height: min(720px, calc(100vh - 330px));
  min-height: 520px;
  padding: 4px 0 16px;
  align-items: stretch;
}

.mobile-stage-picker {
  display: none;
}

.stage-column {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  height: 100%;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(203, 213, 225, 0.85);
  border-radius: var(--radius);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
  overflow: hidden;
}

.stage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.stage-header strong {
  font-size: 14px;
}

.stage-header small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.stage-count {
  min-width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #eef2f7;
  color: #344054;
  font-size: 12px;
  font-weight: 900;
}

.stage-list {
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
  overscroll-behavior: contain;
}

.stage-list.drag-over {
  background: rgba(37, 99, 235, 0.08);
}

.lead-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  background: #fff;
  border: 1px solid #dde5ef;
  border-left: 5px solid var(--accent);
  border-radius: 12px;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
  cursor: grab;
}

.lead-card:active {
  cursor: grabbing;
}

.lead-card h3 {
  font-size: 16px;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.card-delete-button {
  min-height: 34px;
  padding: 8px 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  background: #eef2f7;
  color: #344054;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 800;
}

.pill.gold {
  background: #fff4d6;
  color: #7a4d00;
}

.pill.green {
  background: #dbeafe;
  color: #1d4ed8;
}

.lead-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

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

.dashboard-grid [draggable="true"] {
  cursor: grab;
}

.dashboard-grid [draggable="true"].dragging {
  opacity: 0.55;
  outline: 2px dashed var(--accent);
}

.dashboard-controls {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(120px, 180px) minmax(260px, 1fr);
  align-items: end;
  gap: 12px;
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

.finance-grid {
  display: grid;
  gap: 10px;
}

.finance-stat {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.finance-stat span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.finance-stat strong {
  color: var(--accent);
  font-size: 18px;
}

.checkbox-line {
  display: flex;
  grid-template-columns: unset;
  align-items: center;
  gap: 9px;
  min-height: 42px;
}

.checkbox-line input {
  width: 18px;
  min-height: 18px;
}

.check-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
}

.check-pill {
  display: inline-flex;
  grid-template-columns: unset;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fafc;
  color: #344054;
  font-size: 12px;
}

.check-pill input {
  width: 15px;
  min-height: 15px;
}

.contact-match-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid #f2cf7d;
  border-radius: 12px;
  background: #fff8e6;
}

.match-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: #7a4d00;
  font-size: 13px;
}

.match-header span {
  color: #8a5c0a;
  font-weight: 800;
}

.match-list {
  display: grid;
  gap: 8px;
}

.match-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid #f2cf7d;
  border-radius: 12px;
  background: #fff;
}

.match-card p,
.match-card small {
  display: block;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.settings-grid label {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

.settings-grid .wide {
  grid-column: 1 / -1;
}

.settings-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

.settings-tools p {
  max-width: 720px;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.home-grid,
.home-summary-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(320px, 1.1fr);
  gap: 16px;
}

.home-summary-grid {
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  margin-bottom: 16px;
}

.revenue-metric {
  background: linear-gradient(135deg, #eff6ff, #fff);
  border-color: rgba(37, 99, 235, 0.28);
}

.revenue-metric span {
  color: var(--accent);
}

.task-summary-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.task-summary-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 13px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--accent);
  border-radius: 12px;
  background: #fff;
}

.task-summary-card > div {
  display: grid;
  gap: 4px;
}

.task-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.task-summary-card.completed {
  border-left-color: var(--muted);
  opacity: 0.72;
}

.task-summary-list.compact,
#homeTaskList {
  gap: 8px;
  margin-top: 10px;
}

#homeTaskList .task-summary-card {
  padding: 10px 12px;
  border-radius: 10px;
}

.task-done-button {
  min-width: 70px;
}

.task-edit-button {
  min-width: 58px;
}

.quick-task-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(220px, 1.4fr) minmax(180px, 0.9fr) auto;
  align-items: end;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

.task-archive-panel {
  margin-top: 18px;
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(90px, 1fr));
  gap: 6px;
  margin-top: 10px;
}

.permissions-panel {
  margin: 12px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
}

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

.lead-attachment-row {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin-top: 12px;
}

.attachment-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
  color: var(--text);
  font-weight: 850;
  cursor: pointer;
}

.attachment-button input {
  display: none;
}

.attachment-preview {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.attachment-preview img {
  width: 68px;
  height: 52px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.attachment-preview div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.attachment-preview strong,
.attachment-preview span,
.attachment-preview small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
}

.attachment-preview span,
.attachment-preview small {
  color: var(--muted);
  font-size: 12px;
}

.task-summary-card small {
  color: var(--muted);
  font-weight: 850;
}

.report-panel,
.archive-header {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.report-panel.wide {
  grid-column: 1 / -1;
}

.status-form,
.status-feed {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.status-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.status-card div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.status-card p {
  margin: 0;
  color: #344054;
  line-height: 1.45;
}

.status-card small {
  color: var(--muted);
  font-weight: 700;
}

.bar-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

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

.bar-row-top {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 900;
}

.bar-track {
  height: 10px;
  background: #e8edf4;
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
}

.source-grid,
.archive-list,
.project-list,
.contact-list,
.calendar-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.source-item,
.archive-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.conversion-row {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.conversion-meter {
  display: grid;
  grid-template-columns: minmax(120px, 220px) 48px;
  gap: 10px;
  align-items: center;
  min-width: 230px;
  font-weight: 950;
}

.project-list {
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
}

.project-list.compact {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.contact-list {
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.contact-list.list-view {
  grid-template-columns: 1fr;
}

.contact-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-left: 5px solid #2563eb;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.09);
}

.contact-list.list-view .contact-card {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  align-items: center;
  min-height: 72px;
}

.contact-layout-toggle {
  display: flex;
  gap: 8px;
}

.contact-card h3 {
  margin: 4px 0;
  font-size: 20px;
}

.project-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 252, 0.92)),
    radial-gradient(circle at top right, rgba(37, 99, 235, 0.14), transparent 15rem);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.12);
}

.project-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.project-card h3 {
  margin-top: 4px;
  font-size: 20px;
}

.project-progress {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7edf5;
}

.project-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #60a5fa);
}

.project-facts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.project-facts span {
  min-height: 58px;
  padding: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.project-facts strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
}

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

.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.calendar-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
}

.calendar-legend i {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.calendar-toolbar {
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) auto;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.86);
}

.calendar-toolbar h3 {
  text-align: center;
  font-size: 20px;
}

.calendar-nav,
.calendar-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.calendar-modes {
  justify-content: flex-end;
}

.calendar-mode {
  min-height: 38px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #344054;
  font-size: 13px;
  font-weight: 900;
}

.calendar-mode.active {
  background: #111827;
  border-color: #111827;
  color: #fff;
}

.calendar-canvas {
  margin-top: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.08);
}

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

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

.calendar-weekday {
  color: var(--muted);
  font-size: 12px;
  font-weight: 950;
  text-align: center;
  text-transform: uppercase;
}

.calendar-cell {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 130px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.calendar-week-grid .calendar-cell {
  min-height: 280px;
}

.calendar-cell.muted {
  opacity: 0.48;
  background: #f8fafc;
}

.calendar-cell.today {
  border-color: #111827;
  box-shadow: inset 0 0 0 2px rgba(17, 24, 39, 0.08);
}

.calendar-cell.drag-over,
.calendar-hour.drag-over {
  background: #eff6ff;
  border-color: var(--accent);
}

.calendar-cell-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #344054;
  font-size: 12px;
  font-weight: 900;
}

.calendar-cell-top strong {
  display: grid;
  place-items: center;
  min-width: 28px;
  height: 28px;
  border-radius: 999px;
  background: #eef2f7;
  color: #111827;
}

.calendar-cell.today .calendar-cell-top strong {
  background: #111827;
  color: #fff;
}

.calendar-cell-events {
  display: grid;
  align-content: start;
  gap: 6px;
}

.calendar-cell-events small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.calendar-chip {
  display: block;
  overflow: hidden;
  padding: 6px 8px;
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: #f8fafc;
  color: #344054;
  font-size: 12px;
  font-weight: 850;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-day-board {
  display: grid;
  gap: 8px;
}

.calendar-hour {
  display: grid;
  grid-template-columns: 92px 1fr;
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}

.calendar-hour > span {
  display: grid;
  place-items: center;
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 950;
}

.calendar-hour > div {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px;
}

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

.calendar-year-month {
  display: grid;
  gap: 8px;
  min-height: 110px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.calendar-year-month strong {
  font-size: 18px;
}

.calendar-year-month span {
  color: var(--muted);
  font-weight: 900;
}

.calendar-card {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-left: 7px solid var(--accent);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.09);
}

.calendar-card h3 {
  margin-top: 4px;
  font-size: 18px;
}

.calendar-date {
  display: grid;
  gap: 4px;
  padding: 12px;
  border-radius: 12px;
  background: #f8fafc;
  text-align: center;
}

.calendar-date strong {
  font-size: 18px;
}

.calendar-date span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.calendar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.event-project {
  border-color: #2563eb;
}

.event-crm {
  border-color: #2563eb;
}

.event-team {
  border-color: #9333ea;
}

.event-meeting {
  border-color: #b7791f;
}

.event-deadline {
  border-color: #b42318;
}

i.event-project,
.calendar-card.event-project {
  border-left-color: #2563eb;
}

i.event-crm,
.calendar-card.event-crm {
  border-left-color: #2563eb;
}

i.event-team,
.calendar-card.event-team {
  border-left-color: #9333ea;
}

i.event-meeting,
.calendar-card.event-meeting {
  border-left-color: #b7791f;
}

i.event-deadline,
.calendar-card.event-deadline {
  border-left-color: #b42318;
}

i.event-project {
  background: #2563eb;
}

i.event-crm {
  background: #2563eb;
}

i.event-team {
  background: #9333ea;
}

i.event-meeting {
  background: #b7791f;
}

i.event-deadline {
  background: #b42318;
}

.client-share-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8fafc;
}

.client-share-box p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.client-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.client-status-card {
  width: min(880px, 100%);
  padding: clamp(24px, 5vw, 48px);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.97), rgba(248, 250, 252, 0.9)),
    radial-gradient(circle at top right, rgba(183, 121, 31, 0.2), transparent 20rem);
  border: 1px solid rgba(203, 213, 225, 0.9);
  border-radius: 28px;
  box-shadow: 0 30px 90px rgba(15, 23, 42, 0.16);
}

.client-status-card h1 {
  margin-top: 10px;
}

.client-message {
  max-width: 680px;
  color: #475467;
  font-size: 18px;
  line-height: 1.55;
}

.client-progress {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
  margin: 32px 0;
}

.client-step {
  display: grid;
  gap: 8px;
  justify-items: center;
  color: #98a2b3;
  text-align: center;
  font-size: 12px;
  font-weight: 900;
}

.client-step span {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  background: #e7edf5;
  color: #667085;
}

.client-step.done span {
  background: var(--accent);
  color: #fff;
}

.client-step.current span {
  outline: 5px solid rgba(37, 99, 235, 0.14);
}

.client-step.done {
  color: var(--ink);
}

.client-details {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.client-details div {
  padding: 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
}

.client-details span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.client-details strong {
  display: block;
  margin-top: 8px;
  font-size: 18px;
}

.client-footer {
  margin: 28px 0 0;
  color: var(--muted);
  font-weight: 900;
}

.client-downloads {
  display: grid;
  gap: 14px;
  margin-top: 20px;
  padding: 18px;
  background: #fff8e6;
  border: 1px solid #f2cf7d;
  border-radius: 16px;
}

.download-warning {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #7a4d00;
}

.download-warning span {
  padding: 8px 12px;
  border-radius: 999px;
  background: #111827;
  color: #fff;
  font-weight: 950;
  font-variant-numeric: tabular-nums;
}

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

.download-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.download-actions a.disabled {
  opacity: 0.48;
  pointer-events: none;
}

.modal {
  width: min(920px, calc(100vw - 28px));
  border: 0;
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 0;
}

.modal.compact {
  width: min(520px, calc(100vw - 28px));
}

.modal::backdrop {
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(5px);
}

.modal form {
  padding: 22px;
}

.modal-header {
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

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

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

.full {
  grid-column: 1 / -1;
}

.task-panel {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.activity-panel {
  margin-bottom: 14px;
}

.activity-composer {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  margin-top: 14px;
}

.activity-timeline {
  position: relative;
  display: grid;
  gap: 12px;
  margin-top: 16px;
  padding-left: 18px;
}

.activity-timeline::before {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 7px;
  width: 2px;
  background: #d8e0eb;
}

.activity-item {
  position: relative;
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 10px;
}

.activity-dot {
  position: relative;
  z-index: 1;
  width: 16px;
  height: 16px;
  margin-top: 5px;
  border: 3px solid #fff;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--line-strong);
}

.activity-item > div:last-child {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.activity-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: #344054;
  font-size: 13px;
}

.activity-top span,
.activity-item small {
  color: var(--muted);
  font-weight: 800;
}

.activity-item p {
  margin: 8px 0;
  color: #344054;
  line-height: 1.45;
}

.task-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.task-row {
  display: grid;
  grid-template-columns: 1.3fr 220px auto 40px;
  gap: 8px;
  align-items: center;
}

.modal-actions {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.spacer {
  flex: 1;
}

.hidden {
  display: none !important;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 140px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
}

.win-celebration {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
}

.win-celebration.show {
  opacity: 1;
  visibility: visible;
}

.win-celebration::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 42%, rgba(37, 99, 235, 0.28), transparent 22rem),
    rgba(15, 23, 42, 0.18);
  backdrop-filter: blur(2px);
  animation: winFade 1.9s ease forwards;
}

.win-toast {
  position: relative;
  min-width: min(420px, calc(100vw - 42px));
  padding: 34px;
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: 22px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 252, 0.9)),
    radial-gradient(circle at top right, rgba(183, 121, 31, 0.22), transparent 18rem);
  box-shadow: 0 30px 90px rgba(15, 23, 42, 0.28);
  text-align: center;
  overflow: hidden;
  transform: translateY(20px) scale(0.92);
  animation: winPop 1.9s cubic-bezier(0.2, 0.9, 0.2, 1) forwards;
}

.win-toast::after {
  content: "";
  position: absolute;
  top: -40%;
  left: -60%;
  width: 70%;
  height: 180%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.85), transparent);
  transform: rotate(20deg);
  animation: shineSweep 1.25s ease 0.18s forwards;
}

.win-kicker {
  color: var(--accent);
  font-size: 13px;
  font-weight: 950;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.win-title {
  margin-top: 8px;
  font-size: clamp(48px, 10vw, 82px);
  line-height: 0.95;
  font-weight: 950;
  color: #111827;
}

.win-name {
  margin-top: 12px;
  color: #475467;
  font-weight: 850;
}

.confetti-field {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  top: -24px;
  width: 10px;
  height: 18px;
  border-radius: 3px;
  opacity: 0;
  animation: confettiFall 1.9s ease-out forwards;
}

@keyframes winPop {
  0% {
    opacity: 0;
    transform: translateY(24px) scale(0.88);
  }
  18% {
    opacity: 1;
    transform: translateY(0) scale(1.04);
  }
  32% {
    transform: translateY(0) scale(1);
  }
  78% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-12px) scale(0.96);
  }
}

@keyframes winFade {
  0%,
  82% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@keyframes shineSweep {
  to {
    left: 120%;
  }
}

@keyframes confettiFall {
  0% {
    opacity: 0;
    transform: translate3d(0, 0, 0) rotate(0deg);
  }
  10% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--drift), 105vh, 0) rotate(var(--spin));
  }
}

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

  .sidebar {
    position: static;
    order: 2;
    height: auto;
    display: grid;
    grid-template-columns: 1fr;
  }

  .main {
    order: 1;
  }

  .metric-strip,
  .dashboard-grid,
  .dashboard-controls,
  .pipeline-controls,
  .home-grid,
  .home-summary-grid,
  .permission-grid,
  .quick-task-form,
  .form-grid,
  .settings-grid,
  .activity-composer {
    grid-template-columns: 1fr;
  }

  .topbar-actions {
    width: 100%;
    grid-template-columns: 1fr;
    justify-content: stretch;
  }

  .task-summary-card {
    align-items: stretch;
    flex-direction: column;
  }

  .task-card-actions {
    justify-content: flex-end;
  }

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

  .main {
    padding: 18px;
  }

  .topbar,
  .archive-header,
  .task-header,
  .calendar-toolbar,
  .settings-tools {
    align-items: flex-start;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .calendar-toolbar h3 {
    text-align: left;
  }

  .calendar-modes {
    justify-content: flex-start;
  }

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

  .calendar-weekday {
    display: none;
  }

  .calendar-cell {
    min-height: 150px;
  }

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

  .calendar-card {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .calendar-actions {
    justify-content: flex-start;
  }

  .kanban {
    display: grid;
    grid-auto-flow: row;
    grid-auto-columns: unset;
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
    gap: 14px;
    overflow: visible;
  }

  .mobile-stage-picker {
    display: none;
  }

  .stage-column {
    display: block;
    height: auto;
    min-height: auto;
  }

  .stage-header {
    position: sticky;
    top: 0;
    z-index: 2;
    border-radius: 14px 14px 0 0;
    padding: 16px;
    background: #111827;
    color: #fff;
  }

  .stage-count {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
  }

  .stage-list {
    min-height: 120px;
    max-height: none;
    overflow: visible;
    gap: 10px;
    background: rgba(255, 255, 255, 0.76);
  }

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

  .project-facts,
  .client-details,
  .client-progress {
    grid-template-columns: 1fr;
  }

  .client-step {
    grid-template-columns: 42px 1fr;
    justify-items: start;
    text-align: left;
  }
}
