/* Off-Canvas Sliding Right Sidebar (Drawer) - Simple & Elegant */
.drawer-container {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  visibility: hidden;
  transition: visibility 0.28s ease;
}

.drawer-container.open {
  pointer-events: auto;
  visibility: visible;
}

/* Subtle backdrop overlay with blur */
.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 8, 15, 0.68);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.drawer-container.open .drawer-backdrop {
  opacity: 1;
}

/* Sliding Right Panel */
.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: 480px;
  max-width: 95vw;
  height: 100vh;
  height: 100dvh;
  background: #0f1523;
  border-left: 1px solid var(--border-card);
  box-shadow: var(--shadow-drawer);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.drawer-container.open .drawer-panel {
  transform: translateX(0);
}

/* Drawer Header */
.drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 22px 24px;
  border-bottom: 1px solid var(--border-subtle);
  background: #0c121e;
}

.drawer-eyebrow {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #60a5fa;
  margin-bottom: 4px;
  font-family: var(--font-mono);
}

.drawer-title {
  font-size: 19px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.drawer-sub-meta {
  font-size: 11.5px;
  color: #7b8fa8;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.drawer-pop-pill {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 11px;
  color: #cbd5e1;
  font-family: var(--font-mono);
}

.drawer-invoice-notice {
  margin: 12px 0 6px 0;
  padding: 9px 12px;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #fde68a;
  line-height: 1.4;
}

.drawer-invoice-notice strong {
  color: #fbbf24;
}

.drawer-close-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  width: 30px;
  height: 30px;
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.drawer-close-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
  transform: scale(1.05);
}

/* Drawer Body (Scrollable) */
.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 22px 24px 36px;
  scrollbar-width: thin;
  scrollbar-color: #263654 transparent;
}

.drawer-body::-webkit-scrollbar {
  width: 5px;
}

.drawer-body::-webkit-scrollbar-thumb {
  background: #263654;
  border-radius: 3px;
}

.drawer-body::-webkit-scrollbar-thumb:hover {
  background: #3b82f6;
}

/* Primary Action Row: Smart Portal & Gmail Draft */
.drawer-top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  width: 100%;
  margin-bottom: 16px;
}

.drawer-top-actions > .launch-copy-btn {
  flex: 1 1 160px;
  min-width: 0;
  min-height: 44px;
}

.launch-copy-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 1;
  width: 100%;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  border: 1px solid rgba(96, 165, 250, 0.4);
  color: #ffffff;
  padding: 11px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: inherit;
}

.launch-copy-btn:hover {
  background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
  border-color: #60a5fa;
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.45);
  transform: translateY(-1px);
}

.launch-copy-btn:active {
  transform: translateY(0);
}

.launch-copy-btn.btn-send-action {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  border-color: rgba(52, 211, 153, 0.45);
  box-shadow: 0 4px 14px rgba(5, 150, 105, 0.35);
}

.launch-copy-btn.btn-send-action:hover {
  background: linear-gradient(135deg, #047857 0%, #065f46 100%);
  border-color: #34d399;
  box-shadow: 0 6px 20px rgba(5, 150, 105, 0.45);
}

.launch-copy-btn.btn-gmail-action {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  border-color: rgba(248, 113, 113, 0.45);
  box-shadow: 0 4px 14px rgba(220, 38, 38, 0.35);
}

.launch-copy-btn.btn-gmail-action:hover {
  background: linear-gradient(135deg, #b91c1c 0%, #991b1b 100%);
  border-color: #f87171;
  box-shadow: 0 6px 20px rgba(220, 38, 38, 0.45);
}

.launch-copy-btn.btn-followup-action {
  background: var(--bg-elevated, #1e293b);
  border-color: var(--border-color, #475569);
  color: var(--text-primary, #f1f5f9);
  box-shadow: none;
}
.launch-copy-btn.btn-followup-action:hover {
  background: var(--bg-hover, #334155);
  border-color: var(--accent-blue, #60a5fa);
  box-shadow: none;
}
.launch-copy-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}
.drawer-top-actions svg { flex-shrink: 0; }

/* Portal Row */
.portal-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.portal-link {
  color: var(--accent-blue-hover);
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
}

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

.portal-engine-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 700;
  border: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.25);
}

.statutory-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  margin-bottom: 16px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.statutory-badge.due-soon {
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: #93c5fd;
}

.statutory-badge.overdue {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #fde68a;
}

/* Form Fields */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.dates-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.form-group {
  margin-bottom: 15px;
}

.input-label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-sub);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}

.input-container {
  display: flex;
  position: relative;
  align-items: center;
  width: 100%;
}

.input-container .text-input {
  padding-right: 36px;
}

.text-input, .date-input {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 7px;
  padding: 8px 11px;
  height: 38px;
  font-size: 12.5px;
  color: var(--text-main);
  outline: none;
  transition: all 0.15s ease;
  font-family: inherit;
}

.text-input:focus, .date-input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

#modal-ref-no, #modal-sec-key {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.02em;
}

.date-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 22px;
  margin-bottom: 6px;
}

.date-label-row .input-label {
  margin-bottom: 0;
  white-space: nowrap;
}

.btn-today-shortcut {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.28);
  color: #93c5fd;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
  line-height: 1.3;
}

.btn-today-shortcut:hover {
  background: #2563eb;
  border-color: #3b82f6;
  color: #ffffff;
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.4);
  transform: translateY(-1px);
}

.btn-today-shortcut:active {
  transform: translateY(0);
}

.date-input {
  color-scheme: dark;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

/* Fees Row Styling */
.fees-form-group {
  margin-bottom: 15px;
}

.fees-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  gap: 8px;
}

.fees-label-row .input-label {
  margin-bottom: 0;
}

.fees-quick-pills {
  display: flex;
  align-items: center;
  gap: 5px;
}

.fee-quick-pill {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #94a3b8;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.fee-quick-pill:hover {
  background: rgba(59, 130, 246, 0.18);
  border-color: rgba(59, 130, 246, 0.35);
  color: #93c5fd;
  transform: translateY(-1px);
}

.icon-copy-btn {
  position: absolute;
  right: 6px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.icon-copy-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
  transform: scale(1.08);
}

.icon-copy-btn.copied-active {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399 !important;
}

/* Requested File Presets */
.preset-pills-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.preset-pill {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-sub);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.preset-pill:hover, .preset-pill.active {
  background: rgba(59, 130, 246, 0.18);
  border-color: var(--accent-blue);
  color: #ffffff;
}

/* Message Box & Templates */
.message-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 7px;
}

.msg-status-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 5px;
  letter-spacing: 0.02em;
}

.msg-status-pill.green {
  background: rgba(16, 185, 129, 0.14);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.msg-status-pill.orange {
  background: rgba(245, 158, 11, 0.14);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.msg-status-pill.red {
  background: rgba(239, 68, 68, 0.16);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.32);
}

.msg-status-pill.awaiting {
  background: rgba(59, 130, 246, 0.14);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.32);
}

/* Email Subject Line with Decoupled Copy Button */
.subject-row {
  margin-bottom: 12px;
}

.subject-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.subject-header-row .input-label {
  margin-bottom: 0;
}

.subject-input-wrapper {
  display: flex;
  align-items: center;
  width: 100%;
  position: relative;
}

.subject-input {
  width: 100% !important;
  box-sizing: border-box !important;
  background: var(--bg-input) !important;
  border: 1px solid var(--border-subtle) !important;
  border-radius: 7px !important;
  padding: 8px 12px !important;
  font-size: 12.5px !important;
  font-weight: 500;
  color: #e2e8f0 !important;
  outline: none !important;
  font-family: inherit !important;
  transition: all 0.15s ease;
  height: 38px;
}

.subject-input:focus {
  border-color: var(--accent-blue) !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18) !important;
}

.btn-copy-subject {
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.28);
  color: #93c5fd;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
  font-family: inherit;
  line-height: 1.3;
}

.btn-copy-subject:hover {
  background: #2563eb;
  border-color: #3b82f6;
  color: #ffffff;
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.4);
  transform: translateY(-1px);
}

.btn-copy-subject:active {
  transform: translateY(0);
}

.btn-copy-subject.copied-active {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399 !important;
  border-color: #34d399;
}

.message-box {
  width: 100%;
  min-height: 240px;
  height: 250px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 7px;
  padding: 13px 15px;
  font-size: 12.5px;
  color: var(--text-main);
  line-height: 1.55;
  resize: vertical;
  outline: none;
  margin-bottom: 9px;
  font-family: inherit;
  transition: border-color 0.15s ease;
}

.message-box:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

.template-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 14px;
  margin-bottom: 12px;
  position: relative;
}

.template-radio {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-sub);
  padding: 8px 6px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  font-family: inherit;
  min-height: 48px;
  text-align: center;
  overflow: visible;
  hyphens: none;
  -webkit-hyphens: none;
}

.template-radio:hover {
  border-color: #3b4d6b;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  transform: translateY(-1px);
}

.template-radio.active {
  background: rgba(37, 99, 235, 0.18);
  border-color: #3b82f6;
  color: #ffffff;
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.22);
}

.tmpl-title {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
  letter-spacing: -0.1px;
}

.tmpl-sub {
  font-size: 9.5px;
  font-weight: 500;
  color: var(--text-muted);
  line-height: 1.2;
  white-space: nowrap;
  transition: color 0.15s ease;
}

.template-radio.active .tmpl-sub {
  color: #93c5fd;
}

/* Smart Recommendation Styling */
.template-radio.rec-red {
  border-color: rgba(239, 68, 68, 0.55) !important;
  background: rgba(239, 68, 68, 0.08);
  color: #fca5a5;
}

.template-radio.rec-red:hover {
  background: rgba(239, 68, 68, 0.14);
}

.template-radio.rec-red.active {
  background: rgba(239, 68, 68, 0.24);
  border-color: #ef4444 !important;
  color: #ffffff;
  box-shadow: 0 0 14px rgba(239, 68, 68, 0.28);
}

.template-radio.rec-red.active .tmpl-sub {
  color: #fca5a5;
}

.template-radio.rec-orange {
  border-color: rgba(245, 158, 11, 0.55) !important;
  background: rgba(245, 158, 11, 0.08);
  color: #fde68a;
}

.template-radio.rec-orange:hover {
  background: rgba(245, 158, 11, 0.14);
}

.template-radio.rec-orange.active {
  background: rgba(245, 158, 11, 0.24);
  border-color: #f59e0b !important;
  color: #ffffff;
  box-shadow: 0 0 14px rgba(245, 158, 11, 0.28);
}

.template-radio.rec-orange.active .tmpl-sub {
  color: #fde68a;
}

.template-radio.rec-green {
  border-color: rgba(16, 185, 129, 0.45) !important;
  background: rgba(16, 185, 129, 0.08);
  color: #a7f3d0;
}

.template-radio.rec-green.active {
  background: rgba(16, 185, 129, 0.2);
  border-color: #10b981 !important;
  color: #ffffff;
}

.template-radio.rec-green.active .tmpl-sub {
  color: #a7f3d0;
}

.template-radio.rec-awaiting {
  border-color: rgba(59, 130, 246, 0.4) !important;
  background: rgba(59, 130, 246, 0.08);
  color: #93c5fd;
}

.template-radio.rec-awaiting.active {
  background: rgba(59, 130, 246, 0.22);
  border-color: #60a5fa !important;
  color: #ffffff;
}

/* Floating Micro-Badge on Top Border */
.tmpl-badge {
  display: none;
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 8px;
  font-weight: 800;
  padding: 1.5px 7px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  white-space: nowrap;
  line-height: 1.25;
  pointer-events: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  z-index: 2;
}

.tmpl-badge:not(:empty) {
  display: inline-block;
}

.tmpl-badge.red {
  background: #ef4444;
  color: #ffffff;
}

.tmpl-badge.orange {
  background: #f59e0b;
  color: #181511;
}

.tmpl-badge.green {
  background: #10b981;
  color: #ffffff;
}

.tmpl-badge.awaiting {
  background: #3b82f6;
  color: #ffffff;
}

.message-actions-row {
  display: flex;
  gap: 8px;
  width: 100%;
}

.btn-send-email-action {
  flex: 1.2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  border: 1px solid rgba(52, 211, 153, 0.45);
  color: #ffffff;
  padding: 8px 14px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: inherit;
  box-shadow: 0 3px 12px rgba(5, 150, 105, 0.28);
}

.btn-send-email-action:hover {
  background: linear-gradient(135deg, #047857 0%, #065f46 100%);
  border-color: #34d399;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(5, 150, 105, 0.38);
}

.btn-send-email-action:active {
  transform: translateY(0);
}

.btn-send-email-action[disabled],
.launch-copy-btn[disabled] {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none !important;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.copy-message-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  flex: 1;
  width: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  color: var(--text-main);
  padding: 8px 14px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.copy-message-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--accent-blue);
  color: #ffffff;
  transform: translateY(-1px);
}

.copy-message-btn:active {
  transform: translateY(0);
}

.btn-open-gmail {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: rgba(234, 67, 53, 0.1);
  border: 1px solid rgba(234, 67, 53, 0.35);
  color: #fca5a5;
  padding: 8px 14px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: inherit;
}

.btn-open-gmail:hover {
  background: rgba(234, 67, 53, 0.22);
  border-color: #f87171;
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 3px 12px rgba(234, 67, 53, 0.28);
}

.btn-open-gmail:active {
  transform: translateY(0);
}

/* File Format Badges */
.file-badges-container {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.file-badge {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-sub);
  padding: 4px 11px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: var(--font-mono);
}

.file-badge:hover {
  border-color: #384a6b;
  color: var(--text-main);
}

.file-badge.active {
  background: rgba(59, 130, 246, 0.18);
  border-color: var(--accent-blue);
  color: #60a5fa;
  font-weight: 700;
}

/* Notes Header & Formatting Toolbar */
.notes-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  gap: 8px;
}

.notes-header-row .input-label {
  margin-bottom: 0;
}

.notes-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-note-tool {
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid var(--border-subtle);
  color: var(--text-sub);
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
  font-family: inherit;
}

.btn-note-tool:hover {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(96, 165, 250, 0.4);
  color: #60a5fa;
}

.btn-note-tool:active {
  transform: translateY(1px);
}

/* Notes Textarea */
.notes-box {
  width: 100%;
  height: 90px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 7px;
  padding: 9px 11px;
  font-size: 12px;
  color: var(--text-main);
  line-height: 1.5;
  resize: vertical;
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s ease;
}

.notes-box.bulleted-notes-box {
  height: 125px;
  min-height: 90px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.notes-box:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

/* Modal Overlay for Add Municipality */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 15, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 10000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.open {
  display: flex;
}

.modal-card {
  background: #111827;
  border: 1px solid var(--border-card);
  border-radius: 12px;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.75);
  padding: 26px;
  animation: modal-enter 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-card.modal-sm {
  max-width: 440px;
}

@keyframes modal-enter {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 14px;
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.01em;
}

.close-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.close-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
}

.modal-actions-row {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
}

.btn-cancel {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-sub);
  padding: 8px 16px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.btn-cancel:hover {
  color: #ffffff;
  border-color: #34486d;
}

.btn-submit {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  border: 1px solid rgba(96, 165, 250, 0.4);
  color: #ffffff;
  padding: 8px 18px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.btn-submit:hover {
  background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

/* Municipality Historical Records Section in Drawer */
.drawer-history-section {
  margin-top: 22px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.drawer-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.drawer-history-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.drawer-history-title {
  font-size: 13px;
  font-weight: 700;
  color: #f1f5f9;
  letter-spacing: 0.3px;
}

.drawer-history-count-badge {
  background: rgba(255, 255, 255, 0.08);
  color: #94a3b8;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
}

.drawer-history-avg-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.35);
  color: #93c5fd;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
}

.drawer-history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 280px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #263654 transparent;
  padding-right: 2px;
}

.drawer-history-list::-webkit-scrollbar {
  width: 4px;
}

.drawer-history-list::-webkit-scrollbar-thumb {
  background: #263654;
  border-radius: 2px;
}

.drawer-history-card {
  background: rgba(30, 41, 59, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 10px 12px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.drawer-history-card:hover {
  background: rgba(30, 41, 59, 0.8);
  border-color: rgba(96, 165, 250, 0.3);
}

.drawer-history-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.drawer-history-ref-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.drawer-history-label {
  color: #94a3b8;
  font-weight: 500;
}

.drawer-history-ref-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 600;
  color: #cbd5e1;
}

.drawer-history-ref-value.has-ref {
  color: #60a5fa;
  background: rgba(37, 99, 235, 0.12);
  padding: 1px 6px;
  border-radius: 4px;
}

.drawer-history-identifiers {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.drawer-history-sec-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
}

.drawer-history-sec-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  font-weight: 600;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.1);
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid rgba(56, 189, 248, 0.25);
}

.btn-copy-history-mini {
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 1px 3px;
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.btn-copy-history-mini:hover {
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.15);
}

.drawer-history-portal-link:hover {
  background: rgba(56, 189, 248, 0.22) !important;
  border-color: rgba(56, 189, 248, 0.45) !important;
  color: #7dd3fc !important;
}

.drawer-history-card-badges {
  display: flex;
  align-items: center;
  gap: 6px;
}

.file-ext-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.ext-badge-shp {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.3);
}

.drawer-history-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
  padding: 6px 8px;
  background: rgba(15, 23, 42, 0.45);
  border-radius: 6px;
}

.drawer-history-grid-col {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.drawer-history-col-label {
  font-size: 10px;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-weight: 600;
}

.drawer-history-col-value {
  font-size: 12px;
  font-weight: 600;
  color: #e2e8f0;
}

.drawer-history-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 4px;
}

.drawer-turnaround-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}

.drawer-turnaround-badge.turnaround-fast {
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.28);
}

.drawer-turnaround-badge.turnaround-normal {
  background: rgba(59, 130, 246, 0.12);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.25);
}

.drawer-turnaround-badge.turnaround-awaiting {
  background: rgba(245, 158, 11, 0.12);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.28);
}

.drawer-turnaround-badge.turnaround-unknown {
  background: rgba(255, 255, 255, 0.05);
  color: #64748b;
}

.drawer-history-file-name {
  font-size: 10px;
  color: #64748b;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.drawer-history-empty {
  text-align: center;
  padding: 20px 12px;
  color: #64748b;
}

.drawer-history-empty-icon {
  margin-bottom: 8px;
  stroke: #475569;
}

.drawer-history-empty-title {
  font-size: 12px;
  font-weight: 600;
  color: #94a3b8;
  margin-bottom: 4px;
}

.drawer-history-empty-sub {
  font-size: 11px;
  color: #64748b;
  line-height: 1.4;
}

/* Delete Municipality Action in Drawer */
.delete-action-row {
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid var(--border-subtle);
}

.btn-delete-muni {
  width: 100%;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.28);
  color: #f87171;
  padding: 9px 14px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-family: inherit;
}

.btn-delete-muni:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: #ef4444;
  color: #ffffff;
}

@media (max-width: 768px) {
  .text-input,
  .date-input,
  textarea {
    font-size: 16px;
  }
}
/* Portal dialogs remain usable on small screens and with keyboard navigation. */
.portal-input-dialog { width: min(92vw, 480px); box-sizing: border-box; max-height: 90vh; overflow: auto; padding: 24px; background: #0f172a; color: #f8fafc; border: 1px solid #475569; border-radius: 12px; }
.portal-input-dialog::backdrop, #portal-preview-dialog::backdrop { background: #020617bb; }
.portal-input-dialog h2 { margin-top: 0; font-size: 20px; }
.portal-input-dialog a { color: #7dd3fc; text-decoration: underline; }
.portal-input-dialog ol { padding-left: 22px; }
.portal-input-dialog li { margin-bottom: 8px; }
.portal-input-dialog label { display: block; margin: 16px 0; }
.portal-input-dialog input:not([type=checkbox]) { display: block; width: 100%; box-sizing: border-box; margin-top: 8px; padding: 10px; color: #f8fafc; background: #1e293b; border: 1px solid #64748b; border-radius: 6px; }
.portal-checkbox { display: flex !important; gap: 8px; align-items: flex-start; }
.portal-dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 12px; }
.portal-dialog-actions button { min-height: 44px; padding: 8px 16px; }
#portal-preview-dialog { overflow: auto !important; box-sizing: border-box; }
#portal-preview-dialog * { box-sizing: border-box; max-width: 100%; }
#portal-preview-dialog .portal-dialog-header { flex-wrap: wrap; }
#portal-preview-dialog .portal-dialog-header > div { min-width: 0; overflow-wrap: anywhere; }
#portal-preview-dialog button, #portal-preview-dialog a { min-height: 44px; box-sizing: border-box; display: inline-flex; align-items: center; }
#portal-preview-dialog :focus-visible, .portal-input-dialog :focus-visible { outline: 2px solid #38bdf8; outline-offset: 3px; }
.followup-summary {
  color: var(--text-secondary, #94a3b8);
  font-size: 13px;
  line-height: 1.6;
  overflow-wrap: anywhere;
  margin: 8px 0 12px;
}
.portal-input-dialog textarea { width: 100%; min-height: 130px; box-sizing: border-box; }
#manual-followup-dialog textarea { padding: 12px; background: #1e293b; color: #f8fafc; border: 1px solid #64748b; border-radius: 6px; font-family: inherit; line-height: 1.6; resize: vertical; }
#manual-followup-dialog button { background: #1e293b; color: #f8fafc; border: 1px solid #64748b; border-radius: 6px; cursor: pointer; }
#manual-followup-dialog button:hover { background: #334155; }
#manual-followup-dialog #manual-followup-confirm { background: #0369a1; border-color: #38bdf8; }
#manual-followup-dialog #manual-followup-confirm:hover { background: #075985; }
#manual-followup-dialog button:disabled { opacity: .6; cursor: wait; }
#manual-followup-dialog [role="alert"] { color: #fca5a5; }
.drawer-new-request-note {
  margin: 0 0 14px;
  color: var(--text-secondary, #cbd5e1);
  font-size: 12px;
  line-height: 1.5;
}

.portal-nextrequest-message {
  padding: 12px 20px;
  margin: 0;
  color: #e2e8f0;
  background: #162032;
  text-align: left;
  line-height: 1.5;
}

#portal-preview-dialog[open] {
  display: flex;
  flex-direction: column;
}

#portal-preview-dialog > :not(.portal-preview-scroll) {
  flex-shrink: 0;
}

#portal-preview-dialog .portal-dialog-header {
  flex-wrap: wrap;
}

.portal-preview-scroll {
  min-height: 0;
  flex: 1 1 auto;
}

.drawer-approval-row { display:flex; align-items:center; justify-content:space-between; gap:12px; margin:12px 0; font-size:13px; }
.drawer-approval-row[hidden] { display:none; }
.drawer-approval-row button { min-height:44px; padding:8px 12px; border:1px solid #475569; border-radius:6px; background:#1e293b; color:#f8fafc; cursor:pointer; }
.mort-request-progress { width:min(620px,calc(100vw - 32px)); max-height:85vh; overflow:auto; }
.helper-warnings { color:#fbbf24; }
.portal-dialog-actions { flex-wrap:wrap; }
.portal-input-dialog button { min-height:44px; }
