:root {
  --cream: #F1EFE8;
  --sidebar: #17171F;
  --card: #FFFFFF;
  --ink: #17171F;
  --muted: #6B6B76;
  --line: #E4E1D8;
  --compliance-bg: #D6B3F0;
  --compliance-fg: #6B21A8;
  --money-bg: #FFC299;
  --money-fg: #C2410C;
  --customer-bg: #8EEDE0;
  --customer-fg: #0F766E;
  --sales-bg: #FFA8D8;
  --sales-fg: #BE185D;
  --hr-bg: #FFC299;
  --hr-fg: #C2410C;
  --blue-bg: #B3C6F5;
  --blue-fg: #1E40AF;
  --gold-bg: #FFE199;
  --gold-fg: #A16207;
  --pink-bg: #FFA8D8;
  --pink-fg: #BE185D;
  --teal-bg: #8EEDE0;
  --teal-fg: #0F766E;
  --purple-bg: #D6B3F0;
  --purple-fg: #6B21A8;
  --coral-bg: #FFC299;
  --coral-fg: #C2410C;
  --ok-bg: #D1FAE5;
  --ok-fg: #047857;
  --warn-bg: #FEF3C7;
  --warn-fg: #A16207;
  --bad-bg: #FFE4D6;
  --bad-fg: #C2410C;
  --shadow: 0 18px 50px rgba(23, 23, 31, 0.08);
  --radius: 28px;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sans: "DM Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--sans);
  background: #FFFFFF;
  color: var(--ink);
  min-height: 100%;
}
button, input, select, textarea { font-family: inherit; color: var(--ink); }
button { cursor: pointer; }
img { display: block; max-width: 100%; }
a { color: inherit; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: #FFFFFF;
}

.sidebar {
  width: 88px;
  flex-shrink: 0;
  height: 100vh;
  background: var(--sidebar);
  color: #FFFFFF;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 0 20px;
  z-index: 20;
}
.sidebar-logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--pink-bg);
  display: grid;
  place-items: center;
  border: 0;
  padding: 8px;
  margin-bottom: 28px;
}
.sidebar-logo img { width: 28px; height: 28px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 18px; width: 100%; }
.sidebar-nav.bottom { margin-top: auto; }
.nav-btn {
  background: transparent;
  border: 0;
  color: #FFFFFF;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 4px;
  width: 100%;
}
.nav-btn .nav-icon {
  width: 22px;
  height: 22px;
  border: 1.6px solid #FFFFFF;
  border-radius: 50%;
  display: grid;
  place-items: center;
}
.nav-btn .nav-icon svg { width: 12px; height: 12px; stroke: #FFFFFF; fill: none; stroke-width: 1.8; }
.nav-btn span {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #FFFFFF;
}
.nav-btn.active .nav-icon,
.nav-btn:hover .nav-icon { background: rgba(255,255,255,0.12); }

.stage-wrap {
  flex: 1;
  padding: 16px 16px 16px 8px;
  min-width: 0;
  height: 100vh;
  overflow: auto;
}
.stage {
  background: var(--cream);
  border-radius: var(--radius);
  min-height: calc(100vh - 32px);
  box-shadow: var(--shadow);
  padding: 28px 32px 40px;
  position: relative;
}
#content { min-width: 0; }

.hamburger {
  display: none;
  position: absolute;
  top: 16px;
  left: 16px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 10px;
  background: var(--sidebar);
  color: #FFFFFF;
  z-index: 5;
}
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(23,23,31,0.45);
  z-index: 15;
}

/* Login */
.login-page {
  display: block;
  height: 100vh;
  overflow: auto;
  background: #FFFFFF;
}
.login-reset {
  position: absolute;
  top: 18px;
  left: 18px;
  z-index: 5;
}
.login-page .stage-wrap {
  height: auto;
  min-height: 100vh;
  padding: 16px;
}
.login-page .stage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 32px);
}
.login-card {
  width: min(440px, 100%);
  text-align: center;
}
.login-mark {
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  border: 0;
  border-radius: 16px;
  background: var(--purple-bg);
  display: grid;
  place-items: center;
  padding: 12px;
}
.login-mark img { width: 40px; height: 40px; }
.login-card h1 {
  margin: 0 0 8px;
  font-size: 34px;
  font-weight: 700;
  color: var(--ink);
}
.login-tagline {
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.4;
}
.sso-stack { display: flex; flex-direction: column; gap: 10px; }
.sso-btn {
  width: 100%;
  border: 0;
  border-radius: 14px;
  min-height: 52px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 16px;
  font-weight: 600;
  position: relative;
}
.sso-btn .brand {
  position: absolute;
  left: 16px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
}
.sso-btn .brand img { width: 22px; height: 22px; }
.sso-btn.google { background: var(--teal-bg); color: var(--teal-fg); }
.sso-btn.facebook { background: var(--purple-bg); color: var(--purple-fg); }
.sso-btn.microsoft { background: var(--blue-bg); color: var(--blue-fg); }
.sso-btn.apple { background: var(--gold-bg); color: var(--gold-fg); }
.sso-btn.email { background: var(--coral-bg); color: var(--coral-fg); }
.sso-btn.google .brand {
  background: #FFFFFF;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  padding: 3px;
}
.or-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 22px 0 16px;
  color: var(--muted);
  font-size: 13px;
}
.or-row::before, .or-row::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}
.magic-label {
  text-align: left;
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 10px;
}
.magic-input {
  width: 100%;
  border: 1px solid #D7D3C8;
  background: #FFFFFF;
  border-radius: 10px;
  padding: 14px 14px;
  font-size: 15px;
  outline: none;
  color: var(--ink);
}
.magic-input:focus { border-color: var(--pink-fg); }
.field-error { color: #BE185D; font-size: 13px; text-align: left; margin: 8px 0 0; }
.magic-btn {
  width: 100%;
  margin-top: 12px;
  border: 0;
  border-radius: 14px;
  min-height: 52px;
  background: var(--pink-bg);
  color: var(--pink-fg);
  font-size: 16px;
  font-weight: 700;
}

/* Home */
.page-head { margin-bottom: 22px; }
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #FFFFFF;
  border-radius: 16px;
  padding: 12px 16px;
  box-shadow: 0 1px 0 rgba(23,23,31,0.04);
}
.filter-bar .search-ico { width: 18px; height: 18px; opacity: 0.45; flex-shrink: 0; }
.filter-bar input {
  flex: 1;
  border: 0;
  outline: none;
  font-size: 16px;
  background: transparent;
  color: var(--ink);
}
.filter-bar input::placeholder { color: #B0ADA4; }
.filter-clear {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.4px solid #C8C4B8;
  background: transparent;
  color: #8A867C;
  font-size: 12px;
  line-height: 1;
  display: none;
}
.filter-clear.show { display: grid; place-items: center; }

.tool-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.tool-tile {
  border: 0;
  border-radius: 22px;
  min-height: 168px;
  padding: 18px 12px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
}
.tool-tile img { width: 56px; height: 56px; }
.tool-tile span {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.25;
  max-width: 160px;
}
.tool-tile.compliance { background: var(--compliance-bg); color: var(--compliance-fg); }
.tool-tile.money { background: var(--money-bg); color: var(--money-fg); }
.tool-tile.customer { background: var(--customer-bg); color: var(--customer-fg); }
.tool-tile.sales { background: var(--sales-bg); color: var(--sales-fg); }
.tool-tile.hr { background: var(--hr-bg); color: var(--hr-fg); }
.tool-tile:hover { transform: translateY(-1px); }

/* Shared page */
.back-btn {
  border: 0;
  background: #FFFFFF;
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
  padding: 12px 18px;
  margin-bottom: 18px;
  border-radius: 14px;
  min-height: 48px;
  min-width: 120px;
  box-shadow: 0 1px 0 rgba(23,23,31,0.06);
}
.back-btn:hover { background: #FFFFFF; }
.page-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 8px;
}
.page-title img { width: 40px; height: 40px; }
.page-title h1 {
  margin: 0;
  font-size: 28px;
  color: var(--ink);
}
.page-title .cat {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.lede { color: var(--muted); margin: 0 0 20px; }

.card {
  background: var(--card);
  border-radius: 18px;
  padding: 20px 22px;
  box-shadow: 0 1px 0 rgba(23,23,31,0.03);
}
.card + .card { margin-top: 14px; }
.card h2, .panel h2 {
  margin: 0 0 14px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
}

.hub-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.connect-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.connect-chip {
  border: 0;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
}
.connect-chip.off { background: #FFFFFF; color: var(--ink); }
.connect-chip.on { background: var(--ok-bg); color: var(--ok-fg); }
.connect-chip.disabled { opacity: 0.45; pointer-events: none; }

.btn {
  border: 0;
  border-radius: 12px;
  padding: 11px 16px;
  font-weight: 700;
  font-size: 14px;
}
.btn.accent { color: #FFFFFF; }
.btn.ghost { background: #FFFFFF; color: var(--ink); box-shadow: 0 1px 0 rgba(23,23,31,0.06); }
.btn.small { padding: 7px 10px; font-size: 12px; }
.output-actions .btn,
.output-actions a.btn {
  background: var(--pink-bg);
  color: var(--pink-fg);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 12px;
  font-weight: 700;
}
.output-actions .btn:nth-child(2) { background: var(--teal-bg); color: var(--teal-fg); }
.output-actions .btn:nth-child(3) { background: var(--blue-bg); color: var(--blue-fg); }
.output-actions .btn:nth-child(4) { background: var(--gold-bg); color: var(--gold-fg); }
.output-actions .btn:nth-child(5) { background: var(--purple-bg); color: var(--purple-fg); }
.compliance-accent { background: var(--compliance-fg); }
.money-accent, .hr-accent { background: var(--money-fg); }
.customer-accent { background: var(--customer-fg); }
.sales-accent { background: var(--sales-fg); }

.empty-hub {
  min-height: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
}
.empty-hub h2 { font-family: var(--sans); font-size: 22px; letter-spacing: 0; text-transform: none; margin: 0; }
.empty-hub p { color: var(--muted); margin: 0 0 8px; max-width: 420px; }

.hub-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.panel { background: #FFFFFF; border-radius: 18px; padding: 18px; min-height: 220px; }
.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: 0;
  background: var(--cream);
  border-radius: 12px;
  padding: 12px;
  text-align: left;
  margin-bottom: 8px;
  color: var(--ink);
}
.list-row img { width: 28px; height: 28px; }
.list-row .meta { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.list-row .sub { color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); }

.form-grid { display: flex; flex-direction: column; gap: 14px; }
.field label, .checks legend {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--ink);
}
.field input[type="text"],
.field input[type="email"],
.field input[type="number"],
.field input[type="date"],
.field input[type="datetime-local"],
.field select,
.field textarea {
  width: 100%;
  border: 1px solid #D7D3C8;
  background: #FFFFFF;
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 15px;
  color: var(--ink);
  outline: none;
}
.field textarea { min-height: 110px; resize: vertical; }
.field.notes label { color: var(--muted); font-weight: 500; }
.checks { border: 0; padding: 0; margin: 0; }
.checks label { display: flex; align-items: flex-start; gap: 8px; font-weight: 500; margin: 6px 0; }
.radios { display: flex; gap: 16px; flex-wrap: wrap; }
.radios label { display: flex; align-items: center; gap: 6px; font-weight: 500; }

.dropzone {
  border: 1.6px dashed #C8C4B8;
  border-radius: 16px;
  background: #FBFBF7;
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
}
.dropzone.over { border-color: var(--pink-fg); background: #FFF6FB; }
.dropzone strong { display: block; color: var(--ink); margin-top: 6px; }
.file-chip { margin-top: 8px; font-size: 13px; color: var(--ink); }

.progress {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  padding: 16px 0;
  font-weight: 600;
}
.progress span { font-size: 16px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.spinner {
  width: 16px; height: 16px;
  border: 2px solid #D7D3C8;
  border-top-color: var(--pink-fg);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.output { margin-top: 18px; }
.output-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.preview {
  background: var(--cream);
  border-radius: 14px;
  padding: 16px 18px;
  color: var(--ink);
  line-height: 1.5;
  overflow: auto;
}
.preview h3 { margin: 18px 0 8px; font-size: 16px; }
.preview h3:first-child { margin-top: 0; }
.preview table { width: 100%; border-collapse: collapse; font-size: 14px; }
.preview th, .preview td { border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: left; color: var(--ink); }
.query-time {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--muted);
}
.section-block { margin-bottom: 16px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.flag {
  background: #F3E8FF;
  color: var(--compliance-fg);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-weight: 600;
}
.reminder {
  margin-top: 10px;
  font-size: 14px;
  color: var(--teal-fg);
  font-weight: 600;
}
.status-card { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.status-item { background: var(--cream); border-radius: 12px; padding: 12px; }
.status-item .k { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.status-item .v { font-size: 20px; font-weight: 700; margin-top: 4px; }
.badge { display: inline-block; border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 700; }
.badge.ok { background: var(--ok-bg); color: var(--ok-fg); }
.badge.warn { background: var(--warn-bg); color: var(--warn-fg); }
.badge.bad { background: var(--bad-bg); color: var(--bad-fg); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 12px; }
.chip {
  border: 0;
  background: var(--customer-bg);
  color: var(--customer-fg);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
}

.repeater-row { display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: 8px; margin-bottom: 8px; }
.account-row {
  display: grid;
  grid-template-columns: 40px 1.2fr 1.4fr 1.4fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}
.account-logo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #FFFFFF;
  display: grid;
  place-items: center;
  padding: 5px;
}
.account-logo img { width: 24px; height: 24px; }
.account-row:last-child { border-bottom: 0; }

.about h2 { font-family: var(--sans); text-transform: none; letter-spacing: 0; font-size: 20px; }
.about p { line-height: 1.55; }
.about-card.purple { background: var(--purple-bg); color: var(--purple-fg); }
.about-card.teal { background: var(--teal-bg); color: var(--teal-fg); }
.about-card.pink { background: var(--pink-bg); color: var(--pink-fg); }
.about-card h2, .about-card p { color: inherit; }
.wordmark { font-size: 28px; font-weight: 700; margin: 0 0 6px; }

.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(23,23,31,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
  padding: 20px;
}
.modal {
  background: #FFFFFF;
  color: var(--ink);
  border-radius: 18px;
  padding: 22px;
  width: min(560px, 100%);
  max-height: 80vh;
  overflow: auto;
}
.modal h3 { margin: 0 0 10px; }
.toast, .reset-flash {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 700;
  color: #FFFFFF;
  background: var(--sidebar);
}
.toast { bottom: 24px; }
.reset-flash { top: 24px; background: var(--pink-fg); }

.sample-list button { width: 100%; }

@media (max-width: 1100px) {
  .tool-grid { grid-template-columns: repeat(3, 1fr); }
  .account-row { grid-template-columns: 40px 1fr; }
}
@media (max-width: 860px) {
  .tool-grid { grid-template-columns: repeat(2, 1fr); }
  .hub-grid, .status-card { grid-template-columns: 1fr; }
  .repeater-row { grid-template-columns: 1fr; }
  .stage { padding: 56px 16px 28px; border-radius: 20px; }
  .hamburger { display: grid; place-items: center; }
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  .sidebar.open { transform: none; }
  .sidebar-backdrop.show { display: block; }
  .stage-wrap { padding: 10px; }
}
@media (max-width: 520px) {
  .tool-grid { grid-template-columns: 1fr; }
  .login-card h1 { font-size: 28px; }
}
