:root {
  --bg: #f6f8f5;
  --text: #1c2430;
  --text-muted: #5f6f66;
  --panel: #ffffff;
  --line: #d0d8ce;
  --accent: #2b6f59;
  --rail-w: 96px;
  --notice-bg: #e8f6ef;
  --notice-border: #bde2cc;
  --tab-bg: #f3f6f2;
  --tab-active-bg: #dcece1;
  --tab-active-border: #94b4a2;
  --search-muted: #6b766d;
  --log-bg: #fbfdfb;
  --log-line: #edf3ed;
  --badge-bg: #f8ecd2;
  --badge-text: #7b5b1f;
  --table-row-hover-bg: #f6fbf7;
  --table-row-hover-border: #dce8df;
  --input-border: #bac8be;
  --surface-subtle: #f6faf7;
  --calendar-day-bg: #ffffff;
  --calendar-day-muted-bg: #f3f6f3;
  --calendar-day-muted-text: #758079;
  --calendar-event-text: #173126;
  --calendar-birthday-bg: #e5f6ff;
  --calendar-birthday-border: #98cde7;
  --calendar-contact-bg: #f6f1e3;
  --calendar-contact-border: #d8c78b;
  --calendar-default-bg: #eef4ee;
  --calendar-default-border: #c7d9c8;
  --calendar-more-text: #617267;
  --modal-overlay: rgba(18, 28, 22, 0.35);
  --rail-bg: #0f2b24;
  --rail-border: #234238;
  --rail-logo-bg: linear-gradient(160deg, #0f5c4a, #11362d);
  --rail-logo-border: #2e6151;
  --rail-icon: #d8ece1;
  --rail-icon-hover-bg: rgba(201, 235, 222, 0.15);
  --flyout-shadow: 0 8px 24px rgba(20, 35, 27, 0.18);
  --body-orb-a: rgba(137, 194, 182, 0.42);
  --body-orb-b: rgba(242, 190, 159, 0.36);
  --search-popup-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
  --search-popup-line: #eef3ee;
  --surface-pill-bg: #f7faf8;
  --surface-pill-text: #44574f;
  --surface-pill-hover-bg: #e9f3ee;
  --surface-pill-active-bg: #dbeee8;
  --surface-pill-active-border: #9fcdbf;
  --surface-pill-active-text: #214f43;
  --calendar-day-name-color: #2f443a;
  --calendar-loading-color: #5d6d62;
  --customer-card-surface: rgba(255, 255, 255, 0.9);
  --customer-card-border: rgba(255, 255, 255, 0.82);
  --customer-card-shadow: 0 20px 40px rgba(12, 36, 28, 0.08);
  --flyout-ink: #f3fbf8;
  --flyout-link: #c8e8df;
  --flyout-hover-bg: rgba(185, 221, 209, 0.2);
}

html[data-theme="dark"] {
  --bg: #11161c;
  --text: #d7e1ec;
  --text-muted: #9aa6b4;
  --panel: #1b2430;
  --line: #334155;
  --accent: #72caa8;
  --notice-bg: #18352a;
  --notice-border: #2c6a52;
  --tab-bg: #222f3d;
  --tab-active-bg: #2a3b4d;
  --tab-active-border: #4f6a83;
  --search-muted: #9aa6b4;
  --log-bg: #19222d;
  --log-line: #2d3a49;
  --badge-bg: #4a3d1d;
  --badge-text: #efdca8;
  --table-row-hover-bg: #233244;
  --table-row-hover-border: #39506a;
  --input-border: #415267;
  --surface-subtle: #243243;
  --calendar-day-bg: #0f1620;
  --calendar-day-muted-bg: #121923;
  --calendar-day-muted-text: #8fa0b3;
  --calendar-event-text: #0f1a27;
  --calendar-birthday-bg: #9fc4e2;
  --calendar-birthday-border: #87afcf;
  --calendar-contact-bg: #dbc891;
  --calendar-contact-border: #c3af77;
  --calendar-default-bg: #a9bdcf;
  --calendar-default-border: #93a9bd;
  --calendar-more-text: #9fb1c3;
  --modal-overlay: rgba(8, 12, 18, 0.62);
  --rail-bg: #0c131b;
  --rail-border: #273444;
  --rail-logo-bg: linear-gradient(160deg, #17303a, #102633);
  --rail-logo-border: #34506b;
  --rail-icon: #d0deef;
  --rail-icon-hover-bg: rgba(189, 215, 246, 0.14);
  --flyout-shadow: 0 10px 26px rgba(0, 0, 0, 0.42);
  --body-orb-a: rgba(66, 149, 138, 0.2);
  --body-orb-b: rgba(99, 127, 184, 0.16);
  --search-popup-shadow: 0 10px 24px rgba(0, 0, 0, 0.32);
  --search-popup-line: #2d3a49;
  --surface-pill-bg: #243546;
  --surface-pill-text: #cad8e7;
  --surface-pill-hover-bg: #2a3f54;
  --surface-pill-active-bg: #2d465e;
  --surface-pill-active-border: #426280;
  --surface-pill-active-text: #d0e8f7;
  --calendar-day-name-color: #c9d8e7;
  --calendar-loading-color: #9fb1c3;
  --customer-card-surface: rgba(27, 36, 48, 0.9);
  --customer-card-border: rgba(58, 79, 101, 0.82);
  --customer-card-shadow: 0 24px 40px rgba(0, 0, 0, 0.24);
  --flyout-ink: #f3fbf8;
  --flyout-link: #c4dff7;
  --flyout-hover-bg: rgba(120, 157, 201, 0.23);
  color-scheme: dark;
}

html[data-theme="dark"] .topbar {
  background: rgba(20, 31, 44, 0.88);
  border-color: rgba(58, 78, 103, 0.75);
}

html[data-theme="dark"] .topbar-brand-title {
  color: #d7e1ec;
}

html[data-theme="dark"] .topbar-company {
  color: #a4b2bf;
}

html[data-theme="dark"] .topbar-nav-link {
  color: #a9bbcf;
}

html[data-theme="dark"] .topbar-nav-link:hover {
  background: #26384a;
  color: #dde8f4;
}

html[data-theme="dark"] .topbar-nav-link.is-active {
  background: #2e455b;
  color: #b8def0;
}

html[data-theme="dark"] .topbar-right > span {
  color: #d2ddea;
}

html[data-theme="dark"] .theme-toggle-btn,
html[data-theme="dark"] .signout-btn {
  background: #243546;
  border-color: #395168;
  color: #d7e1ec;
}

html[data-theme="dark"] .crm-auth-card {
  background: rgba(27, 36, 48, 0.88);
  border-color: rgba(58, 78, 103, 0.74);
  box-shadow: 0 24px 46px rgba(0, 0, 0, 0.28);
}

html[data-theme="dark"] .crm-auth-kicker,
html[data-theme="dark"] .crm-auth-subtitle {
  color: #a4b2bf;
}

html[data-theme="dark"] .crm-auth-submit:focus-visible,
html[data-theme="dark"] input:focus-visible,
html[data-theme="dark"] select:focus-visible,
html[data-theme="dark"] textarea:focus-visible {
  outline-color: color-mix(in srgb, var(--accent) 62%, white);
}

body {
  margin: 0;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 16%, var(--bg)) 0%, var(--bg) 220px);
  color: var(--text);
  position: relative;
  min-height: 100vh;
}

body::before,
body::after {
  content: "";
  position: fixed;
  border-radius: 999px;
  pointer-events: none;
  z-index: -1;
}

body::before {
  width: 620px;
  height: 620px;
  right: -130px;
  top: -180px;
  background: radial-gradient(circle, var(--body-orb-a) 0%, transparent 72%);
}

body::after {
  width: 520px;
  height: 520px;
  left: -130px;
  bottom: -180px;
  background: radial-gradient(circle, var(--body-orb-b) 0%, transparent 72%);
}

main {
  max-width: 1100px;
  margin: 0 1rem 1.25rem;
  padding: 1.25rem;
  margin-left: 0;
}

main.main-full-width {
  max-width: unset;
  width: auto;
  margin: 0 1rem 1.25rem;
  margin-left: 0;
}

.auth-card {
  max-width: 460px;
  margin: 2rem auto;
}

.crm-auth-shell {
  min-height: calc(100vh - 4.5rem);
  display: grid;
  place-items: center;
}

.crm-auth-card {
  width: min(100%, 32rem);
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 24px;
  box-shadow: 0 24px 46px rgba(12, 36, 28, 0.12);
  backdrop-filter: blur(10px);
  padding: 1.5rem;
}

.crm-auth-intro {
  display: grid;
  gap: 0.7rem;
  margin-bottom: 1.2rem;
}

.crm-auth-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.crm-auth-brand-mark {
  width: 3rem;
  height: 3rem;
  border-radius: 0.95rem;
  background: linear-gradient(160deg, #006d77, #4ba39b);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.crm-auth-kicker {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.74rem;
  color: var(--text-muted);
}

.crm-auth-card h1 {
  margin: 0.18rem 0 0;
  font-size: clamp(1.9rem, 3vw, 2.35rem);
  font-family: "Fraunces", "Baskerville", serif;
  font-weight: 600;
}

.crm-auth-subtitle {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.5;
}

.crm-auth-form {
  display: grid;
  gap: 0.2rem;
}

.crm-auth-actions {
  margin-top: 1.15rem;
}

.crm-auth-submit {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 0.82rem 1rem;
  background: linear-gradient(145deg, var(--accent), #1b8466);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 650;
  cursor: pointer;
  transition: transform 0.18s ease, filter 0.18s ease;
}

.crm-auth-submit:hover {
  transform: translateY(-1px);
  filter: brightness(1.02);
}

.crm-auth-submit:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 48%, white);
  outline-offset: 2px;
}

body.app-shell-active main {
  margin-left: var(--rail-w);
}

body.app-shell-active main.main-full-width {
  margin-left: var(--rail-w);
}

.topbar {
  margin: 1rem 1rem 0;
  margin-left: var(--rail-w);
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 20px;
  box-shadow: 0 20px 40px rgba(12, 36, 28, 0.11);
  backdrop-filter: blur(8px);
  padding: 0.72rem 1rem;
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
}

.topbar-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.8rem;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.topbar-brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: linear-gradient(160deg, #006d77, #4ba39b);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
}

.topbar-brand-title {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 650;
}

.topbar-company {
  margin: 0;
  color: #5f6f66;
  font-size: 0.76rem;
}

.topbar-nav {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.topbar-nav-link {
  text-decoration: none;
  color: #5f6f66;
  border-radius: 999px;
  padding: 0.42rem 0.66rem;
  font-size: 0.82rem;
  font-weight: 560;
  border: 1px solid transparent;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.topbar-nav-link:hover {
  background: #e8f2ed;
  color: #17211d;
  text-decoration: none;
}

.topbar-nav-link.is-active {
  background: #d7ece6;
  color: #00525a;
}

.topbar-right {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
}

.topbar-right > span {
  font-size: 0.96rem;
  color: #33443d;
}

.signout-btn {
  padding: 0.42rem 0.64rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #f1f4f2;
  color: var(--text);
  cursor: pointer;
}

.theme-toggle-btn {
  padding: 0.42rem 0.64rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #f1f4f2;
  color: var(--text);
  cursor: pointer;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.notice {
  background: var(--notice-bg);
  border: 1px solid var(--notice-border);
  border-radius: 0.4rem;
  padding: 0.6rem;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  padding: 1rem;
  margin-bottom: 1rem;
}

.topbar-right form.button_to {
  display: inline;
  margin: 0;
}

.form-grid {
  display: grid;
  gap: 0.8rem;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.field-checkbox {
  justify-content: flex-end;
}

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

.field-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.small-link {
  font-size: 0.8rem;
}

.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.tab {
  border: 1px solid var(--line);
  border-radius: 0.35rem;
  padding: 0.35rem 0.7rem;
  background: var(--tab-bg);
}

.tab.active {
  background: var(--tab-active-bg);
  border-color: var(--tab-active-border);
  font-weight: 600;
}

.add-contact-row {
  margin-top: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.search-results-popup {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 40;
  border: 1px solid var(--line);
  border-radius: 0.4rem;
  background: var(--panel);
  box-shadow: var(--search-popup-shadow);
  max-height: 260px;
  overflow-y: auto;
}

.search-result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid var(--search-popup-line);
}

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

.search-result-row.muted {
  color: var(--search-muted);
}

.log-window {
  border: 1px solid var(--line);
  background: var(--log-bg);
  border-radius: 0.4rem;
  padding: 0.6rem;
  min-height: 220px;
  max-height: 420px;
  overflow-y: auto;
  font-family: "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.86rem;
  line-height: 1.45;
}

.log-line {
  padding: 0.2rem 0;
  border-bottom: 1px solid var(--log-line);
}

.log-line:last-child {
  border-bottom: 0;
}

input,
select,
textarea {
  padding: 0.45rem;
  border: 1px solid var(--input-border);
  border-radius: 0.35rem;
  background: var(--panel);
  color: var(--text);
}

.actions {
  margin-top: 1rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
}

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

.badge {
  background: var(--badge-bg);
  color: var(--badge-text);
  padding: 0.15rem 0.45rem;
  border-radius: 0.4rem;
  font-size: 0.8rem;
}

.bulk-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.6rem;
  font-size: 0.82rem;
}

.bulk-link,
.bulk-link-button {
  color: var(--accent);
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

.bulk-link:hover,
.bulk-link-button:hover {
  text-decoration: underline;
}

.disabled-link {
  color: var(--text-muted);
  cursor: default;
  pointer-events: none;
  text-decoration: none;
}

.checkbox-col {
  width: 2rem;
}

.clickable-row {
  cursor: pointer;
  transition: background-color 120ms ease, box-shadow 120ms ease;
}

.clickable-row:hover {
  background: var(--table-row-hover-bg);
  box-shadow: inset 0 0 0 1px var(--table-row-hover-border);
}

.table-tools-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.table-search-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.table-search-form input[type="text"] {
  min-width: 260px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--modal-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 80;
  padding: 1rem;
}

.modal-backdrop[hidden] {
  display: none !important;
}

.modal-card {
  width: min(520px, 96vw);
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  padding: 1rem;
}

.column-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 0.4rem 0.8rem;
  margin: 0.8rem 0;
}

.modal-actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.calendar-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.calendar-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.calendar-nav button {
  border: 1px solid var(--line);
  background: var(--surface-subtle);
  color: var(--text);
  border-radius: 0.35rem;
  padding: 0.35rem 0.65rem;
  cursor: pointer;
}

.calendar-filters {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.calendar-filter-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.calendar-grid {
  display: block;
}

.calendar-day-names {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.4rem;
  margin-bottom: 0.4rem;
}

.calendar-week-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.4rem;
  margin-bottom: 0.45rem;
}

.calendar-day-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--calendar-day-name-color);
  padding: 0.35rem 0.4rem;
}

.calendar-day-cell {
  min-height: 130px;
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  background: var(--calendar-day-bg);
  padding: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.calendar-day-cell.muted {
  background: var(--calendar-day-muted-bg);
  color: var(--calendar-day-muted-text);
}

.calendar-day-number {
  font-size: 0.85rem;
  font-weight: 700;
}

.calendar-day-events {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.calendar-event {
  font-size: 0.75rem;
  line-height: 1.2;
  border-radius: 0.3rem;
  padding: 0.2rem 0.3rem;
  text-decoration: none;
  color: var(--calendar-event-text);
  border: 1px solid transparent;
  font-weight: 600;
}

.calendar-event.event-birthday {
  background: var(--calendar-birthday-bg);
  border-color: var(--calendar-birthday-border);
}

.calendar-event.event-last-contact {
  background: var(--calendar-contact-bg);
  border-color: var(--calendar-contact-border);
}

.calendar-event.event-default {
  background: var(--calendar-default-bg);
  border-color: var(--calendar-default-border);
}

.calendar-event.event-activity-due {
  background: color-mix(in srgb, var(--accent) 18%, var(--panel));
  border-color: color-mix(in srgb, var(--accent) 48%, var(--line));
}

.calendar-event.event-activity-completed {
  background: color-mix(in srgb, var(--surface-subtle) 75%, var(--panel));
  border-color: color-mix(in srgb, var(--line) 80%, var(--panel));
  opacity: 0.9;
}

.calendar-event.event-opportunity-follow-up {
  background: color-mix(in srgb, #8ecf40 25%, var(--panel));
  border-color: color-mix(in srgb, #8ecf40 58%, var(--line));
}

.calendar-event.event-opportunity-follow-up-completed {
  background: color-mix(in srgb, #8ecf40 12%, var(--panel));
  border-color: color-mix(in srgb, #8ecf40 38%, var(--line));
  opacity: 0.9;
}

.calendar-event.event-work-order {
  background: color-mix(in srgb, #4f8df7 22%, var(--panel));
  border-color: color-mix(in srgb, #4f8df7 52%, var(--line));
}

.calendar-complete-btn {
  margin-top: 0.15rem;
  border: 1px solid var(--line);
  background: var(--surface-subtle);
  color: var(--text);
  border-radius: 0.28rem;
  font-size: 0.7rem;
  cursor: pointer;
  padding: 0.12rem 0.28rem;
}

.calendar-event-link {
  color: inherit;
  text-decoration: none;
}

.calendar-work-order-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.25rem;
}

.calendar-work-order-action-btn {
  border: 1px solid var(--line);
  background: var(--surface-subtle);
  color: var(--text);
  border-radius: 0.28rem;
  font-size: 0.68rem;
  cursor: pointer;
  padding: 0.12rem 0.28rem;
}

.calendar-work-order-blocked {
  display: inline-block;
  margin-top: 0.2rem;
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 700;
}

.calendar-completed-flag {
  margin-top: 0.15rem;
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
}

.calendar-completed-flag input[type="checkbox"] {
  margin: 0;
}

.calendar-more {
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--calendar-more-text);
  padding-top: 0.1rem;
}

.calendar-expanded-day-panel {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--panel);
  padding: 0.8rem;
}

.calendar-expanded-day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.calendar-expanded-day-events {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.6rem;
}

.calendar-expanded-day-events .calendar-event {
  font-size: 0.85rem;
  padding: 0.35rem 0.45rem;
}

.calendar-work-week-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.6rem;
}

.calendar-work-week-grid.is-seven-day {
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.calendar-work-week-day {
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--calendar-day-bg);
  padding: 0.75rem;
  min-height: 260px;
}

.calendar-work-week-day-head {
  margin-bottom: 0.6rem;
}

.calendar-work-week-day-events {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.calendar-work-week-empty {
  color: var(--muted);
  margin: 0;
  font-size: 0.82rem;
}

.calendar-loading {
  grid-column: 1 / -1;
  padding: 0.6rem;
  color: var(--calendar-loading-color);
}

.side-rail {
  position: fixed;
  top: 1rem;
  left: 1rem;
  bottom: 1rem;
  width: 60px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 22px;
  box-shadow: 0 20px 40px rgba(12, 36, 28, 0.11);
  backdrop-filter: blur(8px);
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 0.5rem;
}

.rail-logo {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(160deg, #006d77, #4ba39b);
  color: #fff;
  display: grid;
  place-items: center;
  border: 0;
  text-decoration: none;
}

.rail-logo-mark {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.rail-nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
  align-items: center;
}

.rail-item {
  position: relative;
}

.rail-icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 0;
  background: #f1f7f4;
  color: #2e5248;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.18s ease, background-color 0.18s ease;
}

.rail-icon-btn:hover,
.rail-item.is-open .rail-icon-btn {
  transform: translateY(-1px);
  background: #dff0eb;
}

.rail-icon-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 1.2;
}

.rail-flyout {
  position: absolute;
  top: 0;
  left: calc(100% + 12px);
  min-width: 210px;
  background: rgba(13, 40, 33, 0.94);
  border-radius: 16px;
  box-shadow: 0 16px 30px rgba(5, 20, 16, 0.35);
  padding: 0.75rem 0.8rem;
  display: block;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-8px) scale(0.98);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.flyout-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.45rem;
  color: var(--flyout-ink);
  font-family: "Fraunces", "Baskerville", serif;
}

.rail-flyout a {
  display: block;
  padding: 0.45rem 0.5rem;
  font-size: 0.87rem;
  border-radius: 10px;
  color: var(--flyout-link);
}

.rail-flyout a:hover {
  text-decoration: none;
  background: var(--flyout-hover-bg);
}

.rail-item.is-open .rail-flyout {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0) scale(1);
}

.customer-edit-shell {
  display: grid;
  gap: 0.9rem;
}

.customer-edit-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.customer-edit-kicker {
  margin: 0;
  color: var(--search-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
}

.customer-edit-title {
  margin: 0.2rem 0 0;
  font-family: "Fraunces", "Baskerville", serif;
  font-weight: 600;
  font-size: clamp(1.45rem, 2.2vw, 1.95rem);
  color: var(--text);
}

.customer-edit-subtitle {
  margin: 0.25rem 0 0;
  color: var(--search-muted);
}

.customer-edit-header-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.customer-edit-header-links a {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-pill-bg);
  color: var(--surface-pill-text);
  padding: 0.4rem 0.72rem;
  font-size: 0.82rem;
}

.customer-edit-header-links a:hover {
  text-decoration: none;
  background: var(--surface-pill-hover-bg);
}

.customer-edit-card {
  border-radius: 20px;
  background: var(--customer-card-surface);
  border: 1px solid var(--customer-card-border);
  box-shadow: var(--customer-card-shadow);
}

.customer-edit-tabs {
  gap: 0.42rem;
}

.customer-edit-tab {
  border-radius: 999px;
  padding: 0.45rem 0.75rem;
  font-size: 0.82rem;
  color: var(--surface-pill-text);
}

.customer-edit-tab.active {
  background: var(--surface-pill-active-bg);
  border-color: var(--surface-pill-active-border);
  color: var(--surface-pill-active-text);
}

.customer-edit-section-title {
  margin: 0 0 0.65rem;
  font-size: 1rem;
}

.customer-edit-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.customer-edit-table-wrap table {
  margin: 0;
}

.customer-edit-live-search {
  margin-top: 0.8rem;
  max-width: 520px;
  position: relative;
}

.customer-edit-log-window {
  margin-top: 0.35rem;
}

.customer-edit-footer-links {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.customer-edit-footer-links a {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-pill-bg);
  color: var(--surface-pill-text);
  padding: 0.4rem 0.72rem;
  font-size: 0.82rem;
}

.customer-edit-footer-links a:hover {
  text-decoration: none;
  background: var(--surface-pill-hover-bg);
}

html[data-theme="dark"] .side-rail {
  background: rgba(19, 29, 41, 0.88);
  border-color: rgba(56, 78, 103, 0.72);
}

html[data-theme="dark"] .rail-logo {
  background: linear-gradient(160deg, #1d5e74, #2e6e63);
}

html[data-theme="dark"] .rail-icon-btn {
  background: #213446;
  color: #cadcf2;
}

html[data-theme="dark"] .rail-icon-btn:hover,
html[data-theme="dark"] .rail-item.is-open .rail-icon-btn {
  background: #2c465f;
}

html[data-theme="dark"] .rail-flyout {
  background: rgba(16, 26, 39, 0.95);
}

html[data-theme="dark"] .rail-flyout a {
  color: #c4dff7;
}

html[data-theme="dark"] .rail-flyout a:hover {
  background: rgba(120, 157, 201, 0.23);
}

html[data-theme="dark"] .customer-edit-title {
  color: #d7e1ec;
}

html[data-theme="dark"] .customer-edit-subtitle,
html[data-theme="dark"] .customer-edit-kicker {
  color: #9fb1c3;
}

html[data-theme="dark"] .customer-edit-card {
  background: rgba(27, 36, 48, 0.9);
  border-color: #334155;
}

html[data-theme="dark"] .customer-edit-tab {
  color: #b6c6d8;
}

html[data-theme="dark"] .customer-edit-tab.active {
  background: #2d465e;
  border-color: #426280;
  color: #d0e8f7;
}

html[data-theme="dark"] .customer-edit-header-links a,
html[data-theme="dark"] .customer-edit-footer-links a {
  background: #243546;
  border-color: #395168;
  color: #cad8e7;
}

html[data-theme="dark"] .customer-edit-header-links a:hover,
html[data-theme="dark"] .customer-edit-footer-links a:hover {
  background: #2a3f54;
}

.campaign-board {
  display: grid;
  gap: 0.8rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.campaign-column {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 0.6rem;
  min-height: 280px;
}

.campaign-cards {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 220px;
}

.campaign-card {
  border: 1px solid var(--line);
  border-radius: 0.42rem;
  background: color-mix(in srgb, var(--panel) 88%, var(--surface-subtle));
  padding: 0.5rem;
  cursor: grab;
}

.campaign-card.dragging {
  opacity: 0.6;
}

.opportunity-edit-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 1rem;
  align-items: start;
  width: 100%;
}

.opportunity-edit-main {
  min-width: 0;
  width: 100%;
}

.opportunity-form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.opportunity-follow-up-rail {
  width: 320px;
  max-width: 320px;
  justify-self: end;
}

.opportunity-follow-up-rail .card {
  position: sticky;
  top: 1rem;
}

.contact-edit-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 1rem;
  align-items: start;
  width: 100%;
}

.contact-edit-main {
  min-width: 0;
  width: 100%;
}

.contact-activity-rail {
  width: 320px;
  max-width: 320px;
  justify-self: end;
}

.contact-activity-rail .card {
  position: sticky;
  top: 1rem;
}

.kanban-scroll-wrap {
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  padding-bottom: 0.3rem;
}

#opportunity_kanban {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.8rem;
  width: max-content;
  min-width: 100%;
  align-items: flex-start;
}

#opportunity_kanban .campaign-column {
  flex: 0 0 280px;
  width: 280px;
  min-height: 320px;
}

@media (max-width: 900px) {
  .side-rail {
    display: none;
  }

  .topbar,
  main {
    margin-left: 0;
  }

  .topbar {
    margin: 0.65rem 0.65rem 0;
  }

  main {
    margin: 0 0.65rem 1rem;
  }

  main.main-full-width {
    width: auto;
  }

  .topbar-nav {
    width: 100%;
  }

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

  .opportunity-follow-up-rail {
    width: 100%;
    max-width: none;
  }

  .opportunity-follow-up-rail .card {
    position: static;
  }

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

  .contact-activity-rail {
    width: 100%;
    max-width: none;
  }

  .contact-activity-rail .card {
    position: static;
  }
}
