/* Product shell aligned with the shadcn/ui component tokens in crm/ui. */
:root {
  --crm-radius: 0.625rem;
  --crm-background: #f8fafc;
  --crm-foreground: #18181b;
  --crm-card: #ffffff;
  --crm-card-foreground: #18181b;
  --crm-primary: #0f6f8f;
  --crm-primary-foreground: #ffffff;
  --crm-secondary: #f1f5f9;
  --crm-secondary-foreground: #334155;
  --crm-muted: #f3f4f6;
  --crm-muted-foreground: #64748b;
  --crm-accent: #e7f2f5;
  --crm-accent-foreground: #0b5d77;
  --crm-destructive: #b42318;
  --crm-border: #e2e8f0;
  --crm-border-strong: #cbd5e1;
  --crm-ring: #0f6f8f;

  --ink: var(--crm-foreground);
  --ink-strong: #0f172a;
  --ink-2: #334155;
  --paper: var(--crm-background);
  --surface: var(--crm-card);
  --surface-subtle: #f8fafc;
  --line: var(--crm-border);
  --line-strong: var(--crm-border-strong);
  --muted: var(--crm-muted-foreground);
  --blue: var(--crm-primary);
  --blue-dark: var(--crm-accent-foreground);
  --blue-soft: var(--crm-accent);
  --green: #167653;
  --amber: #8a5a0a;
  --red: var(--crm-destructive);
  --sidebar: #ffffff;
  --sidebar-raised: var(--crm-accent);
  --radius: var(--crm-radius);
  --control-radius: calc(var(--crm-radius) - 0.125rem);

  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI", sans-serif;
}

html,
body {
  background: var(--crm-background);
}

body {
  color: var(--crm-foreground);
  font-size: 14px;
  line-height: 1.45;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--crm-accent-foreground);
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 100;
  padding: 9px 12px;
  color: var(--crm-primary-foreground);
  background: var(--crm-primary);
  border-radius: var(--control-radius);
  box-shadow: 0 3px 12px rgb(15 23 42 / 18%);
  font-size: 0.76rem;
  font-weight: 650;
  text-decoration: none;
  transform: translateY(calc(-100% - 20px));
}

.skip-link:focus {
  transform: translateY(0);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgb(15 111 143 / 22%);
}

/* Application shell */
.app-sidebar {
  width: 232px;
  color: var(--crm-foreground);
  background: var(--crm-card);
  border-right: 1px solid var(--crm-border);
  box-shadow: none;
}

.sidebar-head {
  min-height: 68px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--crm-border);
}

.brand {
  gap: 7px;
  color: var(--crm-card-foreground);
  letter-spacing: 0;
  font-weight: 700;
}

.brand-mark {
  font-size: 1rem;
  letter-spacing: -0.025em;
}

.brand-product {
  padding-left: 7px;
  color: var(--crm-muted-foreground);
  border-left: 1px solid var(--crm-border-strong);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  font-weight: 650;
}

.brand-context {
  margin-top: 3px;
  color: var(--crm-muted-foreground);
  font-size: 0.67rem;
}

.sidebar-nav {
  gap: 1px;
  padding: 10px 9px 14px;
}

.sidebar-nav p {
  margin: 14px 9px 5px;
  color: #94a3b8;
  letter-spacing: 0.075em;
  font-size: 0.58rem;
  font-weight: 700;
}

.sidebar-nav p:first-child {
  margin-top: 3px;
}

.sidebar-nav a {
  min-height: 35px;
  padding: 7px 9px;
  gap: 9px;
  color: #475569;
  border: 1px solid transparent;
  border-radius: 4px;
  font-size: 0.77rem;
  font-weight: 520;
  transition: color 120ms ease, background-color 120ms ease, border-color 120ms ease;
}

.sidebar-nav a:hover {
  color: var(--crm-card-foreground);
  background: var(--crm-muted);
}

.sidebar-nav a[aria-current="page"] {
  color: var(--crm-accent-foreground);
  background: #f1f7f8;
  border-color: transparent;
  box-shadow: inset 2px 0 0 var(--crm-primary);
  font-weight: 650;
}

.nav-icon,
.control-icon {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  display: inline-grid;
  place-items: center;
}

.nav-icon svg,
.control-icon svg {
  width: 17px;
  height: 17px;
}

.sidebar-nav a[aria-current="page"] .nav-icon {
  color: var(--crm-primary);
}

.account {
  padding: 11px 13px 12px;
  gap: 8px;
  color: var(--crm-foreground);
  background: #fcfdfe;
  border-top: 1px solid var(--crm-border);
}

.account-user {
  gap: 9px;
}

.account-user strong {
  color: var(--crm-card-foreground);
  font-size: 0.76rem;
  font-weight: 600;
}

.account-user small {
  color: var(--crm-muted-foreground);
  font-size: 0.63rem;
}

.account-avatar {
  width: 30px;
  height: 30px;
  flex-basis: 30px;
  color: var(--crm-primary-foreground);
  background: var(--crm-primary);
  border: 0;
  border-radius: var(--control-radius);
  font-size: 0.68rem;
  font-weight: 700;
}

.account .link-button {
  width: 100%;
  min-height: 30px;
  padding: 5px 8px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--crm-muted-foreground);
  border-radius: var(--control-radius);
  font-size: 0.7rem;
  font-weight: 520;
}

.account .link-button:hover {
  color: var(--crm-card-foreground);
  background: var(--crm-muted);
}

.app-shell {
  margin-left: 232px;
}

.page {
  width: min(1520px, calc(100% - 48px));
  padding: 24px 0 48px;
  min-height: calc(100dvh - 54px);
}

.page-head {
  min-height: 0;
  margin-bottom: 22px;
  padding: 4px 0 18px;
  align-items: flex-end;
  gap: 32px;
  border-bottom-color: var(--crm-border);
}

.page-head > div:first-child {
  min-width: 0;
}

.page-head h1 {
  margin: 4px 0;
  color: var(--crm-card-foreground);
  font-size: clamp(1.5rem, 2vw, 1.95rem);
  line-height: 1.14;
  letter-spacing: -0.035em;
  font-weight: 680;
}

.page-head p {
  max-width: 68ch;
  color: var(--crm-muted-foreground);
  font-size: 0.78rem;
  line-height: 1.5;
}

.eyebrow {
  color: var(--crm-primary) !important;
  letter-spacing: 0.075em;
  font-size: 0.61rem;
  font-weight: 720;
}

.head-actions {
  flex-wrap: wrap;
  gap: 8px 10px;
}

.footer {
  padding: 15px 24px;
  color: #94a3b8;
  border-top-color: var(--crm-border);
  font-size: 0.63rem;
}

/* shadcn-equivalent controls for the server-rendered views */
.button {
  min-height: 36px;
  padding: 8px 14px;
  gap: 8px;
  color: var(--crm-primary-foreground);
  background: var(--crm-primary);
  border-color: var(--crm-primary);
  border-radius: var(--control-radius);
  box-shadow: 0 1px 2px rgb(15 23 42 / 4%);
  font-size: 0.77rem;
  font-weight: 580;
  transition: color 120ms ease, background-color 120ms ease, border-color 120ms ease, box-shadow 120ms ease, transform 80ms ease;
}

.button:hover {
  background: #0c617d;
  border-color: #0c617d;
  box-shadow: 0 1px 3px rgb(15 23 42 / 6%);
}

.button.secondary {
  color: var(--crm-secondary-foreground);
  background: var(--crm-card);
  border-color: var(--crm-border-strong);
  box-shadow: 0 1px 2px rgb(15 23 42 / 4%);
}

.button.secondary:hover {
  color: var(--crm-card-foreground);
  background: var(--crm-muted);
  border-color: #b8c3d1;
}

.button.danger {
  background: var(--crm-destructive);
  border-color: var(--crm-destructive);
}

.button:disabled {
  color: #94a3b8;
  background: var(--crm-muted);
  border-color: var(--crm-border);
  opacity: 0.78;
}

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

label:not([data-slot]) {
  gap: 6px;
  color: #334155;
  font-size: 0.7rem;
  font-weight: 600;
}

input:not([data-slot]),
select:not([data-slot]),
textarea:not([data-slot]) {
  min-height: 36px;
  padding: 7px 10px;
  color: var(--crm-card-foreground);
  background: var(--crm-card);
  border-color: var(--crm-border-strong);
  border-radius: var(--control-radius);
  box-shadow: 0 1px 2px rgb(15 23 42 / 3%);
  font-size: 0.78rem;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

input:not([data-slot])::placeholder,
textarea:not([data-slot])::placeholder {
  color: #94a3b8;
}

input:not([data-slot]):hover,
select:not([data-slot]):hover,
textarea:not([data-slot]):hover {
  border-color: #b8c3d1;
}

input:not([data-slot]):focus,
select:not([data-slot]):focus,
textarea:not([data-slot]):focus {
  border-color: var(--crm-ring);
  box-shadow: 0 0 0 3px rgb(15 111 143 / 16%);
}

/* Surfaces, tables and data density */
.panel {
  padding: 18px;
  background: var(--crm-card);
  border-color: var(--crm-border);
  border-radius: var(--crm-radius);
  box-shadow: 0 1px 2px rgb(15 23 42 / 4%);
}

.panel h2,
.section-head h2 {
  color: var(--crm-card-foreground);
  font-weight: 650;
}

.section-head > a {
  color: var(--crm-accent-foreground);
  font-size: 0.73rem;
  font-weight: 600;
}

.metrics {
  background: var(--crm-card);
  border-color: var(--crm-border);
  border-radius: var(--crm-radius);
  box-shadow: 0 1px 2px rgb(15 23 42 / 4%);
}

.metric {
  min-height: 90px;
  padding: 15px 16px;
  border-right-color: var(--crm-border);
}

.metric:hover {
  background: #f8fafc;
}

.metric span {
  color: var(--crm-muted-foreground);
  font-size: 0.69rem;
  font-weight: 570;
}

.metric strong {
  color: var(--crm-card-foreground);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 1.45rem;
  font-weight: 650;
}

.table-wrap {
  border-color: var(--crm-border);
}

table {
  color: var(--crm-foreground);
}

th {
  height: 39px;
  padding: 9px 12px;
  color: var(--crm-muted-foreground);
  background: #fbfcfd;
  border-top-color: var(--crm-border);
  border-bottom-color: var(--crm-border);
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.68rem;
  font-weight: 580;
}

td {
  min-height: 48px;
  padding: 11px 12px;
  background: var(--crm-card);
  border-bottom-color: #edf0f3;
  font-size: 0.76rem;
}

tbody tr:hover td {
  background: #f8fafc;
}

td small {
  color: var(--crm-muted-foreground);
  font-size: 0.66rem;
}

.strong-link {
  color: var(--crm-card-foreground);
  font-weight: 620;
}

.status {
  min-height: 22px;
  padding: 3px 8px;
  border-color: transparent;
  border-radius: 999px;
  font-size: 0.64rem;
  font-weight: 600;
}

.filters {
  margin-bottom: 14px;
  padding: 13px 14px;
  background: var(--crm-card);
  border-color: var(--crm-border);
}

.entity-filters {
  display: flex;
  flex-wrap: wrap;
}

.entity-filters > label {
  flex: 1 1 155px;
}

.entity-filters > label:first-child {
  flex: 2 1 280px;
}

.filter-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.filter-actions .button {
  margin: 0;
}

.filter-reset {
  min-height: 36px;
  padding: 7px 4px;
  display: inline-flex;
  align-items: center;
  color: var(--crm-muted-foreground);
  font-size: .72rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.filter-reset:hover {
  color: var(--crm-foreground);
  text-decoration: underline;
}

.entity-list-head {
  min-height: 44px;
  align-items: flex-end;
  margin-bottom: 14px;
}

.entity-list-head > div:first-child {
  display: grid;
  gap: 2px;
}

.entity-list-head h2 {
  margin: 0;
}

.entity-list-head p {
  margin: 0;
  color: var(--crm-muted-foreground);
  font-size: .68rem;
}

.list-tools {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 8px;
}

.compact-control {
  min-width: 128px;
  gap: 3px !important;
  color: var(--crm-muted-foreground) !important;
  font-size: .62rem !important;
  font-weight: 580 !important;
}

.compact-control select:not([data-slot]) {
  min-height: 32px;
  padding: 5px 28px 5px 9px;
  font-size: .7rem;
}

.view-switch {
  min-height: 32px;
  padding: 3px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--crm-muted);
  border: 1px solid var(--crm-border);
  border-radius: var(--control-radius);
}

.view-switch a {
  min-height: 24px;
  padding: 5px 9px;
  display: inline-flex;
  align-items: center;
  color: var(--crm-muted-foreground);
  border-radius: calc(var(--control-radius) - 3px);
  font-size: .68rem;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
}

.view-switch a[aria-current="page"] {
  color: var(--crm-card-foreground);
  background: var(--crm-card);
  box-shadow: 0 1px 2px rgb(15 23 42 / 9%);
}

.active-filter-strip {
  margin: -2px 0 14px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f8fbfc;
  border: 1px solid #d7e7ec;
  border-radius: var(--control-radius);
}

.active-filter-label {
  flex: 0 0 auto;
  color: var(--crm-muted-foreground);
  font-size: .64rem;
  font-weight: 650;
}

.active-filter-chips {
  min-width: 0;
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  gap: 5px;
}

.active-filter-chips a {
  min-width: 0;
  max-width: 320px;
  padding: 4px 7px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--crm-accent-foreground);
  background: var(--crm-card);
  border: 1px solid #cfe4ea;
  border-radius: 999px;
  font-size: .64rem;
  text-decoration: none;
}

.active-filter-chips a:hover {
  border-color: #9fc6d2;
}

.active-filter-chips strong,
.active-filter-chips span:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.active-filter-reset {
  flex: 0 0 auto;
  color: var(--crm-muted-foreground);
  font-size: .64rem;
  font-weight: 620;
  white-space: nowrap;
}

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

.entity-card {
  min-width: 0;
  padding: 15px;
  display: grid;
  gap: 13px;
  color: inherit;
  background: var(--crm-card);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius);
  text-decoration: none;
  transition: border-color .14s ease, box-shadow .14s ease;
}

.entity-card:hover {
  border-color: var(--crm-border-strong);
  box-shadow: 0 2px 7px rgb(15 23 42 / 7%);
}

.entity-card-head,
.entity-card-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.entity-card-head > div {
  min-width: 0;
}

.entity-card .eyebrow {
  margin-bottom: 4px;
}

.entity-card h3 {
  margin: 0;
  overflow: hidden;
  color: var(--crm-card-foreground);
  font-size: .84rem;
  font-weight: 650;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entity-card-subtitle {
  margin: 3px 0 0;
  overflow: hidden;
  color: var(--crm-muted-foreground);
  font-size: .69rem;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entity-card-facts {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
}

.entity-card-facts div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.entity-card-facts dt {
  color: var(--crm-muted-foreground);
  font-size: .61rem;
  font-weight: 560;
}

.entity-card-facts dd {
  margin: 0;
  overflow: hidden;
  color: var(--crm-foreground);
  font-size: .72rem;
  font-weight: 590;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entity-card-foot {
  padding-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--crm-muted-foreground);
  border-top: 1px solid var(--crm-border);
  font-size: .64rem;
}

/* Shared record workspace */
.record-nav {
  position: sticky;
  top: 0;
  z-index: 12;
  min-height: 38px;
  margin: -8px 0 14px;
  padding: 4px 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgb(248 250 252 / 94%);
  border: 1px solid var(--crm-border);
  border-radius: var(--control-radius);
  box-shadow: 0 1px 2px rgb(15 23 42 / 4%);
  backdrop-filter: blur(8px);
}

.record-nav a {
  min-height: 28px;
  padding: 5px 8px;
  display: inline-flex;
  align-items: center;
  color: var(--crm-secondary-foreground);
  border-radius: calc(var(--control-radius) - 2px);
  font-size: .68rem;
  font-weight: 620;
  text-decoration: none;
  white-space: nowrap;
}

.record-nav a:hover {
  color: var(--crm-card-foreground);
  background: var(--crm-card);
}

.record-sections a[aria-current="location"] {
  color: var(--crm-accent-foreground);
  background: var(--crm-accent);
  box-shadow: inset 0 -2px 0 var(--crm-primary);
}

.record-back {
  border-right: 1px solid var(--crm-border);
  border-radius: 0 !important;
}

.record-sections {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 1px;
  overflow-x: auto;
  scrollbar-width: none;
}

.record-sections::-webkit-scrollbar {
  display: none;
}

.record-save-state {
  margin-left: auto;
  padding: 4px 8px;
  flex: 0 0 auto;
  color: var(--crm-muted-foreground);
  font-size: .64rem;
  white-space: nowrap;
}

.record-save-state.is-dirty {
  color: #8a5a0a;
  background: #fff8e8;
  border-radius: 999px;
  font-weight: 650;
}

.numeric-value {
  font-variant-numeric: tabular-nums;
  font-weight: 680;
}

.record-identifier {
  white-space: nowrap;
}

.value-open {
  color: #8a5a0a;
}

.empty-state {
  min-height: 150px;
  padding: 34px 20px !important;
  display: grid;
  place-items: center;
  text-align: center;
}

.readonly-copy {
  white-space: pre-wrap;
}

.panel[id],
.operations-columns > [id],
.detail-grid > [id] {
  scroll-margin-top: 56px;
}

form[data-record-form] > .button:last-child {
  margin-top: 16px;
  margin-left: auto;
  display: flex;
}

form[data-record-form].is-dirty > .button:last-child {
  position: sticky;
  bottom: 12px;
  z-index: 2;
  box-shadow: 0 5px 16px rgb(15 23 42 / 14%);
}

.status-project-active,
.status-project-completed,
.status-invoice-paid,
.status-datev-transferred {
  color: #167653;
  background: #edf8f3;
  border-color: #ccebdd;
}

.status-project-planned,
.status-invoice-draft,
.status-invoice-issued,
.status-datev-ready,
.status-datev-queued {
  color: #0b5d77;
  background: #edf7fa;
  border-color: #cfe7ee;
}

.status-project-on_hold,
.status-invoice-sent,
.status-invoice-partially_paid,
.status-datev-transferring {
  color: #8a5a0a;
  background: #fff8e8;
  border-color: #eedcaf;
}

.status-project-cancelled,
.status-invoice-cancelled,
.status-datev-rejected {
  color: #5c6470;
  background: #f1f3f5;
  border-color: #dfe3e8;
}

.status-datev-failed {
  color: #991b1b;
  background: #fef2f2;
  border-color: #fecaca;
}

.list-pagination {
  margin: 18px -18px -18px;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  background: #fbfcfd;
  border-top: 1px solid var(--crm-border);
  border-radius: 0 0 var(--crm-radius) var(--crm-radius);
}

.list-pagination > p {
  margin: 0;
  color: var(--crm-muted-foreground);
  font-size: .68rem;
}

.list-pagination nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

.list-pagination nav a,
.list-pagination nav span:not(.pagination-gap) {
  min-width: 29px;
  min-height: 29px;
  padding: 6px 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--crm-muted-foreground);
  border: 1px solid transparent;
  border-radius: var(--control-radius);
  font-size: .68rem;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
}

.list-pagination nav a:hover {
  color: var(--crm-card-foreground);
  background: var(--crm-card);
  border-color: var(--crm-border);
}

.list-pagination nav a[aria-current="page"] {
  color: var(--crm-primary-foreground);
  background: var(--crm-primary);
  border-color: var(--crm-primary);
}

.list-pagination nav span[aria-disabled="true"] {
  opacity: .45;
}

.pagination-gap {
  color: var(--crm-muted-foreground);
  font-size: .7rem;
}

.list-pagination > .compact-control {
  min-width: 84px;
  justify-self: end;
}

.empty,
.muted,
.field-hint {
  color: var(--crm-muted-foreground);
}

.alert {
  color: #991b1b;
  background: #fef2f2;
  border-color: #fecaca;
  border-radius: var(--control-radius);
}

.alert.success {
  color: #166534;
  background: #f0fdf4;
  border-color: #bbf7d0;
}

/* Segmented navigation */
.settings-nav,
.scope-tabs {
  padding: 3px;
  gap: 2px;
  background: var(--crm-muted);
  border-color: var(--crm-border);
  border-radius: var(--control-radius);
}

.settings-nav a,
.scope-tabs a {
  min-height: 32px;
  color: var(--crm-muted-foreground);
  border-radius: calc(var(--control-radius) - 2px);
  font-size: 0.7rem;
  font-weight: 560;
}

.settings-nav a:hover,
.scope-tabs a:hover {
  color: var(--crm-card-foreground);
  background: rgb(255 255 255 / 56%);
}

.settings-nav a.is-active,
.scope-tabs a.is-active {
  color: var(--crm-card-foreground);
  background: var(--crm-card);
  box-shadow: 0 1px 2px rgb(15 23 42 / 8%);
}

.scope-tabs {
  border-radius: var(--control-radius);
}

.scope-tabs a {
  border-radius: calc(var(--control-radius) - 2px);
}

/* Administration */
.settings-grid {
  gap: 12px;
}

.settings-card {
  min-height: 166px;
  padding: 18px;
  background: var(--crm-card);
  border-color: var(--crm-border);
  border-radius: var(--crm-radius);
  box-shadow: 0 1px 2px rgb(15 23 42 / 4%);
  transition: border-color 120ms ease, box-shadow 120ms ease, transform 80ms ease;
}

.settings-card:hover {
  border-color: #b9d4dc;
  box-shadow: 0 4px 10px rgb(15 23 42 / 7%);
  transform: translateY(-1px);
}

.settings-card > span {
  color: var(--crm-primary);
  letter-spacing: 0.06em;
  font-size: 0.59rem;
  font-weight: 700;
}

.settings-card > strong {
  color: var(--crm-card-foreground);
  font-size: 1.02rem;
  font-weight: 650;
}

.settings-card p {
  color: var(--crm-muted-foreground);
  font-size: 0.72rem;
}

.check-row,
.permission-list,
.permission-row {
  background: #fbfcfd;
  border-color: var(--crm-border);
}

/* Sales pipeline */
.view-tabs {
  display: inline-flex;
  gap: 2px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
}

.view-tabs a,
.view-tabs span {
  min-height: 34px;
  padding: 7px 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--crm-muted-foreground);
  border: 1px solid transparent;
  border-radius: var(--control-radius);
  font-size: 0.69rem;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}

.view-tabs a:hover {
  color: var(--crm-card-foreground);
  background: var(--crm-secondary);
}

.view-tabs [aria-current="page"] {
  color: var(--crm-accent-foreground);
  background: var(--crm-accent);
  border-color: #cfe4ea;
  box-shadow: none;
}

.acquisition-tabs {
  max-width: 100%;
  margin-bottom: 12px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-color: var(--crm-border-strong) transparent;
  scrollbar-width: thin;
  scroll-snap-type: inline proximity;
}

.view-tabs.acquisition-tabs a,
.view-tabs.acquisition-tabs span {
  flex: 0 0 auto;
  scroll-snap-align: start;
}

.acquisition-tabs::-webkit-scrollbar { height: 4px; }
.acquisition-tabs::-webkit-scrollbar-track { background: transparent; }
.acquisition-tabs::-webkit-scrollbar-thumb {
  background: var(--crm-border-strong);
  border-radius: 999px;
}

.sequence-step-form {
  margin-top: 14px;
  padding-top: 16px;
  border-top: 1px solid var(--crm-border);
}

.sequence-step-readonly {
  margin-top: 12px;
  padding: 14px;
  display: grid;
  gap: 5px;
  background: var(--crm-muted);
  border: 1px solid var(--crm-border);
  border-radius: var(--control-radius);
}

.sequence-step-readonly span,
.sequence-step-readonly small {
  color: var(--crm-muted-foreground);
}

.sequence-step-readonly p {
  margin: 4px 0;
  white-space: pre-wrap;
}

.inline-action-form {
  display: flex;
  align-items: center;
  gap: 7px;
}

.inline-action-form select {
  min-width: 150px;
  min-height: 34px;
}

.inline-action-form .button {
  min-height: 34px;
  margin-top: 0;
}

.pipeline-metrics {
  margin-bottom: 12px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: transparent;
  border: 1px solid var(--crm-border);
  border-width: 1px 0;
  border-radius: 0;
}

.pipeline-metrics > div {
  min-width: 0;
  padding: 10px 14px;
  display: grid;
  gap: 3px;
  border-left: 1px solid var(--crm-border);
}

.pipeline-metrics > div:first-child { border-left: 0; }
.pipeline-metrics span { color: var(--crm-muted-foreground); font-size: 0.59rem; letter-spacing: 0.015em; }
.pipeline-metrics strong {
  color: var(--crm-card-foreground);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.25;
}

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

.pipeline-toolbar label { width: min(360px, 100%); }
.pipeline-toolbar input { min-height: 34px; }
.pipeline-toolbar p {
  max-width: 430px;
  margin: 0;
  color: var(--crm-muted-foreground);
  font-size: 0.62rem;
  line-height: 1.45;
  text-align: right;
}
.pipeline-toolbar-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.pipeline-scroll-controls {
  display: flex;
  gap: 6px;
}

.pipeline-scroll-controls button {
  min-height: 32px;
  padding: 5px 9px;
  color: var(--crm-secondary-foreground);
  background: transparent;
  border: 1px solid var(--crm-border);
  border-radius: var(--control-radius);
  font-size: 0.64rem;
  font-weight: 650;
  cursor: pointer;
}

.pipeline-scroll-controls button:hover:not(:disabled) {
  color: var(--crm-card-foreground);
  background: var(--crm-secondary);
}

.pipeline-scroll-controls button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.pipeline-live-status { color: var(--crm-primary); font-size: 0.65rem; }
.pipeline-live-status:not(:empty) { min-height: 18px; margin-bottom: 2px; }

.pipeline-board {
  padding-bottom: 24px;
  gap: 12px;
  grid-auto-columns: minmax(300px, 320px);
  align-items: stretch;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-color: var(--crm-border-strong) transparent;
  scrollbar-width: auto;
  scroll-snap-type: inline proximity;
}

.pipeline-board::-webkit-scrollbar { height: 8px; }
.pipeline-board::-webkit-scrollbar-track { background: transparent; }
.pipeline-board::-webkit-scrollbar-thumb {
  background: var(--crm-border-strong);
  border: 2px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
}

.pipeline-board:focus-visible {
  outline: 2px solid var(--crm-ring);
  outline-offset: 2px;
}

.pipeline-column {
  height: var(--pipeline-column-height, 500px);
  min-height: 0;
  padding: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: #f7f9fa;
  border-color: var(--crm-border);
  border-radius: var(--crm-radius);
  scroll-snap-align: start;
  overflow: hidden;
}

.pipeline-column > header {
  position: sticky;
  top: 0;
  z-index: 1;
  min-height: 60px;
  padding: 12px 13px 10px;
  background: #f7f9fa;
  border-bottom-color: var(--crm-border);
}

.pipeline-column header h2 {
  color: var(--crm-card-foreground);
  font-size: 0.77rem;
  font-weight: 650;
}

.pipeline-column header span {
  color: var(--crm-muted-foreground);
  font-size: 0.6rem;
}

.pipeline-column header strong,
.pipeline-card dd {
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

.pipeline-card {
  position: relative;
  padding: 14px 13px;
  gap: 8px;
  background: var(--crm-card);
  border-color: var(--crm-border);
  border-left: 2px solid var(--crm-primary);
  border-radius: var(--control-radius);
  box-shadow: none;
  cursor: grab;
}

.pipeline-card:hover,
.pipeline-card:focus-within {
  border-color: #b9d4dc;
  box-shadow: 0 2px 8px rgb(15 23 42 / 4%);
  transform: none;
}

.pipeline-card:focus-visible {
  outline: 2px solid var(--crm-ring);
  outline-offset: 2px;
}

.pipeline-card > span {
  color: var(--crm-primary);
  font-size: 0.59rem;
}

.pipeline-card > strong {
  color: var(--crm-card-foreground);
  font-size: 0.77rem;
  font-weight: 630;
}

.pipeline-stack {
  min-height: 0;
  padding: 10px 10px 20px;
  gap: 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  transition: background-color 120ms ease, box-shadow 120ms ease;
}

.pipeline-stack.is-drag-over {
  background: #e4f1f2;
  box-shadow: inset 0 0 0 2px var(--crm-primary);
}

.pipeline-card.is-dragging { opacity: 0.45; transform: scale(0.985); }
.pipeline-card.is-saving { opacity: 0.65; cursor: wait; }
.pipeline-card[hidden] { display: none; }

.pipeline-card-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.pipeline-card-head a { min-width: 0; display: grid; gap: 4px; color: inherit; text-decoration: none; }
.pipeline-card-head a > span { color: var(--crm-primary); font-size: 0.57rem; font-weight: 760; letter-spacing: 0.055em; }
.pipeline-card-head a > strong { line-height: 1.32; font-size: 0.8rem; font-weight: 660; }
.pipeline-drag-handle {
  padding: 2px 4px;
  color: var(--crm-muted-foreground);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  font-size: 0.53rem;
  opacity: 0.72;
  cursor: grab;
  transition: opacity 120ms ease, background-color 120ms ease, border-color 120ms ease;
}
.pipeline-card:hover .pipeline-drag-handle,
.pipeline-card:focus-within .pipeline-drag-handle {
  background: var(--crm-secondary);
  border-color: var(--crm-border);
  opacity: 1;
}
.pipeline-card > small { color: var(--crm-muted-foreground); font-size: 0.64rem; line-height: 1.4; }
.pipeline-card > p {
  margin: 0;
  padding: 8px 9px;
  color: var(--crm-card-foreground);
  background: #f5f8f9;
  border-left: 2px solid #cfe4ea;
  border-radius: 4px;
  font-size: 0.66rem;
  line-height: 1.45;
}

.pipeline-card-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 5px 0;
  color: var(--crm-muted-foreground);
  font-size: 0.61rem;
}

.pipeline-card-meta span + span::before {
  margin: 0 7px;
  color: var(--crm-border-strong);
  content: "\00b7";
}

.pipeline-stage-select {
  margin-top: 1px;
  padding-top: 9px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--crm-border);
  color: var(--crm-muted-foreground);
  font-size: 0.56rem;
  font-weight: 680;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.pipeline-stage-select select {
  min-height: 31px;
  padding: 4px 26px 4px 8px;
  font-size: 0.62rem;
  font-weight: 560;
  letter-spacing: 0;
  text-transform: none;
}
.pipeline-card.status-case-won { border-left-color: var(--crm-success); }

.pipeline-card dl {
  margin: 2px 0 1px;
  padding: 9px 0;
  gap: 10px;
  border-top-color: var(--crm-border);
  border-bottom: 1px solid var(--crm-border);
}

.pipeline-card dt { font-size: 0.53rem; font-weight: 680; letter-spacing: 0.055em; }
.pipeline-card dd { margin-top: 4px; color: var(--crm-card-foreground); font-size: 0.68rem; }

.pipeline-card-score { display: grid; gap: 3px; }
.pipeline-card-score > span:first-child { white-space: nowrap; }
.pipeline-card-score .progress-track { width: 100%; height: 3px; margin: 0; display: block; }

.pipeline-empty {
  min-height: 56px;
  margin: 4px 0;
  padding: 16px 12px;
  display: grid;
  place-items: center;
  color: var(--crm-muted-foreground);
  background: transparent;
  border: 0;
  line-height: 1.5;
  text-align: center;
}

.section-description { margin: 3px 0 0; color: var(--crm-muted-foreground); font-size: 0.68rem; font-weight: 400; }
/* Acquisition worklist */
.acquisition-work-count {
  padding: 4px 8px;
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  color: var(--crm-muted-foreground);
  background: var(--crm-muted);
  border: 1px solid var(--crm-border);
  border-radius: 999px;
  font-size: 0.64rem;
  white-space: nowrap;
}
.acquisition-work-count strong { color: var(--crm-card-foreground); font-size: 0.72rem; }
.acquisition-work-table table { min-width: 890px; }
.acquisition-work-table th:first-child,
.acquisition-work-table td:first-child { width: 176px; }
.acquisition-work-table th:nth-child(2),
.acquisition-work-table td:nth-child(2) { min-width: 250px; }
.acquisition-work-table th:nth-child(3),
.acquisition-work-table td:nth-child(3) { min-width: 190px; }
.acquisition-work-table th:nth-child(4),
.acquisition-work-table td:nth-child(4) { width: 210px; }
.acquisition-score { min-width: 145px; display: grid; gap: 5px; }
.acquisition-score > div:first-child { display: flex; align-items: baseline; gap: 3px; }
.acquisition-score > div:first-child strong {
  color: var(--crm-card-foreground);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.88rem;
}
.acquisition-score > div:first-child span { color: var(--crm-muted-foreground); font-size: 0.62rem; }
.acquisition-score .progress-track { width: 100%; margin: 0; }
.acquisition-score details { color: var(--crm-muted-foreground); font-size: 0.61rem; }
.acquisition-score summary { width: max-content; cursor: pointer; }
.acquisition-score details small { max-width: 260px; margin-top: 5px; line-height: 1.45; }
.acquisition-attention { display: flex; flex-wrap: wrap; gap: 4px; }
/* Quote line editor */
.quote-items { gap: 12px; }
.quote-item-card { padding: 0; background: var(--crm-card); overflow: hidden; }
.quote-position-head {
  padding: 11px 13px;
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  background: #f7f9fa;
  border-bottom: 1px solid var(--crm-border);
}
.quote-position-head > div:first-child { min-width: 0; display: grid; gap: 3px; }
.quote-position-head > div:first-child span { color: var(--crm-primary); font-size: 0.59rem; font-weight: 750; }
.quote-position-head > div:first-child strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.75rem; }
.quote-position-totals { display: flex; gap: 14px; color: var(--crm-muted-foreground); font-size: 0.61rem; white-space: nowrap; }
.quote-position-totals strong { margin-left: 3px; color: var(--crm-card-foreground); font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; }
.quote-item-form { padding: 13px; display: grid; grid-template-columns: 1fr; gap: 12px; }
.quote-item-primary { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 10px; align-items: start; }
.quote-item-values { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.quote-item-form textarea { min-height: 72px; }
.quote-item-actions { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.quote-item-actions > span { color: var(--crm-muted-foreground); font-size: 0.62rem; }
.quote-item-actions strong { color: var(--crm-card-foreground); font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; }
.delete-item { margin: 0; padding: 0 13px 10px; text-align: right; }
.add-item { padding: 12px 0 0; }
.add-item > summary { margin: 0 13px; }
.add-form { margin-top: 10px; border-top: 1px solid var(--crm-border); background: #fbfcfd; }

/* Team and personal inbox */
.inbox-page-head {
  margin-bottom: 8px;
  padding: 0 0 10px;
  align-items: center;
  gap: 20px;
}

.inbox-page-head .eyebrow {
  display: none;
}

.inbox-page-head h1 {
  margin: 0 0 2px;
  font-size: 1.4rem;
  letter-spacing: -0.03em;
}

.inbox-page-head p {
  max-width: 76ch;
  font-size: 0.72rem;
  line-height: 1.4;
}

.inbox-page-head .button {
  min-height: 32px;
  padding: 6px 11px;
}

.scope-tabs[aria-label="Inbox-Ansicht"] {
  margin-bottom: 6px;
  padding: 0;
  gap: 2px;
  background: transparent;
  border: 0;
  border-radius: 0;
}

.scope-tabs[aria-label="Inbox-Ansicht"] a {
  min-height: 34px;
  padding: 6px 13px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
}

.scope-tabs[aria-label="Inbox-Ansicht"] a:hover {
  background: var(--crm-secondary);
}

.scope-tabs[aria-label="Inbox-Ansicht"] a.is-active {
  color: var(--crm-accent-foreground);
  background: var(--crm-accent);
  border-color: #cfe4ea;
  box-shadow: none;
}

.inbox-workspace {
  height: max(650px, calc(100dvh - 162px));
  grid-template-columns: 190px minmax(280px, 330px) minmax(520px, 1fr);
  background: var(--crm-card);
  border-color: var(--crm-border);
  border-radius: var(--crm-radius);
  box-shadow: none;
}

.mail-folders {
  padding: 12px 8px;
  background: #fbfcfd;
  border-right-color: var(--crm-border);
}

.mailbox-identity {
  padding: 5px 8px 15px;
}

.mailbox-identity strong {
  color: var(--crm-card-foreground);
  font-weight: 650;
}

.mailbox-identity span,
.mail-sync-meta,
.thread-summary,
.thread-row-meta,
.thread-preview {
  color: var(--crm-muted-foreground);
}

.mail-folders nav a {
  min-height: 34px;
  padding: 7px 8px;
  color: #475569;
  border-radius: 4px;
  font-size: 0.69rem;
  font-weight: 540;
}

.mail-folders nav .team-mailbox-link { min-height: 42px; }

.mail-folders nav a:hover {
  color: var(--crm-card-foreground);
  background: var(--crm-muted);
}

.mail-folders nav a.is-active {
  color: var(--crm-accent-foreground);
  background: #f1f7f8;
  box-shadow: inset 2px 0 0 var(--crm-primary);
  font-weight: 620;
}

.mail-sync-meta {
  border-top-color: var(--crm-border);
}

.thread-column {
  border-right-color: var(--crm-border);
}

.mail-search {
  padding: 9px;
  border-bottom-color: var(--crm-border);
}

.mail-search input,
.mail-search .button { min-height: 32px; }

.thread-summary {
  min-height: 36px;
  padding: 8px 11px;
  background: #fbfcfd;
  border-bottom-color: var(--crm-border);
}

.thread-summary strong {
  color: #334155;
  font-weight: 620;
}

.thread-item {
  min-height: 86px;
  padding: 9px 11px;
  gap: 2px;
  background: var(--crm-card);
  border-bottom-color: #edf0f3;
}

.thread-item:hover {
  background: #f8fafc;
}

.thread-item.is-active {
  background: #f1f7f8;
  box-shadow: inset 2px 0 0 var(--crm-primary);
}

.thread-row-meta strong {
  color: #334155;
  font-weight: 570;
}

.thread-row-meta time {
  color: #64748b;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.thread-subject {
  color: var(--crm-card-foreground);
  font-weight: 620;
  line-height: 1.3;
}

.thread-tags em {
  color: #475569;
  background: var(--crm-muted);
  border-radius: 4px;
}

.thread-tags {
  min-height: 17px;
  align-items: center;
}

.mail-reader {
  background: var(--crm-card);
}

.mail-reader-head {
  min-height: 68px;
  padding: 10px 12px;
  border-bottom-color: var(--crm-border);
}

.mail-reader-kicker {
  overflow: hidden;
  color: var(--crm-primary);
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mail-reader-head h2 {
  display: -webkit-box;
  overflow: hidden;
  color: var(--crm-card-foreground);
  margin: 2px 0;
  font-size: 0.9rem;
  line-height: 1.28;
  font-weight: 660;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.mail-reader-head p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mail-reader-actions {
  gap: 4px;
}

.mail-reader-actions .button {
  min-height: 28px;
  padding: 4px 8px;
  font-size: 0.66rem;
}

.mail-context-bar {
  padding: 7px 10px;
  gap: 10px;
  align-items: start;
  background: #fbfcfd;
  border-bottom-color: var(--crm-border);
}

.mail-context-bar > div > span {
  color: var(--crm-muted-foreground);
  letter-spacing: 0.055em;
}

.mail-record-relation {
  border-left-color: var(--crm-border);
}

.mail-record-relation small {
  color: var(--crm-muted-foreground);
}

.mail-record-relation > a,
.mail-record-relation > strong {
  color: #334155;
  font-weight: 600;
}

.mail-context-bar select {
  width: 100%;
  min-height: 28px;
  padding-block: 3px;
  color: #334155;
  background: var(--crm-card);
  font-weight: 550;
}

.mail-context-bar .mail-context-manage {
  min-height: 28px;
  padding: 4px 8px;
  margin-top: 4px;
  font-size: 0.64rem;
}

.message-stream {
  padding: 10px 12px 16px;
  background: #f7f9fa;
}

.mail-message {
  margin-bottom: 8px;
  border-color: var(--crm-border);
  border-radius: var(--control-radius);
  box-shadow: none;
}

.mail-message.is-outbound {
  background: #fbfdfe;
  border-color: #d7e6ea;
}

.mail-message header {
  min-height: 46px;
  padding: 8px 10px;
  border-bottom-color: #edf0f3;
}

.mail-message header time {
  color: #64748b;
  font-variant-numeric: tabular-nums;
}

.mail-avatar {
  color: var(--crm-primary-foreground);
  background: var(--crm-primary);
  border-radius: var(--control-radius);
}

.mail-message-body {
  padding: 12px 11px 14px;
  color: #334155;
  font-family: inherit;
  font-size: 0.75rem;
  line-height: 1.55;
}

.reply-composer {
  padding: 8px 10px 9px;
  border-top-color: var(--crm-border);
  box-shadow: none;
}

.reply-composer .rich-text-toolbar {
  padding: 0.3rem 0.35rem;
}

.reply-composer .rich-text-content {
  min-height: 5rem;
  max-height: 11rem;
  padding: 0.65rem 0.75rem;
}

.reply-composer .rich-text-field > small {
  font-size: 0.61rem;
}

.reply-composer .file-control {
  min-width: 0;
  max-width: 320px;
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.reply-composer .file-control input {
  min-width: 0;
  min-height: 30px;
  padding: 0;
  flex: 1 1 210px;
  background: transparent;
  border: 0;
}

.reply-composer .file-control input::file-selector-button {
  min-height: 30px;
  margin-right: 8px;
  padding: 5px 9px;
  color: var(--crm-secondary-foreground);
  background: var(--crm-card);
  border: 1px solid var(--crm-border-strong);
  border-radius: calc(var(--crm-radius) - 2px);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

/* Legacy no-JS drawers retain the same visual contract as shadcn Sheet. */
.drawer-overlay {
  background: rgb(15 23 42 / 48%);
}

.drawer {
  width: min(760px, 100vw);
  background: var(--crm-card);
  border-left-color: var(--crm-border);
  box-shadow: -18px 0 46px rgb(15 23 42 / 16%);
}

.drawer-head {
  padding: 21px 24px 18px;
  background: var(--crm-card);
  border-bottom-color: var(--crm-border);
}

.drawer-head h2 {
  color: var(--crm-card-foreground);
  font-size: 1.22rem;
  font-weight: 670;
}

.drawer-close,
.sidebar-close,
.menu-button {
  min-height: 34px;
  padding: 7px 10px;
  align-items: center;
  gap: 7px;
  color: var(--crm-secondary-foreground);
  background: var(--crm-card);
  border-color: var(--crm-border-strong);
  border-radius: var(--control-radius);
  box-shadow: 0 1px 2px rgb(15 23 42 / 4%);
}

.drawer-actions {
  background: var(--crm-card);
  border-top-color: var(--crm-border);
  box-shadow: 0 -4px 12px rgb(15 23 42 / 4%);
}

/* Login and error surfaces */
.auth-body {
  background: var(--crm-background);
}

.login-form {
  background: var(--crm-card);
  border-color: var(--crm-border);
  border-radius: var(--crm-radius);
  box-shadow: 0 8px 28px rgb(15 23 42 / 8%);
}

.login-copy h1,
.error-page h1 {
  color: var(--crm-card-foreground);
}

@media (min-width: 781px) and (max-width: 1280px) {
  .inbox-workspace {
    grid-template-columns: 160px minmax(270px, 290px) minmax(0, 1fr);
  }

  .mail-context-bar {
    grid-template-columns: minmax(132px, .72fr) minmax(0, 1.28fr);
    gap: 12px;
  }

  .mail-record-context {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    row-gap: 4px;
  }

  .mail-record-relation.is-business-case {
    grid-column: auto;
    padding-left: 10px;
    border-left: 1px solid var(--crm-border);
  }

  .mail-context-manage { margin-top: 4px; }
}

@media (max-width: 780px) {
  .inbox-page-head {
    margin-bottom: 7px;
    padding-bottom: 10px;
    gap: 9px;
  }

  .inbox-page-head p {
    display: none;
  }

  .inbox-page-head .head-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .inbox-page-head .head-actions form,
  .inbox-page-head .head-actions .button {
    width: 100%;
  }

  .scope-tabs[aria-label="Inbox-Ansicht"] {
    margin-bottom: 5px;
  }

  .inbox-workspace {
    height: auto;
    min-height: 0;
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .mail-folders {
    padding: 7px;
    gap: 5px;
  }

  .team-mailbox-switcher {
    margin-bottom: 4px;
    padding-bottom: 5px;
  }

  .mail-nav-label {
    margin: 6px 6px 3px;
  }

  .mail-folders nav a {
    min-height: 30px;
    padding: 5px 8px;
  }

  .mail-folders nav .team-mailbox-link {
    min-height: 38px;
  }

  .mail-search {
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 8px;
  }

  .mail-search .button {
    width: auto;
    min-width: 72px;
  }

  .thread-column {
    max-height: 350px;
  }

  .thread-item {
    min-height: 82px;
  }

  .mail-context-bar {
    padding: 8px;
    gap: 8px;
  }

  .mail-record-context {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    row-gap: 0;
  }

  .mail-record-relation,
  .mail-record-relation:first-child {
    padding: 6px 0;
    border-left: 0;
    border-bottom: 1px solid var(--crm-border);
  }

  .mail-record-relation:nth-child(2) {
    padding-left: 10px;
    border-left: 1px solid var(--crm-border);
  }

  .mail-record-relation.is-business-case {
    grid-column: 1 / -1;
    padding-left: 0;
    border-left: 0;
  }

  .mail-context-bar .mail-context-manage {
    width: 100%;
    margin-top: 6px;
  }

  .mail-reader {
    min-height: 560px;
  }

  .message-stream {
    max-height: 480px;
  }

  .reply-composer .file-control {
    width: 100%;
    max-width: none;
  }
}

@media (max-width: 900px) {
  .app-sidebar {
    width: min(304px, 88vw);
    box-shadow: 12px 0 30px rgb(15 23 42 / 16%);
  }

  .app-shell {
    margin-left: 0;
  }

  .sidebar-close {
    display: inline-flex;
    color: var(--crm-secondary-foreground);
    background: var(--crm-card);
    border-color: var(--crm-border-strong);
  }

  .sidebar-overlay {
    background: rgb(15 23 42 / 48%);
  }

  .mobile-topbar {
    min-height: 54px;
    padding: 9px 16px;
    color: var(--crm-card-foreground);
    background: var(--crm-card);
    border-bottom-color: var(--crm-border);
  }

  .menu-button {
    display: inline-flex;
    color: var(--crm-secondary-foreground);
    background: var(--crm-card);
    border-color: var(--crm-border-strong);
  }

  .mobile-brand {
    color: var(--crm-card-foreground);
    font-weight: 650;
  }

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

  .pipeline-metrics > div:nth-child(3) {
    border-left: 0;
    border-top: 1px solid var(--crm-border);
  }

  .pipeline-metrics > div:nth-child(4) {
    border-top: 1px solid var(--crm-border);
  }

  .pipeline-toolbar {
    align-items: stretch;
    flex-direction: column;
    gap: 7px;
  }

  .pipeline-toolbar-meta {
    width: 100%;
    justify-content: space-between;
  }

  .quote-item-values {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .page {
    width: calc(100% - 24px);
    padding-top: 18px;
  }

  .page-head {
    padding-bottom: 15px;
    gap: 12px;
  }

  .panel {
    padding: 14px;
  }

  .drawer {
    width: 100%;
  }

  .entity-filters {
    display: grid;
    grid-template-columns: 1fr;
  }

  .filter-actions {
    margin-left: 0;
  }

  .entity-list-head,
  .list-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .active-filter-strip {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .active-filter-chips {
    flex-basis: calc(100% - 90px);
  }

  .record-nav {
    margin-top: -4px;
  }

  .record-back {
    flex: 0 0 auto;
  }

  .record-sections {
    padding-bottom: 3px;
    scrollbar-width: thin;
    scrollbar-color: var(--crm-border-strong) transparent;
  }

  .record-sections::-webkit-scrollbar {
    height: 3px;
    display: block;
  }

  .record-sections::-webkit-scrollbar-thumb {
    background: var(--crm-border-strong);
    border-radius: 999px;
  }

  .record-sections a {
    flex: 0 0 auto;
  }

  .record-save-state {
    display: none;
  }

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

  .list-pagination {
    margin-right: -14px;
    margin-left: -14px;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .list-pagination nav {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: flex-start;
    overflow-x: auto;
  }

  .list-pagination > .compact-control {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
  }

  form[data-record-form] > .button:last-child,
  form[data-record-form].is-dirty > .button:last-child {
    position: static;
    width: 100%;
    margin-top: 16px;
    box-shadow: none;
  }

  .page-head .head-actions {
    align-items: stretch;
  }

  .view-tabs {
    width: 100%;
  }

  .view-tabs a,
  .view-tabs span {
    flex: 1;
    text-align: center;
  }

  .pipeline-board {
    margin-right: -12px;
    grid-auto-columns: minmax(270px, 88vw);
  }

  .pipeline-metrics > div {
    padding: 9px 10px;
  }

  .pipeline-metrics strong {
    font-size: 0.8rem;
  }

  .pipeline-toolbar p {
    margin: 0;
    text-align: left;
  }

  .pipeline-scroll-controls { flex: 0 0 auto; }

  .quote-position-head,
  .quote-item-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .quote-position-totals {
    justify-content: space-between;
  }

  .quote-item-primary,
  .quote-item-values {
    grid-template-columns: 1fr;
  }

  .quote-item-actions .button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-sidebar,
  .drawer,
  .button,
  .pipeline-card,
  .settings-card {
    transition-duration: 0.01ms !important;
  }
}
