:root {
  color-scheme: light;
  --bg: #eef3f7;
  --bg-soft: #f7fafc;
  --surface: #ffffff;
  --surface-strong: #edf8f4;
  --ink: #101827;
  --muted: #667085;
  --line: #d7e0e8;
  --primary: #0f9f76;
  --primary-dark: #08765a;
  --danger: #b42318;
  --gold: #c77700;
  --sidebar: #0b1220;
  --shadow: 0 20px 60px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 10px 24px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  overflow: hidden;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(15, 159, 118, 0.13), transparent 34%),
    linear-gradient(135deg, #f8fbfc 0%, var(--bg) 48%, #f2f6fb 100%);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

body[data-theme="dark"] {
  --bg: #111827;
  --bg-soft: #111b2e;
  --surface: #162033;
  --surface-strong: #163326;
  --ink: #f4f7fb;
  --muted: #b7c4d6;
  --line: #34445c;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.22);
  --shadow-soft: 0 10px 24px rgba(0, 0, 0, 0.18);
  background:
    radial-gradient(circle at top left, rgba(15, 159, 118, 0.2), transparent 34%),
    linear-gradient(135deg, #0f172a 0%, #111827 52%, #172033 100%);
}

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

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

.sidebar {
  height: 100vh;
  overflow: auto;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(17, 28, 46, 0.96), rgba(11, 18, 32, 0.98)),
    var(--sidebar);
  color: #f7fbf9;
  padding: 28px 20px;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 30px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.05);
  padding: 14px;
}

.brand-mark {
  display: grid;
  width: 50px;
  height: 50px;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(135deg, #16c79a, #0f9f76);
  box-shadow: 0 14px 28px rgba(15, 159, 118, 0.28);
  font-size: 20px;
  font-weight: 700;
}

.brand-label,
.eyebrow,
.metric-label {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand-label {
  color: #98a8bc;
}

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

h1 {
  font-size: 17px;
}

h2 {
  margin-top: 4px;
  font-size: 26px;
  font-weight: 750;
}

h3 {
  margin-top: 4px;
  font-size: 17px;
  font-weight: 700;
}

.nav-list {
  display: grid;
  gap: 7px;
}

.nav-item {
  display: flex;
  width: 100%;
  min-height: 42px;
  align-items: center;
  gap: 11px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: #d9e2ee;
  cursor: pointer;
  padding: 0 13px;
  text-align: left;
  font-size: 14px;
  font-weight: 650;
  transition:
    background 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.nav-item:hover {
  transform: translateX(2px);
}

.nav-item span {
  display: inline-grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 14px;
}

.nav-item.active span {
  background: rgba(15, 159, 118, 0.22);
}

.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 24px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  color: #d9e2ee;
  padding: 13px;
  font-size: 13px;
  font-weight: 650;
}

.switch-button {
  position: relative;
  width: 50px;
  height: 28px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  cursor: pointer;
  padding: 3px;
}

.switch-button span {
  display: block;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #ffffff;
  transition: transform 160ms ease;
}

.switch-button[aria-pressed="true"] {
  background: var(--primary);
}

.switch-button[aria-pressed="true"] span {
  transform: translateX(22px);
}

.main-content {
  height: 100vh;
  overflow: auto;
  padding: 36px;
}

.view {
  display: none;
}

.view.active {
  display: block;
  min-height: 100%;
}

#customersView.view.active {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
  min-height: 0;
}

#renewalsView.view.active {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
  min-height: 0;
}

#costsView.view.active {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
  min-height: 0;
}

.hidden {
  display: none;
}

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

.dashboard-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.segmented-control {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow-soft);
  padding: 4px;
}

.segmented-control button {
  min-height: 36px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  padding: 0 14px;
}

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

.year-picker {
  display: flex;
  min-width: 170px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow-soft);
  padding: 11px 14px;
  color: var(--muted);
  font-weight: 700;
}

body[data-theme="dark"] .metric-card,
body[data-theme="dark"] .panel,
body[data-theme="dark"] .form-panel,
body[data-theme="dark"] .empty-state,
body[data-theme="dark"] .customers-table-panel,
body[data-theme="dark"] .summary-card,
body[data-theme="dark"] .detail-kpi-card {
  background: rgba(22, 32, 51, 0.94);
  border-color: var(--line);
}

body[data-theme="dark"] .metric-card.accent {
  background: linear-gradient(145deg, #172337, #123326);
  border-color: #28624d;
}

body[data-theme="dark"] .metric-card::after {
  background: rgba(18, 184, 134, 0.14);
}

body[data-theme="dark"] .metric-card span,
body[data-theme="dark"] .empty-state p:not(.eyebrow),
body[data-theme="dark"] .table-subline,
body[data-theme="dark"] .formula-list,
body[data-theme="dark"] .calculation-list span,
body[data-theme="dark"] .contract-summary small,
body[data-theme="dark"] .totals-grid small {
  color: var(--muted);
}

body[data-theme="dark"] .metric-card strong,
body[data-theme="dark"] .summary-card strong,
body[data-theme="dark"] h2,
body[data-theme="dark"] h3,
body[data-theme="dark"] td,
body[data-theme="dark"] .formula-list b,
body[data-theme="dark"] .calculation-list strong,
body[data-theme="dark"] .contract-summary strong,
body[data-theme="dark"] .totals-grid strong {
  color: var(--ink);
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  color: var(--ink);
  outline: 0;
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease;
}

body[data-theme="dark"] select,
body[data-theme="dark"] input,
body[data-theme="dark"] textarea,
body[data-theme="dark"] .year-picker,
body[data-theme="dark"] .segmented-control,
body[data-theme="dark"] .secondary-action,
body[data-theme="dark"] .suggest-box {
  background: #0f172a;
  border-color: var(--line);
  color: var(--ink);
}

body[data-theme="dark"] input::placeholder,
body[data-theme="dark"] textarea::placeholder {
  color: #7f8da3;
}

body[data-theme="dark"] .contract-summary div,
body[data-theme="dark"] .totals-grid div,
body[data-theme="dark"] .product-row,
body[data-theme="dark"] .upload-box,
body[data-theme="dark"] .contact-grid div,
body[data-theme="dark"] .list-row,
body[data-theme="dark"] .empty-line,
body[data-theme="dark"] .bar-track {
  background: #101a2d;
  border-color: var(--line);
}

body[data-theme="dark"] th {
  color: #d2dceb;
}

body[data-theme="dark"] .status-badge {
  background: rgba(18, 184, 134, 0.18);
  color: #7ee7c5;
}

body[data-theme="dark"] .secondary-action {
  color: #eef4fb;
}

body[data-theme="dark"] .danger-action {
  background: rgba(180, 35, 24, 0.18);
  color: #ffb4a9;
}

body[data-theme="dark"] .suggest-option {
  background: rgba(18, 184, 134, 0.16);
  border-color: rgba(126, 231, 197, 0.28);
  color: #7ee7c5;
}

body[data-theme="dark"] .suggest-option:hover {
  background: rgba(18, 184, 134, 0.24);
}

select:focus,
input:focus,
textarea:focus {
  border-color: rgba(15, 159, 118, 0.55);
  box-shadow: 0 0 0 4px rgba(15, 159, 118, 0.12);
}

select:invalid,
input:invalid,
textarea:invalid {
  border-color: #f3b8b1;
}

input,
select {
  min-height: 44px;
  padding: 0 12px;
}

textarea {
  min-height: 120px;
  padding: 12px;
  resize: vertical;
}

.year-picker select {
  width: auto;
  min-height: auto;
  border: 0;
  padding: 0;
}

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

.metric-card,
.panel,
.form-panel,
.empty-state,
.customers-table-panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.metric-card {
  position: relative;
  min-height: 168px;
  overflow: hidden;
  padding: 22px;
}

.metric-card::after {
  content: "";
  position: absolute;
  right: -34px;
  top: -34px;
  width: 106px;
  height: 106px;
  border-radius: 999px;
  background: rgba(15, 159, 118, 0.09);
}

.metric-card strong {
  position: relative;
  z-index: 1;
  display: block;
  margin-top: 18px;
  font-size: 27px;
  font-weight: 750;
  line-height: 1;
}

.metric-card span {
  position: relative;
  z-index: 1;
  display: block;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.metric-detail-button {
  position: relative;
  z-index: 1;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  margin-top: 14px;
  padding: 0 10px;
}

.metric-detail-button.active {
  border-color: rgba(15, 159, 118, 0.45);
  background: #effaf6;
  color: var(--primary-dark);
}

.metric-card.accent {
  background: linear-gradient(145deg, #ffffff, var(--surface-strong));
  border-color: #bfe7d8;
}

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

.panel,
.form-panel,
.empty-state,
.customers-table-panel {
  padding: 24px;
}

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

.section-heading {
  display: block;
}

.status-pill {
  border-radius: 999px;
  background: #fff3dc;
  color: var(--gold);
  padding: 8px 11px;
  font-size: 12px;
  font-weight: 700;
}

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

.calculation-list div {
  display: flex;
  min-height: 46px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  gap: 16px;
}

.calculation-list div:last-child {
  border-bottom: 0;
}

.calculation-list span,
.formula-list {
  color: var(--muted);
}

.calculation-list strong {
  white-space: nowrap;
}

.formula-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 18px;
  line-height: 1.45;
}

.formula-list b {
  color: var(--ink);
}

.dashboard-audit-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(280px, 0.7fr);
  gap: 16px;
  margin-top: 16px;
}

.dashboard-detail-list,
.dashboard-warning-list {
  display: grid;
  gap: 8px;
}

.audit-row,
.warning-row,
.audit-empty {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-soft);
  padding: 10px 12px;
}

.audit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.audit-row strong,
.audit-row span {
  display: block;
}

.audit-row strong {
  font-size: 12px;
}

.audit-row span,
.warning-row,
.audit-empty {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.audit-row b {
  white-space: nowrap;
}

.warning-row {
  border-color: rgba(238, 159, 67, 0.38);
  background: rgba(255, 243, 220, 0.72);
  color: #8a5b12;
}

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

.audit-summary-card {
  min-height: 116px;
}

.audit-summary-card strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

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

.audit-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  gap: 16px;
  margin-top: 16px;
  min-height: 0;
}

.audit-main-panel,
.audit-check-panel {
  min-height: 0;
}

.audit-issue-list {
  display: grid;
  gap: 10px;
  max-height: calc(100vh - 330px);
  overflow: auto;
  padding-right: 4px;
}

.audit-issue-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 12px;
  background: var(--surface);
  padding: 12px;
}

.audit-issue-row.compact {
  align-items: flex-start;
  padding: 10px;
}

.audit-issue-row.critical {
  border-left-color: #ef4444;
}

.audit-issue-row.warning {
  border-left-color: #f59e0b;
}

.audit-issue-row.info {
  border-left-color: #3b82f6;
}

.audit-issue-main {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}

.audit-issue-main strong,
.audit-issue-main span {
  display: block;
}

.audit-issue-main strong {
  font-size: 12px;
}

.audit-issue-main div > span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.audit-severity {
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--muted);
  padding: 5px 8px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.audit-issue-row.critical .audit-severity {
  background: rgba(239, 68, 68, 0.11);
  color: #b91c1c;
}

.audit-issue-row.warning .audit-severity {
  background: rgba(245, 158, 11, 0.14);
  color: #a16207;
}

.audit-issue-row.info .audit-severity {
  background: rgba(59, 130, 246, 0.12);
  color: #1d4ed8;
}

.audit-issue-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

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

.audit-check-list div {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-soft);
  padding: 12px;
}

.audit-check-list strong,
.audit-check-list span {
  display: block;
}

.audit-check-list strong {
  font-size: 12px;
}

.audit-check-list span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

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

.customer-form.hidden {
  display: none;
}

.customer-detail {
  display: grid;
  gap: 16px;
}

.customer-detail.hidden {
  display: none;
}

.customer-form:not(.hidden),
.customer-detail:not(.hidden) {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  align-content: start;
  justify-items: center;
  gap: 14px;
  overflow: auto;
  padding: 28px;
  background: rgba(8, 14, 28, 0.58);
  backdrop-filter: blur(10px);
}

.customer-form:not(.hidden) > *,
.customer-detail:not(.hidden) > * {
  width: min(100%, 980px);
}

.customer-detail:not(.hidden) > * {
  width: min(100%, 1120px);
}

.customer-form:not(.hidden) > .form-subheader,
.customer-detail:not(.hidden) > .form-subheader {
  position: sticky;
  z-index: 2;
  top: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}

body[data-theme="dark"] .customer-form:not(.hidden) > .form-subheader,
body[data-theme="dark"] .customer-detail:not(.hidden) > .form-subheader {
  background: #162033;
}

.customer-form:not(.hidden) .form-panel,
.customer-form:not(.hidden) .form-actions,
.customer-detail:not(.hidden) .form-panel,
.customer-detail:not(.hidden) .detail-kpi-card {
  box-shadow: var(--shadow);
}

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

.detail-kpi-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow-soft);
  padding: 18px;
}

.detail-kpi-card span,
.contact-grid span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.detail-kpi-card strong {
  display: block;
  margin-top: 10px;
  font-size: 22px;
  font-weight: 750;
}

.detail-kpi-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

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

.detail-left {
  display: grid;
  gap: 16px;
}

.detail-right {
  position: sticky;
  top: 20px;
}

.inline-entry-form,
.credential-form,
.document-form,
.detail-contract-form,
.pause-form,
#activityForm {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.pause-form.hidden,
.detail-contract-form.hidden {
  display: none;
}

.pause-form {
  grid-template-columns: 150px 150px minmax(0, 1fr);
}

.pause-form button {
  grid-column: 1 / -1;
  justify-self: start;
}

.one-time-contract .recurring-contract-field {
  display: none;
}

.compact-heading {
  margin-top: 10px;
}

.inline-entry-form {
  grid-template-columns: minmax(0, 1fr) 170px 130px 150px;
}

.inline-entry-form button {
  grid-column: 1 / -1;
  justify-self: start;
}

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

.credential-form button,
.document-form button,
.detail-contract-form .form-actions,
#activityForm button {
  justify-self: start;
}

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

.contact-grid div,
.list-row,
.empty-line {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg-soft);
  padding: 12px;
}

.contact-grid strong {
  display: block;
  margin-top: 5px;
  font-size: 13px;
  font-weight: 700;
}

.compact-list,
.activity-list {
  display: grid;
  gap: 8px;
}

.list-row strong {
  display: block;
  font-size: 13px;
  font-weight: 700;
}

.list-row span,
.empty-line {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.credential-row {
  display: grid;
  gap: 10px;
}

.credential-details {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.credential-details span {
  display: grid;
  gap: 3px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  padding: 8px;
}

.credential-details b {
  color: var(--muted);
  font-size: 9px;
  text-transform: uppercase;
}

.credential-details a {
  overflow: hidden;
  color: var(--primary);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contract-history-row {
  gap: 5px;
}

.contract-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.mini-action {
  min-height: 28px;
  border-radius: 9px;
  font-size: 11px;
  padding: 0 10px;
}

.bar-chart {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 8px;
  min-height: 225px;
  align-items: end;
}

.bar-item {
  display: grid;
  gap: 6px;
  justify-items: center;
  position: relative;
}

.bar-value {
  color: var(--ink);
  font-size: 9px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  white-space: normal;
}

.bar-track {
  display: flex;
  width: 12px;
  height: 150px;
  align-items: end;
  border-radius: 999px;
  background: var(--bg-soft);
  overflow: hidden;
}

.bar-track span {
  display: block;
  width: 100%;
  border-radius: 999px 999px 0 0;
  background: linear-gradient(180deg, #16c79a, var(--primary));
}

.bar-item small {
  color: var(--muted);
  font-size: 10px;
}

.customers-overview {
  display: grid;
  gap: 16px;
}

#customersView .topbar {
  margin-bottom: 14px;
}

#customersView .customers-overview:not(.hidden) {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
}

.renewals-overview {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
}

.costs-overview {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(320px, 0.72fr) minmax(0, 1.28fr);
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
}

.costs-overview > .customer-summary-grid {
  grid-column: 1 / -1;
}

.cost-insights-grid {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: 12px;
}

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

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

#customersView .customer-summary-grid {
  gap: 10px;
}

.summary-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow-soft);
  padding: 18px;
}

#customersView .summary-card {
  border-radius: 14px;
  padding: 12px 14px;
}

#costsView .summary-card {
  border-radius: 14px;
  padding: 12px 14px;
}

.summary-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.summary-card strong {
  display: block;
  margin-top: 10px;
  font-size: 22px;
  font-weight: 750;
}

#customersView .summary-card strong {
  margin-top: 5px;
  font-size: 18px;
}

#costsView .summary-card strong {
  margin-top: 5px;
  font-size: 18px;
}

#guvView.view.active {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
  min-height: 0;
}

.guv-overview {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
}

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

#guvView .summary-card {
  border-radius: 14px;
  padding: 12px 14px;
}

#guvView .summary-card strong {
  margin-top: 5px;
  font-size: 18px;
}

.guv-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  padding: 16px;
}

.guv-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.cost-form-panel {
  min-height: 0;
  padding: 16px;
}

.cost-form {
  display: grid;
  gap: 10px;
}

.cost-form-grid {
  grid-template-columns: 1fr;
  gap: 9px;
}

#costsView .cost-form-grid input,
#costsView .cost-form-grid select {
  min-height: 38px;
}

#costsView .cost-form-grid label {
  gap: 5px;
  font-size: 11px;
}

.cost-tax-preview {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.cost-insight-panel {
  min-height: 230px;
  padding: 16px;
}

.cost-category-layout {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  min-height: 155px;
}

.cost-donut {
  width: 150px;
  aspect-ratio: 1;
  border-radius: 999px;
  background: var(--bg-soft);
  position: relative;
  justify-self: center;
}

.cost-donut::after {
  content: "";
  position: absolute;
  inset: 34px;
  border-radius: inherit;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}

.cost-legend {
  display: grid;
  gap: 8px;
}

.cost-legend-item {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 11px;
}

.cost-legend-item span {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.cost-legend-item strong {
  color: var(--ink);
}

.cost-comparison-chart {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  align-items: end;
  min-height: 165px;
  padding: 4px 12px 0;
}

.cost-comparison-item {
  display: grid;
  grid-template-rows: auto 120px auto;
  gap: 8px;
  min-width: 0;
  position: relative;
  text-align: center;
}

.cost-comparison-item strong {
  font-size: 11px;
  white-space: nowrap;
}

.cost-bar-track {
  display: flex;
  align-items: end;
  justify-content: center;
  border-bottom: 1px solid var(--line);
}

.cost-bar {
  width: min(70px, 70%);
  min-height: 4px;
  border-radius: 6px 6px 0 0;
  background: #b9c2d3;
}

.cost-bar.positive {
  background: #9de8c0;
}

.cost-bar.negative {
  background: #f2a7a7;
}

.cost-comparison-item small {
  color: var(--muted);
  font-size: 11px;
}

.statistics-overview {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
}

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

.statistics-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.statistics-panel {
  min-height: 190px;
  padding: 16px;
}

.statistics-panel.wide {
  grid-column: auto;
}

.stats-bar-chart {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 8px;
  align-items: end;
  min-height: 160px;
}

.stats-bar-chart.compact {
  grid-template-columns: repeat(12, minmax(0, 1fr));
}

.stats-bar-item {
  display: grid;
  grid-template-rows: auto 112px auto;
  gap: 7px;
  min-width: 0;
  position: relative;
  text-align: center;
}

.stats-bar-item strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-bar-track {
  display: flex;
  align-items: end;
  justify-content: center;
  border-bottom: 1px solid var(--line);
}

.stats-bar-track span {
  width: min(38px, 72%);
  min-height: 4px;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, #9de8c0, var(--primary));
}

.stats-bar-item small {
  color: var(--muted);
  font-size: 10px;
}

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

.stats-ranking-row {
  display: grid;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-soft);
  padding: 10px;
}

.stats-ranking-row > div:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 11px;
}

.stats-ranking-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-ranking-row span {
  color: var(--muted);
  white-space: nowrap;
}

.stats-ranking-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--bg-soft);
}

.stats-ranking-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #9de8c0;
}

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

.stats-comparison-card {
  display: grid;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-soft);
  padding: 12px;
}

.stats-comparison-card span,
.stats-comparison-card small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.stats-comparison-card strong {
  font-size: 15px;
}

.stats-comparison-card b {
  font-size: 11px;
}

.stats-comparison-card b.positive {
  color: var(--primary-dark);
}

.stats-comparison-card b.negative {
  color: #c24134;
}

.stats-compare-chart {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 10px;
  min-height: 170px;
  align-items: end;
}

.stats-compare-month {
  display: grid;
  grid-template-rows: 130px auto;
  gap: 8px;
  position: relative;
  text-align: center;
}

.stats-compare-bars {
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 5px;
  border-bottom: 1px solid var(--line);
}

.stats-compare-bars span {
  width: 18px;
  min-height: 4px;
  border-radius: 5px 5px 0 0;
}

.stats-compare-bars .current {
  background: #9de8c0;
}

.stats-compare-bars .compare {
  background: #a9c8f5;
}

.stats-compare-month small {
  color: var(--muted);
  font-size: 10px;
}

.bar-item[data-tooltip]::after,
.cost-comparison-item[data-tooltip]::after,
.stats-bar-item[data-tooltip]::after,
.stats-compare-month[data-tooltip]::after {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  z-index: 20;
  width: max-content;
  max-width: 230px;
  transform: translateX(-50%) translateY(4px);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  color: var(--ink);
  content: attr(data-tooltip);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.45;
  opacity: 0;
  padding: 10px 12px;
  pointer-events: none;
  text-align: left;
  transition:
    opacity 0.16s ease,
    transform 0.16s ease;
  white-space: pre-line;
}

.bar-item[data-tooltip]:hover::after,
.cost-comparison-item[data-tooltip]:hover::after,
.stats-bar-item[data-tooltip]:hover::after,
.stats-compare-month[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.stats-type-split {
  display: grid;
  gap: 14px;
}

.type-split-bar {
  display: flex;
  height: 28px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--bg-soft);
}

.type-split-bar span {
  background: #9de8c0;
}

.type-split-bar b {
  background: #ffd979;
}

.type-split-legend {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.empty-state {
  display: grid;
  justify-items: start;
  gap: 12px;
}

.empty-state p:not(.eyebrow) {
  max-width: 620px;
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.form-subheader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.table-wrap {
  max-height: 560px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
}

#customersView .customers-table-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  padding: 16px;
}

#renewalsView .customers-table-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  padding: 16px;
}

#costsView .customers-table-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  padding: 16px;
}

#customersView .customers-table-panel .section-heading {
  margin-bottom: 12px;
}

#renewalsView .customers-table-panel .section-heading {
  margin-bottom: 12px;
}

#costsView .customers-table-panel .section-heading {
  margin-bottom: 12px;
}

#customersView .table-wrap {
  max-height: none;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
}

#renewalsView .table-wrap {
  max-height: none;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
}

#costsView .table-wrap {
  max-height: none;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
}

#guvView .table-wrap {
  max-height: none;
  min-height: 0;
  height: 100%;
  overflow: auto;
}

.customer-tools {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 170px 170px 190px;
  gap: 12px;
  margin-bottom: 18px;
}

#customersView .customer-tools {
  gap: 10px;
  margin-bottom: 12px;
}

.renewal-tools {
  grid-template-columns: minmax(240px, 1fr) 220px;
}

.cost-tools {
  grid-template-columns: minmax(160px, 1fr) 130px 130px;
}

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

#customersView table {
  min-width: 0;
  table-layout: fixed;
}

.renewals-table {
  min-width: 0;
  table-layout: fixed;
}

.costs-table {
  min-width: 0;
  table-layout: fixed;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 9px;
  text-align: left;
  white-space: nowrap;
}

thead th {
  position: sticky;
  z-index: 2;
  top: 0;
  background: var(--surface);
}

body[data-theme="dark"] thead th {
  background: #162033;
}

th {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

td {
  font-size: 12px;
}

#customersView th,
#customersView td {
  overflow: hidden;
  padding: 8px 5px;
  text-overflow: ellipsis;
}

#customersView th {
  font-size: 8px;
}

#customersView td {
  font-size: 10px;
}

#renewalsView th,
#renewalsView td {
  overflow: hidden;
  padding: 8px 7px;
  text-overflow: ellipsis;
}

#costsView th,
#costsView td {
  overflow: hidden;
  padding: 8px 7px;
  text-overflow: ellipsis;
}

#guvView th,
#guvView td {
  overflow: hidden;
  padding: 8px 7px;
  text-overflow: ellipsis;
}

#renewalsView th {
  font-size: 9px;
}

#renewalsView td {
  font-size: 11px;
}

#costsView th {
  font-size: 9px;
}

#costsView td {
  font-size: 11px;
}

#guvView th {
  font-size: 9px;
}

#guvView td,
#guvView tfoot td {
  font-size: 11px;
}

.guv-table {
  min-width: 1120px;
  table-layout: fixed;
}

.guv-table tfoot td {
  position: sticky;
  bottom: 0;
  z-index: 2;
  border-top: 1px solid var(--line);
  background: var(--surface);
  font-weight: 800;
}

body[data-theme="dark"] .guv-table tfoot td {
  background: #162033;
}

.risk-cell {
  color: #c24134;
  font-weight: 800;
}

.margin-badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  padding: 0 9px;
  white-space: nowrap;
}

.margin-red {
  background: rgba(239, 68, 68, 0.14);
  color: #dc2626;
}

.margin-yellow {
  background: rgba(245, 158, 11, 0.16);
  color: #b45309;
}

.margin-green {
  background: rgba(34, 197, 94, 0.16);
  color: #15803d;
}

.margin-purple {
  background: rgba(139, 92, 246, 0.18);
  color: #7c3aed;
}

#renewalsView th:nth-child(1),
#renewalsView td:nth-child(1) {
  width: 20%;
}

#renewalsView th:nth-child(2),
#renewalsView td:nth-child(2),
#renewalsView th:nth-child(3),
#renewalsView td:nth-child(3),
#renewalsView th:nth-child(4),
#renewalsView td:nth-child(4) {
  width: 12%;
}

#renewalsView th:nth-child(5),
#renewalsView td:nth-child(5),
#renewalsView th:nth-child(6),
#renewalsView td:nth-child(6),
#renewalsView th:nth-child(7),
#renewalsView td:nth-child(7) {
  width: 11%;
}

#renewalsView th:nth-child(8),
#renewalsView td:nth-child(8) {
  width: 9%;
}

#costsView th:nth-child(1),
#costsView td:nth-child(1) {
  width: 25%;
}

#costsView th:nth-child(2),
#costsView td:nth-child(2) {
  width: 13%;
}

#costsView th:nth-child(3),
#costsView td:nth-child(3) {
  width: 20%;
}

#costsView th:nth-child(4),
#costsView td:nth-child(4) {
  width: 15%;
}

#costsView th:nth-child(5),
#costsView td:nth-child(5) {
  width: 12%;
}

#costsView th:nth-child(6),
#costsView td:nth-child(6) {
  width: 15%;
}

#costsView .table-actions {
  gap: 4px;
}

#costsView .table-action {
  width: 24px;
  min-height: 24px;
  padding: 0;
  overflow: hidden;
  font-size: 0;
}

#costsView .table-action::before {
  font-size: 12px;
}

#costsView .table-action[data-cost-action="edit"]::before {
  content: "✎";
}

#costsView .table-action[data-cost-action="delete"]::before {
  content: "×";
  font-size: 16px;
}

#customersView th:nth-child(1),
#customersView td:nth-child(1) {
  width: 13%;
}

#customersView th:nth-child(2),
#customersView td:nth-child(2) {
  width: 10%;
}

#customersView th:nth-child(3),
#customersView td:nth-child(3) {
  width: 8%;
}

#customersView th:nth-child(4),
#customersView td:nth-child(4) {
  width: 11%;
}

#customersView th:nth-child(5),
#customersView td:nth-child(5) {
  width: 7%;
}

#customersView th:nth-child(6),
#customersView td:nth-child(6) {
  width: 9%;
}

#customersView th:nth-child(7),
#customersView td:nth-child(7),
#customersView th:nth-child(8),
#customersView td:nth-child(8) {
  width: 8%;
}

#customersView th:nth-child(9),
#customersView td:nth-child(9),
#customersView th:nth-child(10),
#customersView td:nth-child(10) {
  width: 7%;
}

#customersView th:nth-child(11),
#customersView td:nth-child(11) {
  width: 6%;
}

#customersView th:nth-child(12),
#customersView td:nth-child(12) {
  width: 6%;
}

.sort-button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-align: left;
  text-transform: inherit;
}

.sort-button::after {
  content: "↕";
  color: #9aa6b8;
  font-size: 9px;
}

.sort-button.active::after {
  content: "↑";
  color: var(--primary);
}

.sort-button.active[data-direction="desc"]::after {
  content: "↓";
}

td {
  color: var(--ink);
}

.status-badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border-radius: 999px;
  background: #effaf6;
  color: var(--primary-dark);
  font-size: 11px;
  font-weight: 700;
  padding: 0 10px;
}

.table-actions {
  display: flex;
  gap: 6px;
}

.table-action {
  min-height: 28px;
  align-items: center;
  display: inline-flex;
  justify-content: center;
  padding: 0 9px;
  text-decoration: none;
  white-space: nowrap;
}

#customersView .table-actions {
  gap: 4px;
}

#customersView .table-action {
  width: 24px;
  min-height: 24px;
  padding: 0;
  overflow: hidden;
  font-size: 0;
}

#customersView .table-action::before {
  font-size: 12px;
}

#customersView .table-action[data-action="details"]::before {
  content: "👁";
}

#customersView .table-action[data-action="edit"]::before {
  content: "✎";
}

#customersView .table-action[data-action="delete"]::before {
  content: "×";
  font-size: 16px;
}

#renewalsView .table-action {
  width: auto;
  min-height: 28px;
  padding: 0 10px;
  font-size: 11px;
}

.table-subline {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

#customersView .table-subline {
  font-size: 9px;
}

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

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.suggest-field {
  position: relative;
}

.suggest-box {
  display: none;
  position: absolute;
  z-index: 5;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  border: 1px solid rgba(15, 159, 118, 0.28);
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 18px 38px rgba(15, 23, 42, 0.14);
  padding: 10px;
}

.suggest-box.visible {
  display: block;
}

.suggest-box > span {
  display: block;
  margin: 0 0 8px;
  color: var(--primary-dark);
  font-size: 10px;
  font-weight: 750;
  text-transform: uppercase;
}

.suggest-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  max-height: 150px;
  overflow: auto;
}

.suggest-option {
  min-height: 34px;
  border: 1px solid #cfe7df;
  border-radius: 999px;
  background: #effaf6;
  color: var(--primary-dark);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  padding: 0 11px;
}

.suggest-option:hover {
  background: #dff8ef;
}

.primary-action,
.secondary-action,
.danger-action {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  padding: 0 16px;
  transition:
    transform 150ms ease,
    box-shadow 150ms ease,
    background 150ms ease;
}

.primary-action {
  background: linear-gradient(135deg, #12b886, var(--primary));
  color: #ffffff;
  box-shadow: 0 12px 24px rgba(15, 159, 118, 0.24);
}

.primary-action:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.secondary-action {
  border-color: var(--line);
  background: #ffffff;
  color: var(--ink);
}

.secondary-action:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}

.danger-action {
  background: #fff1ed;
  color: var(--danger);
}

.contract-summary,
.totals-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

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

.contract-summary div,
.totals-grid div {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg-soft);
  padding: 16px;
}

.contract-summary span,
.totals-grid span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.contract-summary strong,
.totals-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 18px;
  font-weight: 750;
}

.contract-summary small,
.totals-grid small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.35;
}

.tax-row {
  margin-bottom: 12px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
}

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

.inline-check {
  align-self: end;
  min-height: 44px;
}

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

.product-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 170px 160px 44px;
  gap: 10px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg-soft);
  padding: 12px;
}

.product-row .danger-action {
  width: 44px;
  padding: 0;
}

.note-field {
  margin-top: 18px;
}

.upload-box {
  display: grid;
  min-height: 130px;
  place-items: center;
  border: 1px dashed #b9c8c2;
  border-radius: 16px;
  background: var(--bg-soft);
  cursor: pointer;
  margin-top: 18px;
  padding: 20px;
  text-align: center;
}

.upload-box input {
  max-width: 320px;
}

.upload-box span {
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

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

.dashboard-lead-panel {
  margin-top: 16px;
}

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

.lead-reminder-row {
  display: flex;
  min-height: 46px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-soft);
  padding: 10px 12px;
}

.lead-reminder-row strong,
.lead-reminder-row span {
  display: block;
}

.lead-reminder-row strong {
  font-size: 12px;
}

.lead-reminder-row span {
  color: var(--muted);
  font-size: 11px;
}

#leadsView.view.active {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
  min-height: 0;
}

.lead-topbar {
  margin-bottom: 18px;
}

.lead-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.lead-meta-pill {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 9px;
  font-size: 11px;
  font-weight: 800;
}

.lead-meta-pill.blue {
  background: rgba(147, 197, 253, 0.16);
  color: #60a5fa;
}

.lead-meta-pill.purple {
  background: rgba(167, 139, 250, 0.16);
  color: #8b5cf6;
}

.lead-top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lead-top-actions .secondary-action {
  min-height: 38px;
}

.leads-overview {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
}

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

.lead-phase-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow-soft);
  padding: 14px;
}

.lead-phase-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.lead-phase-card strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
  font-weight: 800;
}

.lead-phase-card div {
  height: 4px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5e7eb;
}

.lead-phase-card i {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.phase-blue strong {
  color: #60a5fa;
}

.phase-blue i {
  background: #bfdbfe;
}

.phase-orange strong {
  color: #ea580c;
}

.phase-orange i {
  background: #fdba74;
}

.phase-green strong {
  color: #34d399;
}

.phase-green i {
  background: #a7f3d0;
}

.phase-red strong {
  color: #ef4444;
}

.phase-red i {
  background: #fca5a5;
}

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

.lead-forecast-card {
  min-height: 150px;
  padding: 16px;
}

.lead-forecast-card.won {
  background: rgba(236, 253, 245, 0.78);
  border-color: rgba(16, 185, 129, 0.24);
}

.lead-forecast-card.muted-card {
  background: rgba(244, 246, 248, 0.9);
}

.forecast-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.forecast-card-head span {
  border-radius: 8px;
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
  font-size: 11px;
  font-weight: 800;
  padding: 5px 8px;
}

.lead-forecast-card > span,
.forecast-values span,
.forecast-mini-grid small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.lead-forecast-card > strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
  font-weight: 800;
}

.forecast-mini-grid,
.forecast-values {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.forecast-values {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 0;
  margin-top: 14px;
  padding-top: 0;
}

.forecast-mini-grid b,
.forecast-values strong {
  display: block;
  margin-top: 4px;
  font-size: 14px;
  font-weight: 800;
}

.forecast-values strong {
  font-size: 22px;
}

.lead-forecast-card small {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.lead-breakdown-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.lead-breakdown-list div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.lead-breakdown-list b {
  color: var(--primary);
}

.leads-table-panel {
  min-height: 0;
}

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

#leadsView .summary-card {
  border-radius: 14px;
  padding: 12px 14px;
}

#leadsView .summary-card strong {
  margin-top: 5px;
  font-size: 18px;
}

.leads-table-panel {
  min-height: 0;
  padding: 16px;
}

.lead-form-modal {
  position: fixed;
  inset: 0;
  z-index: 35;
  display: grid;
  align-content: start;
  justify-items: center;
  overflow: auto;
  padding: 28px;
  background: rgba(8, 14, 28, 0.58);
  backdrop-filter: blur(10px);
}

.lead-form-modal.hidden {
  display: none;
}

.lead-form-modal .lead-form-panel {
  width: min(100%, 980px);
  padding: 20px;
}

.lead-mail-settings-panel {
  width: min(100%, 1120px);
  padding: 20px;
}

.lead-settings-block {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg-soft);
  padding: 14px;
}

.placeholder-help {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -4px 0 16px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.placeholder-help code {
  border-radius: 7px;
  background: var(--bg-soft);
  color: var(--ink);
  padding: 2px 6px;
}

.lead-mail-settings-form {
  display: grid;
  gap: 14px;
}

.lead-mail-template-list {
  display: grid;
  gap: 12px;
}

.lead-mail-template {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg-soft);
  padding: 14px;
}

.lead-mail-template h4 {
  margin: 0;
  font-size: 14px;
}

.lead-mail-template label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.lead-mail-template textarea {
  min-height: 140px;
}

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

.lead-probability-grid label,
.lead-form label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.lead-probability-grid input,
#leadsView input,
#leadsView select {
  min-height: 38px;
}

.lead-form {
  display: grid;
  gap: 10px;
}

.lead-upsell-toggle {
  justify-content: flex-start;
  border: 1px solid rgba(15, 159, 118, 0.22);
  border-radius: 12px;
  background: rgba(15, 159, 118, 0.08);
  color: var(--ink);
  padding: 10px 12px;
  text-transform: none;
}

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

.lead-position-block {
  display: grid;
  gap: 8px;
}

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

.lead-position-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px 34px;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-soft);
  padding: 8px;
}

.lead-position-row .remove-lead-position {
  min-height: 34px;
  padding: 0;
}

.lead-tools {
  margin-bottom: 10px;
}

.leads-table-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
}

#leadsView .table-wrap {
  min-height: 0;
  overflow: auto;
}

.leads-table {
  min-width: 900px;
}

#leadsView th,
#leadsView td {
  font-size: 11px;
  padding: 9px 10px;
}

#leadsView .table-actions {
  justify-content: flex-end;
  gap: 5px;
}

#leadsView .table-action {
  min-height: 26px;
  font-size: 10px;
  padding: 0 8px;
}

.lead-status-select {
  width: 150px;
  min-height: 30px !important;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 800;
  padding: 0 8px;
}

.lead-reminder-pill {
  display: inline-grid;
  justify-items: start;
  gap: 4px;
}

.lead-reminder-pill strong {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  border: 1px solid #dbeafe;
  border-radius: 999px;
  background: #eff6ff;
  color: #60a5fa;
  font-size: 11px;
  font-weight: 800;
  padding: 0 10px;
}

.lead-reminder-pill span {
  color: #60a5fa;
  font-size: 10px;
  font-weight: 750;
}

.lead-reminder-pill.due strong {
  border-color: #fde68a;
  background: #fffbeb;
  color: #d97706;
}

.lead-reminder-pill.due span {
  color: #d97706;
}

.lead-reminder-pill.overdue strong {
  border-color: #fecaca;
  background: #fef2f2;
  color: #dc2626;
}

.lead-reminder-pill.overdue span {
  color: #dc2626;
}

.lead-reminder-pill.neutral strong {
  border-color: var(--line);
  background: var(--bg-soft);
  color: var(--muted);
}

.lead-reminder-pill.neutral span {
  color: var(--muted);
}

body[data-theme="dark"] .lead-reminder-row,
body[data-theme="dark"] .lead-phase-card,
body[data-theme="dark"] .lead-settings-block,
body[data-theme="dark"] .lead-mail-template,
body[data-theme="dark"] .lead-position-row,
body[data-theme="dark"] .lead-upsell-toggle,
body[data-theme="dark"] .lead-forecast-card.muted-card {
  background: #101a2d;
  border-color: var(--line);
}

body[data-theme="dark"] .lead-forecast-card.won {
  background: rgba(16, 185, 129, 0.1);
}

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

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

  .sidebar {
    position: static;
  }

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

  .metric-grid,
  .detail-layout,
  .dashboard-audit-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .costs-overview {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto minmax(0, 1fr);
  }

  .leads-overview {
    grid-template-rows: auto auto auto minmax(0, 1fr);
  }

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

  .cost-insights-grid {
    grid-template-columns: 1fr;
  }

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

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

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

@media (max-width: 820px) {
  .main-content,
  .sidebar {
    padding: 22px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .dashboard-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .nav-list,
  .metric-grid,
  .detail-layout,
  .dashboard-audit-grid,
  .customer-summary-grid,
  .cost-insights-grid,
  #costsView .customer-summary-grid,
  .leads-summary-grid,
  .lead-phase-grid,
  .lead-forecast-grid,
  .lead-probability-grid,
  .statistics-summary-grid,
  .guv-summary-grid,
  .statistics-grid,
  .stats-ranking-list,
  .stats-comparison-grid,
  .cost-category-layout,
  .detail-kpi-grid,
  .detail-main-grid,
  .contact-grid,
  .inline-entry-form,
  .credential-form,
  .customer-tools,
  .form-grid,
  .contract-summary,
  .totals-grid,
  .product-row,
  .lead-form-grid,
  .lead-position-row,
  .forecast-mini-grid,
  .forecast-values {
    grid-template-columns: 1fr;
  }

  h2 {
    font-size: 24px;
  }

  .metric-card strong {
    font-size: 25px;
  }
}

/* Ruhigere CRM-Oberfläche: dichter, flacher und stärker auf Tabellenarbeit ausgelegt. */
:root {
  --bg: #f5f6f8;
  --bg-soft: #f8fafc;
  --surface: #ffffff;
  --surface-strong: #f2f8f5;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e2e8f0;
  --primary: #0f8f69;
  --primary-dark: #0b6b50;
  --sidebar: #111827;
  --shadow: none;
  --shadow-soft: none;
}

body {
  background: var(--bg);
  font-size: 13px;
}

body[data-theme="dark"] {
  --bg: #0f172a;
  --bg-soft: #121c2f;
  --surface: #172033;
  --surface-strong: #172d24;
  --ink: #f8fafc;
  --muted: #a8b3c7;
  --line: #2d3a50;
  background: var(--bg);
}

.app-shell {
  grid-template-columns: 248px minmax(0, 1fr);
}

.sidebar {
  background: var(--sidebar);
  padding: 18px 12px;
}

.brand {
  gap: 10px;
  margin-bottom: 18px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  padding: 8px 10px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: rgba(15, 143, 105, 0.18);
  box-shadow: none;
  font-size: 15px;
}

.brand-label {
  font-size: 9px;
}

h1 {
  font-size: 15px;
}

h2 {
  font-size: 22px;
  font-weight: 700;
}

h3 {
  font-size: 15px;
  font-weight: 700;
}

.eyebrow,
.metric-label {
  font-size: 10px;
  font-weight: 700;
}

.nav-list {
  gap: 2px;
}

.nav-item {
  min-height: 35px;
  border-radius: 8px;
  gap: 9px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 600;
}

.nav-item:hover {
  transform: none;
}

.nav-item span {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: transparent;
  font-size: 13px;
}

.nav-item.active {
  background: rgba(255, 255, 255, 0.09);
}

.sidebar-toggle {
  min-height: 38px;
  margin-top: 16px;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
}

.switch-button {
  width: 42px;
  height: 24px;
}

.switch-button span {
  width: 18px;
  height: 18px;
}

.switch-button[aria-pressed="true"] span {
  transform: translateX(18px);
}

.main-content {
  padding: 22px;
}

.topbar {
  margin-bottom: 16px;
}

.dashboard-controls,
.lead-top-actions {
  gap: 8px;
}

.metric-grid,
.detail-layout,
.dashboard-audit-grid,
.customer-summary-grid,
.cost-insights-grid,
.statistics-summary-grid,
.statistics-grid,
.stats-ranking-list,
.stats-comparison-grid,
.guv-summary-grid,
.lead-phase-grid,
.lead-forecast-grid,
.costs-overview,
.guv-overview,
.statistics-overview,
.customers-overview,
.renewals-overview,
.leads-overview {
  gap: 10px;
}

.metric-card,
.panel,
.form-panel,
.empty-state,
.customers-table-panel,
.summary-card,
.detail-kpi-card,
.lead-phase-card,
.lead-forecast-card,
.stats-ranking-row,
.stats-comparison-card,
.lead-mail-template,
.lead-settings-block,
.contact-grid div,
.list-row,
.empty-line,
.contract-summary div,
.totals-grid div,
.product-row,
.lead-position-row,
.upload-box,
.audit-row,
.warning-row,
.audit-empty,
.lead-reminder-row {
  border-radius: 8px;
  background: var(--surface);
  box-shadow: none;
}

.metric-card,
.panel,
.form-panel,
.empty-state,
.customers-table-panel {
  border-color: var(--line);
}

.metric-card {
  min-height: 118px;
  padding: 16px;
}

.metric-card::after {
  display: none;
}

.metric-card strong {
  margin-top: 12px;
  font-size: 22px;
  font-weight: 700;
}

.metric-card span {
  margin-top: 9px;
  font-size: 11px;
}

.metric-card.accent {
  background: var(--surface);
  border-color: rgba(15, 143, 105, 0.32);
}

.metric-detail-button {
  min-height: 26px;
  border-radius: 7px;
  margin-top: 10px;
  font-size: 10px;
}

.panel,
.form-panel,
.empty-state,
.customers-table-panel {
  padding: 16px;
}

.panel-heading,
.section-heading,
.section-heading.with-action {
  margin-bottom: 12px;
}

.segmented-control,
.year-picker {
  border-radius: 8px;
  background: var(--surface);
  box-shadow: none;
}

.segmented-control button {
  min-height: 31px;
  border-radius: 6px;
  font-size: 12px;
}

.year-picker {
  min-width: 140px;
  padding: 8px 10px;
  font-size: 12px;
}

input,
select {
  min-height: 36px;
}

select,
input,
textarea {
  border-radius: 8px;
}

textarea {
  min-height: 96px;
}

.primary-action,
.secondary-action,
.danger-action {
  min-height: 36px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 650;
  padding: 0 12px;
}

.primary-action {
  background: var(--primary);
  box-shadow: none;
}

.primary-action:hover,
.secondary-action:hover {
  transform: none;
  box-shadow: none;
}

.summary-card,
#customersView .summary-card,
#costsView .summary-card,
#guvView .summary-card,
#leadsView .summary-card {
  border-radius: 8px;
  padding: 12px;
}

.summary-card strong,
#customersView .summary-card strong,
#costsView .summary-card strong,
#guvView .summary-card strong,
#leadsView .summary-card strong {
  margin-top: 5px;
  font-size: 17px;
  font-weight: 700;
}

.detail-kpi-card {
  padding: 14px;
}

.detail-kpi-card strong {
  font-size: 19px;
}

.lead-phase-card {
  padding: 12px;
}

.lead-phase-card strong {
  font-size: 21px;
}

.lead-forecast-card {
  min-height: 126px;
  padding: 14px;
}

.lead-forecast-card > strong,
.forecast-values strong {
  font-size: 19px;
}

.forecast-mini-grid,
.forecast-values {
  gap: 8px;
}

.table-wrap {
  border-radius: 8px;
}

th,
td {
  padding: 8px 8px;
}

thead th {
  box-shadow: inset 0 -1px 0 var(--line);
}

tbody tr:hover {
  background: rgba(15, 143, 105, 0.035);
}

.status-badge,
.status-pill,
.margin-badge,
.lead-meta-pill,
.forecast-card-head span {
  border-radius: 7px;
}

.customer-tools {
  gap: 8px;
  margin-bottom: 10px;
}

.form-grid,
.lead-form-grid {
  gap: 10px;
}

label,
.lead-probability-grid label,
.lead-form label,
.lead-mail-template label {
  font-size: 11px;
  font-weight: 650;
}

.customer-form:not(.hidden),
.customer-detail:not(.hidden),
.lead-form-modal {
  padding: 22px;
  background: rgba(15, 23, 42, 0.48);
}

.customer-form:not(.hidden) > .form-subheader,
.customer-detail:not(.hidden) > .form-subheader {
  border-radius: 8px;
  box-shadow: none;
}

.lead-form-modal .lead-form-panel,
.lead-mail-settings-panel {
  border-radius: 8px;
}

.bar-track span,
.stats-bar-track span,
.cost-bar,
.stats-compare-bars span {
  background: var(--primary);
}

.cost-bar.positive,
.stats-compare-bars .current,
.type-split-bar span,
.stats-ranking-track span {
  background: #8bdcb6;
}

.cost-bar.negative {
  background: #efb0b0;
}

body[data-theme="dark"] .metric-card.accent,
body[data-theme="dark"] .metric-card,
body[data-theme="dark"] .panel,
body[data-theme="dark"] .form-panel,
body[data-theme="dark"] .empty-state,
body[data-theme="dark"] .customers-table-panel,
body[data-theme="dark"] .summary-card,
body[data-theme="dark"] .detail-kpi-card,
body[data-theme="dark"] .audit-issue-row {
  background: var(--surface);
}

.login-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(15, 143, 105, 0.14), transparent 36%),
    var(--bg);
}

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

.login-card {
  width: min(100%, 420px);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 28px;
}

.login-card h1 {
  margin: 6px 0 22px;
  font-size: 24px;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-error {
  margin: 0;
  border-radius: 8px;
  background: rgba(239, 68, 68, 0.1);
  color: #b91c1c;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 700;
}

.logout-button {
  width: 100%;
  margin-top: 12px;
}

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

  .audit-layout {
    grid-template-columns: 1fr;
  }
}

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

  .audit-issue-row,
  .audit-issue-meta {
    align-items: flex-start;
    flex-direction: column;
  }
}
