:root {
  --color-bg: #f5f6f7;
  --color-surface: #ffffff;
  --color-border: #d2d6dc;
  --color-accent: #2d6cdf;
  --color-accent-muted: #eef3ff;
  --color-text: #1f2933;
  --color-muted: #606f7b;
  --color-label: #1f3c88;
  --color-error: #dc2626;
  --color-bg-secondary: #f8f9fa;
  --sidebar-width: 260px;
  --font-body: "Segoe UI", Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--color-text);
  background: var(--color-bg);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  gap: 1rem;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.brand .logo {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-accent);
}

.brand .subtitle {
  font-size: 0.85rem;
  color: var(--color-muted);
}

.case-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.case-selector select {
  min-width: 220px;
  padding: 0.35rem 0.5rem;
  border-radius: 0.4rem;
  border: 1px solid var(--color-border);
  font-size: 0.95rem;
}

.case-selector button {
  padding: 0.3rem 0.6rem;
  border-radius: 0.4rem;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  cursor: pointer;
}

.case-selector #new-case {
  background: var(--color-accent-muted);
  border-color: var(--color-accent);
  color: var(--color-label);
  font-weight: 600;
}

.case-selector #new-case:hover {
  background: var(--color-accent);
  color: #ffffff;
}

.case-selector button:hover {
  background: var(--color-accent-muted);
}

.actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.user-info {
  position: relative;
  margin-left: 0.5rem;
  padding-left: 0.75rem;
  border-left: 1px solid var(--color-border);
}

.user-menu-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: transparent;
  border: none;
  padding: 0.4rem 0.6rem;
  font-size: 0.9rem;
  color: var(--color-text);
  font-weight: 500;
  cursor: pointer;
  border-radius: 0.4rem;
  transition: background 0.2s;
}

.profile-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
  background: var(--color-accent);
  color: white;
  overflow: hidden;
  flex-shrink: 0;
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-menu-toggle:hover {
  background: var(--color-accent-muted);
}

.user-menu-arrow {
  font-size: 0.7rem;
  color: var(--color-muted);
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  min-width: 150px;
  z-index: 1000;
}

.user-dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  color: var(--color-text);
  cursor: pointer;
  transition: background 0.2s;
  border-radius: 0.5rem;
}

.user-dropdown-item:hover {
  background: #fee;
  color: #c33;
}

/* Notification Bell */
.notification-bell-container {
  position: relative;
  margin-left: 0.5rem;
  padding-left: 0.75rem;
  border-left: 1px solid var(--color-border);
}

.notification-bell-button {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  padding: 0.5rem;
  color: var(--color-text);
  cursor: pointer;
  border-radius: 0.4rem;
  transition: background 0.2s, color 0.2s;
}

.notification-bell-button:hover {
  background: var(--color-accent-muted);
  color: var(--color-accent);
}

.notification-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: #ef4444;
  color: white;
  border-radius: 50%;
  min-width: 18px;
  height: 18px;
  font-size: 0.7rem;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.notification-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  width: 380px;
  max-height: 500px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
}

.notification-dropdown[hidden] {
  display: none;
}

.notification-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border);
}

.notification-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
}

.notification-header-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.mark-all-read-btn,
.clear-all-btn {
  background: transparent;
  border: none;
  padding: 0.4rem;
  color: var(--color-muted);
  cursor: pointer;
  border-radius: 0.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}

.mark-all-read-btn:hover {
  background: var(--color-accent-muted);
  color: var(--color-accent);
}

.clear-all-btn:hover {
  background: rgba(220, 38, 38, 0.1);
  color: rgb(220, 38, 38);
}

.notification-list {
  overflow-y: auto;
  max-height: 420px;
}

.notification-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--color-muted);
  font-size: 0.9rem;
}

.notification-item {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.notification-item:hover {
  background: var(--color-accent-muted);
}

.notification-item.unread {
  background: #f0f9ff;
}

.notification-item.unread:hover {
  background: #e0f2fe;
}

.notification-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 600;
}

.notification-content {
  flex: 1;
  min-width: 0;
}

.notification-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text);
  margin: 0 0 0.25rem 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.notification-unread-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3b82f6;
  flex-shrink: 0;
}

.notification-message {
  font-size: 0.85rem;
  color: var(--color-muted);
  margin: 0 0 0.25rem 0;
  line-height: 1.4;
}

.notification-time {
  font-size: 0.75rem;
  color: var(--color-muted);
}

button {
  font-family: inherit;
  font-size: 0.95rem;
  border: 1px solid var(--color-border);
  border-radius: 0.6rem;
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  background: var(--color-surface);
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

/* Case Info Hamburger Menu */
.case-info-menu-container {
  position: relative;
  margin-left: 0.5rem;
  margin-right: 0.5rem;
}

.case-info-menu-button {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  padding: 0.5rem;
  color: var(--color-text);
  cursor: pointer;
  border-radius: 0.4rem;
  transition: background 0.2s, color 0.2s;
}

.case-info-menu-button:hover:not(:disabled) {
  background: var(--color-accent-muted);
  color: var(--color-accent);
}

.case-info-menu-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.case-info-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  min-width: 220px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.case-info-dropdown[hidden] {
  display: none;
}

.case-info-menu-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  color: var(--color-text);
  cursor: pointer;
  transition: background 0.2s;
  font-size: 0.95rem;
}

.case-info-menu-item:hover {
  background: var(--color-hover);
}

.case-info-menu-item svg {
  flex-shrink: 0;
  color: var(--color-muted);
}

.case-info-menu-item:hover svg {
  color: var(--color-accent);
}

.case-info-menu-item + .case-info-menu-item {
  border-top: 1px solid var(--color-border);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

button.primary {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
}

button.primary:not(:disabled):hover {
  box-shadow: 0 0 0 3px rgba(45, 108, 223, 0.18);
}

.danger-button {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #b42318;
  padding: 0.3rem 0.6rem;
}

.danger-button:not(:disabled):hover {
  background: #fecaca;
}

.app-shell {
  position: fixed;
  top: 60px;
  left: 0;
  right: 0;
  bottom: 40px;
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
}

.sidebar {
  background: linear-gradient(180deg, #f7f9fc 0%, #f0f4fb 100%);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  padding: 1rem 0.75rem;
  gap: 1.5rem;
  overflow-y: auto;
  transition: width 0.2s ease, padding 0.2s ease;
  position: relative;
}

/* Sidebar toggle button - tab style on edge */
.sidebar-toggle {
  position: fixed;
  top: 50%;
  left: 280px;
  transform: translateY(-50%);
  width: 20px;
  height: 48px;
  border: 1px solid var(--color-border);
  border-left: none;
  border-radius: 0 6px 6px 0;
  background: var(--color-surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--color-muted);
  z-index: 1000;
  transition: left 0.2s ease, background 0.15s ease;
  box-shadow: 2px 0 4px rgba(0, 0, 0, 0.08);
}

.sidebar-toggle:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
}

.sidebar-toggle .toggle-icon {
  transition: transform 0.2s ease;
}

/* Collapsed sidebar state */
.sidebar.collapsed {
  width: 0 !important;
  min-width: 0;
  padding: 0;
  overflow: hidden;
}

.app-shell.sidebar-collapsed .sidebar-toggle {
  left: 0;
}

.sidebar.collapsed .sidebar-toggle .toggle-icon {
  transform: rotate(180deg);
}

.sidebar.collapsed .audit-section,
.sidebar.collapsed .case-summary,
.sidebar.collapsed .case-closeout-section,
.sidebar.collapsed .review-section {
  display: none;
}

/* App shell adjustment for collapsed sidebar */
.app-shell.sidebar-collapsed {
  grid-template-columns: 0 1fr;
}

.audit-section {
  background: rgba(255, 255, 255, 0.85);
  border-radius: 0.75rem;
  padding: 0.9rem 0.8rem;
  border: 1px solid rgba(210, 214, 220, 0.6);
}

.audit-section h2 {
  font-size: 0.95rem;
  margin: 0 0 0.6rem 0;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.audit-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.tab-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.tab-button {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-radius: 0.4rem;
  border: none;
  background: transparent;
  color: var(--color-muted);
  font-size: 0.95rem;
}

.tab-button:hover,
.tab-button:focus {
  background: var(--color-accent-muted);
  color: var(--color-accent);
  outline: none;
}

.tab-button.active {
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--color-accent);
  color: var(--color-accent);
  font-weight: 600;
}

.case-summary {
  background: rgba(255, 255, 255, 0.85);
  border-radius: 0.75rem;
  padding: 0.9rem 0.8rem;
  border: 1px solid rgba(210, 214, 220, 0.6);
}

.case-summary h2 {
  font-size: 0.95rem;
  margin: 0 0 0.6rem 0;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.case-summary dl {
  margin: 0;
  display: grid;
  gap: 0.5rem;
}

.case-summary dt {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-muted);
}

.case-summary dt.clickable-label {
  cursor: pointer;
  transition: color 0.2s, text-decoration 0.2s;
}

.case-summary dt.clickable-label:hover {
  color: var(--color-accent);
  text-decoration: underline;
}

.case-summary dd {
  margin: 0;
  font-weight: 600;
  color: var(--color-text);
}

.case-closeout-section {
  background: rgba(255, 255, 255, 0.85);
  border-radius: 0.75rem;
  padding: 0.9rem 0.8rem;
  border: 1px solid rgba(210, 214, 220, 0.6);
  margin-top: 1rem;
}

.case-closeout-section h2 {
  font-size: 0.95rem;
  margin: 0 0 0.6rem 0;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.review-section {
  background: rgba(255, 255, 255, 0.85);
  border-radius: 0.75rem;
  padding: 0.9rem 0.8rem;
  border: 1px solid rgba(210, 214, 220, 0.6);
  margin-top: 1rem;
}

.review-section h2 {
  font-size: 0.95rem;
  margin: 0 0 0.6rem 0;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.review-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.admin-section {
  background: rgba(255, 255, 255, 0.85);
  border-radius: 0.75rem;
  padding: 0.9rem 0.8rem;
  border: 1px solid rgba(210, 214, 220, 0.6);
  margin-top: 1rem;
}

.admin-section h2 {
  font-size: 0.95rem;
  margin: 0 0 0.6rem 0;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.admin-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.content-area {
  padding: 1.25rem 1.75rem;
  overflow-y: auto;
  background: var(--color-bg);
}

#status-bar {
  min-height: 1.2rem;
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
  color: var(--color-muted);
}

.status-success {
  color: #0c6b34;
}

.status-error {
  color: #b42318;
}

.tab-content {
  background: var(--color-surface);
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
  border: 1px solid rgba(210, 214, 220, 0.6);
  min-height: calc(100% - 2rem);
}

.section-title {
  margin-top: 0;
  margin-bottom: 1rem;
  font-size: 1.1rem;
  font-weight: 600;
}

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

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

.form-field label {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-label);
  font-weight: 600;
}

.form-field input,
.form-field select,
.form-field textarea {
  padding: 0.45rem 0.55rem;
  border-radius: 0.5rem;
  border: 1px solid var(--color-border);
  font-size: 0.95rem;
  font-family: inherit;
  background: #fff;
}

.form-field textarea {
  min-height: 120px;
  resize: vertical;
}

.form-hint {
  margin: 0 0 0.75rem;
  font-size: 0.82rem;
  color: var(--color-muted);
}

.state-selector {
  margin-top: 1.5rem;
  padding: 1.15rem;
}

.state-selector-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.state-badge-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.state-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--color-accent-muted);
  color: var(--color-label);
  font-size: 0.8rem;
  font-weight: 600;
}

.state-badge.empty {
  background: #f1f5f9;
  color: var(--color-muted);
  font-weight: 500;
}

.state-checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(52px, 1fr));
  gap: 0.4rem 0.75rem;
}

.state-checkbox {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--color-text);
}

.state-checkbox input {
  width: 1rem;
  height: 1rem;
}

.inline-group {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.flags-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
}

.flags-grid .form-field select {
  min-width: 0;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
  overflow: hidden;
}

.data-table thead {
  background: var(--color-accent-muted);
  color: var(--color-text);
  font-size: 0.85rem;
}

.data-table th,
.data-table td {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
}

.data-table tbody tr:hover {
  background: rgba(45, 108, 223, 0.06);
}

.data-table input,
.data-table select {
  width: 100%;
  border-radius: 0.35rem;
  border: 1px solid var(--color-border);
  padding: 0.3rem 0.45rem;
  font-size: 0.9rem;
}

.class-code-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0.75rem 0;
}

.group-header-row {
  background: #f1f5f9;
}

.group-header-cell {
  font-weight: 600;
  padding: 0.75rem;
  border-top: 2px solid #cbd5e1;
}

.group-header-label {
  color: #475569;
}

.group-header-separator {
  margin: 0 0.5rem;
  color: #cbd5e1;
}

.class-code-library {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
}

.class-code-library__controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.class-code-library__controls input {
  min-width: 220px;
  max-width: 320px;
}

.class-code-library__results {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: 0.6rem;
  padding: 0.5rem;
  background: var(--color-bg);
}

.compact-table {
  font-size: 0.85rem;
}

.compact-table th,
.compact-table td {
  padding: 0.35rem 0.45rem;
}

.entity-summary {
  margin-top: 1.5rem;
}

.muted-text {
  color: var(--color-muted);
  margin: 0.2rem 0;
}

.error-text {
  color: #b91c1c;
  margin: 0.2rem 0;
}

.location-summary {
  margin-top: 1.5rem;
}

.location-summary-table {
  margin-top: 0.75rem;
  table-layout: fixed;
}

.location-summary-table th:first-child,
.location-summary-table td:first-child {
  width: 200px;
  vertical-align: top;
}

.location-summary-table td {
  vertical-align: top;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border-radius: 2rem;
  padding: 0.15rem 0.6rem;
  font-size: 0.75rem;
  background: var(--color-accent-muted);
  color: var(--color-accent);
}

.two-column {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.card {
  background: #fff;
  border: 1px solid rgba(210, 214, 220, 0.7);
  border-radius: 0.75rem;
  padding: 1rem;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.05);
}

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

.list-selector select {
  flex: 1;
  padding: 0.4rem 0.5rem;
  border-radius: 0.5rem;
  border: 1px solid var(--color-border);
}

.list-selector button {
  padding: 0.4rem 0.6rem;
}

.app-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1.25rem;
  font-size: 0.85rem;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  color: var(--color-muted);
}

#dirty-indicator.dirty {
  color: #b42318;
}

/* Removed 980px media query - collapsible sidebar handles small screens */

@media (max-width: 640px) {
  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .case-selector {
    width: 100%;
  }

  .actions {
    width: 100%;
    justify-content: flex-end;
  }
}

.chat-widget {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.75rem;
}

.chat-toggle {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
  border-radius: 999px;
  padding: 0.6rem 1.2rem;
  font-weight: 600;
  box-shadow: 0 12px 30px rgba(45, 108, 223, 0.35);
}

.chat-toggle:hover {
  box-shadow: 0 14px 36px rgba(45, 108, 223, 0.45);
}

.chat-panel {
  width: min(360px, 90vw);
  max-height: min(520px, 80vh);
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border: 1px solid rgba(30, 64, 175, 0.18);
  border-radius: 1rem;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.26);
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  background: var(--color-accent);
  color: #fff;
}

.chat-title {
  margin: 0;
  font-size: 1rem;
}

.chat-close {
  background: transparent;
  color: inherit;
  border: none;
  font-size: 1.25rem;
  padding: 0 0.3rem;
  cursor: pointer;
}

.chat-messages {
  flex: 1;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  overflow-y: auto;
  background: linear-gradient(180deg, #f9fbff 0%, #ffffff 45%, #f4f5f7 100%);
}

.chat-message {
  display: flex;
  gap: 0.65rem;
  line-height: 1.35;
}

.chat-message .bubble {
  padding: 0.6rem 0.75rem;
  border-radius: 0.85rem;
  max-width: 85%;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
  background: #eef3ff;
}

.chat-message.user {
  justify-content: flex-end;
}

.chat-message.user .bubble {
  background: var(--color-accent);
  color: #fff;
}

.chat-message.assistant .bubble {
  background: #fff;
  border: 1px solid rgba(45, 108, 223, 0.18);
}

.chat-message.system .bubble {
  background: #fef3c7;
  border: 1px solid #facc15;
}

.chat-form {
  display: flex;
  gap: 0.6rem;
  padding: 0.85rem 1rem 1rem;
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
}

.chat-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--color-border);
  border-radius: 0.65rem;
  padding: 0.6rem 0.75rem;
  font-size: 0.95rem;
  line-height: 1.4;
  max-height: 8rem;
}

.chat-send {
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: 0.65rem;
  padding: 0 1.2rem;
  font-weight: 600;
}

.chat-send:disabled {
  opacity: 0.6;
  cursor: wait;
}

.chat-widget:not(.active) .chat-panel {
  display: none;
}

.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;
}

.expandable-input {
  transition: height 0.2s ease;
  resize: none;
  overflow: hidden;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
  box-sizing: border-box;
}

.expandable-input.expanded {
  min-height: 80px;
  overflow-y: auto;
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal[hidden] {
  display: none;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
}

.modal-content {
  position: relative;
  background: var(--color-surface);
  border-radius: 1rem;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.3);
  width: min(900px, 90vw);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  z-index: 1;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
}

.modal-header h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-text);
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.75rem;
  line-height: 1;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  color: var(--color-muted);
}

.modal-close:hover {
  color: var(--color-text);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-large .modal-content {
  width: min(1200px, 95vw);
  max-height: 85vh;
}

/* Create Letter Modal - Make it bigger to show all content */
#create-letter-modal .modal-content {
  width: min(1400px, 98vw);
  max-height: 95vh;
}

#create-letter-modal .modal-body {
  padding: 1rem;
  overflow-y: auto;
}

.current-case-display {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.8rem;
  background: rgba(45, 108, 223, 0.08);
  border-radius: 0.6rem;
  border: 1px solid rgba(45, 108, 223, 0.2);
}

.case-label {
  font-size: 0.85rem;
  color: var(--color-muted);
  font-weight: 500;
}

#current-case-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text);
}

.case-inventory-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  height: 100%;
}

.case-inventory-toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--color-border);
}

.case-search-input {
  flex: 1;
  padding: 0.6rem 0.9rem;
  font-size: 0.95rem;
  border: 1px solid var(--color-border);
  border-radius: 0.6rem;
  background: var(--color-surface);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.case-search-input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(45, 108, 223, 0.1);
}

.case-count {
  font-size: 0.9rem;
  color: var(--color-muted);
  white-space: nowrap;
}

.case-count span {
  font-weight: 600;
  color: var(--color-text);
}

.case-inventory-table-wrapper {
  flex: 1;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: 0.6rem;
}

.case-inventory-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
}

.case-inventory-table thead {
  position: sticky;
  top: 0;
  background: var(--color-accent-muted);
  z-index: 1;
}

.case-inventory-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--color-text);
  border-bottom: 2px solid var(--color-border);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.case-inventory-table tbody tr {
  border-bottom: 1px solid var(--color-border);
  transition: background 0.15s ease;
}

.case-inventory-table tbody tr:hover:not(.current-case-row) {
  background: rgba(45, 108, 223, 0.04);
}

.case-inventory-table tbody tr.current-case-row {
  background: rgba(45, 180, 223, 0.1);
}

.case-inventory-table td {
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  color: var(--color-text);
}

.case-id-cell {
  font-weight: 600;
  font-family: 'Courier New', monospace;
}

.status-badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 0.4rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ========== SETTINGS MODAL ========== */
.setting-item {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--color-border);
}

.setting-item:last-child {
  border-bottom: none;
}

.setting-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 26px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: 0.3s;
  border-radius: 26px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
  background-color: var(--color-accent);
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(24px);
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--color-text);
}

.form-group input[type="password"] {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 0.9rem;
}

.btn-primary {
  padding: 0.6rem 1.2rem;
  background-color: var(--color-accent);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
}

.btn-primary:hover {
  opacity: 0.9;
}

/* ========== DARK MODE ========== */
body.dark-mode {
  --color-bg: #1a1d23;
  --color-surface: #252930;
  --color-border: #3a3f4b;
  --color-accent: #4d8aff;
  --color-accent-muted: #1e2936;
  --color-error: #ef4444;
  --color-bg-secondary: #2d3238;
  --color-text: #e4e6eb;
  --color-muted: #b0b3b8;
  --color-label: #8ab4f8;
  background-color: var(--color-bg);
  color: var(--color-text);
}

/* Dark mode scrollbars */
body.dark-mode::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

body.dark-mode::-webkit-scrollbar-track {
  background: var(--color-bg);
}

body.dark-mode::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 6px;
}

body.dark-mode::-webkit-scrollbar-thumb:hover {
  background: #4a4f5b;
}

body.dark-mode *::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

body.dark-mode *::-webkit-scrollbar-track {
  background: var(--color-surface);
}

body.dark-mode *::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 6px;
}

body.dark-mode *::-webkit-scrollbar-thumb:hover {
  background: #4a4f5b;
}

body.dark-mode .modal-content {
  background-color: var(--color-surface);
  color: var(--color-text);
}

body.dark-mode input[type="text"],
body.dark-mode input[type="password"],
body.dark-mode input[type="number"],
body.dark-mode input[type="date"],
body.dark-mode input[type="email"],
body.dark-mode input[type="tel"],
body.dark-mode input[type="url"],
body.dark-mode textarea,
body.dark-mode select {
  background-color: #1a1d23 !important;
  color: var(--color-text) !important;
  border-color: var(--color-border) !important;
}

body.dark-mode input[data-bind] {
  background-color: #1a1d23 !important;
  color: var(--color-text) !important;
  border-color: var(--color-border) !important;
}

body.dark-mode .form-section,
body.dark-mode .audit-content,
body.dark-mode .card {
  background-color: var(--color-surface);
  border-color: var(--color-border);
}

body.dark-mode button {
  background-color: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
}

body.dark-mode .btn-primary,
body.dark-mode .primary-action {
  background-color: var(--color-accent);
  color: white;
}

body.dark-mode .user-dropdown-item:hover {
  background-color: #3a3f4b;
}

body.dark-mode .app-shell {
  background-color: var(--color-bg) !important;
}

body.dark-mode .app-header {
  background-color: var(--color-surface);
  border-bottom-color: var(--color-border);
}

body.dark-mode .sidebar {
  background: var(--color-surface);
  border-right-color: var(--color-border);
}

body.dark-mode .sidebar-nav button {
  color: var(--color-text);
}

body.dark-mode .sidebar-nav button:hover,
body.dark-mode .sidebar-nav button.active {
  background-color: var(--color-accent-muted);
  color: var(--color-accent);
}

body.dark-mode .content-area {
  background-color: var(--color-bg) !important;
}

body.dark-mode .tab-content {
  background-color: var(--color-bg) !important;
}

body.dark-mode .case-list-item {
  background-color: var(--color-surface);
  border-color: var(--color-border);
}

body.dark-mode .case-list-item:hover {
  background-color: #2d3238;
}

body.dark-mode .section-title {
  color: var(--color-text);
  border-bottom-color: var(--color-border);
}

body.dark-mode label {
  color: var(--color-text);
}

body.dark-mode .user-dropdown {
  background-color: var(--color-surface);
  border-color: var(--color-border);
}

body.dark-mode .modal-header {
  border-bottom-color: var(--color-border);
}

body.dark-mode table {
  color: var(--color-text);
}

body.dark-mode table th {
  background-color: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
}

body.dark-mode table td {
  border-color: var(--color-border);
}

body.dark-mode .chat-messages {
  background-color: var(--color-surface);
}

body.dark-mode .chat-message {
  background-color: #2d3238;
  color: var(--color-text);
}

body.dark-mode .chat-input {
  background-color: var(--color-surface);
  border-top-color: var(--color-border);
}

body.dark-mode .chat-input textarea {
  background-color: #1a1d23;
  color: var(--color-text);
  border-color: var(--color-border);
}

body.dark-mode input::placeholder,
body.dark-mode textarea::placeholder {
  color: var(--color-muted);
}

body.dark-mode .modal-overlay {
  background-color: rgba(0, 0, 0, 0.7);
}

body.dark-mode h1,
body.dark-mode h2,
body.dark-mode h3,
body.dark-mode h4,
body.dark-mode h5,
body.dark-mode h6 {
  color: var(--color-text);
}

body.dark-mode .brand-title,
body.dark-mode .brand-subtitle {
  color: var(--color-text);
}

body.dark-mode .user-menu-toggle {
  color: var(--color-text);
  border-color: var(--color-border);
}

body.dark-mode .user-menu-toggle:hover {
  background-color: var(--color-surface);
}

/* Catch-all for any inputs that might have been missed */
body.dark-mode input:not([type="submit"]):not([type="button"]):not([type="checkbox"]):not([type="radio"]) {
  background-color: #1a1d23 !important;
  color: var(--color-text) !important;
  border-color: var(--color-border) !important;
}

body.dark-mode .audit-form input,
body.dark-mode .audit-form select,
body.dark-mode .audit-form textarea {
  background-color: #1a1d23 !important;
  color: var(--color-text) !important;
  border-color: var(--color-border) !important;
}

body.dark-mode .form-row input,
body.dark-mode .form-row select,
body.dark-mode .form-row textarea {
  background-color: #1a1d23 !important;
  color: var(--color-text) !important;
  border-color: var(--color-border) !important;
}

body.dark-mode .group-header-row {
  background: var(--color-surface);
}

body.dark-mode .group-header-cell {
  border-top-color: var(--color-border);
}

body.dark-mode .group-header-label {
  color: var(--color-text);
}

body.dark-mode .group-header-separator {
  color: var(--color-border);
}

body.dark-mode .overdue-critical {
  background-color: #4a1a1a;
  color: #ff6b6b;
}

body.dark-mode .overdue-warning {
  background-color: #3a3210;
  color: #fbbf24;
}

body.dark-mode .empty-state-message {
  color: var(--color-muted);
}

/* Sidebar sections */
body.dark-mode .audit-section,
body.dark-mode .case-summary,
body.dark-mode .case-closeout-section,
body.dark-mode .review-section,
body.dark-mode .admin-section {
  background-color: var(--color-surface);
  color: var(--color-text);
}

body.dark-mode .audit-section h2,
body.dark-mode .case-summary h2,
body.dark-mode .case-closeout-section h2,
body.dark-mode .review-section h2,
body.dark-mode .admin-section h2 {
  color: var(--color-text);
  border-bottom-color: var(--color-border);
}

body.dark-mode .tab-button {
  background-color: transparent;
  color: var(--color-text);
  border-color: var(--color-border);
}

body.dark-mode .tab-button:hover {
  background-color: var(--color-accent-muted);
  color: var(--color-accent);
}

body.dark-mode .tab-button.active {
  background-color: var(--color-accent-muted);
  color: var(--color-accent);
  border-color: var(--color-accent);
}

body.dark-mode .case-summary dt {
  color: var(--color-label);
}

body.dark-mode .case-summary dd {
  color: var(--color-text);
}

body.dark-mode .case-closeout-section dt {
  color: var(--color-label);
}

body.dark-mode .case-closeout-section dd {
  color: var(--color-text);
}

body.dark-mode .reviewer-only,
body.dark-mode .admin-only {
  background-color: transparent !important;
  color: var(--color-text) !important;
  border-color: var(--color-border) !important;
}

body.dark-mode .reviewer-only:hover,
body.dark-mode .admin-only:hover {
  background-color: var(--color-accent-muted) !important;
  color: var(--color-accent) !important;
}

/* Letter Form Styles */
.letter-form {
  font-size: 0.95rem;
}

.letter-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.letter-section-title {
  margin: 0 0 1rem 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-accent);
  border-bottom: 2px solid var(--color-accent-muted);
  padding-bottom: 0.5rem;
}

.letter-form .form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.letter-form .form-group {
  display: flex;
  flex-direction: column;
}

.letter-form .form-group.full-width {
  grid-column: span 2;
}

.letter-form .form-group.half-width {
  grid-column: span 1;
}

.letter-form .form-group.quarter-width {
  grid-column: span 1;
}

.letter-form .form-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-label);
  margin-bottom: 0.4rem;
}

.letter-form .form-group input[type="text"],
.letter-form .form-group input[type="email"],
.letter-form .form-group input[type="tel"],
.letter-form .form-group input[type="date"],
.letter-section textarea {
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--color-border);
  border-radius: 0.3rem;
  font-size: 0.9rem;
  font-family: var(--font-body);
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color 0.2s;
}

.letter-form .form-group input:focus,
.letter-section textarea:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-muted);
}

.letter-section textarea {
  width: 100%;
  resize: vertical;
  min-height: 100px;
}

.form-hint {
  font-size: 0.8rem;
  color: var(--color-muted);
  margin: 0 0 0.75rem 0;
  font-style: italic;
}

.quarter-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
}

.radio-label,
.checkbox-label {
  display: flex;
  align-items: start;
  gap: 0.5rem;
  padding: 0.5rem;
  cursor: pointer;
  border-radius: 0.3rem;
  transition: background-color 0.2s;
}

.radio-label:hover,
.checkbox-label:hover {
  background-color: var(--color-accent-muted);
}

.radio-label input[type="radio"],
.checkbox-label input[type="checkbox"] {
  margin-top: 0.2rem;
  flex-shrink: 0;
  cursor: pointer;
}

.radio-label {
  margin-bottom: 0.25rem;
}

.checkbox-label {
  margin-bottom: 0.5rem;
}

/* Dark mode support for letter form */
body.dark-mode .letter-section {
  background: var(--color-surface);
  border-color: var(--color-border);
}

body.dark-mode .letter-section-title {
  color: var(--color-accent);
}

body.dark-mode .letter-form .form-group label {
  color: var(--color-label);
}

body.dark-mode .letter-form .form-group input,
body.dark-mode .letter-section textarea {
  background: var(--color-bg);
  border-color: var(--color-border);
  color: var(--color-text);
}

/* Dark mode support for notifications */
body.dark-mode .notification-item.unread {
  background: rgba(59, 130, 246, 0.15);
}

body.dark-mode .notification-item.unread:hover {
  background: rgba(59, 130, 246, 0.25);
}

body.dark-mode .letter-form .form-group input:focus,
body.dark-mode .letter-section textarea:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(45, 108, 223, 0.15);
}

body.dark-mode .radio-label:hover,
body.dark-mode .checkbox-label:hover {
  background-color: rgba(45, 108, 223, 0.1);
}

body.dark-mode .form-hint {
  color: var(--color-muted);
}

body.dark-mode .review-nav button,
body.dark-mode .admin-nav button {
  background-color: transparent !important;
  color: var(--color-text) !important;
}

body.dark-mode .review-nav button:hover,
body.dark-mode .admin-nav button:hover {
  background-color: var(--color-accent-muted) !important;
  color: var(--color-accent) !important;
}

/* Override white backgrounds with dark mode colors */
body.dark-mode .tab-button.active {
  background: var(--color-surface) !important;
  box-shadow: inset 0 0 0 1px var(--color-accent);
}

body.dark-mode .card {
  background: var(--color-surface) !important;
  border-color: var(--color-border);
}

body.dark-mode .form-field input,
body.dark-mode .form-field select,
body.dark-mode .form-field textarea {
  background: var(--color-bg) !important;
}

body.dark-mode .chat-messages {
  background: var(--color-bg) !important;
}

body.dark-mode .chat-message.assistant .bubble {
  background: var(--color-surface) !important;
  border-color: var(--color-border);
  color: var(--color-text);
}

/* Override inline styles for dark mode */
body.dark-mode #import-drop-zone {
  background: var(--color-surface) !important;
  border-color: var(--color-border) !important;
}

body.dark-mode #new-class-code-description {
  background: var(--color-bg) !important;
  border-color: var(--color-border) !important;
  color: var(--color-text) !important;
}

/* Aggressive catch-all for any remaining white backgrounds */
body.dark-mode * {
  scrollbar-color: var(--color-border) var(--color-bg);
}

body.dark-mode [style*="background: #fff"],
body.dark-mode [style*="background:#fff"],
body.dark-mode [style*="background: white"],
body.dark-mode [style*="background:white"],
body.dark-mode [style*="background: #f"],
body.dark-mode [style*="background-color: #fff"],
body.dark-mode [style*="background-color:#fff"],
body.dark-mode [style*="background-color: white"],
body.dark-mode [style*="background-color:white"] {
  background: var(--color-bg) !important;
  background-color: var(--color-bg) !important;
}

.status-open {
  background: #dbeafe;
  color: #1e40af;
}

.status-pending {
  background: #fef3c7;
  color: #92400e;
}

.status-completed {
  background: #d1fae5;
  color: #065f46;
}

.status-closed {
  background: #e5e7eb;
  color: #374151;
}

.select-case-btn {
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
  background: var(--color-accent);
  color: white;
  border: none;
  border-radius: 0.4rem;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.15s ease;
}

.select-case-btn:hover {
  background: #1e54b7;
}

.current-case-indicator {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
  background: rgba(45, 180, 223, 0.15);
  color: var(--color-accent);
  border-radius: 0.4rem;
  font-weight: 600;
}

.overdue-critical {
  background-color: #fee;
  color: #c00;
}

.overdue-warning {
  background-color: #fffbeb;
  color: #92400e;
}

.empty-state-message {
  text-align: center;
  padding: 2rem;
  color: #999;
}

.assign-case-btn {
  margin-left: 0.5rem;
  padding: 0.2rem 0.5rem;
  font-size: 0.85rem;
}

/* Critical Flag Styles */
.critical-indicator {
  display: inline-block;
  margin-right: 0.5rem;
  font-size: 1.2rem;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

/* New Case Indicator */
.new-case-indicator {
  display: inline-block;
  margin-right: 0.5rem;
  padding: 0.1rem 0.4rem;
  font-size: 0.7rem;
  font-weight: bold;
  color: white;
  background-color: #28a745;
  border-radius: 3px;
  vertical-align: middle;
}

.toggle-critical-btn {
  margin-left: 0.5rem;
  padding: 0.2rem 0.5rem;
  font-size: 1.2rem;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 0.25rem;
  cursor: pointer;
  color: var(--color-text-secondary);
  transition: all 0.2s;
}

.toggle-critical-btn:hover {
  background: var(--color-surface);
  color: #ffc107;
  border-color: #ffc107;
}

.toggle-critical-btn.critical-active {
  color: #ffc107;
  border-color: #ffc107;
  background: rgba(255, 193, 7, 0.1);
}

.toggle-critical-btn.critical-active:hover {
  background: rgba(255, 193, 7, 0.2);
}

.review-queue-container {
  overflow-x: auto;
}

.review-queue-container table {
  min-width: 800px;
}

.reviewer-only {
  display: none;
}

.documents-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.upload-button-label {
  display: inline-block;
  background: var(--color-accent);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 0.6rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.upload-button-label:hover {
  box-shadow: 0 0 0 3px rgba(45, 108, 223, 0.18);
}

.action-button {
  background: var(--color-accent-muted);
  border-color: var(--color-accent);
  color: var(--color-accent);
  padding: 0.3rem 0.6rem;
  font-size: 0.85rem;
}

.action-button:not(:disabled):hover {
  background: var(--color-accent);
  color: #fff;
}

.document-link {
  color: var(--color-accent);
  text-decoration: none;
  font-weight: 500;
}

.document-link:hover {
  text-decoration: underline;
}

.drag-over {
  position: relative;
}

.drag-over::after {
  content: "Drop files to upload";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(45, 108, 223, 0.1);
  border: 3px dashed var(--color-accent);
  border-radius: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-accent);
  z-index: 10;
  pointer-events: none;
}

/* Location Reorder Modal */
.location-reorder-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.location-reorder-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0.4rem;
  cursor: move;
  transition: all 0.2s ease;
}

.location-reorder-item:hover {
  background: var(--color-accent-muted);
  border-color: var(--color-accent);
}

.location-reorder-item .drag-handle {
  color: var(--color-muted);
  font-size: 1.2rem;
  cursor: grab;
  user-select: none;
}

.location-reorder-item .drag-handle:active {
  cursor: grabbing;
}

.location-reorder-item .location-id {
  font-weight: 600;
  color: var(--color-accent);
  min-width: 3rem;
}

.location-reorder-item .location-name {
  flex: 1;
  color: var(--color-text);
}

.location-reorder-item .location-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.location-reorder-item .location-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.location-reorder-item .location-address {
  font-size: 0.85rem;
  color: var(--color-muted);
  margin-left: 3.75rem;
}

/* Validation error styling */
.validation-error {
  border-color: #dc3545 !important;
  background-color: #fff5f5 !important;
  box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.25) !important;
}

.validation-error:focus {
  border-color: #dc3545 !important;
  box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.35) !important;
}

/* Entity reorder styling */
.entity-reorder-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.entity-reorder-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  cursor: grab;
  transition: all 0.15s ease;
}

.entity-reorder-item:hover {
  border-color: var(--color-accent);
  background: var(--color-surface-hover);
}

.entity-reorder-item:active {
  cursor: grabbing;
}

.entity-reorder-item .entity-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.entity-reorder-item .entity-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.entity-reorder-item .entity-id {
  font-weight: 600;
  color: var(--color-accent);
  min-width: 2rem;
}

.entity-reorder-item .entity-name {
  flex: 1;
  color: var(--color-text);
}

.entity-reorder-item .entity-details {
  font-size: 0.85rem;
  color: var(--color-muted);
  margin-left: 2.75rem;
}

/* Class Codes table wrapper for horizontal scroll on small screens */
.class-codes-table-wrapper {
  overflow-x: auto;
  margin: 0 -0.5rem;
  padding: 0 0.5rem;
}

/* Class Codes table styling */
.class-codes-table {
  table-layout: auto;
  width: 100%;
  min-width: 830px;
}

.class-codes-table input,
.class-codes-table select {
  width: 100%;
  box-sizing: border-box;
}

.class-codes-table td {
  overflow: hidden;
  text-overflow: ellipsis;
}

.class-codes-table input[data-bind*="description"] {
  min-width: 180px;
}

.class-codes-table .estimate-input {
  text-align: right;
}

/* Description tooltip bubble */
.class-codes-table .description-cell {
  position: relative;
}

.class-codes-table .description-tooltip {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  background: #1f2937;
  color: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  line-height: 1.4;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  white-space: normal;
  word-wrap: break-word;
  max-width: 400px;
  min-width: 200px;
  margin-bottom: 6px;
}

.class-codes-table .description-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 20px;
  border: 6px solid transparent;
  border-top-color: #1f2937;
}

.class-codes-table .description-cell:hover .description-tooltip {
  display: block;
}
