:root {
  --ink: #111827;
  --muted: #64748b;
  --line: #d7deea;
  --panel: #ffffff;
  --bg: #f3f5f1;
  --nav: #05070b;
  --gold: #f7c624;
  --gold-strong: #f2a900;
  --blue: #2854c5;
  --blue-dark: #183b92;
  --green: #0f7a55;
  --amber: #b7791f;
  --shadow: 0 18px 40px rgba(15, 23, 42, .10);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.auth-pending .app-shell {
  visibility: hidden;
}

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(24px, 5vw, 72px);
  background:
    radial-gradient(circle at 16% 18%, rgba(247, 198, 36, .28), transparent 32%),
    radial-gradient(circle at 84% 16%, rgba(15, 122, 85, .22), transparent 34%),
    linear-gradient(120deg, rgba(5, 7, 11, .98) 0%, rgba(16, 20, 29, .94) 48%, rgba(5, 7, 11, .86) 100%);
}

.login-overlay[hidden] {
  display: none;
}

.login-shell {
  width: min(1180px, 100%);
  min-height: min(680px, calc(100vh - 80px));
  display: grid;
  grid-template-columns: minmax(0, 1.28fr) minmax(360px, 430px);
  border: 1px solid rgba(247, 198, 36, .22);
  border-radius: 20px;
  overflow: hidden;
  background: rgba(5, 7, 11, .72);
  box-shadow: 0 36px 100px rgba(0, 0, 0, .58);
  backdrop-filter: blur(14px);
}

.login-hero {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 520px;
  padding: clamp(34px, 5vw, 64px);
  overflow: hidden;
}

.login-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, transparent 0%, rgba(5, 7, 11, .72) 72%, rgba(5, 7, 11, .95) 100%),
    linear-gradient(135deg, rgba(247, 198, 36, .18), transparent 46%);
  pointer-events: none;
}

.login-hero > * {
  position: relative;
  z-index: 1;
}

.login-hero-logo {
  width: min(250px, 54vw);
  height: auto;
  margin-bottom: auto;
  padding: 12px;
  border-radius: 12px;
  background: linear-gradient(135deg, #ffffff, #fff3b8);
  filter: drop-shadow(0 16px 26px rgba(0, 0, 0, .5));
}

.login-kicker {
  margin: 0 0 10px;
  color: var(--gold);
  font-size: .82rem;
  font-weight: 950;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.login-hero h1 {
  max-width: 760px;
  margin: 0;
  color: #ffffff;
  font-size: clamp(3.2rem, 7vw, 6.8rem);
  line-height: .9;
  letter-spacing: 0;
}

.login-copy {
  max-width: 640px;
  margin: 24px 0 0;
  color: rgba(248, 250, 252, .84);
  font-size: clamp(1rem, 1.5vw, 1.24rem);
  line-height: 1.55;
}

.login-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

.login-tags span {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(247, 198, 36, .28);
  border-radius: 999px;
  padding: 0 14px;
  background: rgba(247, 198, 36, .1);
  color: #fff8d5;
  font-size: .78rem;
  font-weight: 900;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.login-card {
  display: grid;
  gap: 16px;
  align-content: center;
  width: 100%;
  padding: clamp(28px, 4vw, 48px);
  border-left: 1px solid rgba(247, 198, 36, .18);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .98), rgba(255, 251, 232, .98));
}

.login-card h2 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(2rem, 3vw, 2.7rem);
  line-height: 1;
}

.login-form-copy {
  margin: -4px 0 6px;
  color: var(--muted);
  font-size: .92rem;
}

.login-card input {
  width: 100%;
  min-height: 48px;
}

.password-field {
  position: relative;
  display: block;
}

.password-field input {
  padding-right: 52px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 10px;
  width: 34px;
  height: 34px;
  transform: translateY(-50%);
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(17, 24, 39, .14);
  border-radius: 8px;
  background: #fff8d5;
  color: #111827;
  cursor: pointer;
}

.password-toggle:hover {
  background: #f7c624;
}

.password-toggle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.login-submit {
  min-height: 50px;
  margin-top: 4px;
  font-size: 1rem;
}

.login-status {
  min-height: 20px;
  margin: 0;
  color: #b45309;
  font-size: .86rem;
  font-weight: 900;
}

.app-shell {
  display: grid;
  grid-template-columns: 284px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  background:
    radial-gradient(circle at 20% 0%, rgba(247, 198, 36, .22), transparent 30%),
    linear-gradient(180deg, #05070b 0%, #10141d 58%, #05070b 100%);
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand-block {
  display: grid;
  grid-template-columns: 82px 1fr;
  gap: 12px;
  align-items: center;
}

.brand-logo {
  width: 82px;
  max-height: 44px;
  object-fit: contain;
  padding: 4px;
  border-radius: 8px;
  background: linear-gradient(135deg, #ffffff, #fff6cc);
}

.eyebrow {
  margin: 0 0 6px;
  color: #0f7a55;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.brand-block .eyebrow { color: var(--gold); }
.brand-block h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1;
}
.brand-block span {
  color: #cbd5e1;
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 10px;
}

.project-menu {
  border: 1px solid rgba(247, 198, 36, .32);
  border-radius: 10px;
  background: rgba(255,255,255,.06);
  overflow: hidden;
}

.project-menu summary {
  min-height: 54px;
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  align-items: center;
  padding: 10px;
  color: #f8fafc;
  cursor: pointer;
  list-style: none;
}

.project-menu summary::-webkit-details-marker {
  display: none;
}

.project-menu summary::after {
  content: "";
  justify-self: end;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--gold);
  border-bottom: 2px solid var(--gold);
  transform: rotate(45deg);
  grid-column: 2;
  grid-row: 1;
}

.project-menu[open] summary::after {
  transform: rotate(225deg);
}

.project-menu summary span,
.nav-item span {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: rgba(247,198,36,.16);
  color: var(--gold);
  font-size: 12px;
}

.project-menu-items {
  display: grid;
  gap: 8px;
  padding: 0 8px 10px 18px;
}

.nav-item {
  width: 100%;
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  align-items: center;
  min-height: 48px;
  padding: 10px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px;
  background: rgba(255,255,255,.05);
  color: #e5e7eb;
  text-align: left;
  font-weight: 800;
  cursor: pointer;
}

.nav-item.active {
  border-color: var(--gold);
  background: linear-gradient(135deg, #ffe066, var(--gold-strong));
  color: #111827;
  box-shadow: 0 10px 28px rgba(247, 198, 36, .18);
}

.nav-item.active span {
  background: rgba(17, 24, 39, .12);
  color: #111827;
}

.nav-item.disabled {
  opacity: .55;
  cursor: not-allowed;
}

.sidebar-foot {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(247,198,36,.25);
  border-radius: 10px;
  background: rgba(247,198,36,.08);
}

.sidebar-foot span {
  display: block;
  color: #cbd5e1;
  font-size: 12px;
}

.sidebar-foot strong {
  display: block;
  margin-top: 4px;
  font-size: 14px;
}

.main {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.topbar h2 {
  margin: 0;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1;
}

.subtitle {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 16px;
}

.primary-btn {
  min-height: 42px;
  padding: 0 18px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, #111827, #020617);
  color: var(--gold);
  font-weight: 900;
  cursor: pointer;
}

.primary-btn.small {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.secondary-btn {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(17, 24, 39, .16);
  border-radius: 8px;
  background: linear-gradient(135deg, #ffffff, #fff7d1);
  color: #111827;
  font-weight: 900;
  cursor: pointer;
}

.secondary-btn.small {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.section {
  display: none;
}
.section.active {
  display: block;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255,255,255,.96), rgba(255,248,210,.88)),
    radial-gradient(circle at 100% 0%, rgba(247,198,36,.34), transparent 34%);
  box-shadow: var(--shadow);
}

.section-head h3 {
  margin: 0;
  font-size: 28px;
}

.section-head p {
  margin: 8px 0 0;
  color: var(--muted);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #fff7ed;
  color: var(--amber);
  font-size: 12px;
  font-weight: 900;
}

.status-pill.ok {
  background: #dcfce7;
  color: var(--green);
}

.status-pill.error {
  background: #fee2e2;
  color: #b91c1c;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0;
}

.metric-card {
  min-height: 126px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #f9fbff);
  box-shadow: 0 10px 28px rgba(15, 23, 42, .06);
}

.metric-card span {
  display: block;
  color: #936900;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.metric-card strong {
  display: block;
  margin-top: 10px;
  font-size: 28px;
  line-height: 1.05;
}

.metric-card p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, .75fr);
  gap: 18px;
}

.content-grid.single-main {
  grid-template-columns: 1fr;
  margin-top: 18px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.panel-head {
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, #111827, #1e293b);
  color: #f8fafc;
}

.panel-head h4 {
  margin: 0;
  font-size: 20px;
}

.panel-head p {
  margin: 6px 0 0;
  color: #cbd5e1;
}

.owners-list {
  display: grid;
  gap: 0;
}

.owner-table-head,
.owner-table-row,
.owner-table-footer {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) minmax(220px, 1.2fr) 130px 190px;
  gap: 12px;
  align-items: center;
}

.owner-table-head {
  padding: 12px 18px;
  background: #fff1a6;
  color: #111827;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.owner-table-row,
.owner-table-footer {
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, #ffffff, #fffdf2);
}

.owner-table-row:last-child {
  border-bottom: 0;
}

.owner-table-row small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.owner-table-row > span {
  overflow-wrap: anywhere;
}

.owner-table-footer {
  border-top: 2px solid #f7c624;
  border-bottom: 0;
  background: linear-gradient(135deg, #111827, #1e293b);
  color: #f8fafc;
}

.owner-block {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, #ffffff, #fffdf2);
}

.owner-block:last-child {
  border-bottom: 0;
}

.owner-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  align-items: flex-start;
}

.owner-title strong {
  font-size: 16px;
}

.owner-title span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.task-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.task-item {
  padding: 10px 12px;
  border: 1px solid #e6edf5;
  border-radius: 8px;
  background: #fbfdff;
}

.task-item strong {
  display: block;
  font-size: 14px;
}

.task-item span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.detail-list {
  margin: 0;
  padding: 18px;
}

.detail-list div {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.detail-list div:first-child { padding-top: 0; }
.detail-list dt {
  color: #936900;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.detail-list dd {
  margin: 5px 0 0;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.secondary-link {
  display: inline-flex;
  margin: 0 18px 18px;
  min-height: 38px;
  align-items: center;
  padding: 0 14px;
  border-radius: 8px;
  background: #fff1a6;
  color: #111827;
  font-weight: 900;
  text-decoration: none;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.empty-state {
  padding: 24px 18px;
  color: var(--muted);
}

.workflow-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  padding: 18px;
}

.workflow-card,
.person-card,
.user-row {
  border: 1px solid #e0e8f2;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #fffdf2);
}

.workflow-card {
  min-height: 150px;
  padding: 16px;
}

.workflow-card span {
  display: inline-grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 6px;
  background: #111827;
  color: var(--gold);
  font-weight: 900;
}

.workflow-card strong {
  display: block;
  margin-top: 14px;
  font-size: 16px;
}

.workflow-card p,
.draft-output p,
.criteria-body p {
  color: var(--muted);
  line-height: 1.5;
}

.draft-output {
  margin: 0 18px 18px;
  padding: 18px;
  border: 1px dashed #c9a227;
  border-radius: 8px;
  background: #fffdf2;
}

.draft-output.compact-output {
  margin-top: 16px;
}

.comms-panel {
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, #fffdf2, #f8fbff);
}

.comms-panel .inline-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  border-bottom: 0;
  background: transparent;
  color: var(--ink);
}

.comms-panel .inline-head p {
  color: var(--muted);
}

.comms-panel .draft-output {
  background: #ffffff;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, .52);
}

.modal-backdrop[hidden] {
  display: none;
}

.status-modal {
  width: min(460px, 100%);
  padding: 28px;
  border: 1px solid rgba(247, 198, 36, .55);
  border-radius: 12px;
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 28px 80px rgba(15, 23, 42, .32);
  text-align: center;
}

.status-modal h3 {
  margin: 14px 0 8px;
  font-size: 24px;
}

.status-modal p {
  margin: 0 0 18px;
  color: var(--muted);
}

.modal-spinner {
  width: 42px;
  height: 42px;
  margin: 0 auto;
  border: 4px solid #fef3c7;
  border-top-color: var(--gold-strong);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

.modal-spinner[hidden] {
  display: none;
}

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

.draft-output h4 {
  margin: 0 0 8px;
  font-size: 20px;
}

.draft-output pre {
  margin: 16px 0 0;
  padding: 14px;
  border-radius: 8px;
  background: #111827;
  color: #e5e7eb;
  white-space: pre-wrap;
  overflow-x: auto;
}

.draft-checklist {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.draft-checklist span {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.draft-checklist .ok {
  background: #dcfce7;
  color: var(--green);
}

.draft-checklist .pending {
  background: #fff7ed;
  color: var(--amber);
}

.draft-results {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.draft-result-card {
  padding: 12px;
  border: 1px solid #cfe0f6;
  border-radius: 8px;
  background: #ffffff;
}

.draft-result-card strong,
.draft-result-card span,
.draft-result-card small {
  display: block;
}

.draft-result-card span,
.draft-result-card small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.draft-skipped {
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  background: #fff7ed;
}

.draft-skipped p {
  margin: 4px 0;
  color: var(--amber);
  font-weight: 800;
}

.people-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 18px;
}

.person-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
}

.person-card strong,
.person-card span,
.person-card a,
.person-card small {
  display: block;
  overflow-wrap: anywhere;
}

.person-card span,
.person-card small {
  color: var(--muted);
  font-size: 12px;
}

.person-card a {
  margin: 5px 0;
  color: #0f4aa0;
  font-weight: 800;
}

.person-draft-btn {
  white-space: nowrap;
}

.criteria-list {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.criteria-list details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
}

.criteria-list summary {
  padding: 16px 18px;
  color: var(--blue-dark);
  font-weight: 900;
  cursor: pointer;
}

.criteria-body {
  padding: 0 18px 18px;
}

.criteria-body ul {
  margin: 0;
  padding-left: 20px;
  color: #1f2937;
  line-height: 1.55;
}

.email-assets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.email-assets a {
  padding: 9px 11px;
  border-radius: 8px;
  background: #e8f0ff;
  color: var(--blue-dark);
  font-weight: 900;
  text-decoration: none;
}

.people-table {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.table-head,
.table-row {
  display: grid;
  grid-template-columns: 1fr 1.2fr 1.4fr 1fr;
}

.table-head span,
.table-row span {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere;
}

.table-head span {
  background: #f8fbff;
  color: var(--blue-dark);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.table-row:last-child span {
  border-bottom: 0;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(280px, .5fr) minmax(280px, .5fr) minmax(360px, 1fr);
  gap: 18px;
  margin-top: 18px;
}

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

.gmail-box {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: end;
  padding: 18px;
}

.detail-list.compact {
  padding: 0;
}

.link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.stack-form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.stack-form label {
  display: grid;
  gap: 7px;
  color: #42526a;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.stack-form input {
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid #c7d3e3;
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
}

.users-list {
  display: grid;
  gap: 10px;
  padding: 18px;
}

.user-row {
  padding: 12px;
}

.user-row span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 980px) {
  .login-shell {
    grid-template-columns: 1fr;
  }

  .login-hero {
    min-height: 360px;
  }

  .login-card {
    border-left: 0;
    border-top: 1px solid rgba(247, 198, 36, .18);
  }

  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
  }
  .metrics-grid, .content-grid, .workflow-grid, .people-list, .settings-grid, .table-head, .table-row, .gmail-box, .owner-table-head, .owner-table-row, .owner-table-footer {
    grid-template-columns: 1fr;
  }
  .topbar {
    flex-direction: column;
  }
}
