/* DealerSource AI · Internal Admin Dashboard
   Brand: navy #011B40, blue #0077F9, white. Matches dealersourceai.com. */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("../assets/inter-latin-var.woff2") format("woff2");
}

:root {
  --navy: #011B40;
  --navy-2: #0A2A5C;
  --blue: #0077F9;
  --blue-ink: #0064D6;
  --blue-ink-hover: #0052B0;
  --blue-light: #6BB3FF;
  --white: #FFFFFF;
  --ink: #0F1B2D;
  --muted: #4A5A70;
  --line: #E2E8F0;
  --soft: #F3F7FC;
  --soft-blue: #E8F2FF;
  --success: #0B7A4B;
  --success-bg: #E6F7EF;
  --warn: #9A6700;
  --warn-bg: #FFF6E0;
  --danger: #B42318;
  --danger-bg: #FEECEC;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(1, 27, 64, .06), 0 8px 24px rgba(1, 27, 64, .06);
  --shadow-lg: 0 2px 4px rgba(1, 27, 64, .06), 0 16px 40px rgba(1, 27, 64, .12);
  --header-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.55;
  color: var(--ink);
  background: var(--soft);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

img { display: block; max-width: 100%; height: auto; }

h1, h2, h3 {
  color: var(--navy);
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0 0 .4em;
  font-weight: 750;
}
h1 { font-size: 1.65rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; font-weight: 700; }

p { margin: 0 0 .75em; }
p:last-child { margin-bottom: 0; }

a { color: var(--blue-ink); }
button, input, select, textarea { font: inherit; }

:focus { outline: none; }
:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
  border-radius: 6px;
}

.hidden { display: none !important; }

/* ---------- Auth gate ---------- */
.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at top, rgba(0, 119, 249, .12), transparent 55%),
    var(--soft);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 32px 28px 28px;
  border: 1px solid var(--line);
}
.auth-card .logo {
  height: 36px;
  width: auto;
  margin-bottom: 18px;
}
.auth-card .eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--blue-ink);
  margin-bottom: 6px;
}
.auth-card h1 { margin-bottom: 8px; }
.auth-card .sub {
  color: var(--muted);
  font-size: .95rem;
  margin-bottom: 22px;
}
.role-grid {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}
.role-btn {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  text-align: left;
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--white);
  cursor: pointer;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.role-btn:hover {
  border-color: var(--blue);
  background: var(--soft-blue);
  box-shadow: var(--shadow);
}
.role-btn .role-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--soft-blue);
  color: var(--blue-ink);
  display: grid;
  place-items: center;
  font-weight: 750;
  font-size: .95rem;
  flex: none;
}
.role-btn strong { display: block; color: var(--navy); }
.role-btn span { display: block; color: var(--muted); font-size: .85rem; margin-top: 2px; }
.auth-hint {
  font-size: .8rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 4px;
}

/* ---------- App shell ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  background: var(--navy);
  color: var(--white);
  border-bottom: 3px solid var(--blue);
  display: flex;
  align-items: center;
}
.app-header .inner {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.app-header .logo-light { height: 28px; width: auto; }
.app-header .brand-text {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--blue-light);
  margin-left: -4px;
}
.app-header .spacer { flex: 1; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 650;
  background: rgba(255,255,255,.1);
  color: var(--white);
  border: 1px solid rgba(255,255,255,.14);
}
.btn-ghost {
  background: transparent;
  border: 1px solid rgba(255,255,255,.28);
  color: var(--white);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-ghost:hover { background: rgba(255,255,255,.1); }

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}

.page-title {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}
.page-title .meta { color: var(--muted); font-size: .9rem; }

/* ---------- Cards / layout ---------- */
.grid {
  display: grid;
  gap: 16px;
}
@media (min-width: 800px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .grid-stats { grid-template-columns: repeat(4, 1fr); }
}
.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.card-header h2 { margin: 0; }
.card .eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--blue-ink);
  margin-bottom: 4px;
}

.stat {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}
.stat .label {
  font-size: .78rem;
  font-weight: 650;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.stat .value {
  font-size: 1.45rem;
  font-weight: 750;
  color: var(--navy);
  letter-spacing: -0.02em;
  margin-top: 4px;
}
.stat .hint { font-size: .8rem; color: var(--muted); margin-top: 4px; }

/* ---------- Status chips ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .02em;
}
.chip-ok { background: var(--success-bg); color: var(--success); }
.chip-setup { background: var(--soft-blue); color: var(--blue-ink); }
.chip-off { background: #EEF1F5; color: var(--muted); }
.chip-warn { background: var(--warn-bg); color: var(--warn); }
.chip-high { background: var(--danger-bg); color: var(--danger); }
.chip-med { background: var(--warn-bg); color: var(--warn); }
.chip-low { background: #EEF1F5; color: var(--muted); }

/* ---------- Area cards / toggles ---------- */
.area-list { display: grid; gap: 12px; }
.area-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--soft);
}
.area-row.off { opacity: .7; background: #F7F8FA; }
.area-row .bot-name {
  font-weight: 750;
  color: var(--navy);
  font-size: 1.02rem;
}
.area-row .area-title { color: var(--ink); font-size: .92rem; }
.area-row .area-note { color: var(--muted); font-size: .82rem; margin-top: 4px; }
.area-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.toggle {
  display: inline-block;
  position: relative;
  width: 52px;
  height: 30px;
  flex: none;
}
.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.toggle .slider {
  position: absolute;
  inset: 0;
  background: #C5CDD8;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s;
}
.toggle .slider::before {
  content: "";
  position: absolute;
  width: 24px; height: 24px;
  left: 3px; top: 3px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
  transition: transform .15s;
}
.toggle input:checked + .slider { background: var(--blue); }
.toggle input:checked + .slider::before { transform: translateX(22px); }
.toggle input:focus-visible + .slider {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}
.toggle.readonly .slider { cursor: default; opacity: .9; }

/* Partner (read-only) cannot toggle — show status only */
.partner-ro .toggle { pointer-events: none; }

/* ---------- Lists ---------- */
.item-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.item-list li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--white);
  font-size: .92rem;
}
.item-list .check {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid var(--line);
  margin-top: 2px;
  flex: none;
}
.item-list .check.done {
  background: var(--success);
  border-color: var(--success);
  box-shadow: inset 0 0 0 3px white;
}
.milestone-list li { grid-template-columns: auto 1fr auto; }
.answered li { opacity: .85; }
.answered .check { background: var(--success-bg); border-color: var(--success); }

.empty {
  color: var(--muted);
  font-size: .92rem;
  padding: 12px;
  background: var(--soft);
  border-radius: var(--radius-sm);
  border: 1px dashed var(--line);
}

/* ---------- Notes ---------- */
.notes-box textarea {
  width: 100%;
  min-height: 110px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--ink);
  resize: vertical;
}
.notes-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45em;
  min-height: 40px;
  padding: .55em 1.15em;
  border-radius: 999px;
  border: 2px solid transparent;
  font-weight: 650;
  font-size: .92rem;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.btn-primary {
  background: var(--blue-ink);
  color: var(--white);
}
.btn-primary:hover { background: var(--blue-ink-hover); }
.btn-secondary {
  background: var(--white);
  color: var(--navy);
  border-color: var(--line);
}
.btn-secondary:hover { border-color: var(--blue); background: var(--soft-blue); }
.save-status {
  font-size: .82rem;
  color: var(--muted);
}
.save-status.ok { color: var(--success); }
.save-status.err { color: var(--danger); }

/* ---------- Account strip ---------- */
.account-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  padding: 14px 18px;
  background: var(--white);
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  font-size: .9rem;
}
.account-strip strong { color: var(--navy); }
.account-strip .sep { color: var(--line); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--navy);
  color: var(--white);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: .9rem;
  font-weight: 600;
  z-index: 100;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s, transform .2s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ---------- Banner ---------- */
.info-banner {
  background: var(--soft-blue);
  border: 1px solid #C5DDF8;
  color: var(--navy);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  margin-bottom: 16px;
}

.footer-note {
  margin-top: 28px;
  font-size: .78rem;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 600px) {
  .area-row { grid-template-columns: 1fr; }
  .area-row .toggle-wrap { justify-self: start; }
}

/* ---------- Phone tweaks (hosted /admin/) ---------- */
@media (max-width: 600px) {
  main { padding: 16px 12px 40px; }
  .card { padding: 16px; }
  .app-header .inner { padding: 0 12px; gap: 8px; }
  .app-header .logo-light { height: 22px; }
  .app-header .badge { font-size: .7rem; padding: 3px 8px; }
  .btn-ghost { padding: 6px 10px; font-size: .78rem; }
  .account-strip { font-size: .85rem; word-break: break-word; }
  .grid-stats { grid-template-columns: 1fr 1fr; }
  .page-title h1 { font-size: 1.35rem; }
  textarea, input, select { font-size: 16px; } /* stop iOS zoom on focus */
}
body { padding-bottom: env(safe-area-inset-bottom); }

/* Prevent grid children from forcing horizontal scroll on narrow screens */
.grid > *, .area-row > *, .item-list li > * { min-width: 0; }
.area-note, .account-strip, .item-list li { overflow-wrap: anywhere; }
html, body { overflow-x: hidden; }
@media (max-width: 600px) {
  .area-row { grid-template-columns: 1fr auto; align-items: start; }
  .area-row .toggle-wrap { justify-self: end; }
}
