:root {
  color-scheme: dark;
  --bg-app: #080b10;
  --bg-app-rgb: 8, 11, 16;
  --bg-card: rgba(15, 22, 36, 0.65);
  --bg-input: #0c101a;
  --border-color: rgba(255, 255, 255, 0.07);
  --border-color-hover: rgba(255, 255, 255, 0.15);
  --text-primary: #f3f4f6;
  --text-muted: #9ca3af;
  --red: #ff3b30;
  --red-glow: rgba(255, 59, 48, 0.25);
  --red-dark: #d6261c;
  --accent: #ff3b30;
  --accent-dark: #d6261c;
  --warning: #f59e0b;
  --warning-glow: rgba(245, 158, 11, 0.15);
  --danger: #ef4444;
  --good: #10b981;
  --good-glow: rgba(16, 185, 129, 0.15);
  
  --font-body: "DM Sans", Inter, "Segoe UI", Arial, sans-serif;
  --font-heading: "Space Grotesk", Inter, sans-serif;
  --font-ui: "Space Grotesk", sans-serif;
  
  --radius-lg: 12px;
  --radius-md: 8px;
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-body);
  background: radial-gradient(circle at 50% 0%, #1e1b4b 0%, #06080d 50%), #06080d;
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

h1,
h2,
h3,
.company-line h2,
.login-card h1,
.drawer-head h2,
.boot-loader h1 {
  font-family: var(--font-heading);
  letter-spacing: -0.02em;
}

/* Bootloader */
.boot-loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  grid-template-rows: 1fr auto;
  padding: clamp(24px, 5vw, 64px);
  overflow: hidden;
  background: #000000;
  color: #ffffff;
  font-family: var(--font-body);
  transition: opacity 420ms cubic-bezier(0.16, 1, 0.3, 1), visibility 420ms cubic-bezier(0.16, 1, 0.3, 1);
}

.boot-loader::before {
  content: "";
  position: absolute;
  inset: 0;
  background: #06080d;
  transform-origin: left center;
  animation: redmonoWipe 1450ms cubic-bezier(0.86, 0, 0.07, 1) both;
  animation-delay: 280ms;
}

.boot-loader::after {
  content: "redmono redmono redmono redmono";
  position: absolute;
  left: -2vw;
  right: -2vw;
  bottom: clamp(78px, 13vh, 138px);
  z-index: 0;
  color: rgba(255, 255, 255, 0.03);
  font-size: clamp(76px, 13vw, 210px);
  line-height: 0.75;
  font-weight: 950;
  white-space: nowrap;
  animation: bootMarquee 6200ms linear infinite;
}

.boot-loader.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.boot-grid {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  pointer-events: none;
}

.boot-grid span {
  border-left: 1px solid rgba(255, 255, 255, 0.05);
}

.boot-main,
.boot-foot {
  position: relative;
  z-index: 1;
}

.boot-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-ui);
  font-weight: 900;
  font-size: 20px;
  letter-spacing: 0;
  animation: bootIn 760ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.boot-mark {
  width: 30px;
  height: 30px;
  display: inline-block;
  background: var(--red);
  box-shadow: 0 0 20px var(--red-glow);
  animation: bootMark 1150ms cubic-bezier(0.16, 1, 0.3, 1) infinite alternate;
}

.boot-kicker {
  margin: clamp(64px, 12vh, 120px) 0 18px;
  font-family: var(--font-ui);
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 12px;
  opacity: 0.82;
  animation: bootIn 760ms cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: 120ms;
}

.boot-loader h1 {
  margin: 0;
  max-width: 980px;
  font-size: clamp(46px, 8.7vw, 128px);
  line-height: 0.9;
  font-weight: 950;
  letter-spacing: -0.03em;
  text-transform: lowercase;
  animation: bootIn 760ms cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: 220ms;
}

.boot-loader h1 strong {
  color: var(--red);
  font-style: normal;
  font-weight: 950;
  text-shadow: 0 0 40px var(--red-glow);
}

.boot-progress {
  width: min(420px, 68vw);
  height: 4px;
  margin-top: clamp(28px, 5vh, 44px);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 99px;
}

.boot-progress span {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--red);
  box-shadow: 0 0 10px var(--red-glow);
  transform-origin: left center;
  animation: bootProgress 1250ms cubic-bezier(0.76, 0, 0.24, 1) infinite;
}

.boot-foot {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  font-family: var(--font-ui);
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 12px;
  color: #ffffff;
  opacity: 0.66;
  animation: bootFade 900ms ease both;
  animation-delay: 360ms;
}

@keyframes bootIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes bootFade {
  from { opacity: 0; }
  to { opacity: 0.72; }
}

@keyframes redmonoWipe {
  0% { transform: scaleX(1); }
  42% { transform: scaleX(1); }
  100% { transform: scaleX(0); }
}

@keyframes bootProgress {
  0% { transform: scaleX(0); }
  50% { transform: scaleX(0.78); }
  100% { transform: scaleX(1); }
}

@keyframes bootMark {
  from { transform: scale(1); }
  to { transform: scale(0.72); }
}

@keyframes bootMarquee {
  from { transform: translateX(0); }
  to { transform: translateX(-18%); }
}

/* Login Screen */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at center, #1e1b4b 0%, #06080d 100%), #06080d;
}

.login-card {
  width: min(100%, 380px);
  display: grid;
  gap: 18px;
  background: rgba(17, 24, 39, 0.7);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(20px);
}

.login-card h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 900;
  background: linear-gradient(to right, #fff, #9ca3af);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-square {
  width: 14px;
  height: 14px;
  display: inline-block;
  background: var(--red);
  box-shadow: 0 0 10px var(--red-glow);
}

.login-error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-weight: 700;
  font-size: 13px;
}

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

.app-shell {
  min-height: 100vh;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 28px;
  background: rgba(6, 8, 13, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 5;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--red);
  font-family: var(--font-ui);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.brand-mark {
  width: 8px;
  height: 8px;
  display: inline-block;
  background: var(--red);
  box-shadow: 0 0 8px var(--red-glow);
}

.topbar h1 {
  font-size: 24px;
  font-weight: 900;
  background: linear-gradient(to right, #fff, #9ca3af);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

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

.panel-actions {
  display: inline-flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
}

.panel-actions button,
#exportExcelBtn,
.user-chip,
.summary span {
  border-radius: 8px;
}

.panel-actions button {
  min-height: 38px;
  font-family: var(--font-ui);
  font-weight: 800;
  background: transparent;
  border: 0;
  color: var(--text-muted);
  padding: 0 16px;
  transition: all 0.2s;
}

.panel-actions button:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.panel-actions button.primary {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
  box-shadow: 0 4px 12px var(--red-glow);
}

.panel-actions button.primary:hover {
  background: var(--red-dark);
  box-shadow: 0 6px 16px var(--red-glow);
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border-color);
  padding: 4px 6px 4px 12px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-primary);
  font-weight: 700;
  font-size: 13px;
  min-height: 48px;
}

.user-chip button {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  transition: all 0.2s;
}

.user-chip button:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-color-hover);
}

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

.summary span {
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 13px;
  line-height: 1;
}

/* Custom stats pill highlights */
.summary span:nth-child(2) {
  border-color: rgba(255, 59, 48, 0.2);
  color: #fca5a5;
  background: rgba(255, 59, 48, 0.02);
}
.summary span:nth-child(3) {
  border-color: rgba(16, 185, 129, 0.2);
  color: #a7f3d0;
  background: rgba(16, 185, 129, 0.02);
}
.summary span:nth-child(4) {
  border-color: rgba(139, 92, 246, 0.2);
  color: #c7d2fe;
  background: rgba(139, 92, 246, 0.02);
}

#exportExcelBtn {
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.1);
  color: #6ee7b7;
  font-weight: 800;
  min-height: 48px;
  padding: 0 16px;
  transition: all 0.2s;
}

#exportExcelBtn:hover {
  background: rgba(16, 185, 129, 0.2);
  box-shadow: 0 0 15px var(--good-glow);
}

/* Workspace Layout */
.workspace {
  display: block;
  min-height: calc(100vh - 88px);
}

.list-panel {
  width: min(100%, 1400px);
  margin: 0 auto;
  padding: 32px 28px 48px;
}

/* Toolbar */
.toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 210px;
  gap: 12px;
  margin-bottom: 24px;
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background: rgba(17, 24, 39, 0.4);
  backdrop-filter: blur(12px);
}

.toolbar input,
.toolbar select {
  min-height: 44px;
  border-radius: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-weight: 700;
  padding: 8px 14px;
  transition: all 0.2s;
}

.toolbar input:focus,
.toolbar select:focus {
  border-color: var(--red);
  box-shadow: 0 0 12px var(--red-glow);
}

/* Contact Cards Grid */
.contacts {
  display: grid;
  gap: 12px;
}

.contact-card {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(180px, 240px) auto;
  gap: 20px;
  padding: 20px;
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-left-width: 5px;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(12px);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), 
              border-color 0.25s cubic-bezier(0.4, 0, 0.2, 1), 
              box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.contact-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-color-hover);
  box-shadow: var(--shadow-lg);
}

.company-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.company-line h2 {
  font-size: 20px;
  font-weight: 900;
  line-height: 1.1;
  margin: 0;
  color: #ffffff;
}

.star {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 8px currentColor;
}

.meta,
.submeta,
.analysis {
  font-size: 13.5px;
  line-height: 1.5;
}

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

.meta a {
  color: #60a5fa;
  text-decoration: none;
  font-weight: 600;
  border-bottom: 1px dotted rgba(96, 165, 250, 0.4);
  transition: all 0.2s;
}

.meta a:hover {
  color: #93c5fd;
  border-bottom-style: solid;
}

.submeta {
  margin-top: 10px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  color: var(--text-muted);
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.badge {
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.03);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.badge.contract {
  border-color: rgba(16, 185, 129, 0.2);
  color: #34d399;
  background: rgba(16, 185, 129, 0.05);
}

.badge.warning {
  border-color: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.05);
}

.badge.added {
  border-color: rgba(139, 92, 246, 0.2);
  color: #a78bfa;
  background: rgba(139, 92, 246, 0.05);
}

.badge.mail-sent {
  border-color: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
  background: rgba(59, 130, 246, 0.05);
}

/* Card Right Section: Analysis */
.analysis {
  padding-left: 16px;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

.score {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  width: auto;
  height: auto;
  padding: 4px 10px;
  border: 1px solid transparent;
  background: transparent;
  font-size: 20px;
  font-family: var(--font-ui);
  font-weight: 800;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s;
  margin-bottom: 10px;
}

.score strong {
  font-size: 22px;
}

.score span {
  font-size: 12px;
  opacity: 0.6;
  font-weight: 700;
}

.score.low {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.15);
}
.score.low:hover {
  background: rgba(239, 68, 68, 0.15);
}

.score.mid {
  color: #fde047;
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.15);
}
.score.mid:hover {
  background: rgba(245, 158, 11, 0.15);
}

.score.high {
  color: #6ee7b7;
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.15);
}
.score.high:hover {
  background: rgba(16, 185, 129, 0.15);
}

.score-breakdown {
  display: none;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.04);
  background: rgba(0, 0, 0, 0.15);
  border-radius: 8px;
}

.contact-card.score-open .score-breakdown {
  display: grid;
  gap: 6px;
}

.score-breakdown div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.score-breakdown strong {
  color: var(--text-primary);
  font-family: var(--font-ui);
}

.score-breakdown .score-segment {
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

.score-breakdown .score-segment strong {
  color: var(--text-muted);
}

/* Service Recommendations */
.service-picks {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.service-picks strong {
  display: block;
  margin-bottom: 6px;
  color: var(--text-primary);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.service-picks div {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.service-picks span {
  border: 1px solid rgba(255, 59, 48, 0.2);
  border-radius: 6px;
  padding: 3px 8px;
  background: rgba(255, 59, 48, 0.05);
  color: #fecaca;
  font-size: 11px;
  font-weight: 800;
}

/* Actions Column (Right Side) */
.row-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: flex-start;
  align-items: flex-end;
}

.row-actions button {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  display: grid;
  place-items: center;
  transition: all 0.2s;
  cursor: pointer;
}

.row-actions button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border-color: var(--border-color-hover);
}

.row-actions button[data-action="delete"]:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--red);
  border-color: rgba(239, 68, 68, 0.2);
}

.row-actions button[data-action="mail"]:hover {
  background: rgba(59, 130, 246, 0.1);
  color: #60a5fa;
  border-color: rgba(59, 130, 246, 0.2);
}

.mail-check {
  width: 54px;
  min-height: 36px;
  display: grid;
  place-items: center;
  gap: 2px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 900;
  cursor: pointer;
  text-transform: uppercase;
  transition: all 0.2s;
}

.mail-check:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border-color-hover);
  color: var(--text-primary);
}

.mail-check input {
  width: 15px;
  height: 15px;
  accent-color: var(--red);
  margin: 0;
}

.contact-card.important .row-actions button[data-action="mail"],
.special-target {
  border-color: rgba(249, 115, 22, 0.4);
  background: rgba(249, 115, 22, 0.1);
  color: #fb923c;
  font-weight: 800;
}

.contact-card.important .row-actions button[data-action="mail"]:hover {
  background: rgba(249, 115, 22, 0.2);
}

/* Drawers - Side Panels */
.entry-panel,
.mail-panel {
  position: fixed;
  top: 0;
  bottom: 0;
  z-index: 30;
  width: min(92vw, 500px);
  overflow: auto;
  background: rgba(13, 19, 32, 0.88);
  backdrop-filter: blur(24px);
  border: 0;
  margin: 0;
  padding: 24px;
  box-shadow: var(--shadow-lg);
  transition: transform 260ms cubic-bezier(0.16, 1, 0.3, 1);
}

.entry-panel {
  left: 0;
  border-right: 1px solid var(--border-color);
  transform: translateX(calc(-100% - 24px));
}

.mail-panel {
  right: 0;
  width: min(94vw, 720px);
  border-left: 1px solid var(--border-color);
  transform: translateX(calc(100% + 24px));
}

.entry-open .entry-panel,
.mail-open .mail-panel {
  transform: translateX(0);
}

.drawer-head {
  position: sticky;
  top: -24px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -24px -24px 18px;
  padding: 20px 24px;
  background: rgba(13, 19, 32, 0.95);
  backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--border-color);
}

.drawer-head h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
}

.drawer-close {
  width: 38px;
  height: 38px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.05);
  font-size: 20px;
  line-height: 1;
  color: var(--text-muted);
  transition: all 0.2s;
}

.drawer-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  border-color: var(--border-color-hover);
}

.card-upload,
.mail-panel,
.form-grid {
  border-radius: var(--radius-lg);
}

/* Card Upload Area inside Drawer */
.card-upload {
  display: grid;
  gap: 10px;
  border: 1px solid rgba(255, 59, 48, 0.2);
  padding: 16px;
  margin-bottom: 18px;
  background: rgba(255, 59, 48, 0.03);
}

.ocr-engine-name {
  color: var(--red);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ocr-engine-name::before {
  content: "";
  width: 6px;
  height: 6px;
  background: var(--red);
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 8px var(--red-glow);
}

.bulk-cards {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.bulk-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.02);
}

.bulk-card.has-error {
  border-color: rgba(239, 68, 68, 0.2);
  background: rgba(239, 68, 68, 0.03);
}

.bulk-title {
  font-weight: 800;
  margin-bottom: 4px;
  font-size: 14px;
}

.bulk-step {
  color: var(--red);
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  margin-bottom: 4px;
  letter-spacing: 0.05em;
}

.bulk-fair-field {
  display: grid;
  gap: 4px;
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
}

.bulk-fair-field input {
  min-height: 34px;
  padding: 7px 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-input);
}

.bulk-fair-choices {
  display: grid;
  gap: 5px;
  max-height: 170px;
  overflow: auto;
  margin-top: 6px;
  padding: 6px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-input);
}

.bulk-fair-choices button {
  display: grid;
  gap: 2px;
  padding: 7px 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-primary);
  text-align: left;
}

.bulk-fair-choices button:hover {
  border-color: rgba(255, 59, 48, 0.2);
  background: rgba(255, 59, 48, 0.05);
}

.bulk-fair-choices span {
  font-weight: 900;
}

.bulk-fair-choices small,
.bulk-fair-empty {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
}

.bulk-fair-empty {
  margin-top: 5px;
}

.bulk-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 6px;
}

.bulk-actions {
  display: grid;
  gap: 6px;
  min-width: 92px;
}

.bulk-actions button {
  padding: 8px;
  font-size: 12px;
  font-weight: 800;
}

.hidden {
  display: none !important;
}

.empty {
  padding: 48px;
  text-align: center;
  color: var(--text-muted);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-lg);
  font-size: 15px;
}

/* Forms general styling inside Drawer */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

label {
  display: grid;
  gap: 5px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 9px 12px;
  background: var(--bg-input);
  color: var(--text-primary);
  transition: all 0.2s;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--red);
  box-shadow: 0 0 10px var(--red-glow);
}

textarea {
  resize: vertical;
}

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

.inline-action {
  display: grid;
  grid-template-columns: 1fr 42px;
  gap: 6px;
}

.fair-select {
  margin-top: 6px;
  background: rgba(255, 59, 48, 0.02);
  border-color: rgba(255, 59, 48, 0.15);
  color: #fca5a5;
}

.fair-search {
  margin-top: 6px;
}

.fair-results {
  display: grid;
  gap: 6px;
  margin-top: 6px;
  max-height: 240px;
  overflow: auto;
}

.fair-result {
  width: 100%;
  display: grid;
  gap: 2px;
  text-align: left;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
}

.fair-result span {
  font-size: 12.5px;
  font-weight: 850;
  line-height: 1.25;
}

.fair-result small,
.fair-empty {
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.35;
}

.fair-result:hover {
  border-color: rgba(255, 59, 48, 0.3);
  background: rgba(255, 59, 48, 0.05);
}

.fair-empty {
  padding: 8px 2px;
}

.icon-button {
  width: 42px;
  min-width: 42px;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 18px;
}

.toggle-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: center;
}

.check {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  cursor: pointer;
}

.check input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--red);
}

.important-row {
  padding: 8px 12px;
  border: 1px solid rgba(255, 59, 48, 0.2);
  border-radius: 8px;
  background: rgba(255, 59, 48, 0.03);
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.actions button {
  flex: 1;
}

/* Mail Drawer Panel specifically */
.mail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.mail-head h2 {
  margin: 0;
  font-size: 18px;
}

.mail-actions,
.mail-send-actions,
.placeholder-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

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

@media (min-width: 760px) {
  .mail-panel .template-grid {
    grid-template-columns: minmax(0, 1fr) minmax(140px, 200px);
  }
}

.placeholder-strip {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 10px 0;
  margin: 12px 0;
}

.placeholder-strip button {
  padding: 6px 10px;
  font-size: 11.5px;
  color: #fb923c;
  border-color: rgba(249, 115, 22, 0.2);
  background: rgba(249, 115, 22, 0.05);
  font-weight: 800;
}

.placeholder-strip button:hover {
  background: rgba(249, 115, 22, 0.12);
  border-color: rgba(249, 115, 22, 0.4);
}

.mail-preview {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.2);
  margin-bottom: 16px;
}

.preview-subject {
  border-bottom: 1px solid var(--border-color);
  padding: 12px 16px;
  font-weight: 800;
  color: var(--text-primary);
  font-size: 14px;
}

.mail-preview pre {
  margin: 0;
  padding: 16px;
  white-space: pre-wrap;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-muted);
  max-height: 300px;
  overflow: auto;
}

.mail-send-actions {
  margin-top: 16px;
}

/* Media Queries for Responsiveness */
@media (max-width: 980px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    padding: 16px 20px;
  }
  
  .topbar-actions {
    justify-content: flex-start;
    width: 100%;
  }

  .list-panel {
    padding: 20px 16px;
  }

  .contact-card {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .analysis {
    padding-left: 0;
    border-left: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 16px;
  }

  .row-actions {
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
  }
}

@media (max-width: 620px) {
  .topbar-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .panel-actions,
  .user-chip,
  .summary,
  #exportExcelBtn {
    width: 100%;
  }

  .panel-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

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

  .entry-panel,
  .mail-panel {
    width: 100vw;
  }
}
