:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-muted: #f1f3f5;
  --line: #dfe3e8;
  --line-strong: #c8ced6;
  --text: #1f2933;
  --muted: #667085;
  --soft: #8a94a6;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --green: #12805c;
  --amber: #b7791f;
  --red: #c2410c;
  --cyan: #087ea4;
  --purple: #6d5bd0;
  --shadow: 0 10px 24px rgba(31, 41, 51, 0.08);
  --radius: 8px;
  --sidebar: 248px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% 0%, rgba(37, 99, 235, 0.08), transparent 28%),
    linear-gradient(180deg, #f8fafc 0%, var(--bg) 260px);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 14px 12px;
  border-right: 1px solid var(--line);
  background: rgba(251, 252, 253, 0.96);
  backdrop-filter: blur(10px);
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding: 0 8px 12px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: #111827;
  color: white;
  font-weight: 700;
}

.brand-name {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.brand-name strong {
  font-size: 14px;
}

.brand-name span {
  color: var(--muted);
  font-size: 12px;
}

.nav-section {
  margin: 16px 0;
}

.nav-title {
  padding: 0 10px 6px;
  color: var(--soft);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 8px 10px;
  border-radius: 8px;
  color: #334155;
  font-weight: 500;
}

.nav-link:hover,
.nav-link.active {
  background: #eef2f7;
  color: #111827;
}

.nav-link.active {
  box-shadow: inset 3px 0 0 var(--primary);
}

.nav-link i,
.button i,
.icon-button i,
.toolbar-button i,
.chip i,
.icon,
.nav-link svg,
.button svg,
.icon-button svg,
.toolbar-button svg,
.chip svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  stroke-width: 1.9;
}

.icon {
  display: inline-grid;
  place-items: center;
}

.icon svg {
  width: 100%;
  height: 100%;
}

.main {
  min-width: 0;
  padding: 18px 24px 32px;
}

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

.page-title {
  min-width: 0;
}

.page-title h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
  font-weight: 700;
}

.page-title p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.breadcrumb {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.breadcrumb a {
  color: var(--primary-dark);
}

.breadcrumb i,
.breadcrumb svg {
  width: 14px;
  height: 14px;
  color: var(--soft);
}

.top-actions,
.row-actions,
.button-row,
.filter-row,
.tab-row,
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.button,
.icon-button,
.toolbar-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: #1f2937;
  padding: 7px 12px;
  font-weight: 600;
  white-space: nowrap;
}

.button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}

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

.button.subtle,
.toolbar-button {
  background: #f8fafc;
}

.button.active,
.toolbar-button.active {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: var(--primary-dark);
}

.button.danger {
  border-color: #fed7aa;
  color: var(--red);
  background: #fff7ed;
}

.icon-button {
  width: 34px;
  padding: 0;
}

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

.page-grid.two {
  grid-template-columns: minmax(0, 1.7fr) minmax(320px, 0.8fr);
}

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

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(16, 24, 40, 0.03), 0 12px 28px rgba(16, 24, 40, 0.04);
}

.panel.editing-panel {
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.10), 0 12px 28px rgba(16, 24, 40, 0.04);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.panel-header .filter-row {
  flex: 1 1 660px;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(260px, 1.6fr) repeat(auto-fit, minmax(148px, 0.85fr));
  align-items: center;
  gap: 10px;
}

.panel-title-block {
  flex: 0 1 290px;
  min-width: 220px;
}

.panel-header .filter-row > * {
  min-width: 0;
}

.panel-header .filter-row .searchbox,
.panel-header .filter-row .select {
  min-height: 38px;
}

.panel-header .filter-row .search-wrap.compact {
  flex: initial;
}

.panel-header .core-filter-row {
  flex-basis: 780px;
  grid-template-columns: minmax(280px, 1.8fr) repeat(3, minmax(128px, 0.72fr));
}

.panel-header .review-filter-row {
  flex-basis: 730px;
  grid-template-columns: minmax(220px, 1.35fr) minmax(126px, 0.66fr) minmax(180px, 0.95fr) minmax(164px, auto);
}

.panel-header .review-queue-filter-row {
  flex-basis: 620px;
  grid-template-columns: minmax(280px, 1.7fr) minmax(132px, 0.7fr) minmax(144px, 0.8fr);
}

.panel-header .audit-filter-row {
  flex-basis: 760px;
  grid-template-columns: minmax(280px, 1.8fr) repeat(3, minmax(128px, 0.72fr));
}

.filter-badges {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
}

.filter-badges .pill {
  white-space: nowrap;
}

.panel-header .toolbar {
  flex: 0 0 auto;
  align-self: center;
}

.panel-header > .button {
  flex: 0 0 auto;
  align-self: center;
}

.panel-header h2,
.panel-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.panel-header p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.panel-body {
  padding: 16px;
}

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

.metric-card,
.record-card,
.stage-card,
.import-card,
.mail-card,
.rule-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.metric-card {
  padding: 14px;
}

.metric-link {
  cursor: pointer;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.metric-link:hover,
.metric-link:focus {
  border-color: #bfdbfe;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
  outline: 0;
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
}

.metric-value {
  margin-top: 8px;
  font-size: 24px;
  line-height: 1.1;
  font-weight: 750;
}

.metric-foot {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.searchbox,
.input,
.select,
.textarea {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 7px 10px;
}

.searchbox {
  max-width: none;
  padding-left: 34px;
}

.search-wrap {
  position: relative;
  width: 100%;
  min-width: 0;
}

.search-wrap.compact {
  flex: 1 1 240px;
}

.search-wrap > i,
.search-wrap > .icon,
.search-wrap > svg {
  position: absolute;
  left: 10px;
  top: 50%;
  z-index: 1;
  width: 16px;
  height: 16px;
  color: var(--muted);
  pointer-events: none;
  transform: translateY(-50%);
}

.search-wrap > .icon svg {
  position: static;
  width: 100%;
  height: 100%;
  transform: none;
}

.select {
  width: 100%;
  min-width: 0;
}

.textarea {
  min-height: 132px;
  resize: vertical;
}

.textarea.small {
  min-height: 84px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

tr.selected-row td {
  background: #eff6ff;
}

.companies-table-wrap {
  overflow-x: hidden;
}

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

.companies-table th,
.companies-table td {
  min-width: 0;
  padding: 9px 7px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.companies-table th {
  font-size: 11px;
}

.companies-table .avatar-row {
  min-width: 0;
}

.companies-table .avatar {
  width: 26px;
  height: 26px;
  font-size: 10px;
}

.companies-table .cell-main,
.companies-table .cell-main strong,
.companies-table .cell-main span {
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}

.companies-table .tag,
.companies-table .grade {
  min-height: 22px;
  padding: 2px 6px;
  font-size: 11px;
}

.companies-table th:nth-child(1),
.companies-table td:nth-child(1) {
  width: 18%;
}

.companies-table th:nth-child(2),
.companies-table td:nth-child(2) {
  width: 7%;
}

.companies-table th:nth-child(3),
.companies-table td:nth-child(3) {
  width: 8%;
}

.companies-table th:nth-child(4),
.companies-table td:nth-child(4) {
  width: 12%;
}

.companies-table th:nth-child(5),
.companies-table td:nth-child(5) {
  width: 20%;
}

.companies-table th:nth-child(6),
.companies-table td:nth-child(6) {
  width: 9%;
}

.companies-table th:nth-child(7),
.companies-table td:nth-child(7),
.companies-table th:nth-child(8),
.companies-table td:nth-child(8) {
  width: 6%;
}

.companies-table th:nth-child(9),
.companies-table td:nth-child(9) {
  width: 8%;
}

.companies-table th:nth-child(10),
.companies-table td:nth-child(10) {
  width: 6%;
}

.dashboard-follow-wrap {
  overflow-x: hidden;
}

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

.dashboard-follow-table th,
.dashboard-follow-table td {
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
  padding: 10px 9px;
}

.dashboard-follow-table tbody tr {
  height: 64px;
}

.dashboard-follow-table tbody tr:has(.clamp-cell[data-expanded="true"]) {
  height: auto;
}

.dashboard-follow-table .cell-main,
.dashboard-follow-table .cell-main strong,
.dashboard-follow-table .cell-main span {
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}

.dashboard-follow-table .button {
  width: 100%;
  min-width: 0;
  min-height: 30px;
  gap: 4px;
  padding: 5px 6px;
  white-space: normal;
  font-size: 12px;
}

.dashboard-follow-table .button i,
.dashboard-follow-table .button .icon,
.dashboard-follow-table .button svg {
  width: 14px;
  height: 14px;
}

.email-review-grid {
  grid-template-columns: minmax(0, 2.05fr) minmax(280px, 0.7fr);
}

.email-review-table,
.users-table {
  min-width: 0;
  table-layout: fixed;
}

.email-review-table th,
.email-review-table td,
.users-table th,
.users-table td {
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}

.email-review-table th:nth-child(1),
.email-review-table td:nth-child(1) {
  width: 22%;
}

.email-review-table th:nth-child(2),
.email-review-table td:nth-child(2) {
  width: 17%;
}

.email-review-table th:nth-child(3),
.email-review-table td:nth-child(3) {
  width: 7%;
}

.email-review-table th:nth-child(4),
.email-review-table td:nth-child(4) {
  width: 22%;
}

.email-review-table th:nth-child(5),
.email-review-table td:nth-child(5) {
  width: 15%;
}

.email-review-table th:nth-child(6),
.email-review-table td:nth-child(6) {
  width: 17%;
}

.email-review-table .button-row.compact {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.email-review-table .button {
  min-width: 0;
  justify-content: center;
  padding: 7px 8px;
}

.users-table-wrap {
  overflow-x: hidden;
}

.users-table th:nth-child(1),
.users-table td:nth-child(1) {
  width: 15%;
}

.users-table th:nth-child(2),
.users-table td:nth-child(2) {
  width: 22%;
}

.users-table th:nth-child(3),
.users-table td:nth-child(3),
.users-table th:nth-child(4),
.users-table td:nth-child(4) {
  width: 9%;
}

.users-table th:nth-child(5),
.users-table td:nth-child(5) {
  width: 14%;
}

.users-table th:nth-child(6),
.users-table td:nth-child(6) {
  width: 21%;
}

.users-table th:nth-child(7),
.users-table td:nth-child(7) {
  width: 10%;
}

.opportunities-table,
.smtp-table {
  min-width: 0;
  table-layout: fixed;
}

.opportunities-table th,
.opportunities-table td,
.smtp-table th,
.smtp-table td {
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}

.opportunities-table th:nth-child(1),
.opportunities-table td:nth-child(1) {
  width: 18%;
}

.opportunities-table th:nth-child(2),
.opportunities-table td:nth-child(2) {
  width: 16%;
}

.opportunities-table th:nth-child(3),
.opportunities-table td:nth-child(3) {
  width: 12%;
}

.opportunities-table th:nth-child(4),
.opportunities-table td:nth-child(4),
.opportunities-table th:nth-child(5),
.opportunities-table td:nth-child(5),
.opportunities-table th:nth-child(6),
.opportunities-table td:nth-child(6),
.opportunities-table th:nth-child(8),
.opportunities-table td:nth-child(8),
.opportunities-table th:nth-child(9),
.opportunities-table td:nth-child(9) {
  width: 9%;
}

.opportunities-table th:nth-child(7),
.opportunities-table td:nth-child(7) {
  width: 18%;
}

.opportunity-cell-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.opportunity-cell {
  margin: 0;
}

.smtp-table th:nth-child(1),
.smtp-table td:nth-child(1) {
  width: 18%;
}

.smtp-table th:nth-child(2),
.smtp-table td:nth-child(2),
.smtp-table th:nth-child(4),
.smtp-table td:nth-child(4) {
  width: 21%;
}

.smtp-table th:nth-child(3),
.smtp-table td:nth-child(3),
.smtp-table th:nth-child(5),
.smtp-table td:nth-child(5),
.smtp-table th:nth-child(6),
.smtp-table td:nth-child(6),
.smtp-table th:nth-child(7),
.smtp-table td:nth-child(7) {
  width: 10%;
}

.dashboard-follow-table th:nth-child(1),
.dashboard-follow-table td:nth-child(1) {
  width: 26%;
}

.dashboard-follow-table th:nth-child(2),
.dashboard-follow-table td:nth-child(2) {
  width: 11%;
}

.dashboard-follow-table th:nth-child(3),
.dashboard-follow-table td:nth-child(3) {
  width: 14%;
}

.dashboard-follow-table th:nth-child(4),
.dashboard-follow-table td:nth-child(4) {
  width: 15%;
}

.dashboard-follow-table th:nth-child(5),
.dashboard-follow-table td:nth-child(5) {
  width: 16%;
}

.dashboard-follow-table th:nth-child(6),
.dashboard-follow-table td:nth-child(6) {
  width: 16%;
}

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

.clamp-cell {
  display: grid;
  align-items: start;
  gap: 3px;
  height: 40px;
  overflow: hidden;
}

.clamp-cell[data-expanded="true"] {
  height: auto;
}

.clamp-full,
.clamp-cell[data-expanded="true"] .clamp-short {
  display: none;
}

.clamp-cell[data-expanded="true"] .clamp-full {
  display: inline;
}

.inline-link {
  width: fit-content;
  border: 0;
  background: transparent;
  color: var(--primary-dark);
  padding: 0;
  font-size: 12px;
  font-weight: 700;
}

.session-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 18px 4px 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.session-bar div {
  min-width: 0;
}

.session-bar strong,
.session-bar span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-bar span {
  color: var(--muted);
  font-size: 12px;
}

.login-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-shell {
  width: min(420px, 100%);
}

.login-panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 18px;
}

.login-brand {
  height: auto;
  margin: 0 0 20px;
}

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

.login-button {
  width: 100%;
}

table {
  width: 100%;
  min-width: 880px;
  border-collapse: separate;
  border-spacing: 0;
}

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

th {
  color: #5b6575;
  background: #fafbfc;
  font-size: 12px;
  font-weight: 700;
}

tbody tr:hover {
  background: #fbfdff;
}

tbody tr.clickable-row {
  cursor: pointer;
}

tbody tr.row-hidden,
.deal-card.row-hidden,
.activity-card.row-hidden,
.rule-card.row-hidden,
.metric-card.row-hidden,
.record-card.row-hidden {
  display: none;
}

tbody tr.keyboard-focus,
.deal-card.keyboard-focus,
.activity-card.keyboard-focus,
.rule-card.keyboard-focus,
.metric-card.keyboard-focus,
.record-card.keyboard-focus {
  outline: 2px solid #93c5fd;
  outline-offset: -2px;
}

.cell-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cell-main strong {
  color: #111827;
}

.cell-main span {
  color: var(--muted);
  font-size: 12px;
}

.avatar-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #e2e8f0;
  color: #334155;
  font-size: 12px;
  font-weight: 700;
}

.pill,
.grade,
.tag,
.stage {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 700;
}

.grade-a,
.status-won {
  background: #dcfce7;
  color: #166534;
}

.grade-b,
.status-active {
  background: #dbeafe;
  color: #1d4ed8;
}

.grade-c,
.status-watch {
  background: #fef3c7;
  color: #92400e;
}

.grade-x,
.status-risk {
  background: #fee2e2;
  color: #991b1b;
}

.status-pending {
  background: #ede9fe;
  color: #5b21b6;
}

.status-locked {
  background: #e2e8f0;
  color: #334155;
}

.tag {
  background: #f1f5f9;
  color: #475569;
  font-weight: 600;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 5px 10px;
  color: #334155;
  font-weight: 600;
}

.chip.active {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: var(--primary-dark);
}

.summary-list,
.timeline,
.field-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.summary-item,
.timeline-item,
.field-item {
  display: grid;
  gap: 3px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.summary-item:last-child,
.timeline-item:last-child,
.field-item:last-child {
  border-bottom: 0;
}

.summary-item span,
.timeline-item span,
.field-item span {
  color: var(--muted);
  font-size: 12px;
}

.summary-item strong,
.timeline-item strong,
.field-item strong {
  font-size: 13px;
}

.record-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
}

.record-identity {
  display: flex;
  gap: 14px;
  min-width: 0;
}

.record-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: #eef2ff;
  color: var(--primary);
}

.record-icon i,
.record-icon .icon,
.record-icon svg {
  width: 22px;
  height: 22px;
}

.record-identity h1 {
  margin: 0 0 6px;
  font-size: 22px;
  line-height: 1.2;
}

.meta-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
}

.tab-row {
  border-bottom: 1px solid var(--line);
  padding: 0 16px;
}

.tab {
  min-height: 42px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 9px 4px;
  font-weight: 700;
}

.tab.active {
  border-color: var(--primary);
  color: var(--primary-dark);
}

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

.form-field {
  display: grid;
  gap: 6px;
}

.form-field label {
  color: #475569;
  font-size: 12px;
  font-weight: 700;
}

.form-field.wide {
  grid-column: 1 / -1;
}

.smtp-status {
  display: flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 7px 10px;
  color: var(--muted);
  font-weight: 700;
}

.smtp-status[data-state="ready"] {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #166534;
}

.smtp-status[data-state="pending"] {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}

.smtp-status[data-state="error"] {
  border-color: #fed7aa;
  background: #fff7ed;
  color: var(--red);
}

.dropzone {
  display: grid;
  place-items: center;
  min-height: 188px;
  border: 1.5px dashed #b6c1d1;
  border-radius: 8px;
  background: #f8fafc;
  text-align: center;
  padding: 22px;
}

.dropzone i,
.dropzone .icon,
.dropzone svg {
  width: 32px;
  height: 32px;
  color: var(--primary);
  margin-bottom: 10px;
}

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

.step {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px 10px;
  color: var(--muted);
  font-weight: 700;
}

.step.active {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: var(--primary-dark);
}

.step-index {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #e5e7eb;
  color: #475569;
  font-size: 12px;
}

.step.active .step-index {
  background: var(--primary);
  color: #fff;
}

.kanban {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 12px;
  align-items: start;
}

.stage-card {
  min-height: 340px;
  background: #f8fafc;
  min-width: 0;
}

.stage-head {
  display: flex;
  justify-content: space-between;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
}

.deal-card,
.activity-card {
  display: block;
  margin: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  min-width: 0;
  text-decoration: none;
}

.deal-card h3,
.activity-card h3 {
  margin: 0 0 8px;
  font-size: 14px;
  line-height: 1.35;
  white-space: normal;
  overflow-wrap: anywhere;
}

.deal-card p,
.activity-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  white-space: normal;
  overflow-wrap: anywhere;
}

.deal-list {
  display: grid;
  gap: 0;
}

.mail-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.7fr) minmax(0, 1.3fr);
  gap: 14px;
}

.mail-preview {
  min-height: 520px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.mail-preview-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.mail-body {
  padding: 18px;
  color: #1f2937;
}

.mail-body p {
  margin: 0 0 12px;
}

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

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

.approval-step {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.approval-step strong {
  display: block;
  margin-bottom: 6px;
}

.approval-step span {
  color: var(--muted);
  font-size: 12px;
}

.permission-grid {
  display: grid;
  grid-template-columns: 1.1fr repeat(5, minmax(90px, 0.5fr));
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.permission-grid > div {
  min-height: 42px;
  padding: 10px 12px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fff;
  white-space: nowrap;
}

.permission-grid > div:nth-child(6n) {
  border-right: 0;
}

.permission-grid .head {
  background: #f8fafc;
  color: #475569;
  font-weight: 700;
}

.audit-line {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) 160px;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

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

.audit-line span {
  color: var(--muted);
  font-size: 12px;
}

.audit-line strong {
  display: block;
  margin-bottom: 3px;
}

.rule-card {
  padding: 14px;
}

.rule-card h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.rule-card p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12px;
}

.mini-chart {
  display: flex;
  align-items: end;
  gap: 6px;
  height: 92px;
  padding-top: 12px;
}

.bar {
  width: 100%;
  min-width: 16px;
  border-radius: 4px 4px 0 0;
  background: #9cc7ff;
}

.bar.green {
  background: #8fd7bd;
}

.bar.amber {
  background: #f2c36b;
}

.bar.cyan {
  background: #7dc7d8;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 180px;
  color: var(--muted);
  text-align: center;
}

.empty-state.compact {
  min-height: 86px;
  margin: 10px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: #fff;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  flex-wrap: wrap;
}

.pager-actions,
.button-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pager-size {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
}

.pager-size .select {
  width: 80px;
  min-height: 32px;
}

.utility-panel {
  display: grid;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfdff;
}

.utility-panel[hidden] {
  display: none;
}

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

.utility-panel-grid > div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 9px 10px;
}

.utility-panel-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.utility-panel-grid strong {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.column-setting-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 8px;
}

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

.check-row {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 6px 8px;
  color: #334155;
  font-weight: 700;
}

.col-hidden {
  display: none;
}

.button-row.compact {
  gap: 6px;
}

.button[disabled],
.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.empty-state.compact {
  min-height: 84px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: #f8fafc;
  margin-top: 10px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(360px, calc(100vw - 40px));
  background: #111827;
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
  z-index: 20;
  font-weight: 700;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.42);
  padding: 18px;
  z-index: 30;
}

.modal-panel {
  width: min(820px, 100%);
  max-height: min(88vh, 760px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.modal-header h2 {
  margin: 0;
  font-size: 16px;
}

.modal-body {
  display: grid;
  gap: 14px;
  max-height: calc(min(88vh, 760px) - 56px);
  overflow-y: auto;
  padding: 16px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 4px;
}

.json-preview {
  max-height: 360px;
  overflow: auto;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f172a;
  color: #e2e8f0;
  padding: 12px;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

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

.audit-detail-grid > div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 10px 12px;
}

.audit-detail-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 3px;
}

.audit-detail-grid strong {
  overflow-wrap: anywhere;
}

.control-dirty {
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1280px) {
  .panel-header .core-filter-row,
  .panel-header .audit-filter-row {
    grid-template-columns: minmax(240px, 1.4fr) repeat(3, minmax(122px, 0.75fr));
  }

  .panel-header .review-filter-row {
    grid-template-columns: minmax(240px, 1fr) minmax(128px, 0.55fr) minmax(180px, 0.75fr);
  }

  .panel-header .review-filter-row .filter-badges {
    grid-column: 1 / -1;
  }
}

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

  .page-grid.two,
  .mail-layout,
  .approval-flow {
    grid-template-columns: minmax(0, 1fr);
  }

  .panel-header .core-filter-row,
  .panel-header .review-queue-filter-row,
  .panel-header .audit-filter-row {
    grid-template-columns: minmax(240px, 1.2fr) repeat(2, minmax(132px, 0.9fr));
  }
}

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

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-section {
    margin: 10px 0;
  }

  .nav-section .nav-link {
    display: inline-flex;
    margin: 2px;
  }

  .main {
    padding: 14px;
  }

  .topbar,
  .record-header,
  .panel-header {
    align-items: stretch;
    flex-direction: column;
  }

  .panel-header .filter-row {
    flex: 0 0 auto;
    width: 100%;
    grid-template-columns: 1fr;
  }

  .panel-title-block {
    flex-basis: auto;
    min-width: 0;
  }

  .panel-header .toolbar,
  .panel-header > .button {
    width: 100%;
    justify-content: flex-start;
  }

  .filter-badges {
    grid-column: auto;
  }

  .metric-grid,
  .rule-grid,
  .form-grid,
  .stepper,
  .approval-flow {
    grid-template-columns: 1fr;
  }

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

  table {
    min-width: 760px;
  }

  .dashboard-follow-table {
    min-width: 0;
  }

  .utility-panel-grid,
  .column-setting-grid {
    grid-template-columns: 1fr;
  }
}
