:root {
  --bg: #f4efe8;
  --bg-accent: #efe2d2;
  --surface: rgba(255, 250, 245, 0.82);
  --surface-strong: #fffaf5;
  --text: #231815;
  --muted: #6d5e55;
  --line: rgba(65, 39, 22, 0.12);
  --primary: #bd5b35;
  --primary-dark: #8f3f22;
  --warning: #e6a33a;
  --danger: #cb4d38;
  --success: #287b57;
  --shadow: 0 20px 50px rgba(63, 32, 16, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Aptos", "Segoe UI Variable", "Trebuchet MS", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top left, #f8e4cc 0%, var(--bg) 42%, #f7f3ef 100%);
}

.shell-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 80% 10%, rgba(189, 91, 53, 0.18), transparent 22%),
    radial-gradient(circle at 18% 78%, rgba(230, 163, 58, 0.14), transparent 20%);
}

.layout {
  position: relative;
  max-width: 100%;
  margin: 0 auto;
  padding: 20px;
}

.topbar,
.panel,
.hero-panel,
.form-panel,
.stat-card,
.hero-strip {
  backdrop-filter: blur(16px);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.topbar,
.hero-strip,
.panel,
.hero-panel,
.form-panel,
.stat-card {
  border-radius: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  margin-bottom: 16px;
}

.brand-title,
h2,
h3,
h4 {
  margin: 0;
  font-family: "Georgia", "Times New Roman", serif;
  letter-spacing: -0.02em;
}

.brand-title {
  font-size: 1.7rem;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--muted);
}

.lead {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
}

.topbar-actions,
.user-chip,
.hero-metrics,
.stats-grid,
.toolbar,
.validation-boxes,
.action-bar,
.detail-badges,
.hero-actions,
.upload-actions,
.upload-meta,
.compact-row,
.ocr-header {
  display: flex;
  gap: 12px;
  align-items: center;
}

.user-chip {
  background: var(--surface-strong);
  border: 1px solid var(--line);
  padding: 10px 14px;
  border-radius: 999px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, #72d28b, #2f8d5e);
  display: inline-block;
}

.flash-stack {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.flash {
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
}

.flash-success {
  background: rgba(40, 123, 87, 0.12);
}

.flash-error {
  background: rgba(203, 77, 56, 0.12);
}

.login-page {
  min-height: calc(100vh - 56px);
  display: grid;
  grid-template-columns: 1.35fr 0.9fr;
  gap: 22px;
  align-items: center;
}

.login-panel,
.panel,
.hero-strip {
  padding: 24px;
}

.hero-panel {
  min-height: 520px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 32px;
}

.hero-panel h2 {
  font-size: clamp(2rem, 4vw, 4.25rem);
  line-height: 1.03;
  max-width: 10ch;
}

.hero-metrics,
.stats-grid {
  flex-wrap: wrap;
}

.metric-card,
.stat-card,
.validation-card {
  min-width: 150px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
}

.metric-card span,
.stat-card span,
.validation-card span {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
}

.metric-card strong,
.stat-card strong,
.validation-card strong {
  font-size: 1.4rem;
}

.form-panel {
  padding: 28px;
}

.azure-login-block {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.azure-login-button {
  width: 100%;
  text-align: center;
}

.login-divider {
  position: relative;
  margin: 18px 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
}

.login-divider::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: var(--line);
}

.login-divider span {
  position: relative;
  padding: 0 12px;
  background: rgba(255, 250, 245, 0.92);
}

.panel-heading {
  margin-bottom: 18px;
}

.stack-form,
.page-stack {
  display: grid;
  gap: 20px;
}

.stack-form label,
.field-grid label {
  display: grid;
  gap: 8px;
}

.stack-form input,
.stack-form select,
.stack-form textarea,
.toolbar input,
.toolbar select {
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(80, 47, 27, 0.14);
  padding: 13px 14px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--text);
  font: inherit;
}

.stack-form textarea {
  resize: vertical;
}

.admin-section-grid,
.catalog-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.admin-settings-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.56);
}

.catalog-table-wrap {
  overflow-x: auto;
}

.catalog-table input,
.catalog-table select {
  min-width: 140px;
}

.primary-button,
.ghost-button,
.danger-button {
  border: 0;
  border-radius: 14px;
  padding: 12px 18px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.primary-button:hover,
.ghost-button:hover,
.danger-button:hover {
  transform: translateY(-1px);
}

.primary-button {
  color: white;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  box-shadow: 0 12px 24px rgba(143, 63, 34, 0.28);
}

.ghost-button {
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
  color: var(--text);
  text-decoration: none;
}

.back-button {
  display: inline-flex;
  margin-bottom: 14px;
}

.danger-button {
  background: rgba(203, 77, 56, 0.14);
  color: var(--danger);
  border: 1px solid rgba(203, 77, 56, 0.22);
}

.hint-text {
  margin: 0;
  color: var(--muted);
}

.hero-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.status-buckets-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

.status-filter-card {
  text-decoration: none;
  color: inherit;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.status-filter-card:hover {
  transform: translateY(-2px);
}

.status-filter-card.is-active {
  border-color: rgba(189, 91, 53, 0.48);
  box-shadow: 0 16px 30px rgba(143, 63, 34, 0.18);
  background: rgba(255, 245, 236, 0.92);
}

.warning {
  background: rgba(230, 163, 58, 0.16);
}

.toolbar {
  justify-content: space-between;
  margin-bottom: 18px;
}

.toolbar input {
  flex: 1;
}

.upload-panel {
  display: grid;
  gap: 16px;
}

.compact-row {
  justify-content: space-between;
}

.upload-form {
  display: grid;
  gap: 16px;
}

.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;
}

.dropzone {
  display: grid;
  gap: 10px;
  min-height: 180px;
  place-items: center;
  text-align: center;
  padding: 28px;
  border-radius: 24px;
  border: 2px dashed rgba(189, 91, 53, 0.32);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 248, 241, 0.92)),
    radial-gradient(circle at top right, rgba(230, 163, 58, 0.18), transparent 28%);
  cursor: pointer;
  transition: border-color 140ms ease, transform 140ms ease, background 140ms ease;
}

.dropzone:hover,
.dropzone.is-dragover {
  transform: translateY(-2px);
  border-color: var(--primary);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(255, 243, 232, 1)),
    radial-gradient(circle at top right, rgba(189, 91, 53, 0.2), transparent 28%);
}

.dropzone-kicker {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.78rem;
  color: var(--primary-dark);
}

.dropzone strong {
  font-size: 1.5rem;
  font-family: "Georgia", "Times New Roman", serif;
}

.dropzone p {
  max-width: 56ch;
  color: var(--muted);
  margin: 0;
}

.upload-actions {
  justify-content: space-between;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 16px 14px;
  border-bottom: 1px solid var(--line);
}

tbody tr {
  cursor: pointer;
  transition: background 140ms ease;
}

tbody tr:hover {
  background: rgba(189, 91, 53, 0.07);
}

.table-subject,
small,
.empty-state,
.audit-meta {
  color: var(--muted);
}

.status-badge,
.confidence-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 0.82rem;
  font-weight: 700;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.status-review_required,
.status-callback_failed,
.status-email_failed,
.status-failed,
.low {
  background: rgba(203, 77, 56, 0.12);
  color: #8f2f22;
}

.status-second_opinion {
  background: rgba(56, 96, 203, 0.12);
  color: #25419a;
}

.status-ready_for_review,
.status-processing,
.status-not_sent,
.warning-card {
  background: rgba(230, 163, 58, 0.16);
  color: #7f5514;
}

.status-approved,
.status-completed,
.status-email_sent,
.status-sent,
.high,
.error-card {
  background: rgba(40, 123, 87, 0.12);
  color: #1f6849;
}

.status-disabled,
.status-not_configured {
  background: rgba(230, 163, 58, 0.16);
  color: #7f5514;
}

.status-rejected {
  background: rgba(61, 50, 44, 0.13);
  color: #43352e;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr);
  gap: 16px;
  min-height: 0;
}

.case-body-grid {
  align-items: stretch;
  height: calc(100vh - 250px);
}

.panel-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.document-frame {
  width: 100%;
  min-height: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: white;
}

.document-image {
  width: 100%;
  max-height: 100%;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: white;
}

.document-text-preview {
  min-height: 100%;
  margin: 0;
  padding: 18px;
  white-space: pre-wrap;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: white;
  font-family: "Consolas", "Cascadia Mono", monospace;
  font-size: 0.92rem;
}

.excel-preview-wrap {
  display: grid;
  gap: 14px;
}

.excel-preview-meta {
  display: flex;
  gap: 10px;
  align-items: center;
}

.excel-table-wrap {
  overflow: auto;
  max-height: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: white;
}

.excel-preview-table td {
  min-width: 140px;
  vertical-align: top;
  background: rgba(255, 255, 255, 0.94);
}

.document-fallback {
  min-height: 240px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.5);
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.document-panel,
.form-panel-wide {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.document-panel {
  overflow: hidden;
  min-height: 0;
  height: 100%;
}

.document-panel .panel-header-row {
  margin-bottom: 8px;
}

.form-panel-wide {
  overflow: auto;
  gap: 8px;
}

.case-workspace {
  display: grid;
  gap: 12px;
  height: calc(100vh - 120px);
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.review-column {
  display: grid;
  grid-template-rows: 132px minmax(0, 1fr);
  gap: 12px;
  min-height: 0;
  height: 100%;
}

.suggestions-panel {
  display: grid;
  gap: 8px;
  padding-top: 12px;
  padding-bottom: 12px;
}

.inline-suggestions-panel {
  min-height: 0;
  overflow: hidden;
}

.suggestion-grid-wide {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  max-height: none;
  height: 100%;
  overflow: auto;
}

.top-suggestion-grid {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(170px, 220px);
  grid-template-columns: none;
  overflow-x: auto;
  overflow-y: hidden;
  align-items: stretch;
  padding-bottom: 4px;
}

.field-span-2 {
  grid-column: span 2;
}

.toggle-field {
  display: flex !important;
  align-items: center;
  gap: 12px !important;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.toggle-field input {
  width: auto;
}

.validation-list-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.ocr-section {
  display: grid;
  gap: 14px;
}

.ocr-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.55);
}

.ocr-header {
  justify-content: space-between;
}

.suggestion-grid,
.ocr-lines {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.suggestion-chip,
.ocr-line-chip {
  border: 1px solid rgba(189, 91, 53, 0.16);
  background: rgba(255, 251, 247, 0.94);
  border-radius: 16px;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.suggestion-chip {
  display: grid;
  gap: 4px;
  min-width: 0;
  max-width: 100%;
}

.compact-suggestion-chip {
  padding: 8px 10px;
  border-radius: 14px;
}

.ocr-line-chip {
  max-width: 100%;
}

.suggestion-chip:hover,
.ocr-line-chip:hover {
  transform: translateY(-1px);
  border-color: var(--primary);
  box-shadow: 0 10px 24px rgba(143, 63, 34, 0.12);
}

.suggestion-field {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.76rem;
}

.empty-inline {
  color: var(--muted);
}

.validation-list-grid ul,
.audit-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.validation-list-grid li,
.audit-item {
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 10px 12px;
}

.separate-actions {
  justify-content: flex-end;
}

.action-bar-start {
  justify-content: flex-start;
}

.admin-menu-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.admin-menu-link {
  padding: 12px 16px;
  border-radius: 14px;
  text-decoration: none;
  color: var(--text);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.66);
}

.admin-menu-link.is-active {
  background: linear-gradient(135deg, rgba(189, 91, 53, 0.16), rgba(230, 163, 58, 0.16));
  border-color: rgba(189, 91, 53, 0.35);
}

.single-column-grid {
  grid-template-columns: 1fr;
}

.danger-surface {
  background: rgba(203, 77, 56, 0.08);
}

.inline-form-actions {
  gap: 10px;
}

.simple-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.audit-list {
  display: grid;
  gap: 12px;
}

.embedded-audit-section {
  display: grid;
  gap: 12px;
  margin-top: 8px;
}

.embedded-audit-list {
  max-height: 84px;
  overflow: auto;
}

.case-review-form {
  gap: 10px;
}

.detail-hero {
  align-items: flex-start;
  gap: 10px;
  padding-top: 10px;
  padding-bottom: 10px;
  min-height: 82px;
}

.detail-hero h2 {
  font-size: clamp(1.12rem, 1.7vw, 1.55rem);
}

.detail-hero .lead {
  font-size: 0.84rem;
  line-height: 1.25;
  margin-top: 2px;
}

.detail-badges {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.validation-boxes {
  flex-wrap: nowrap;
  gap: 8px;
}

.validation-card {
  min-width: 0;
  flex: 1;
  padding: 8px 10px;
  border-radius: 14px;
}

.validation-card strong {
  font-size: 1rem;
}

.document-panel .panel-header-row h3,
.form-panel-wide .panel-header-row h3,
.suggestions-panel .panel-header-row h3,
.embedded-audit-section h4 {
  font-size: 1.05rem;
}

.review-actions-row {
  justify-content: space-between;
}

.review-actions-row .primary-button,
.review-actions-row .ghost-button,
.detail-hero .ghost-button,
.form-panel-wide .ghost-button,
.danger-button {
  padding: 9px 14px;
  border-radius: 12px;
  font-size: 0.92rem;
}

.compact-validation-list-grid h4 {
  margin-bottom: 6px;
  font-size: 0.95rem;
}

.compact-textarea-field textarea {
  min-height: 70px;
}

.notes-field textarea {
  min-height: 48px;
}

.compact-badges {
  flex-wrap: wrap;
  gap: 8px;
}

.field-grid label > span,
.suggestion-chip strong,
.suggestion-chip small,
.validation-list-grid li,
.embedded-audit-section,
.hint-text,
small {
  font-size: 0.8rem;
}

.suggestion-chip strong {
  font-size: 0.92rem;
}

.suggestion-chip small {
  line-height: 1.2;
}

.separate-secondary-action {
  margin-top: -4px;
}

.audit-disclosure {
  margin-top: 4px;
}

.audit-summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  list-style: none;
}

.audit-summary-row::-webkit-details-marker {
  display: none;
}

.audit-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.audit-meta {
  display: grid;
  text-align: right;
  min-width: 180px;
}

@media (max-width: 1100px) {
  .login-page,
  .detail-grid,
  .stats-grid,
  .status-buckets-grid,
  .validation-list-grid,
  .admin-section-grid,
  .catalog-grid {
    grid-template-columns: 1fr;
  }

  .hero-strip,
  .topbar,
  .toolbar,
  .action-bar,
  .audit-item,
  .upload-actions,
  .compact-row,
  .ocr-header {
    flex-direction: column;
    align-items: stretch;
  }

  .field-grid {
    grid-template-columns: 1fr;
  }

  .validation-boxes {
    flex-wrap: wrap;
  }

  .field-span-2 {
    grid-column: span 1;
  }

  .document-frame {
    min-height: 420px;
  }

  .case-workspace {
    height: auto;
    overflow: visible;
  }

  .review-column {
    grid-template-rows: auto;
    min-height: 0;
    height: auto;
  }

  .case-body-grid {
    height: auto;
  }

  .suggestion-grid-wide,
  .form-panel-wide,
  .document-panel {
    max-height: none;
    overflow: visible;
  }

  .top-suggestion-grid {
    grid-auto-flow: row;
    grid-auto-columns: auto;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    overflow: visible;
  }

  .document-panel {
    min-height: 0;
  }
}

/* ===== ULTRA COMPACT LAYOUT ===== */
.case-workspace-ultra {
  display: grid;
  gap: 6px;
  height: calc(100vh - 75px);
  grid-template-rows: auto minmax(0, 1fr);
}

.ultra-compact-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  backdrop-filter: blur(16px);
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.compact-back-link {
  text-decoration: none;
  color: var(--primary-dark);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(189, 91, 53, 0.08);
}

.compact-back-link:hover {
  background: rgba(189, 91, 53, 0.15);
}

.inline-case-title {
  margin: 0;
  font-size: 1.2rem;
  font-family: "Georgia", "Times New Roman", serif;
  letter-spacing: -0.02em;
}

.inline-subject {
  color: var(--muted);
  font-size: 0.88rem;
}

.micro-text {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.ultra-body-grid {
  display: grid;
  grid-template-columns: 0.75fr 1fr;
  gap: 8px;
  min-height: 0;
  height: 100%;
}

.compact-document-panel,
.ultra-compact-form-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px;
  backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
}

.compact-document-panel {
  overflow: hidden;
  max-height: calc(100vh - 115px);
}

.ultra-compact-form-panel {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.micro-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
  flex-shrink: 0;
}

.micro-header-left {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.micro-header strong {
  font-size: 1.15rem;
  font-family: "Georgia", "Times New Roman", serif;
  color: var(--text);
}

.micro-badge {
  display: inline-flex;
  padding: 3px 8px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 700;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.error-badge {
  background: rgba(40, 123, 87, 0.12);
  color: #1f6849;
}

.warning-badge {
  background: rgba(230, 163, 58, 0.16);
  color: #7f5514;
}

.micro-button,
.micro-button-primary,
.micro-button-danger {
  border: 0;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 100ms ease, background 100ms ease;
}

.micro-button {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--line);
  color: var(--text);
}

.micro-button-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
}

.micro-button-danger {
  background: rgba(203, 77, 56, 0.14);
  color: var(--danger);
  border: 1px solid rgba(203, 77, 56, 0.22);
}

.micro-button:hover,
.micro-button-primary:hover,
.micro-button-danger:hover {
  transform: translateY(-1px);
}

.datetime-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px;
  gap: 8px;
}

.datetime-part-group {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  position: relative;
}

.datetime-time-group {
  grid-template-columns: minmax(0, 1fr) auto;
}

.datetime-part-input {
  min-width: 0;
}

.datetime-picker-button {
  border: 1px solid var(--line);
  background: white;
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.75rem;
  cursor: pointer;
}

.native-picker-input {
  position: absolute;
  inset: auto 0 0 auto;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.compact-document-frame,
.compact-document-image {
  width: 100%;
  height: 100%;
  min-height: 240px;
  max-height: calc(100vh - 155px);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  object-fit: contain;
}

iframe.compact-document-frame {
  height: calc(100vh - 220px);
  min-height: 680px;
}

.document-preview-stack {
  display: grid;
  gap: 10px;
}

.document-preview-hints {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.compact-document-text {
  margin: 0;
  padding: 8px;
  min-height: 240px;
  max-height: calc(100vh - 160px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  font-family: "Consolas", "Cascadia Mono", monospace;
  font-size: 0.75rem;
  white-space: pre-wrap;
}

.compact-fallback {
  min-height: 120px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.5);
  font-size: 0.75rem;
  color: var(--muted);
}

.compact-excel-wrap {
  display: grid;
  gap: 6px;
}

.micro-meta {
  display: flex;
  gap: 6px;
  align-items: center;
}

.compact-table-wrap {
  overflow: auto;
  max-height: calc(100vh - 200px);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
}

.micro-link {
  font-size: 0.75rem;
  padding: 4px 8px;
  text-decoration: none;
  color: var(--primary-dark);
  background: rgba(189, 91, 53, 0.08);
  border-radius: 6px;
  display: inline-block;
}

.inline-ocr-suggestions {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 6px 0;
  flex-wrap: nowrap;
  min-height: 64px;
  align-items: flex-start;
  flex-shrink: 0;
}

.micro-chip {
  display: grid;
  gap: 3px;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid rgba(189, 91, 53, 0.16);
  background: rgba(255, 251, 247, 0.94);
  text-align: left;
  cursor: pointer;
  transition: border-color 100ms ease, transform 100ms ease;
  min-width: 140px;
  flex-shrink: 0;
}

.micro-chip:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}

.chip-label {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.74rem;
  font-weight: 600;
}

.micro-chip strong {
  font-size: 0.98rem;
  word-break: break-word;
}

.micro-chip small {
  font-size: 0.76rem;
  color: var(--muted);
}

.ultra-compact-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.ultra-field-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  flex-shrink: 0;
}

.ultra-field-grid label {
  display: grid;
  gap: 3px;
  grid-column: span 2;
}

.ultra-field-grid label > span {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}

.ultra-field-grid input,
.ultra-field-grid select,
.ultra-field-grid textarea {
  width: 100%;
  border-radius: 8px;
  border: 1px solid rgba(80, 47, 27, 0.14);
  padding: 8px 11px;
  background: rgba(255, 255, 255, 0.85);
  color: var(--text);
  font: inherit;
  font-size: 0.94rem;
}

.ultra-field-grid textarea {
  resize: vertical;
  min-height: 38px;
  max-height: 120px;
}

.ultra-field-grid small {
  font-size: 0.78rem;
  color: var(--muted);
}

.span-3 {
  grid-column: span 6 !important;
}

.span-half {
  grid-column: span 3 !important;
}

.toggle-compact {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 6px !important;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.toggle-compact input {
  width: auto !important;
}

.toggle-compact span {
  font-size: 0.88rem;
}

.ultra-validation-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 2px;
  flex-shrink: 0;
}

.micro-heading {
  font-size: 0.92rem;
  font-weight: 700;
  margin-bottom: 4px;
  display: block;
}

.micro-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 3px;
}

.micro-list li {
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 0.84rem;
}

.ultra-action-bar {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-top: 4px;
  flex-shrink: 0;
}

.action-group-left {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.micro-audit {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}

.micro-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  list-style: none;
  font-size: 0.75rem;
}

.micro-summary::-webkit-details-marker {
  display: none;
}

.micro-audit-list {
  display: grid;
  gap: 4px;
  margin-top: 6px;
  max-height: 120px;
  overflow: auto;
}

.micro-audit-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 6px;
}

.micro-audit-item strong {
  font-size: 0.72rem;
}

.micro-audit-item p {
  margin: 0;
  font-size: 0.68rem;
  color: var(--muted);
}

.micro-audit-meta {
  display: grid;
  text-align: right;
  font-size: 0.65rem;
  color: var(--muted);
  min-width: 140px;
}

@media (max-width: 1200px) {
  .ultra-body-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }
  
  .compact-document-panel {
    max-height: 320px;
  }
  
  .ultra-field-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .ultra-field-grid {
    grid-template-columns: 1fr;
  }
  
  .span-3 {
    grid-column: span 1;
  }
}