:root {
  color-scheme: light;
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-soft: #eef2f8;
  --surface-muted: #f7f8fb;
  --sidebar-bg: #ffffff;
  --rail: #0758df;
  --rail-deep: #073ba4;
  --text: #20242c;
  --muted: #8a909b;
  --line: #e2e6ee;
  --brand: #0758df;
  --brand-strong: #0644b4;
  --brand-soft: #c2d4ff;
  --green: #209e63;
  --amber: #e37f32;
  --red: #d94848;
  --ink: #17202d;
  --shadow: 0 18px 42px rgba(29, 42, 63, 0.08);
  --shadow-soft: 0 1px 2px rgba(29, 42, 63, 0.08);
}

:root.dark {
  color-scheme: dark;
  --bg: #14161b;
  --surface: #1b1d23;
  --surface-soft: #232733;
  --surface-muted: #17191f;
  --sidebar-bg: #181a20;
  --rail: #0758df;
  --rail-deep: #073ba4;
  --text: #f0f2f8;
  --muted: #858b99;
  --line: #2b3039;
  --brand: #2f66ff;
  --brand-strong: #9bb4ff;
  --brand-soft: #263a72;
  --green: #2bbf75;
  --amber: #f39b4b;
  --red: #ff6b6b;
  --ink: #f0f2f8;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
  --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  font-family:
    Manrope, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

body.auth-locked {
  background: #f6f8fc;
}

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

body.auth-ready .auth-shell,
body.auth-public .auth-shell {
  display: none;
}

body.auth-public .app-shell {
  display: block;
}

body.auth-public .icon-rail,
body.auth-public .sidebar,
body.auth-public .topbar {
  display: none;
}

.platform-admin-only {
  display: none !important;
}

.platform-admin-session-only {
  display: none !important;
}

body.platform-admin-session .platform-admin-session-only {
  display: inline-flex !important;
}

body.platform-admin .platform-admin-only {
  display: grid !important;
}

body.platform-admin .nav-group.platform-admin-only {
  display: block !important;
}

body.platform-admin .rail-nav .rail-item:not(.platform-admin-only),
body.platform-admin .rail-bottom,
body.platform-admin .nav-list > .nav-group:not(.platform-admin-only) {
  display: none !important;
}

body.platform-admin .brand,
body.platform-admin .rail-logo {
  cursor: default;
}

body.platform-admin .admin-top-actions {
  display: none !important;
}

body.platform-admin .topbar.admin-context .admin-top-actions {
  display: flex !important;
}

body.platform-admin .topbar.admin-context .quick-actions {
  display: none;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-shell {
  display: grid;
  grid-template-columns: 76px 312px minmax(0, 1fr);
  width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
  transition: grid-template-columns 180ms ease;
}

.auth-shell {
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(7, 88, 223, 0.06) 1px, transparent 1px),
    linear-gradient(180deg, rgba(7, 88, 223, 0.05) 1px, transparent 1px),
    #f6f8fc;
  background-size: 56px 56px;
  color: var(--text);
}

.auth-topbar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(520px, calc(100% - 48px));
  margin: 0 auto;
  padding: 96px 0 0;
}

.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 20px;
  color: var(--brand-strong);
  text-decoration: none;
}

.auth-brand img {
  width: 104px;
  height: auto;
  filter: hue-rotate(181deg) saturate(1.7) brightness(0.95);
}

.auth-brand span {
  color: var(--brand-strong);
  font-size: 62px;
  font-weight: 800;
  letter-spacing: 0;
}

.auth-main {
  display: grid;
  place-items: center;
  width: min(520px, calc(100% - 48px));
  min-height: auto;
  margin: 0 auto;
  padding: 58px 0 72px;
}

.auth-card {
  width: 100%;
  border: 1px solid #dfe5ef;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 24px 60px rgba(29, 42, 63, 0.12);
  padding: 34px;
}

.auth-panel {
  display: grid;
  gap: 18px;
}

.auth-panel h2 {
  margin: 0;
  color: var(--ink);
  font-size: 32px;
  letter-spacing: 0;
}

.auth-verification-note {
  margin: -8px 0 0;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.5;
}

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

.auth-panel label {
  display: grid;
  gap: 8px;
  color: #525b69;
  font-weight: 800;
}

.auth-panel input {
  width: 100%;
  min-height: 54px;
  border: 1px solid #dfe5ef;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 0 14px;
  font-weight: 800;
}

.auth-panel input:focus {
  border-color: var(--brand);
  outline: 3px solid rgba(7, 88, 223, 0.14);
}

.auth-panel .primary-action {
  justify-content: center;
  min-height: 54px;
  margin-top: 4px;
}

.text-action {
  justify-self: start;
  border: 0;
  background: transparent;
  color: var(--brand-strong);
  padding: 0;
  font-weight: 800;
}

.auth-status {
  min-height: 24px;
  margin: 18px 0 0;
  color: var(--muted);
  font-weight: 800;
}

.auth-status.is-error {
  color: var(--red);
}

.auth-status.is-success {
  color: var(--green);
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  padding: 6px 8px 6px 6px;
  box-shadow: var(--shadow-soft);
}

.user-chip span {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 5px;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-size: 13px;
  font-weight: 900;
}

.user-chip strong {
  max-width: 160px;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-chip button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.user-chip button:hover {
  color: var(--brand-strong);
}

.admin-top-actions {
  align-items: center;
  gap: 8px;
}

.platform-surface-switch {
  text-decoration: none;
}

.admin-filterbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  margin: 0 0 16px;
  padding: 8px;
  box-shadow: var(--shadow-soft);
}

.admin-filterbar button {
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  padding: 0 12px;
  font-weight: 900;
}

.admin-filterbar button.active,
.admin-filterbar button:hover {
  border-color: color-mix(in srgb, var(--brand) 38%, var(--line));
  background: var(--brand-soft);
  color: var(--brand-strong);
}

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

.admin-metric-card {
  display: grid;
  gap: 8px;
  min-height: 126px;
  align-content: center;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 20px;
  box-shadow: var(--shadow-soft);
}

.admin-metric-card span,
.admin-health-item small {
  color: var(--muted);
  font-weight: 800;
}

.admin-metric-card strong {
  color: var(--ink);
  font-size: 32px;
  line-height: 1.05;
}

.admin-metric-card small {
  color: var(--brand-strong);
  font-weight: 900;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
}

.admin-side-panel {
  align-self: start;
}

.admin-health-list {
  display: grid;
  gap: 12px;
}

.admin-health-item {
  display: grid;
  gap: 6px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.admin-health-item:first-child {
  border-top: 0;
  padding-top: 0;
}

.admin-health-item strong {
  color: var(--text);
  font-size: 18px;
}

.admin-empty-row {
  height: 120px;
  color: var(--muted);
  text-align: center;
  font-weight: 900;
}

.admin-status {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  min-height: 30px;
  border-radius: 5px;
  padding: 0 10px;
  background: #edf2fa;
  color: #5f6b7a;
  font-size: 13px;
  font-weight: 900;
}

.admin-status.active {
  background: color-mix(in srgb, var(--green) 14%, #fff);
  color: var(--green);
}

.admin-status.platform {
  background: color-mix(in srgb, var(--brand) 18%, #fff);
  color: var(--brand-strong);
}

.admin-status.owner {
  background: color-mix(in srgb, #111827 9%, #fff);
  color: var(--ink);
}

.admin-status.trial {
  background: color-mix(in srgb, var(--brand) 14%, #fff);
  color: var(--brand-strong);
}

.admin-status.past_due {
  background: color-mix(in srgb, var(--amber) 16%, #fff);
  color: #a05b13;
}

.admin-status.suspended {
  background: color-mix(in srgb, var(--red) 12%, #fff);
  color: var(--red);
}

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

.icon-rail {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  height: 100vh;
  flex-direction: column;
  align-items: center;
  background: linear-gradient(180deg, var(--rail), #0b55df);
  padding: 14px 10px 18px;
  color: #fff;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.18);
}

.rail-logo {
  display: grid;
  width: 48px;
  height: 54px;
  place-items: center;
  margin-bottom: 22px;
}

.rail-logo img {
  width: 34px;
  height: auto;
  filter: brightness(0) invert(1);
}

.rail-nav,
.rail-bottom {
  display: grid;
  gap: 13px;
}

.rail-bottom {
  margin-top: auto;
}

.rail-item {
  position: relative;
  display: grid;
  width: 50px;
  height: 50px;
  place-items: center;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: rgba(255, 255, 255, 0.92);
}

.rail-item svg {
  width: 25px;
  height: 25px;
  stroke-width: 1.9;
}

.rail-item:hover,
.rail-item.active {
  background: rgba(0, 31, 112, 0.38);
  color: #fff;
}

.rail-notification-button {
  background: rgba(255, 255, 255, 0.16);
}

.rail-notification-button .notification-count {
  top: -4px;
  right: -4px;
  border-color: #0b55df;
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  height: 100vh;
  min-height: 0;
  min-width: 0;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--sidebar-bg);
  padding: 22px 18px 20px;
  overflow: hidden;
  transition:
    border-color 180ms ease,
    opacity 160ms ease,
    padding 180ms ease;
}

.sidebar-toggle {
  position: absolute;
  top: 28px;
  right: -17px;
  z-index: 6;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--brand-strong);
  box-shadow: var(--shadow-soft);
}

.sidebar-toggle svg {
  width: 18px;
  height: 18px;
  transition: transform 180ms ease;
}

.sidebar-toggle:hover {
  border-color: color-mix(in srgb, var(--brand) 42%, var(--line));
}

.app-shell.dashboard-sidebar-locked .sidebar-toggle {
  display: none;
  pointer-events: none;
}

.app-shell.sidebar-collapsed .sidebar {
  width: 0;
  border-color: transparent;
  overflow: visible;
  padding-right: 0;
  padding-left: 0;
}

.app-shell.sidebar-collapsed .sidebar > *:not(.sidebar-toggle) {
  opacity: 0;
  pointer-events: none;
}

.app-shell.sidebar-collapsed .sidebar-toggle {
  right: -14px;
}

.app-shell.sidebar-collapsed .sidebar-toggle svg {
  transform: rotate(180deg);
}

.brand {
  position: relative;
  z-index: 1;
  display: block;
  color: var(--text);
  border-bottom: 0;
  padding: 0 0 18px;
  text-decoration: none;
}

.brand-mark {
  display: none;
}

.brand-mark img {
  display: block;
  width: 42px;
  height: auto;
  filter: drop-shadow(0 6px 8px rgba(7, 80, 88, 0.12));
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1;
  text-transform: uppercase;
}

.brand small {
  display: none;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.78rem;
}

.nav-list {
  position: relative;
  z-index: 1;
  display: grid;
  align-content: start;
  gap: 10px;
  margin-top: 0;
  min-height: 0;
  overflow-y: auto;
  padding-right: 8px;
  scrollbar-gutter: stable;
  max-width: 100%;
}

.nav-list > .nav-item {
  display: none;
}

.nav-list > .nav-item.active {
  display: flex;
}

.nav-list::-webkit-scrollbar,
.nav-submenu::-webkit-scrollbar {
  width: 8px;
}

.nav-list::-webkit-scrollbar-thumb,
.nav-submenu::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 26%, transparent);
}

.nav-group {
  display: none;
  gap: 7px;
  position: relative;
}

.nav-group.open,
.nav-group:has(.nav-item.active) {
  display: grid;
}

.nav-item {
  display: flex;
  min-height: 40px;
  align-items: center;
  gap: 11px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  padding: 0 6px;
  text-align: left;
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
  transition:
    background 140ms ease,
    color 140ms ease;
}

.nav-parent {
  width: 100%;
}

.nav-parent .chevron {
  display: none;
}

.chevron {
  margin-left: auto;
  transition: transform 160ms ease;
}

.nav-group.open .chevron {
  transform: rotate(180deg);
}

.nav-submenu {
  display: none;
  gap: 7px;
  max-height: none;
  overflow: visible;
  margin: 0;
  border-left: 0;
  padding-left: 0;
}

.nav-group.open .nav-submenu {
  display: grid;
}

.nav-group:has(.nav-item.active) .nav-submenu {
  display: grid;
}

.nav-subheading {
  margin: 12px 0 5px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.document-menu {
  gap: 10px;
}

.document-nav-section {
  display: grid;
  gap: 6px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.document-nav-section:first-child {
  border-top: 0;
  padding-top: 0;
}

.document-nav-section .nav-subheading {
  margin: 0;
}

.document-nav-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 7px;
}

.nav-subitem,
.document-subitem {
  display: flex;
  min-height: 40px;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text);
  padding: 0 12px;
  text-align: left;
  font-size: 1rem;
  font-weight: 700;
}

.document-menu .nav-subitem {
  min-height: 34px;
  border: 1px solid transparent;
  background: transparent;
  padding: 0 8px;
  font-size: 0.88rem;
  font-weight: 800;
}

.document-menu .nav-subitem.is-wide {
  width: 100%;
}

.document-menu .nav-subitem.active,
.document-menu .nav-subitem:hover {
  border-color: color-mix(in srgb, var(--brand) 45%, var(--line));
  background: color-mix(in srgb, var(--brand) 14%, var(--surface));
}

.nav-subitem::before,
.document-subitem::before {
  display: none;
}

.document-group-toggle::after {
  content: "";
  width: 7px;
  height: 7px;
  margin-left: auto;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.16s ease;
}

.document-nav-section.open .document-group-toggle::after {
  transform: rotate(225deg);
}

.document-nav-children {
  display: none;
  gap: 5px;
  margin-left: 8px;
  padding-left: 10px;
  border-left: 1px solid var(--line);
}

.document-nav-section.open .document-nav-children {
  display: grid;
}

.document-nav-children .nav-subitem {
  min-height: 31px;
  padding-left: 9px;
  font-size: 0.84rem;
  font-weight: 750;
}

.nav-subicon {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  color: color-mix(in srgb, var(--brand) 58%, var(--muted));
  stroke-width: 1.9;
}

.nav-subitem.active .nav-subicon,
.nav-subitem:hover .nav-subicon,
.document-subitem.active .nav-subicon,
.document-subitem:hover .nav-subicon {
  color: currentColor;
}

.nav-subitem.active,
.nav-subitem:hover,
.document-subitem.active,
.document-subitem:hover {
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.nav-item svg,
.icon-button svg,
.primary-action svg,
.ghost-action svg,
.search svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

.nav-item.active,
.nav-item:hover {
  background: transparent;
  color: var(--brand-strong);
}

.nav-item.active {
  box-shadow: none;
  font-weight: 750;
}

.main {
  min-width: 0;
  background: var(--bg);
  padding: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  margin-bottom: 0;
  min-height: 72px;
  padding: 0 24px;
}

.topbar-title {
  display: none;
}

.topbar h1,
.panel h2,
.invoice-dialog h2 {
  margin: 0;
}

.topbar h1 {
  font-size: 1.08rem;
  line-height: 1.2;
}

.eyebrow {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  min-width: min(100%, 680px);
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-left: auto;
}

.topbar.admin-context .topbar-actions {
  min-width: min(100%, 900px);
}

.topbar.admin-context .search {
  min-width: 320px;
}

.search {
  display: flex;
  min-width: 280px;
  height: 44px;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
  padding: 0 12px;
  box-shadow: var(--shadow-soft);
}

.search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.icon-button,
.primary-action,
.ghost-action {
  display: inline-flex;
  height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 4px;
  white-space: normal;
  transition:
    border-color 140ms ease,
    background 140ms ease,
    color 140ms ease,
    transform 140ms ease;
}

.quick-actions {
  position: relative;
  display: inline-flex;
}

.notification-center {
  position: relative;
  display: inline-flex;
}

body.platform-admin .notification-center,
body.auth-public .notification-center {
  display: none;
}

.notification-button {
  position: relative;
  border-color: color-mix(in srgb, var(--brand) 18%, var(--line));
  background: color-mix(in srgb, var(--brand) 7%, var(--surface));
  color: var(--brand-strong);
}

.notification-button svg {
  width: 19px;
  height: 19px;
}

.notification-count {
  position: absolute;
  top: -7px;
  right: -7px;
  display: inline-grid;
  min-width: 20px;
  height: 20px;
  place-items: center;
  border: 2px solid var(--surface);
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1;
  padding: 0 5px;
}

.notification-count.hidden {
  display: none;
}

.notification-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 50;
  display: none;
  width: min(420px, calc(100vw - 24px));
  max-height: min(640px, calc(100vh - 96px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

.notification-panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 14px;
}

.notification-panel-heading strong {
  display: block;
  margin-top: 2px;
}

.notification-filters {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  padding: 10px 14px;
}

.notification-filters button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-muted);
  color: var(--muted);
  padding: 0 10px;
  font-weight: 800;
}

.notification-filters button.active {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.notification-list {
  display: grid;
  gap: 8px;
  overflow: auto;
  padding: 10px;
}

.notification-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  padding: 8px;
}

.notification-item.is-read {
  opacity: 0.68;
}

.notification-main {
  display: grid;
  gap: 4px;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0;
  text-align: left;
}

.notification-main span,
.notification-main small {
  overflow-wrap: anywhere;
}

.notification-main small {
  color: var(--muted);
}

.notification-read-button {
  align-self: start;
  width: 34px;
  height: 34px;
}

.notification-empty {
  display: grid;
  gap: 4px;
  border-radius: 8px;
  background: var(--surface-muted);
  color: var(--muted);
  padding: 14px;
}

.notification-empty strong {
  color: var(--text);
}

.quick-actions .primary-action .chevron {
  width: 16px;
  height: 16px;
  margin-left: 2px;
}

.quick-action-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 30;
  display: none;
  width: 260px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 6px;
}

.quick-actions.open .quick-action-menu {
  display: grid;
  gap: 2px;
}

.quick-actions.open .primary-action .chevron {
  transform: rotate(180deg);
}

.quick-action-item {
  display: grid;
  gap: 3px;
  min-height: 52px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  padding: 8px 10px;
  text-align: left;
}

.quick-action-item:hover {
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.quick-action-item span {
  font-weight: 800;
}

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

.icon-button:hover,
.primary-action:hover,
.ghost-action:hover,
.row-action:hover {
  transform: translateY(-1px);
}

.icon-button {
  width: 42px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-soft);
}

.primary-action {
  border: 0;
  background: var(--brand);
  color: #fff;
  padding: 0 16px;
  font-weight: 700;
  box-shadow: var(--shadow-soft);
}

.primary-action:hover {
  background: var(--brand-strong);
}

.ghost-action {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  padding: 0 14px;
}

.ghost-action:hover,
.row-action:hover {
  border-color: color-mix(in srgb, var(--brand) 38%, var(--line));
  color: var(--brand-strong);
}

.danger-action {
  margin-right: auto;
  border-color: color-mix(in srgb, var(--red) 34%, var(--line));
  color: var(--red);
}

.danger-action:hover {
  border-color: color-mix(in srgb, var(--red) 58%, var(--line));
  background: color-mix(in srgb, var(--red) 8%, var(--surface));
  color: var(--red);
}

.view {
  display: none;
  padding: 24px;
}

.view.active {
  display: block;
}

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

.metric-card,
.panel,
.customer-card {
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.metric-card {
  min-height: 118px;
  border-top: 0;
  border-left: 4px solid var(--brand);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--brand) 4%, transparent), transparent 42%),
    var(--surface);
  padding: 16px;
}

.metric-card:nth-child(2) {
  border-top-color: #b7801d;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--amber) 5%, transparent), transparent 42%),
    var(--surface);
}

.metric-card:nth-child(3) {
  border-top-color: #168264;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--green) 4%, transparent), transparent 42%),
    var(--surface);
}

.metric-card:nth-child(4) {
  border-top-color: #a83d4a;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--red) 4%, transparent), transparent 42%),
    var(--surface);
}

.metric-card span {
  color: var(--muted);
  font-size: 0.92rem;
}

.metric-card strong {
  display: block;
  margin: 8px 0;
  font-size: 1.58rem;
  letter-spacing: 0;
}

.trend {
  font-weight: 700;
}

.positive {
  color: var(--green);
}

.warning {
  color: var(--amber);
}

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

.neutral {
  color: var(--muted);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(320px, 0.9fr);
  gap: 14px;
}

.subscription-guard {
  margin: 14px 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  box-shadow: var(--shadow-soft);
}

.subscription-guard.is-warning {
  border-color: rgba(245, 158, 11, 0.35);
  background: #fffbeb;
}

.subscription-guard.is-locked {
  border-color: rgba(239, 68, 68, 0.28);
  background: #fff7f7;
}

.subscription-guard strong {
  color: var(--ink);
}

.subscription-guard span {
  color: var(--muted);
  font-weight: 750;
}

body.subscription-restricted .quick-action-menu,
body.subscription-restricted #quickActionButton {
  opacity: 0.62;
}

.panel {
  min-width: 0;
  padding: 16px;
}

.panel.wide {
  min-height: 300px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  border-left: 5px solid var(--brand);
  margin: -2px 0 14px;
  padding: 0 0 12px 18px;
}

.panel-heading-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.compact-action {
  min-height: 36px;
  padding: 0 13px;
  white-space: nowrap;
}

.panel h2 {
  margin-top: 4px;
  font-size: 1.04rem;
  line-height: 1.25;
}

.panel-subtitle {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.segmented,
.status-tabs {
  display: inline-flex;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-muted);
  overflow: hidden;
}

.status-tabs {
  flex-wrap: wrap;
  overflow: visible;
}

.segmented button,
.status-tabs button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0 11px;
}

.segmented button.active,
.status-tabs button.active {
  background: var(--ink);
  color: #fff;
}

.cash-chart {
  display: grid;
  grid-template-columns: repeat(8, minmax(34px, 1fr));
  align-items: end;
  gap: 12px;
  height: 218px;
  border-bottom: 1px solid var(--line);
  padding-top: 16px;
}

.chart-bar {
  display: flex;
  min-height: 34px;
  flex-direction: column;
  justify-content: flex-end;
  gap: 8px;
}

.bar-track {
  position: relative;
  min-height: 36px;
  border-radius: 8px 8px 0 0;
  background: color-mix(in srgb, var(--brand) 10%, transparent);
  overflow: hidden;
}

.bar-value {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  border-radius: 8px 8px 0 0;
  background: linear-gradient(180deg, var(--green), var(--brand));
}

.chart-bar small {
  min-height: 18px;
  color: var(--muted);
  text-align: center;
}

.task-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.task-list li,
.queue-item,
.timeline-item,
.inventory-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  padding: 11px 12px;
}

.inventory-actions {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

.task-list strong,
.queue-item strong,
.timeline-item strong,
.inventory-item strong {
  display: block;
}

.task-list small,
.queue-item small,
.timeline-item small,
.inventory-item small,
.customer-card small {
  color: var(--muted);
}

.badge,
.status-pill {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  border-radius: 6px;
  padding: 0 10px;
  font-size: 0.78rem;
  font-weight: 800;
}

.badge.green,
.status-paid {
  background: color-mix(in srgb, var(--green) 16%, transparent);
  color: var(--green);
}

.badge.amber,
.status-due {
  background: color-mix(in srgb, var(--amber) 16%, transparent);
  color: var(--amber);
}

.badge.red,
.status-waiting {
  background: color-mix(in srgb, var(--red) 14%, transparent);
  color: var(--red);
}

.badge.neutral {
  background: var(--surface-soft);
  color: var(--muted);
}

.status-overdue {
  background: color-mix(in srgb, var(--red) 18%, transparent);
  color: var(--red);
}

.status-partial {
  background: color-mix(in srgb, var(--brand) 14%, transparent);
  color: var(--brand-strong);
}

.table-wrap {
  border: 1px solid var(--line);
  border-radius: 3px;
  overflow: auto;
}

#invoicesView.quote-list-clean table th:nth-child(6),
#invoicesView.quote-list-clean table td:nth-child(6) {
  display: none;
}

.invoice-flow-guide {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  margin: 16px 0;
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: 4px;
  background: var(--surface-muted);
  padding: 14px 16px;
}

.invoice-flow-guide strong,
.invoice-flow-guide small {
  display: block;
}

.invoice-flow-guide small {
  color: var(--muted);
  font-weight: 700;
  line-height: 1.45;
}

.invoice-flow-counts {
  display: grid;
  grid-template-columns: repeat(4, minmax(58px, 1fr));
  gap: 8px;
}

.invoice-flow-counts span {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  padding: 8px 10px;
}

.invoice-flow-counts small,
.invoice-flow-counts strong {
  display: block;
}

.invoice-flow-counts small {
  color: var(--muted);
  font-size: 0.72rem;
}

.invoice-flow-counts strong {
  font-size: 1.08rem;
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  background: var(--surface);
}

#invoicesView table {
  min-width: 1120px;
}

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

th {
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
}

tbody tr:hover {
  background: color-mix(in srgb, var(--brand) 5%, transparent);
}

.transaction-row td:first-child {
  border-left: 4px solid transparent;
}

.transaction-income td:first-child,
.timeline-item.transaction-income {
  border-left-color: var(--green);
}

.transaction-expense td:first-child,
.timeline-item.transaction-expense {
  border-left-color: var(--red);
}

.transaction-stock td:first-child {
  border-left-color: var(--brand);
}

.transaction-income .transaction-amount {
  color: var(--green);
  font-weight: 800;
}

.transaction-expense .transaction-amount {
  color: var(--red);
  font-weight: 800;
}

.transaction-stock .transaction-amount {
  color: var(--brand-strong);
  font-weight: 800;
}

.installment-progress-row td {
  background-color: color-mix(in srgb, #d6dde0 var(--installment-progress), var(--surface));
}

.installment-progress-row:hover td {
  background-color: color-mix(in srgb, #cbd5d8 var(--installment-progress), color-mix(in srgb, var(--brand) 5%, var(--surface)));
}

tr:last-child td {
  border-bottom: 0;
}

.align-right {
  text-align: right;
}

.row-action {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  padding: 0 10px;
}

.row-action:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.primary-row-action {
  border-color: color-mix(in srgb, var(--brand) 40%, var(--line));
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-weight: 800;
}

.delete-row-action {
  border-color: color-mix(in srgb, var(--red) 34%, var(--line));
  color: var(--red);
}

.delete-row-action:hover {
  border-color: color-mix(in srgb, var(--red) 58%, var(--line));
  background: color-mix(in srgb, var(--red) 8%, var(--surface));
  color: var(--red);
}

.action-cell {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.queue,
.timeline,
.inventory-list,
.module-grid {
  display: grid;
  gap: 10px;
}

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

.module-card {
  display: grid;
  min-height: 124px;
  align-content: start;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface-muted);
  padding: 14px;
}

.module-card:hover {
  border-color: color-mix(in srgb, var(--brand) 42%, var(--line));
  background: color-mix(in srgb, var(--brand) 4%, var(--surface));
}

.module-card strong {
  display: block;
}

.module-card small {
  color: var(--muted);
  line-height: 1.45;
}

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

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
  padding-bottom: 14px;
}

.section-heading h2 {
  margin: 4px 0 0;
  font-size: 1.18rem;
}

.section-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.customer-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto minmax(150px, 190px) minmax(150px, 190px);
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}

.customer-search-field {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  padding: 0 12px;
}

.customer-search-field svg {
  width: 19px;
  height: 19px;
  stroke: var(--muted);
}

.customer-search-field input {
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 700;
}

.customer-search-field input::placeholder {
  color: var(--muted);
  font-weight: 700;
}

.customer-toolbar select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
  font: inherit;
  font-weight: 800;
}

.customer-role-filter,
.view-segment {
  min-height: 42px;
}

.customer-card {
  padding: 16px;
}

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

.customer-card-identity {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.customer-card-identity > div:last-child {
  min-width: 0;
}

.customer-card-logo {
  display: grid;
  flex: 0 0 56px;
  width: 56px;
  height: 56px;
  place-items: center;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--brand) 30%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--brand) 12%, var(--surface));
  color: var(--brand-strong);
  font-size: 0.9rem;
  font-weight: 900;
}

.customer-card-logo.has-logo {
  border-color: var(--line);
  background: var(--surface);
}

.customer-card-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 6px;
}

.customer-list-wrap table {
  min-width: 1180px;
}

.customer-table-identity {
  display: flex;
  min-width: 230px;
  align-items: center;
  gap: 10px;
}

.customer-table-identity span {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.customer-table-identity strong,
.customer-table-identity small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.customer-list-logo {
  flex-basis: 42px;
  width: 42px;
  height: 42px;
  font-size: 0.72rem;
}

.customer-table-chip {
  margin-top: 0;
  white-space: nowrap;
}

.table-row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  white-space: nowrap;
}

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

.customer-empty-state {
  grid-column: 1 / -1;
  border: 1px dashed var(--line);
  border-radius: 4px;
  background: var(--surface);
  padding: 34px;
}

.customer-empty-state strong,
.customer-empty-state small,
.empty-table-cell strong,
.empty-table-cell small {
  display: block;
}

.customer-empty-state strong,
.empty-table-cell strong {
  color: var(--text);
}

.customer-card h2 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.customer-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.customer-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.customer-contact {
  display: grid;
  gap: 4px;
  margin-top: 14px;
}

.role-chip {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  margin-top: 12px;
  border-radius: 6px;
  background: var(--brand-soft);
  color: var(--brand-strong);
  padding: 0 10px;
  font-size: 0.76rem;
  font-weight: 800;
}

.muted-chip {
  background: var(--surface-muted);
  color: var(--muted);
}

.customer-stats div {
  border-radius: 8px;
  background: var(--surface-muted);
  padding: 12px;
}

.customer-stats strong {
  display: block;
  margin-top: 4px;
}

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

.customer-logo-field {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  padding: 10px;
}

.customer-logo-preview {
  display: grid;
  overflow: hidden;
  width: 74px;
  height: 74px;
  place-items: center;
  border: 1px dashed color-mix(in srgb, var(--brand) 36%, var(--line));
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.customer-logo-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 6px;
}

.customer-logo-controls {
  display: grid;
  gap: 8px;
}

.customer-logo-controls > span {
  color: var(--text);
  font-weight: 900;
}

.customer-logo-controls > div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

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

.settings-section-panel {
  display: none;
  grid-column: 1 / -1;
}

.settings-section-panel.active {
  display: block;
}

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

.integration-status-card {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
  box-shadow: var(--shadow-soft);
}

.integration-status-card span,
.integration-note span {
  color: var(--muted);
}

.integration-status-card strong {
  font-size: 1.25rem;
}

.integration-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 14px;
  margin-bottom: 14px;
}

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

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

.integration-note {
  display: grid;
  gap: 4px;
  margin-top: 14px;
  border-radius: 8px;
  background: var(--surface-muted);
  padding: 12px;
}

.integration-flow {
  display: grid;
  gap: 10px;
}

.integration-flow span {
  position: relative;
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  padding: 12px;
  color: var(--text);
  font-weight: 800;
}

.integration-flow small {
  color: var(--brand-strong);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.72rem;
}

.method-code {
  border-radius: 6px;
  background: var(--surface-muted);
  color: var(--brand-strong);
  padding: 4px 6px;
  font-size: 0.75rem;
}

.sync-action {
  width: 100%;
  margin-top: 14px;
  justify-content: center;
}

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

.company-profile-panel {
  grid-column: 1 / -1;
}

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

.company-logo-field {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  padding: 14px;
}

.company-logo-preview {
  display: grid;
  place-items: center;
  width: 92px;
  height: 92px;
  flex: 0 0 92px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 900;
}

.company-logo-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 8px;
}

.company-logo-field > div:last-child {
  display: grid;
  gap: 6px;
}

.company-logo-field small,
.company-profile-actions small {
  color: var(--muted);
}

.company-profile-actions small.is-success {
  color: var(--green);
}

.company-profile-actions small.is-error {
  color: var(--red);
}

.company-logo-actions,
.company-profile-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.settings-form label,
.dialog-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
}

.settings-form input,
.settings-form select,
.settings-form textarea,
.dialog-grid input,
.dialog-grid select {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
}

.settings-form textarea {
  min-height: 86px;
  resize: vertical;
  padding: 10px 12px;
  line-height: 1.5;
}

.settings-form input:focus,
.settings-form select:focus,
.settings-form textarea:focus,
.document-toolbar input:focus,
.document-toolbar select:focus,
.document-totals-panel input:focus,
.document-totals-panel select:focus,
.document-note-field input:focus,
.dialog-grid input:focus,
.dialog-grid select:focus,
.invoice-section > label input:focus,
.search:focus-within {
  border-color: color-mix(in srgb, var(--brand) 62%, var(--line));
  outline: 3px solid color-mix(in srgb, var(--brand) 14%, transparent);
}

.toggle-row {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

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

.toggle-row input {
  width: 44px;
  height: 24px;
  accent-color: var(--brand);
}

.notification-settings-panel {
  align-self: start;
}

.notification-settings-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.notification-settings-summary span {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  padding: 10px;
}

.notification-settings-summary small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.notification-settings-summary strong {
  overflow-wrap: anywhere;
}

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

.notification-setting-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  padding: 10px;
}

.notification-setting-icon {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: color-mix(in srgb, var(--brand) 12%, var(--surface));
  color: var(--brand-strong);
}

.notification-setting-icon svg {
  width: 18px;
  height: 18px;
}

.notification-setting-row > span:nth-child(2) {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.notification-setting-row strong,
.notification-setting-row small {
  overflow-wrap: anywhere;
}

.notification-setting-row small {
  color: var(--muted);
  line-height: 1.35;
}

.notification-setting-row input {
  width: 44px;
  height: 24px;
  accent-color: var(--brand);
}

.email-template-settings-panel {
  align-self: start;
}

.email-template-variable-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.email-template-variable-list span,
.email-template-meta code {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-muted);
  color: var(--brand-strong);
  padding: 5px 7px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.76rem;
  font-weight: 800;
}

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

.email-template-item {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
  box-shadow: var(--shadow-soft);
}

.email-template-meta,
.email-template-content {
  display: grid;
  gap: 12px;
}

.email-template-meta {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
}

.email-template-meta code {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.email-template-content {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.9fr);
}

.email-template-copy {
  display: grid;
  align-content: start;
  gap: 10px;
}

.email-template-copy h3,
.email-template-preview h4 {
  margin: 0;
}

.email-template-copy dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

.email-template-copy dl div {
  display: grid;
  gap: 4px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.email-template-copy dt {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.email-template-copy dd {
  margin: 0;
  color: var(--text);
  line-height: 1.45;
}

.email-template-preview {
  display: grid;
  align-content: start;
  gap: 12px;
  border-left: 4px solid var(--brand);
  background: var(--surface-muted);
  padding: 16px;
}

.email-template-preview > span {
  color: var(--brand-strong);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.email-template-preview p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

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

.email-template-preview-facts small {
  display: grid;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  padding: 8px;
  font-weight: 800;
}

.email-template-preview-facts strong {
  color: var(--text);
}

.email-template-preview button {
  justify-self: start;
  border: 0;
  border-radius: 6px;
  background: var(--brand);
  color: white;
  padding: 10px 14px;
  font-weight: 900;
}

.email-template-footer {
  font-size: 0.86rem;
}

.team-settings-panel {
  align-self: start;
}

.team-invite-form,
.team-list,
.team-invite-list {
  display: grid;
  gap: 12px;
}

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

.team-invite-form input,
.team-invite-form select {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
}

.team-invite-form input:focus,
.team-invite-form select:focus {
  border-color: color-mix(in srgb, var(--brand) 62%, var(--line));
  outline: 3px solid color-mix(in srgb, var(--brand) 14%, transparent);
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

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

.permission-grid label {
  display: flex;
  min-height: 36px;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.permission-grid input {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
}

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

.team-invite-status {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.team-invite-status.is-success {
  color: #1f9d5a;
}

.team-invite-status.is-error {
  color: #c2413b;
}

.team-invite-link {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  color: var(--brand-strong);
  padding: 10px 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

.team-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
}

.team-card strong,
.team-card span {
  min-width: 0;
}

.team-card small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-weight: 700;
}

.team-pill {
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-strong);
  padding: 5px 9px;
  font-size: 0.78rem;
  font-weight: 900;
}

.team-permission-list {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.team-permission-list span {
  border-radius: 6px;
  background: var(--surface-muted);
  color: var(--muted);
  padding: 5px 7px;
  font-size: 0.76rem;
  font-weight: 800;
}

.panel-copy {
  margin: 0 0 16px;
  color: var(--muted);
}

.hidden {
  display: none !important;
}

@media (max-width: 980px) {
  .auth-main {
    place-items: center;
  }

  .auth-card {
    width: 100%;
  }

  .admin-metrics,
  .admin-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .auth-topbar,
  .auth-main {
    width: min(100% - 28px, 520px);
  }

  .auth-topbar {
    padding-top: 66px;
  }

  .auth-brand {
    gap: 14px;
  }

  .auth-brand img {
    width: 78px;
  }

  .auth-brand span {
    font-size: 46px;
  }

  .auth-card {
    padding: 22px;
  }

  .user-chip strong {
    display: none;
  }

  .admin-metrics {
    gap: 10px;
  }

  .admin-metric-card {
    min-height: 104px;
  }
}

.inline-field {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 8px;
}

.tax-lookup-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.tax-lookup-row button {
  min-width: 132px;
}

.tax-lookup-panel {
  display: grid;
  gap: 14px;
  border: 1px solid color-mix(in srgb, var(--brand) 22%, var(--line));
  border-left: 4px solid var(--brand);
  border-radius: 8px;
  background: color-mix(in srgb, var(--brand) 4%, var(--surface));
  padding: 14px;
}

.tax-lookup-header {
  display: grid;
  gap: 4px;
}

.tax-lookup-header strong {
  color: var(--text);
  font-size: 1rem;
}

.tax-lookup-header small {
  max-width: 780px;
  color: var(--muted);
  line-height: 1.45;
}

.registry-result-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
}

.registry-result-heading,
.registry-result-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.registry-result-heading span,
.registry-result-heading strong,
.registry-result-heading small {
  display: block;
}

.registry-result-heading small,
.registry-result-actions small,
.registry-result-grid small {
  color: var(--muted);
}

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

.registry-result-grid span {
  min-width: 0;
  border-radius: 6px;
  background: var(--surface-muted);
  padding: 10px;
}

.registry-result-grid strong {
  display: block;
  overflow: hidden;
  margin-top: 3px;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.form-hint {
  min-height: 18px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
  line-height: 1.35;
}

.form-hint.success {
  color: var(--green);
}

.form-hint.warning {
  color: var(--amber);
}

.form-hint.error {
  color: var(--red);
}

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

.document-builder-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.document-builder-main,
.document-totals-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
  box-shadow: var(--shadow-soft);
}

.document-totals-panel {
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(260px, 1fr) minmax(320px, 1.1fr);
  gap: 12px;
  align-items: start;
}

.document-totals-panel .form-section-heading {
  grid-column: 1 / -1;
}

.document-totals-panel .invoice-totals {
  grid-column: 3;
  grid-row: 2 / span 3;
  margin-top: 0;
  max-width: none;
  border-left: 1px solid var(--line);
  padding-left: 18px;
}

.document-toolbar,
.e-document-grid {
  display: grid;
  gap: 12px;
  align-items: end;
}

.document-toolbar {
  grid-template-columns: 1.1fr minmax(220px, 1.5fr) 150px 170px;
}

.quote-workflow-panel,
.quote-detail-panel {
  display: grid;
  gap: 14px;
  margin-top: 12px;
  border: 1px solid color-mix(in srgb, var(--brand) 28%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--brand) 5%, var(--surface));
  padding: 16px;
}

.quote-workflow-panel.hidden,
.quote-detail-panel.hidden,
#detailQuoteMessageButton.hidden,
#detailQuoteMailButton.hidden,
#detailQuotePortalButton.hidden,
#detailQuoteReviseButton.hidden,
#detailQuoteCopyButton.hidden,
.quote-only-field.hidden {
  display: none;
}

.quote-workflow-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}

.quote-workflow-grid label,
.quote-message-field,
.quote-next-step-field {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: color-mix(in srgb, var(--text) 76%, var(--muted));
  font-size: 0.9rem;
  font-weight: 780;
}

.quote-workflow-grid input,
.quote-workflow-grid select,
.quote-message-field textarea,
.quote-next-step-field input {
  width: 100%;
  min-width: 0;
}

.quote-message-field {
  margin-top: 2px;
}

.quote-workflow-panel textarea {
  min-height: 96px;
  resize: vertical;
}

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

.quote-permissions label {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 0 10px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.quote-share-card,
.quote-portal-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.quote-share-card span,
.quote-portal-summary span {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px 12px;
}

.quote-share-card small,
.quote-portal-summary small {
  display: block;
  color: var(--muted);
  font-weight: 800;
}

.quote-share-card strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.quote-workspace-view {
  max-width: 1280px;
  margin: 0 auto;
}

.quote-workspace-shell {
  display: grid;
  gap: 16px;
}

.quote-workspace-heading .section-actions {
  flex-wrap: wrap;
}

.quote-workspace-heading .danger-action {
  margin-right: 0;
}

.quote-workspace-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 16px;
  align-items: start;
}

.quote-workspace-shell.quote-locked-archive .quote-workspace-body {
  grid-template-columns: 1fr;
}

.quote-workspace-left,
.quote-workspace-right {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.quote-workspace-shell.quote-locked-archive .quote-workspace-right {
  display: block;
}

.quote-workspace-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px 6px;
  box-shadow: var(--shadow-soft);
}

.quote-workspace-share,
.quote-workspace-main,
.quote-workspace-activity {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.quote-workspace-summary span {
  display: grid;
  gap: 8px;
  min-width: 0;
  min-height: 74px;
  align-content: center;
  border-right: 1px solid var(--line);
  padding: 0 18px;
}

.quote-workspace-summary span:last-child {
  border-right: 0;
}

.quote-workspace-summary small,
.quote-workspace-share small {
  color: var(--muted);
  font-weight: 800;
}

.quote-workspace-summary strong {
  overflow: hidden;
  color: var(--text);
  font-size: 1.08rem;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.quote-workspace-summary span:nth-child(2) strong {
  color: var(--brand-strong);
  font-size: 1.42rem;
}

.quote-workspace-share {
  display: grid;
  gap: 10px;
  align-content: start;
  padding: 18px;
}

.quote-workspace-shell.quote-locked-archive .quote-workspace-share {
  display: none;
}

.quote-workspace-share .eyebrow {
  color: var(--brand-strong);
}

.quote-workspace-share > strong {
  display: block;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  padding: 10px 12px;
  color: var(--brand-strong);
  font-size: 0.84rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quote-workspace-share > small {
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.quote-mail-recipient-field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.quote-mail-recipient-field input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 11px 12px;
  color: var(--text);
  font: inherit;
  font-weight: 800;
}

.quote-mail-recipient-field input:focus {
  border-color: var(--brand);
  outline: 3px solid rgba(45, 93, 219, 0.12);
}

.quote-workspace-share .quote-share-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.quote-workspace-share .quote-share-actions button {
  justify-content: center;
}

.quote-workspace-share .quote-share-actions button:last-child {
  grid-column: 1 / -1;
}

.quote-workspace-controls {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.quote-workspace-controls label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.quote-workspace-controls select {
  width: 100%;
  min-width: 0;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 10px;
  font: inherit;
  font-weight: 800;
}

.quote-workspace-controls .primary-action {
  justify-content: center;
}

.quote-workspace-workflow-actions {
  display: grid;
  gap: 8px;
}

.quote-workspace-workflow-actions:empty {
  display: none;
}

.quote-workspace-workflow-actions .primary-action {
  width: 100%;
}

.quote-workspace-controls small {
  color: var(--muted);
  font-weight: 800;
  line-height: 1.35;
}

.quote-workspace-main,
.quote-workspace-activity {
  padding: 18px;
}

.quote-workspace-main .form-section-heading,
.quote-workspace-activity .form-section-heading {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  align-items: start;
  justify-content: start;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
  padding-bottom: 12px;
}

.quote-workspace-main .form-section-heading::before,
.quote-workspace-activity .form-section-heading::before {
  top: 0;
  bottom: 12px;
}

.quote-workspace-main .table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.quote-workspace-main .table-wrap table {
  min-width: 720px;
}

.quote-workspace-totals {
  max-width: 380px;
  margin-top: 16px;
}

.quote-workspace-activity {
  display: grid;
  gap: 12px;
  position: sticky;
  top: 88px;
}

.quote-workspace-shell.quote-locked-archive .quote-workspace-activity {
  position: static;
}

.quote-workspace-activity .compact-action {
  width: 100%;
  justify-content: center;
}

.quote-workspace-shell.quote-locked-archive .quote-workspace-activity .compact-action {
  display: none;
}

.quote-workspace-activity .quote-thread {
  max-height: 520px;
  overflow: auto;
  padding-right: 4px;
}

.quote-workspace-shell.quote-locked-archive .quote-workspace-activity .quote-thread {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  max-height: none;
  gap: 12px;
  overflow: visible;
  padding-right: 0;
}

.quote-workspace-activity .quote-thread-item {
  border-left: 3px solid color-mix(in srgb, var(--brand) 48%, var(--line));
  box-shadow: none;
}

.quote-thread-item.muted-thread-item {
  border-left-color: var(--line);
  color: var(--muted);
}

.quote-customer-updates {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
  border: 1px solid color-mix(in srgb, var(--brand) 28%, var(--line));
  border-left: 4px solid var(--brand);
  border-radius: 8px;
  background: color-mix(in srgb, var(--brand) 4%, var(--surface));
  padding: 14px;
}

.quote-version-panel {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  padding: 14px;
}

.quote-customer-updates .compact-heading {
  margin: 0;
  padding: 0 0 10px;
}

.quote-version-panel .compact-heading {
  margin: 0;
  padding: 0 0 10px;
}

.quote-customer-update-list {
  display: grid;
  gap: 8px;
}

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

.quote-customer-update-list article,
.quote-version-list article {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px 12px;
}

.quote-version-list article.active {
  border-color: color-mix(in srgb, var(--brand) 42%, var(--line));
  background: color-mix(in srgb, var(--brand) 5%, var(--surface));
}

.quote-version-list article > span {
  color: var(--brand-strong);
  font-weight: 900;
}

.quote-customer-update-list small,
.quote-version-list small,
.line-revision-note {
  color: var(--muted);
  font-weight: 800;
}

.line-revision-note {
  display: block;
  margin-top: 4px;
  color: var(--brand-strong);
  font-size: 0.76rem;
}

.quote-thread {
  display: grid;
  gap: 8px;
}

.quote-thread-item {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px 12px;
}

.quote-thread-item small {
  color: var(--muted);
  font-weight: 800;
}

.quote-portal-notes {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--brand) 3%, var(--surface));
  padding: 14px;
}

.quote-portal-notes strong {
  display: block;
  margin-top: 2px;
}

.quote-portal-notes textarea {
  min-height: 108px;
  resize: vertical;
}

.quote-portal-note-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.quote-portal-note-actions small {
  color: var(--muted);
  font-weight: 800;
}

.quote-portal-view {
  max-width: 1120px;
  margin: 0 auto;
}

.quote-portal-shell {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
  box-shadow: var(--shadow-soft);
}

.quote-portal-header,
.quote-portal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.quote-portal-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.portal-quantity-control {
  display: inline-grid;
  grid-template-columns: 74px auto;
  gap: 6px;
  align-items: center;
  justify-content: end;
}

.portal-quantity-control input {
  width: 74px;
  height: 38px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 8px;
  text-align: right;
  font: inherit;
  font-weight: 800;
}

.portal-quantity-control span {
  color: var(--muted);
  font-weight: 800;
}

.e-document-fields {
  width: fit-content;
  margin-top: 10px;
  border: 0;
  background: transparent;
  padding: 0;
}

.e-document-summary {
  display: flex;
  min-height: auto;
  cursor: pointer;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface-soft) 72%, white);
  padding: 8px 10px;
  color: var(--brand-strong);
  list-style: none;
}

.e-document-summary::-webkit-details-marker {
  display: none;
}

.e-document-summary::after {
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  content: "";
  transform: rotate(45deg);
  transition: transform 0.18s ease;
}

.e-document-fields[open] .e-document-summary::after {
  transform: rotate(225deg);
}

.e-document-summary span {
  display: flex;
  align-items: center;
  gap: 8px;
}

.e-document-summary strong {
  color: var(--text);
  font-size: 0.86rem;
}

.e-document-summary small {
  display: none;
  font-weight: 700;
}

.e-document-grid {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  width: min(1120px, calc(100vw - 120px));
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  padding: 14px;
}

.document-toolbar label,
.e-document-grid label,
.document-totals-panel label,
.document-note-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
}

.document-toolbar input,
.document-toolbar select,
.e-document-grid input,
.e-document-grid select,
.document-totals-panel input,
.document-totals-panel select,
.document-note-field input {
  height: 42px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
}

.document-type-hint.document-builder-hints {
  display: flex;
}

.document-line-editor {
  margin-top: 14px;
  overflow-x: auto;
}

.document-note-field {
  margin-top: 14px;
}

.invoice-dialog {
  width: min(1100px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0;
  box-shadow: var(--shadow);
}

.customer-dialog {
  width: min(1180px, calc(100vw - 32px));
}

.customer-dialog form {
  display: flex;
  flex-direction: column;
  max-height: min(88vh, 820px);
}

.customer-dialog-body {
  display: grid;
  grid-template-columns: 192px minmax(0, 1fr);
  gap: 14px;
  height: clamp(380px, 58vh, 560px);
  min-height: 0;
}

.customer-tabs {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
  margin: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  padding: 6px;
}

.customer-tabs button {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 800;
  padding: 9px 10px;
  text-align: left;
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    color 0.18s ease;
  white-space: normal;
}

.customer-tabs button.active {
  border-color: color-mix(in srgb, var(--brand) 42%, var(--line));
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.customer-tabs button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--brand) 28%, transparent);
  outline-offset: 2px;
}

.customer-form-layout {
  min-height: 0;
  height: 100%;
  overflow: auto;
  padding-right: 4px;
}

.form-section {
  display: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  padding: 14px;
}

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

.form-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

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

.currency-settings-field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

.currency-choice-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.currency-choice-group label {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
}

.currency-choice-group input {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
}

.compact-action {
  height: 34px;
  padding: 0 10px;
  flex-shrink: 0;
  white-space: nowrap;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

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

.customer-address-row {
  display: grid;
  grid-template-columns: 112px minmax(130px, 1fr) 110px 110px 108px 110px 42px;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px;
}

.customer-address-row input,
.customer-address-row select {
  width: 100%;
  min-width: 0;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 10px;
}

.customer-address-row .address-line {
  grid-column: 1 / -2;
}

.file-dropzone {
  display: grid;
  gap: 4px;
  border: 1px dashed color-mix(in srgb, var(--brand) 36%, var(--line));
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  padding: 14px;
}

.file-dropzone strong {
  color: var(--text);
  font-size: 0.95rem;
}

.file-dropzone.dragging {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.customer-file-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.customer-file-row,
.empty-file-state {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 38px;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px;
}

.empty-file-state {
  grid-template-columns: 1fr;
  color: var(--muted);
}

.customer-file-row strong,
.empty-file-state strong {
  display: block;
  color: var(--text);
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.customer-file-row span,
.empty-file-state span {
  color: var(--muted);
  font-size: 0.82rem;
}

.file-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.file-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.detail-dialog {
  width: min(1060px, calc(100vw - 32px));
}

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

.customer-ledger-panel .detail-meta {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 0;
}

.ledger-table-wrap table {
  min-width: 900px;
}

.ledger-table-wrap td small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.empty-ledger-state {
  display: grid;
  gap: 4px;
  border-radius: 8px;
  background: var(--surface-muted);
  color: var(--muted);
  padding: 14px;
}

.empty-ledger-state strong {
  color: var(--text);
}

.installment-dialog {
  width: min(720px, calc(100vw - 32px));
}

.installment-payment-dialog {
  width: min(640px, calc(100vw - 32px));
}

.recurring-dialog {
  width: min(920px, calc(100vw - 32px));
}

.recurring-line-grid {
  display: grid;
  grid-template-columns: minmax(180px, 2fr) repeat(4, minmax(90px, 1fr));
  gap: 10px;
}

.recurring-line-grid label,
.recurring-note-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
}

.recurring-line-grid input,
.recurring-note-field input {
  height: 40px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 10px;
}

.recurring-note-field {
  margin-top: 10px;
}

.installment-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items: start;
}

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

.installment-form input,
.installment-form select {
  height: 40px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 10px;
}

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

.installment-dialog .installment-list {
  max-height: 320px;
  overflow: auto;
  margin-top: 12px;
  padding-right: 4px;
}

.installment-row {
  display: grid;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px;
}

.installment-row {
  grid-template-columns: minmax(0, 1fr) 120px 110px 86px 38px;
}

.installment-row small,
.installment-dialog small {
  display: block;
  color: var(--muted);
}

.ledger-icon-action {
  width: 34px;
  height: 34px;
  color: var(--brand-strong);
  box-shadow: none;
}

.invoice-dialog::backdrop {
  background: rgba(10, 16, 24, 0.48);
}

.invoice-dialog form {
  display: flex;
  max-height: min(88vh, 820px);
  flex-direction: column;
  padding: 20px;
}

.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

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

.invoice-dialog-body {
  display: grid;
  grid-template-columns: 164px minmax(0, 1fr);
  gap: 14px;
  min-height: 430px;
  overflow: auto;
}

.invoice-form-layout {
  min-width: 0;
}

.invoice-section {
  display: none;
  min-height: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  padding: 14px;
}

.invoice-section.active {
  display: block;
}

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

.invoice-section > label input {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
}

.document-type-hint {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.document-type-hint span {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface-soft) 76%, white);
  padding: 8px 10px;
}

.document-type-hint small {
  color: var(--muted);
  font-weight: 700;
}

.document-type-hint strong {
  color: var(--text);
  font-size: 0.9rem;
}

.line-editor {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  padding: 14px;
}

.embedded-line-editor {
  margin-top: 0;
  border: 0;
  background: transparent;
  padding: 0;
}

.line-editor-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.line-items {
  display: grid;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.line-head {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 72px 78px 108px 82px 90px 112px 42px;
  gap: 8px;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
  min-width: 812px;
}

.draft-line {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 72px 78px 108px 82px 90px 112px 42px;
  gap: 8px;
  align-items: center;
  min-width: 812px;
}

.line-number {
  display: grid;
  place-items: center;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface-soft) 78%, white);
  color: var(--muted);
  font-weight: 800;
}

.draft-line input,
.draft-line select {
  height: 40px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 10px;
}

.draft-line input[readonly] {
  background: color-mix(in srgb, var(--surface-soft) 80%, white);
  color: var(--muted);
  font-weight: 800;
}

.line-extra {
  grid-column: 1 / -1;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.line-extra summary {
  cursor: pointer;
  color: var(--brand-strong);
  font-size: 0.82rem;
  font-weight: 800;
  list-style: none;
}

.line-extra summary::-webkit-details-marker {
  display: none;
}

.line-extra-grid {
  display: grid;
  grid-template-columns: minmax(140px, 0.8fr) minmax(220px, 1.4fr) repeat(4, minmax(140px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.line-extra-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.invoice-totals {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  margin-left: auto;
  max-width: 320px;
}

.invoice-totals span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  color: var(--muted);
}

.invoice-totals strong {
  color: var(--text);
}

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

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

.detail-meta span {
  border-radius: 8px;
  background: var(--surface-muted);
  padding: 12px;
}

.detail-meta small,
.detail-meta strong {
  display: block;
}

.detail-meta small {
  color: var(--muted);
}

.qnb-status-panel {
  display: grid;
  gap: 8px;
  margin: 0 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  padding: 12px;
}

.qnb-status-panel.hidden {
  display: none;
}

.qnb-status-panel > strong {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.qnb-status-panel small {
  color: var(--muted);
  font-weight: 750;
  line-height: 1.45;
}

.qnb-flow {
  display: grid;
  gap: 7px;
  min-width: 210px;
}

.qnb-flow-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.qnb-flow-step {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  padding: 5px 8px;
  font-size: 0.72rem;
  font-weight: 850;
  white-space: nowrap;
}

.qnb-flow-step i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.qnb-flow-step.done {
  border-color: color-mix(in srgb, var(--green) 26%, var(--line));
  background: color-mix(in srgb, var(--green) 10%, var(--surface));
  color: var(--green);
}

.qnb-flow-step.current {
  border-color: color-mix(in srgb, var(--brand) 34%, var(--line));
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.qnb-flow-step.error {
  border-color: color-mix(in srgb, var(--red) 32%, var(--line));
  background: color-mix(in srgb, var(--red) 10%, var(--surface));
  color: var(--red);
}

.qnb-flow.compact {
  min-width: 270px;
}

.qnb-flow.compact .qnb-flow-step {
  padding: 4px 7px;
  font-size: 0.68rem;
}

.flow-empty {
  color: var(--muted);
}

.table-wrap.compact table {
  min-width: 620px;
}

.document-preview {
  display: flex;
  min-height: 360px;
  flex-direction: column;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  padding: 18px;
}

.preview-header,
.preview-body {
  display: grid;
  gap: 8px;
}

.preview-header {
  align-items: start;
  grid-template-columns: 1fr auto;
}

.preview-header span {
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--brand-strong);
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 800;
}

.preview-body strong {
  font-size: 2rem;
}

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

.invoice-dialog menu {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 18px 0 0;
  padding: 0;
}

@media (max-width: 1120px) {
  .metric-grid,
  .directory-grid,
  .module-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content-grid,
  .settings-layout,
  .integration-layout,
  .detail-layout,
  .document-builder-shell {
    grid-template-columns: 1fr;
  }

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

  .document-totals-panel {
    grid-template-columns: 1fr;
  }

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

  .document-totals-panel .invoice-totals {
    grid-column: auto;
    grid-row: auto;
    border-left: 0;
    border-top: 1px solid var(--line);
    padding-top: 14px;
    padding-left: 0;
  }

  .document-toolbar,
  .e-document-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .customer-toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .customer-search-field {
    grid-column: 1 / -1;
  }

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

  .draft-line {
    grid-template-columns: minmax(220px, 1fr) 72px 78px 108px 82px 90px 112px 42px;
  }

  .line-head {
    grid-template-columns: minmax(220px, 1fr) 72px 78px 108px 82px 90px 112px 42px;
  }

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

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

  .customer-address-row {
    grid-template-columns: repeat(2, minmax(0, 1fr)) 42px;
  }

  .customer-address-row .address-line {
    grid-column: 1 / -2;
  }
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 76px 312px minmax(0, 1fr);
    min-width: 0;
  }

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

  .icon-rail {
    width: 76px;
    padding-inline: 10px;
  }

  .rail-item {
    width: 50px;
    height: 50px;
  }

  .sidebar {
    position: sticky;
    top: 0;
    display: flex;
    width: 312px;
    height: 100vh;
    padding: 22px 18px 20px;
  }

  .nav-list {
    display: grid;
    gap: 10px;
    margin-top: 0;
    max-width: 100%;
    overflow-y: auto;
    padding-bottom: 0;
  }

  .nav-item {
    flex: initial;
  }

  .nav-group {
    flex: initial;
  }

  .nav-submenu {
    position: static;
    width: auto;
    min-width: 0;
    max-height: none;
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
    padding: 0;
    box-shadow: none;
  }

  .main {
    padding: 0;
  }

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

  .topbar-actions {
    min-width: 0;
    justify-content: stretch;
  }

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

  .section-actions,
  .customer-toolbar {
    justify-content: stretch;
  }

  .customer-toolbar {
    grid-template-columns: 1fr;
  }

  .customer-role-filter,
  .view-segment {
    width: 100%;
  }

  .customer-role-filter button,
  .view-segment button {
    flex: 1;
  }

  .search {
    min-width: 0;
    flex: 1 1 auto;
  }

  .quick-actions {
    width: 100%;
  }

  .quick-actions .primary-action {
    width: 100%;
  }

  .quick-action-menu {
    position: fixed;
    top: 312px;
    right: 18px;
    left: 18px;
    width: auto;
  }

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

@media (max-width: 560px) {
  .topbar-actions {
    flex-wrap: wrap;
  }

  .search,
  .primary-action {
    width: 100%;
  }

  .directory-grid,
  .module-grid,
  .dialog-grid,
  .integration-status-grid,
  .integration-form {
    grid-template-columns: 1fr;
  }

  .document-type-hint,
  .document-toolbar,
  .e-document-grid,
  .quote-workflow-grid,
  .quote-permissions {
    grid-template-columns: 1fr;
  }

  .e-document-summary {
    align-items: flex-start;
  }

  .e-document-summary small {
    display: none;
  }

  .customer-dialog {
    width: min(100vw - 20px, 520px);
  }

  .customer-dialog form {
    padding: 18px;
  }

  .customer-dialog-body {
    grid-template-columns: 124px minmax(0, 1fr);
    gap: 10px;
    height: clamp(360px, 58vh, 520px);
  }

  .customer-tabs {
    padding: 4px;
  }

  .customer-tabs button {
    min-height: 40px;
    padding: 8px;
  }

  .draft-line {
    grid-template-columns: 1fr 1fr;
    min-width: 0;
  }

  .customer-address-row {
    grid-template-columns: 1fr 42px;
  }

  .customer-address-row .address-line,
  .customer-address-row select,
  .customer-address-row input:not(.address-line) {
    grid-column: 1 / -1;
  }

  .customer-address-row [data-remove-address] {
    grid-column: 1 / -1;
    width: 100%;
  }

  .line-head {
    display: none;
    min-width: 0;
  }

  .draft-line [data-line="description"],
  .draft-line [data-line-computed="lineTotal"],
  .draft-line .line-extra,
  .draft-line [data-remove-line] {
    grid-column: 1 / -1;
  }

  .line-extra-grid {
    grid-template-columns: 1fr;
  }

  .installment-form,
  .installment-row,
  .recurring-line-grid {
    grid-template-columns: 1fr;
  }

  .detail-meta {
    grid-template-columns: 1fr;
  }

  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .section-actions {
    width: 100%;
    flex-wrap: wrap;
    justify-content: stretch;
  }

  .section-actions .ghost-action,
  .section-actions .primary-action {
    flex: 1 1 180px;
  }

  .status-tabs {
    width: 100%;
    overflow: auto;
  }
}

/* Previous Muhsis shell refresh */
.view > .section-heading:first-child,
.view > .panel:first-child,
.document-builder-shell,
.customer-ledger-header {
  margin-top: 0;
}

.panel,
.document-builder-main,
.document-totals-panel,
.customer-ledger-header,
.invoice-dialog,
.settings-card,
.integration-card {
  border-radius: 2px;
}

label {
  color: var(--text);
  font-weight: 750;
}

input,
select,
textarea {
  border-radius: 3px !important;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand) !important;
  outline: 2px solid color-mix(in srgb, var(--brand) 18%, transparent) !important;
}

.form-section-heading {
  border-left: 5px solid var(--brand);
  padding-left: 16px;
}

.document-builder-main > .form-section:first-child,
.customer-dialog .form-section.active {
  border-left: 5px solid var(--brand);
  padding-left: 18px;
}

.customer-dialog .form-section.active .form-section-heading {
  border-left: 0;
  padding-left: 0;
}

.customer-tabs {
  background: var(--surface-muted);
  border-right: 1px solid var(--line);
  padding: 10px;
}

.customer-tabs button {
  border-radius: 3px;
}

.customer-tabs button.active {
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.topbar::before {
  display: none;
}

.topbar-title {
  display: none;
}

.topbar-actions {
  margin-right: 0;
  margin-left: auto;
  justify-content: flex-end;
}

.search::after {
  content: "⌘ + K";
  display: inline-flex;
  min-width: 56px;
  height: 24px;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.topbar .quick-actions {
  margin-left: 10px;
}

:root.dark .search::after {
  background: #242832;
}

.record-page {
  align-content: start;
}

.record-form,
.document-builder-form {
  display: grid;
  gap: 22px;
  width: min(1120px, 100%);
}

.record-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

.record-breadcrumb span::after {
  margin-left: 10px;
  color: color-mix(in srgb, var(--muted) 54%, transparent);
  content: "/";
}

.record-breadcrumb strong {
  color: var(--text);
}

.record-heading,
.document-builder-form > .section-heading {
  position: relative;
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  margin: 0;
  padding: 0 0 18px 14px;
}

.record-heading::before,
.document-builder-form > .section-heading::before,
.customer-dialog .dialog-heading::before,
.invoice-dialog .dialog-heading::before {
  position: absolute;
  top: 4px;
  bottom: 18px;
  left: 0;
  width: 5px;
  background: var(--brand);
  content: "";
}

.record-heading h2,
.document-builder-form > .section-heading h2,
.customer-dialog .dialog-heading h2 {
  margin: 4px 0 0;
  font-size: clamp(1.25rem, 2vw, 1.65rem);
  line-height: 1.18;
}

.record-section,
.document-builder-main,
.document-totals-panel,
.customer-dialog .form-section.active {
  border: 0;
  border-radius: 2px;
  background: transparent;
  box-shadow: none;
  padding: 0;
}

.record-section {
  display: grid;
  gap: 14px;
}

.record-section + .record-section,
.document-line-editor,
.document-totals-panel,
.document-note-field {
  margin-top: 22px;
}

.record-section-heading,
.record-section .form-section-heading,
.document-builder-main .form-section-heading,
.document-totals-panel .form-section-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  border-bottom: 1px dashed var(--line);
  margin: 0 0 2px;
  padding: 0 0 10px;
  color: var(--text);
  font-weight: 850;
}

.record-section-heading::before {
  width: 18px;
  height: 18px;
  border: 1px dashed var(--muted);
  border-radius: 4px;
  content: "";
}

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

.record-field,
.record-check,
.document-toolbar label,
.e-document-grid label,
.document-totals-panel label,
.document-note-field,
.dialog-grid label {
  display: grid;
  gap: 8px;
  color: color-mix(in srgb, var(--text) 76%, var(--muted));
  font-size: 0.9rem;
  font-weight: 780;
}

.record-field > span {
  color: var(--red);
}

.record-field input,
.record-field select,
.document-toolbar input,
.document-toolbar select,
.e-document-grid input,
.e-document-grid select,
.document-totals-panel input,
.document-totals-panel select,
.document-note-field input,
.dialog-grid input,
.dialog-grid select {
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
  color: var(--text);
  padding: 0 14px;
}

.record-check {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  align-items: start;
  border: 0;
  border-top: 1px dashed var(--line);
  padding-top: 14px;
}

.record-check input {
  width: 20px;
  height: 20px;
  accent-color: var(--brand);
}

.record-check small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-weight: 600;
  line-height: 1.45;
}

.choice-toggle {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface-muted);
  padding: 4px;
}

.choice-toggle button {
  min-height: 40px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  padding: 0 16px;
  font-weight: 850;
}

.choice-toggle button.active {
  background: color-mix(in srgb, var(--green) 16%, var(--surface));
  color: var(--green);
  box-shadow: var(--shadow-soft);
}

.disabled-section {
  opacity: 0.5;
}

.line-editor,
.e-document-grid {
  border-radius: 2px;
  background: color-mix(in srgb, var(--surface-muted) 72%, transparent);
  box-shadow: none;
}

.document-builder-form {
  width: min(1480px, 100%);
}

.document-builder-shell {
  grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
  column-gap: 24px;
  row-gap: 22px;
}

.document-builder-main {
  min-width: 0;
  max-width: none;
}

.quote-workflow-panel {
  position: sticky;
  top: 18px;
  grid-column: 2;
  grid-row: 1;
  align-self: start;
  margin-top: 0;
}

.quote-workflow-panel .form-section-heading {
  display: grid;
  gap: 3px;
  border-bottom: 1px dashed var(--line);
  padding-bottom: 10px;
}

.quote-workflow-panel .form-section-heading::before {
  display: none;
}

.quote-workflow-grid,
.quote-permissions {
  grid-template-columns: 1fr;
}

.document-toolbar {
  grid-template-columns: repeat(12, minmax(0, 1fr));
  align-items: start;
}

.document-toolbar label:nth-child(1),
.document-toolbar label:nth-child(2),
.document-toolbar label:nth-child(5),
.document-toolbar label:nth-child(6) {
  grid-column: span 3;
}

.document-toolbar label:nth-child(3),
.document-toolbar label:nth-child(4) {
  grid-column: span 6;
}

.draft-address-preview {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  color: var(--muted);
  padding: 11px 12px;
  font-size: 0.9rem;
  line-height: 1.45;
}

.draft-address-preview strong {
  color: var(--text);
}

.document-totals-panel {
  grid-column: 1;
  grid-template-columns: minmax(220px, 0.8fr) minmax(260px, 0.9fr) minmax(320px, 1fr);
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.customer-dialog form {
  padding: 24px;
}

.invoice-dialog .dialog-heading {
  position: relative;
  margin-bottom: 20px;
  padding-left: 14px;
}

@media (max-width: 1180px) {
  .document-builder-shell {
    grid-template-columns: 1fr;
  }

  .quote-workspace-body {
    grid-template-columns: 1fr;
  }

  .quote-workspace-activity {
    position: static;
  }

  .quote-workflow-panel {
    position: static;
    grid-column: auto;
    grid-row: auto;
  }

  .document-totals-panel {
    grid-column: auto;
  }

  .document-toolbar label:nth-child(1),
  .document-toolbar label:nth-child(2),
  .document-toolbar label:nth-child(3),
  .document-toolbar label:nth-child(4),
  .document-toolbar label:nth-child(5),
  .document-toolbar label:nth-child(6) {
    grid-column: span 6;
  }
}

.customer-tabs {
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  padding: 0 12px 0 0;
}

.customer-tabs button {
  border: 0;
  background: transparent;
  padding-inline: 12px;
}

.customer-tabs button.active {
  background: var(--brand-soft);
}

.customer-record-page.customer-dialog {
  width: 100%;
  max-width: none;
  box-sizing: border-box;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.customer-record-page.customer-dialog form {
  display: grid;
  flex-direction: initial;
  gap: 22px;
  width: 100%;
  max-width: 1120px;
  max-height: none;
  padding: 0;
}

.customer-record-page .dialog-heading {
  margin-bottom: 0;
}

.customer-record-page .dialog-heading::before {
  bottom: 18px;
}

.customer-record-page .customer-dialog-body {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 24px;
  height: auto;
  min-height: 560px;
}

.customer-record-page .customer-form-layout {
  height: auto;
  overflow: visible;
  padding-right: 0;
}

.customer-record-page .form-section.active {
  min-height: 560px;
}

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

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

@media (max-width: 820px) {
  .app-shell,
  .app-shell.sidebar-collapsed {
    grid-template-columns: 76px minmax(0, 1fr);
  }

  .main {
    grid-column: 2;
    grid-row: 1;
  }

  .sidebar {
    position: fixed;
    left: 76px;
    width: min(312px, calc(100vw - 76px));
    box-shadow: var(--shadow);
    transform: translateX(0);
  }

  .app-shell.sidebar-collapsed .sidebar {
    width: min(312px, calc(100vw - 76px));
    padding: 22px 18px 20px;
    visibility: hidden;
    pointer-events: none;
    transform: translateX(calc(-100% - 76px));
  }

  .app-shell.sidebar-collapsed .sidebar-toggle {
    top: 86px;
    right: -10px;
    transform: none;
  }

  .app-shell.sidebar-collapsed .sidebar > *:not(.sidebar-toggle) {
    opacity: 1;
  }

  .view {
    padding: 16px;
  }

  .topbar {
    min-height: auto;
    padding: 14px;
  }

  .topbar::before {
    display: none;
  }

  .topbar > div:first-child,
  .topbar-actions {
    order: initial;
  }

  .invoice-flow-guide {
    grid-template-columns: 1fr;
  }

  .invoice-flow-counts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

  .record-grid,
  .document-toolbar,
  .customer-record-page .dialog-grid,
  .customer-record-page .customer-dialog-body {
    grid-template-columns: 1fr;
  }

  .document-toolbar label:nth-child(1),
  .document-toolbar label:nth-child(2),
  .document-toolbar label:nth-child(3),
  .document-toolbar label:nth-child(4),
  .document-toolbar label:nth-child(5),
  .document-toolbar label:nth-child(6) {
    grid-column: 1;
  }

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

  .registry-result-heading,
  .registry-result-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .registry-result-grid {
    grid-template-columns: 1fr;
  }

  .customer-record-page .customer-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 0 0 12px;
  }

  .record-heading,
  .document-builder-form > .section-heading {
    gap: 14px;
  }

  .choice-toggle {
    width: 100%;
  }

  .choice-toggle button {
    flex: 1;
  }
}

@media (max-width: 620px) {
  .quote-workspace-summary {
    grid-template-columns: 1fr;
  }
}
