:root {
  color-scheme: light;
  --ink: #10202b;
  --ink-soft: #60717d;
  --navy: #071520;
  --navy-2: #102633;
  --canvas: #f3f6f7;
  --surface: #ffffff;
  --line: #dce4e8;
  --mint: #57d7c7;
  --mint-dark: #0e8175;
  --amber: #d58a16;
  --red: #c94646;
  --blue: #2a6f97;
  --shadow: 0 18px 50px rgba(7, 21, 32, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--canvas); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--canvas);
  font-size: 1rem;
  line-height: 1.5;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

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

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
  background:
    radial-gradient(circle at 80% 20%, rgba(87, 215, 199, 0.14), transparent 32rem),
    linear-gradient(135deg, #06131c, #0e2633);
}

.login-card {
  width: min(100%, 27rem);
  padding: 2.25rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 1.35rem;
  color: white;
  background: rgba(10, 28, 39, 0.92);
  box-shadow: 0 35px 90px rgba(0, 0, 0, 0.32);
}

.brand-mark {
  width: 3.5rem;
  height: 3.5rem;
  display: grid;
  place-items: center;
  border-radius: 1rem;
  color: var(--navy);
  background: var(--mint);
  font-size: 1.05rem;
  font-weight: 850;
  letter-spacing: -0.04em;
}

.brand-mark-small { width: 2.5rem; height: 2.5rem; border-radius: 0.72rem; font-size: 0.85rem; }
.eyebrow { margin: 1.5rem 0 0.3rem; color: var(--mint-dark); font-size: 0.75rem; font-weight: 800; letter-spacing: 0.13em; text-transform: uppercase; }
.login-card .eyebrow { color: var(--mint); }
.login-card h1 { margin: 0; font-size: clamp(1.8rem, 5vw, 2.45rem); letter-spacing: -0.045em; }
.login-copy { margin: 0.7rem 0 1.7rem; color: #b7c6cf; }
.login-form { display: grid; gap: 0.8rem; }

label { display: grid; gap: 0.45rem; color: var(--ink); font-size: 0.9rem; font-weight: 700; }
.login-card label { color: #dbe6ea; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0.72rem;
  color: var(--ink);
  background: white;
  outline: none;
  font-weight: 500;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

input, select { min-height: 2.85rem; padding: 0 0.85rem; }
textarea { padding: 0.85rem; line-height: 1.55; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--mint-dark); box-shadow: 0 0 0 3px rgba(87, 215, 199, 0.2); }
.login-card input { border-color: #35505f; color: white; background: #0b202c; }

.button {
  min-height: 2.7rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.62rem 1rem;
  border: 1px solid transparent;
  border-radius: 0.72rem;
  font-size: 0.9rem;
  font-weight: 800;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: 0.52; transform: none; }
.button-primary { color: #06241f; background: var(--mint); }
.button-primary:hover { background: #6be3d4; }
.button-dark { color: white; background: var(--navy); }
.button-dark:hover { background: var(--navy-2); }
.button-secondary { border-color: var(--line); color: var(--ink); background: white; }
.button-secondary:hover { border-color: #aebdc5; }
.button-block { width: 100%; margin-top: 0.35rem; }

.form-error { min-height: 1.4rem; margin: 0; color: #f07d7d; font-size: 0.85rem; font-weight: 650; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 15.5rem minmax(0, 1fr); }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1rem;
  color: white;
  background: var(--navy);
}

.sidebar-brand { display: flex; align-items: center; gap: 0.75rem; padding: 0.25rem 0.35rem 1.8rem; }
.sidebar-brand strong, .sidebar-brand span { display: block; }
.sidebar-brand strong { font-size: 0.95rem; }
.sidebar-brand span { color: #879ba7; font-size: 0.78rem; }
.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.72rem;
  padding: 0.78rem;
  border: 0;
  border-radius: 0.72rem;
  color: #b8c8d0;
  background: transparent;
  text-align: left;
  font-weight: 700;
}
.nav-item svg { width: 1.2rem; fill: none; stroke: currentColor; stroke-width: 1.8; }
.nav-item-active { color: white; background: #14303e; }
.sidebar-footer { margin-top: auto; padding: 1rem 0.4rem 0; border-top: 1px solid #1e3542; }
.sidebar-footer p { margin: 0; color: #dbe7eb; font-size: 0.85rem; font-weight: 750; }
.sidebar-footer span { color: #718894; font-size: 0.75rem; }
.nav-logout { margin-top: 0.8rem; padding-left: 0; }

.workspace { min-width: 0; padding: 2.25rem clamp(1.25rem, 3.5vw, 3rem) 3rem; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; }
.page-header .eyebrow { margin-top: 0; }
.page-header h1 { margin: 0; font-size: clamp(1.9rem, 4vw, 2.65rem); letter-spacing: -0.05em; }
.header-actions { display: flex; align-items: center; gap: 0.65rem; flex-wrap: wrap; justify-content: flex-end; }
.smtp-chip { min-height: 2.7rem; display: inline-flex; align-items: center; gap: 0.55rem; padding: 0 0.85rem; border: 1px solid var(--line); border-radius: 0.72rem; color: var(--ink-soft); background: white; font-size: 0.82rem; font-weight: 700; }
.status-dot { width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--mint-dark); box-shadow: 0 0 0 4px rgba(14, 129, 117, 0.1); }

.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.85rem; margin: 2rem 0 1.2rem; }
.summary-card { min-height: 7rem; display: flex; flex-direction: column; justify-content: space-between; padding: 1.1rem 1.2rem; border: 1px solid var(--line); border-radius: 1rem; background: white; }
.summary-card span { color: var(--ink-soft); font-size: 0.82rem; font-weight: 700; }
.summary-card strong { font-size: 2rem; letter-spacing: -0.05em; }
.summary-card-total { border-color: transparent; color: white; background: var(--navy-2); }
.summary-card-total span { color: #a9bac3; }

.lead-panel { border: 1px solid var(--line); border-radius: 1.1rem; background: var(--surface); overflow: hidden; box-shadow: 0 8px 30px rgba(17, 40, 53, 0.04); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.25rem; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin: 0; font-size: 1.1rem; }
.panel-heading p { margin: 0.18rem 0 0; color: var(--ink-soft); font-size: 0.85rem; }
.filters { display: flex; gap: 0.6rem; }
.filters select { min-width: 11rem; }
.search-field { position: relative; display: block; }
.search-field svg { position: absolute; top: 0.8rem; left: 0.8rem; width: 1.15rem; fill: none; stroke: #71838d; stroke-width: 1.8; pointer-events: none; }
.search-field input { width: min(22rem, 32vw); padding-left: 2.5rem; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 0.95rem 1.2rem; border-bottom: 1px solid #ebf0f2; text-align: left; vertical-align: middle; }
th { color: #71818b; background: #f9fbfb; font-size: 0.73rem; font-weight: 850; letter-spacing: 0.06em; text-transform: uppercase; }
tbody tr { transition: background 120ms ease; }
tbody tr:hover { background: #f8fbfb; }
tbody tr:last-child td { border-bottom: 0; }
.company-cell strong, .company-cell span { display: block; }
.company-cell span { margin-top: 0.16rem; color: var(--ink-soft); font-size: 0.76rem; }
.subject-cell { max-width: 18rem; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.align-right { text-align: right; }
.row-button { min-height: 2.25rem; padding: 0.4rem 0.72rem; }

.badge { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.35rem 0.58rem; border-radius: 99px; font-size: 0.73rem; font-weight: 800; white-space: nowrap; }
.badge-confirmed { color: #087266; background: #e3f8f4; }
.badge-pending { color: #93610d; background: #fff3d9; }
.badge-blocked { color: #a23a3a; background: #fdeaea; }
.badge-sent { color: #235f87; background: #e6f2fa; }
.empty-state { padding: 3rem; color: var(--ink-soft); text-align: center; }

.dialog { width: min(92vw, 56rem); max-height: 92vh; padding: 0; border: 0; border-radius: 1.1rem; color: var(--ink); background: white; box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(3, 14, 21, 0.67); backdrop-filter: blur(4px); }
.dialog-confirm { width: min(92vw, 33rem); }
.dialog-header, .dialog-footer { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.1rem 1.25rem; }
.dialog-header { border-bottom: 1px solid var(--line); }
.dialog-header .eyebrow { margin: 0 0 0.15rem; }
.dialog-header h2 { margin: 0; font-size: 1.25rem; }
.dialog-body { display: grid; gap: 1rem; max-height: calc(92vh - 9rem); padding: 1.25rem; overflow-y: auto; }
.dialog-footer { border-top: 1px solid var(--line); }
.dialog-footer-right { justify-content: flex-end; }
.dialog-actions { display: flex; gap: 0.55rem; margin-left: auto; }
.icon-button { width: 2.5rem; height: 2.5rem; border: 0; border-radius: 50%; color: var(--ink-soft); background: transparent; font-size: 1.6rem; line-height: 1; }
.icon-button:hover { background: var(--canvas); }
.field-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(12rem, 0.6fr); gap: 0.8rem; }
.confirmation-box { padding: 0.9rem; border: 1px solid #f0d49d; border-radius: 0.8rem; background: #fff9ed; }
.confirm-summary { padding: 0.9rem; border: 1px solid var(--line); border-radius: 0.8rem; background: #f8fafb; }
.confirm-summary strong, .confirm-summary span { display: block; }
.confirm-summary span { margin-top: 0.2rem; color: var(--ink-soft); font-size: 0.82rem; overflow-wrap: anywhere; }
.safety-note { margin: 0; color: var(--ink-soft); font-size: 0.82rem; }
.sent-note { color: var(--blue); font-size: 0.82rem; font-weight: 750; }

.toast { position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 20; max-width: min(90vw, 25rem); padding: 0.85rem 1rem; border-radius: 0.8rem; color: white; background: var(--navy); box-shadow: var(--shadow); opacity: 0; transform: translateY(1rem); pointer-events: none; transition: opacity 180ms ease, transform 180ms ease; }
.toast-visible { opacity: 1; transform: translateY(0); }

@media (max-width: 1000px) {
  .app-shell { grid-template-columns: 5rem minmax(0, 1fr); }
  .sidebar-brand > div:last-child { display: none; }
  .nav-item:not(.nav-logout) { font-size: 0; }
  .nav-item { justify-content: center; }
  .nav-item svg { width: 1.35rem; }
  .sidebar-footer p, .sidebar-footer span { display: none; }
  .nav-logout { justify-content: center; padding-left: 0.78rem; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-header { align-items: flex-start; flex-direction: column; }
  .header-actions { justify-content: flex-start; }
  .panel-heading { align-items: stretch; flex-direction: column; }
  .search-field input { width: 100%; }
  .filters { width: 100%; }
  .filters label { flex: 1; }
  .filters select { min-width: 0; }
}

@media (max-width: 680px) {
  .app-shell { display: block; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; justify-content: space-between; padding: 0.75rem 1rem; }
  .sidebar-brand { padding: 0; }
  .sidebar nav, .sidebar-footer p, .sidebar-footer span { display: none; }
  .sidebar-footer { margin: 0; padding: 0; border: 0; }
  .nav-logout { margin: 0; }
  .workspace { padding: 1.4rem 1rem 2rem; }
  .header-actions { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .smtp-chip { grid-column: 1 / -1; }
  .summary-grid { gap: 0.6rem; margin-top: 1.3rem; }
  .summary-card { min-height: 6rem; padding: 0.9rem; }
  .filters { flex-direction: column; }
  .field-grid { grid-template-columns: 1fr; }
  .dialog-footer { align-items: stretch; flex-direction: column; }
  .dialog-actions { display: grid; grid-template-columns: 1fr 1fr; width: 100%; margin: 0; }
  #send-lead { grid-column: 1 / -1; }
  th, td { padding: 0.8rem; }
  th:nth-child(2), td:nth-child(2), th:nth-child(4), td:nth-child(4) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
