:root {
  --bg: #f2f2ef;
  --surface: #ffffff;
  --surface-strong: #f7f7f4;
  --text: #171917;
  --muted: #74766f;
  --line: #e4e3de;
  --accent: #5b9f79;
  --accent-dark: #34714f;
  --accent-soft: #e5f2ea;
  --warn: #b48a40;
  --danger: #b65d55;
  --blue: #426f9f;
  --blue-soft: #e7eff8;
  --sidebar: #f6f6f2;
  --sidebar-soft: #e7eee8;
  --shadow: 0 8px 24px rgba(31, 38, 34, 0.06);
  --page-max: 1380px;
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  font-weight: 400;
  letter-spacing: 0;
}

body.auth-body {
  display: block;
  background:
    linear-gradient(135deg, rgba(31, 122, 90, 0.08), rgba(246, 247, 244, 0.96)),
    var(--bg);
}

body.detail-body {
  display: grid;
  grid-template-columns: 280px 1fr;
}

button,
input,
select,
textarea {
  max-width: 100%;
  min-width: 0;
  font: inherit;
}

.sidebar {
  min-width: 0;
  min-height: 100vh;
  padding: 24px;
  overflow: hidden;
  background: var(--sidebar);
  color: var(--text);
  position: sticky;
  top: 0;
}

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

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 700;
  text-transform: uppercase;
}

.brand small {
  display: block;
  max-width: 170px;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.3;
}

.nav {
  display: grid;
  gap: 8px;
  max-width: 100%;
  scrollbar-width: none;
}

.nav::-webkit-scrollbar {
  display: none;
}

.nav-item {
  width: 100%;
  min-height: 44px;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
}

.nav-item:hover,
.nav-item.active {
  background: var(--sidebar-soft);
  color: var(--accent-dark);
}

.nav-icon {
  width: 20px;
  height: 20px;
  fill: currentColor;
  opacity: 0.86;
}

.app-shell {
  width: 100%;
  max-width: var(--page-max);
  min-width: 0;
  margin: 0 auto;
  padding: 28px;
}

.detail-shell {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px;
}

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

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

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

.detail-panel,
.detail-side .panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.detail-panel {
  padding: 18px;
}

.detail-side {
  display: grid;
  align-content: start;
  gap: 16px;
}

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

.side-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 800;
}

.detail-panel-stack {
  display: grid;
  align-content: start;
  gap: 16px;
}

.timeline-list {
  display: grid;
  gap: 10px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: var(--surface-strong);
}

.timeline-date {
  color: var(--accent-dark);
  font-size: 0.86rem;
  font-weight: 900;
}

.timeline-date span,
.timeline-date small {
  display: block;
}

.timeline-date small {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.35;
}

.timeline-item strong,
.timeline-item small {
  display: block;
  margin-top: 6px;
}

.timeline-content {
  min-width: 0;
}

.timeline-delete-form {
  display: flex;
  margin-top: 10px;
}

.timeline-delete-form .danger-button {
  width: auto;
}

.appointment-summary-panel {
  border-left: 4px solid var(--blue);
}

.appointment-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.appointment-summary-grid article {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.appointment-summary-grid small,
.appointment-summary-grid strong {
  display: block;
}

.appointment-summary-grid small {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.appointment-summary-grid strong {
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.button-link {
  display: inline-grid;
  place-items: center;
  text-decoration: none;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.global-search {
  position: relative;
  min-width: 0;
  margin-bottom: 18px;
}

.global-search input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.global-results {
  display: none;
  position: absolute;
  z-index: 20;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  max-height: min(520px, 70vh);
  overflow-y: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.global-results.active {
  display: grid;
  gap: 8px;
}

.global-result {
  display: grid;
  gap: 4px;
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-strong);
}

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

.global-result span {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.logout-form {
  display: block;
}

.logout-form[hidden] {
  display: none;
}

.dashboard-only-action[hidden] {
  display: none;
}

.danger-zone {
  margin-top: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-color: rgba(182, 93, 85, 0.35);
  background: #fff8f6;
}

.danger-zone small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

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

h1,
h2,
p {
  margin-top: 0;
  overflow-wrap: anywhere;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.8rem, 3vw, 2.7rem);
  line-height: 1.05;
}

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

.primary-button,
.secondary-button,
.danger-button {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 650;
  white-space: nowrap;
}

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

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

.secondary-button {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
}

.danger-button {
  background: #f8e8e5;
  border-color: #edc8c3;
  color: var(--danger);
}

.danger-button:hover {
  background: #f4d8d2;
}

.view {
  display: none;
  min-width: 0;
}

.view.active {
  display: block;
}

.dashboard-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
  padding: 20px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.dashboard-hero h2 {
  margin-bottom: 6px;
  font-size: 1.45rem;
}

.dashboard-hero p:last-child {
  margin-bottom: 0;
  color: var(--muted);
}

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

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.metric,
.panel,
.pipeline-column,
.quote-card,
.task-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.metric {
  padding: 18px;
}

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

.metric strong {
  display: block;
  font-size: 1.8rem;
  margin: 8px 0;
  font-weight: 650;
}

.content-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 16px;
}

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

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

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

.shortcut-card {
  display: grid;
  gap: 6px;
  min-height: 92px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.shortcut-card:hover {
  border-color: #b8decb;
  background: #edf8f2;
}

.shortcut-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #ffffff;
  color: var(--accent-dark);
  font-weight: 900;
  box-shadow: inset 0 0 0 1px var(--line);
}

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

.panel {
  padding: 18px;
}

.panel-heading,
.section-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.panel-heading span,
.section-header p {
  min-width: 0;
  color: var(--muted);
  margin-bottom: 0;
}

.list,
.task-list,
.quote-grid,
.document-grid {
  display: grid;
  gap: 10px;
}

.list-item,
.task-row {
  display: grid;
  gap: 5px;
  padding: 12px;
  border-radius: 16px;
  background: var(--surface-strong);
}

.list-item strong,
.task-row strong {
  font-size: 0.96rem;
}

.list-item small,
.task-row small,
.pipeline-card small,
.quote-card small {
  color: var(--muted);
}

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.toolbar input {
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.client-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.client-count {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
}

.client-filters {
  margin-bottom: 0;
}

.client-more-button {
  display: none;
  width: 100%;
  margin-top: 12px;
}

.client-more-button:not([hidden]) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.client-mobile-only {
  display: none;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.client-avatar {
  width: 42px;
  height: 42px;
  display: none;
  place-items: center;
  border-radius: 999px;
  background: #efeadd;
  color: #403b31;
  font-size: 0.82rem;
  font-weight: 650;
  text-transform: uppercase;
}

.client-summary {
  min-width: 0;
}

.client-summary small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-weight: 400;
}

.client-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.client-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.client-card-actions a {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--accent-dark);
  font-size: 0.82rem;
  font-weight: 650;
  text-decoration: none;
}

.soft-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #e7e6e1;
  color: #6d6d66;
  font-size: 0.78rem;
  font-weight: 550;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1040px;
}

#clients table {
  display: block;
  min-width: 0;
}

#clients thead {
  display: none;
}

#clients tbody {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
}

#clients tbody tr {
  display: block;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 2px 10px rgba(31, 38, 34, 0.045);
  cursor: pointer;
}

th,
td {
  padding: 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

#clients tbody td {
  display: none;
}

#clients tbody .empty-cell {
  display: block;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
}

#clients tbody td[data-label="Client"] {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 0;
  border-bottom: 0;
}

#clients tbody .client-avatar {
  display: grid;
}

.empty-cell {
  color: var(--muted);
  text-align: center;
}

.table-link {
  color: var(--accent-dark);
  font-weight: 800;
  text-decoration: none;
}

.table-link:hover {
  text-decoration: underline;
}

.stacked-cell {
  display: block;
  line-height: 1.45;
}

.line-table-wrap {
  overflow-x: auto;
  margin-bottom: 16px;
}

.line-table {
  min-width: 760px;
  background: var(--surface);
}

.line-table td small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}

.line-table td:last-child,
.line-table th:last-child {
  width: 120px;
  text-align: right;
}

.quote-line-form {
  margin-top: 16px;
}

th {
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 0.82rem;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 0.8rem;
  font-weight: 650;
}

.status[data-status="Contact"],
.status[data-status="Prospect"] {
  background: #e6f3ec;
  color: #34714f;
}

.status[data-status="À relancer"] {
  background: #f8edcf;
  color: #8b671d;
}

.status[data-status="Demande de devis"],
.status[data-status="En attente de réponse"] {
  background: var(--blue-soft);
  color: var(--blue);
}

.status[data-status="R1"],
.status[data-status="R2"] {
  background: #eaf0f8;
  color: #2f5c8e;
}

.status[data-status="Signé"],
.status[data-status="Client"] {
  background: #dff1e6;
  color: #276940;
}

.status[data-status="Perdu"] {
  background: #f7e4df;
  color: #9b4a3f;
}

.pipeline-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(220px, 1fr));
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
  -webkit-overflow-scrolling: touch;
}

.pipeline-column {
  padding: 12px;
  min-height: 420px;
}

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

.pipeline-column h2 small {
  min-width: 28px;
  min-height: 28px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 0.8rem;
}

.pipeline-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  margin-bottom: 10px;
  border-radius: 8px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
}

.pipeline-empty {
  padding: 10px 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
}

.amount {
  color: var(--accent-dark);
  font-weight: 800;
}

.task-row {
  grid-template-columns: 1fr auto;
  align-items: center;
  box-shadow: none;
}

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

.task-actions form {
  display: block;
}

.compact-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 0.86rem;
}

.task-row[data-priority="urgent"] {
  border-left: 4px solid var(--danger);
}

.task-row[data-priority="high"] {
  border-left: 4px solid var(--warn);
}

.agenda-list {
  display: grid;
  gap: 10px;
}

.agenda-overview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.agenda-metric {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.agenda-metric span,
.agenda-metric small {
  color: var(--muted);
  font-size: 0.88rem;
}

.agenda-metric strong {
  color: var(--ink);
  font-size: 1.8rem;
}

.segmented-control {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 5px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.segmented-control button {
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
}

.segmented-control button.active {
  background: var(--accent);
  color: #fff;
}

.agenda-item {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 14px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.agenda-item .status {
  border-radius: 999px;
  padding: 4px 9px;
}

.agenda-item[data-kind="Rendez-vous"] {
  border-left: 4px solid var(--accent);
}

.agenda-item[data-kind="Rendez-vous"] .status {
  background: #e7f4ef;
  color: var(--accent-dark);
}

.agenda-item[data-kind="Relance"] {
  border-left: 4px solid var(--warn);
}

.agenda-item[data-kind="Relance"] .status {
  background: #fff0df;
  color: #8b4a1c;
}

.agenda-item[data-past="true"] {
  background: #fff7ed;
}

.agenda-item[data-kind="Relance"][data-past="true"] {
  border-left-color: var(--danger);
}

.agenda-item[data-kind="Relance"][data-past="true"] .status {
  background: #ffe4e0;
  color: var(--danger);
}

.agenda-date {
  color: var(--accent-dark);
  font-weight: 800;
}

.agenda-item strong,
.agenda-item small {
  display: block;
  margin-top: 6px;
}

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

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

.quote-card,
.document-card {
  padding: 16px;
}

.quote-card strong {
  display: block;
  margin: 8px 0;
  font-size: 1.4rem;
}

.document-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.document-card h2 {
  margin: 8px 0;
  overflow-wrap: anywhere;
}

.document-card p {
  color: var(--muted);
  margin-bottom: 10px;
}

.document-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.prospecting-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(360px, 1.1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.prospecting-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.prospecting-help {
  display: grid;
  gap: 4px;
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-strong);
}

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

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

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

.manual-street-row {
  margin: 0;
}

.manual-street-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.manual-street-remove {
  min-width: 34px;
  padding: 0;
}

.manual-add-street {
  justify-self: start;
}

.prospecting-history {
  display: grid;
  gap: 6px;
}

.prospecting-history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--surface-strong);
}

.prospecting-history-item.highlighted {
  border-color: #d94a3a;
  background: #fff0ed;
  box-shadow: 0 0 0 3px rgba(217, 74, 58, 0.12);
}

.prospecting-history-main {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.prospecting-history-title {
  overflow: hidden;
  font-size: 0.82rem;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.prospecting-history-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.2;
}

.prospecting-history-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.prospecting-history-actions .compact-button {
  min-height: 25px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 0.72rem;
  line-height: 1;
  white-space: nowrap;
}

.prospecting-map-panel {
  overflow: hidden;
  margin-bottom: 16px;
}

.prospecting-map {
  width: 100%;
  min-height: 440px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.map-popup {
  display: grid;
  gap: 6px;
  max-width: 260px;
}

.map-popup small {
  color: #6d6d66;
}

.map-popup ul {
  margin: 2px 0 0;
  padding-left: 16px;
}

.map-popup li + li {
  margin-top: 6px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: start;
  justify-items: center;
  padding: 20px;
  background: rgba(24, 35, 29, 0.56);
  overflow-y: auto;
}

.modal.open {
  display: grid;
}

.modal-card {
  width: min(520px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 20px;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.modal-card-wide {
  width: min(760px, 100%);
}

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

.icon-button {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  font-size: 1.4rem;
  line-height: 1;
}

form {
  display: grid;
  gap: 14px;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-panel {
  width: min(460px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-brand {
  color: var(--text);
  margin-bottom: 26px;
}

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

.auth-panel h1 {
  font-size: 2rem;
  margin-bottom: 8px;
}

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

.alert {
  padding: 12px;
  margin-bottom: 14px;
  border-radius: 8px;
  border: 1px solid #e8b6b2;
  background: #fff0ef;
  color: var(--danger);
  font-weight: 700;
}

.checkbox-line {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 500;
}

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

.checkbox-group {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.checkbox-group legend {
  padding: 0 6px;
  color: var(--muted);
  font-weight: 800;
}

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

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

.quantity-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 76px;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 600;
}

.quantity-line input {
  width: 76px;
  min-height: 36px;
  text-align: center;
}

.auth-switch {
  margin: 18px 0 0;
  text-align: center;
}

.auth-switch a {
  color: var(--accent-dark);
  font-weight: 800;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
}

label input,
label select,
label textarea {
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

label textarea {
  min-height: 96px;
  padding: 10px 12px;
  resize: vertical;
}

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

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

.flash-message {
  padding: 12px;
  margin-bottom: 14px;
  border-radius: 8px;
  border: 1px solid #b8decb;
  background: #edf8f2;
  color: var(--accent-dark);
  font-weight: 800;
}

.form-help {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 0.92rem;
}

.client-quick-panel {
  border-left: 4px solid var(--accent);
}

.client-action-grid {
  display: grid;
  gap: 9px;
}

.client-action-grid small {
  color: var(--muted);
  line-height: 1.35;
}

.workflow-panel {
  border-left: 4px solid var(--accent);
}

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

.workflow-actions form {
  display: block;
}

.compact-workflow-button {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  padding: 0 10px;
  white-space: normal;
}

.admin-user-list {
  display: grid;
  gap: 10px;
}

.admin-user-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--muted);
  border-radius: 12px;
  background: var(--surface-strong);
}

.admin-user-card[data-status="approved"] {
  border-left-color: var(--accent);
}

.admin-user-card[data-status="pending"] {
  border-left-color: var(--warn);
}

.admin-user-card[data-status="blocked"] {
  border-left-color: var(--danger);
}

.admin-user-card strong,
.admin-user-card small {
  display: block;
  margin-top: 6px;
}

.admin-status {
  margin-left: 6px;
  background: var(--blue-soft);
  color: var(--blue);
}

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

.admin-user-actions form {
  display: block;
}

@media (max-width: 980px) {
  body:not(.detail-body) {
    display: block;
  }

  body:not(.detail-body) .sidebar {
    min-height: auto;
    height: auto;
    align-self: start;
    position: static;
    padding: 16px;
  }

  body:not(.detail-body) .nav {
    display: flex;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }

  body:not(.detail-body) .nav-item {
    width: auto;
    flex: 0 0 auto;
  }

  .app-shell {
    max-width: none;
    padding: 18px;
  }

  .metrics-grid,
  .content-grid,
  .dashboard-grid,
  .quote-grid,
  .document-grid,
  .agenda-overview,
  .prospecting-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-hero,
  .shortcut-grid {
    grid-template-columns: 1fr;
  }

  .quick-actions {
    justify-content: stretch;
  }

  .detail-header {
    display: grid;
  }

  .detail-side {
    order: -1;
  }
}

@media (max-width: 620px) {
  body {
    font-size: 15px;
  }

  body.detail-body {
    display: block;
  }

  .sidebar {
    min-height: auto;
    height: auto;
    align-self: start;
    position: static;
    padding: 10px 14px;
  }

  .nav {
    display: flex;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    margin-right: -14px;
    padding-right: 14px;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }

  .brand {
    margin-bottom: 10px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .brand small {
    max-width: 250px;
    font-size: 0.78rem;
  }

  .nav {
    gap: 6px;
  }

  .nav-item {
    width: auto;
    flex: 0 0 auto;
    min-height: 38px;
    padding: 8px 10px;
  }

  .app-shell,
  .detail-shell {
    width: 100%;
    padding: 14px;
  }

  h1 {
    font-size: 1.65rem;
    line-height: 1.12;
  }

  .topbar,
  .toolbar,
  .client-tools,
  .panel-heading,
  .section-header {
    display: grid;
    gap: 10px;
  }

  .dashboard-hero,
  .panel,
  .metric,
  .agenda-metric,
  .agenda-item,
  .document-card,
  .quote-card,
  .detail-panel,
  .detail-side .panel {
    box-shadow: none;
  }

  .primary-button,
  .secondary-button,
  .danger-button {
    width: 100%;
    min-width: 0;
    white-space: normal;
  }

  .topbar-actions {
    display: grid;
    width: 100%;
  }

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

  .task-actions {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .admin-user-card {
    grid-template-columns: 1fr;
  }

  .admin-user-actions {
    justify-content: stretch;
  }

  .admin-user-actions form,
  .admin-user-actions button {
    width: 100%;
  }

  .prospecting-actions,
  .prospecting-history-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .prospecting-history-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
  }

  .prospecting-history-actions .secondary-button,
  .prospecting-history-actions .danger-button {
    width: auto;
  }

  .prospecting-history-actions .compact-button {
    min-height: 25px;
    padding: 0 7px;
  }

  .manual-add-street {
    width: auto;
  }

  .manual-street-remove {
    width: 34px;
  }

  .prospecting-history-item {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 8px;
  }

  .danger-zone {
    display: grid;
    gap: 14px;
  }

  .prospecting-map {
    min-height: 340px;
  }

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

  .checkbox-grid,
  .quantity-grid {
    grid-template-columns: 1fr;
  }

  .agenda-item {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .timeline-item {
    grid-template-columns: 1fr;
  }

  .timeline-delete-form .danger-button {
    width: auto;
  }

  .appointment-summary-grid {
    grid-template-columns: 1fr 1fr;
  }

  .modal {
    align-items: start;
    justify-items: stretch;
    padding: 10px;
  }

  .modal-card {
    width: 100%;
    max-height: calc(100dvh - 20px);
    padding: 16px;
    border-radius: 14px;
  }

  .segmented-control {
    width: 100%;
  }

  .segmented-control button {
    flex: 1 1 calc(50% - 6px);
  }

  .client-count {
    padding: 0 2px;
  }

  #clients .table-wrap {
    overflow-x: visible;
    border: 0;
    background: transparent;
  }

  #clients table {
    min-width: 0;
  }

  #clients thead {
    display: none;
  }

  #clients tbody {
    display: grid;
    gap: 10px;
  }

  #clients tbody tr {
    display: block;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: 0 2px 8px rgba(31, 38, 34, 0.04);
    cursor: pointer;
  }

  #clients tbody td {
    display: none;
  }

  #clients tbody td[data-label="Client"],
  #clients tbody td.client-mobile-only {
    display: block;
    padding: 0;
    border-bottom: 0;
  }

  #clients tbody td[data-label="Client"] {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    font-size: 1rem;
    font-weight: 650;
  }

  #clients tbody td.client-mobile-only {
    display: none;
  }

  #clients tbody .client-avatar {
    display: grid;
  }

  #clients tbody .client-card-badges {
    display: flex;
  }

  .line-table {
    min-width: 760px;
  }

  .pipeline-board {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    overflow-x: visible;
    padding-bottom: 0;
  }

  .pipeline-column {
    min-height: 0;
    padding: 10px;
  }

  .pipeline-column h2 {
    margin-bottom: 8px;
    font-size: 1rem;
  }

  .pipeline-column h2 small {
    min-width: 24px;
    min-height: 24px;
    font-size: 0.75rem;
  }

  .pipeline-card {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 10px;
    align-items: center;
    padding: 10px;
    margin-bottom: 7px;
  }

  .pipeline-card strong,
  .pipeline-card small {
    min-width: 0;
  }

  .pipeline-card small {
    grid-column: 1 / -1;
  }

  .pipeline-card .amount {
    grid-column: 2;
    grid-row: 1;
    white-space: nowrap;
    font-size: 0.84rem;
  }

  .pipeline-empty {
    padding: 8px 10px;
  }
}
