/* =========================================================================
   NZT BusinessLab — real-estate expert system UI.
   Built on the Danifo design system (tokens imported below). Navy sidebar +
   light workspace; orange CTAs; Unbounded (display) + Futura PT (body).
   Structural class names are unchanged from the original so app.js markup is
   untouched — only values/theme change.
   ========================================================================= */

@import "tokens/tokens.css";

/* App-level aliases mapped onto Danifo semantic tokens. */
:root {
  --bg: #f5f5fa;                 /* faint navy tint behind the workspace */
  --surface: var(--surface-default);
  --surface-2: #f3f2fa;
  --ink: var(--text-primary);    /* navy */
  --muted: var(--text-secondary);
  --line: var(--border-subtle);

  --primary: var(--action-default);   /* orange */
  --primary-2: var(--action-hover);

  /* Status palette — kept distinct from the orange CTA for clarity. */
  --ok: #1f7a5a;
  --warn: #c98a1f;
  --danger: #c0392b;
  --info: var(--danifo-purple);

  --shadow: 0 18px 40px -22px rgba(41, 37, 106, 0.35);
}

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--danifo-font-body);
  font-size: var(--ts-body);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
svg { display: block; }
a { color: inherit; text-decoration: none; }

:focus-visible {
  outline: 2px solid var(--danifo-orange);
  outline-offset: 2px;
  border-radius: 2px;
}

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

/* ---- Sidebar (navy) ------------------------------------------------------ */
.sidebar {
  background: var(--surface-navy);
  color: #fff;
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  border-right: 1px solid rgba(255, 255, 255, 0.10);
}

.brand {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.brand-tagline {
  font-family: var(--danifo-font-body);
  font-size: var(--ts-small);
  color: rgba(255, 255, 255, 0.62);
}

/* NZT BusinessLab wordmark (lifted from nzt-businesslab site.css). */
.nzt {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  line-height: 1;
}
.nzt__spark { width: 22px; height: 22px; flex: none; color: var(--danifo-orange); }
.nzt__name { display: inline-flex; align-items: baseline; gap: 0.32em; }
.nzt__n {
  font-family: var(--danifo-font-display);
  font-weight: 900;
  font-size: 20px;
  letter-spacing: 0.02em;
  color: var(--text-primary);
}
.nzt__b {
  font-family: var(--danifo-font-body);
  font-weight: 400;
  font-size: 18px;
  letter-spacing: 0.01em;
  color: var(--text-secondary);
}
.nzt--on-dark .nzt__n { color: #fff; }
.nzt--on-dark .nzt__b { color: rgba(255, 255, 255, 0.82); }
.nzt--lg .nzt__spark { width: 26px; height: 26px; }
.nzt--lg .nzt__n { font-size: 24px; }
.nzt--lg .nzt__b { font-size: 21px; }

.sidebar-actions,
.topbar-actions,
.form-row {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

/* ---- Buttons ------------------------------------------------------------- */
.btn {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font-family: var(--danifo-font-body);
  font-weight: 700;
  color: var(--ink);
  background: var(--surface);
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

.btn:hover { transform: translateY(-1px); }

.btn.primary {
  background: var(--primary);
  color: var(--text-on-orange);
  border-radius: var(--radius-pill);
}
.btn.primary:hover { background: var(--primary-2); }

.btn.ghost {
  color: #fff;
  background: transparent;
  border-color: rgba(255, 255, 255, 0.35);
}
.btn.ghost:hover { background: rgba(255, 255, 255, 0.10); }

.btn.subtle {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--ink);
}

.btn.danger {
  color: #fff;
  background: var(--danger);
  border-radius: var(--radius-pill);
}

.btn.wide { width: 100%; }

/* ---- Inputs -------------------------------------------------------------- */
.search-box input,
.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: var(--radius-md);
  padding: 11px 12px;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(244, 121, 41, 0.18);
}

.search-box input {
  background: rgba(255, 255, 255, 0.10);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.20);
}
.search-box input::placeholder { color: rgba(255, 255, 255, 0.55); }

/* ---- Case list (sidebar) ------------------------------------------------- */
.case-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  overflow: auto;
  padding-right: 2px;
}

.case-item {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
  color: #fff;
  padding: var(--space-3);
  text-align: left;
  transition: border-color 140ms ease, background 140ms ease;
}
.case-item:hover { background: rgba(255, 255, 255, 0.11); }

.case-item.active {
  border-color: var(--danifo-orange);
  background: rgba(244, 121, 41, 0.16);
}

.case-name { display: block; font-weight: 700; line-height: 1.25; }

.case-meta {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  margin-top: var(--space-2);
  color: rgba(255, 255, 255, 0.66);
  font-size: var(--ts-eyebrow);
}

/* ---- Workspace ----------------------------------------------------------- */
.workspace { padding: var(--space-5); overflow: auto; }

.topbar {
  display: flex;
  justify-content: space-between;
  gap: var(--space-5);
  align-items: flex-start;
  margin-bottom: var(--space-4);
}

h1, h2, h3, p { margin-top: 0; }

h1 {
  margin-bottom: 0;
  font-family: var(--danifo-font-display);
  font-weight: 900;
  font-size: clamp(24px, 3vw, 38px);
  line-height: 1.06;
  max-width: 820px;
}

h2 {
  font-family: var(--danifo-font-body);
  font-weight: 700;
  font-size: 18px;
  margin-bottom: 6px;
}

h3 {
  font-family: var(--danifo-font-body);
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 8px;
}

p { color: var(--muted); line-height: var(--lh-body); }

.eyebrow {
  font-family: var(--danifo-font-body);
  font-weight: 700;
  font-size: var(--ts-eyebrow);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--text-accent);
}

/* ---- Layout grids -------------------------------------------------------- */
.intake-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.75fr);
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: var(--space-5);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: var(--space-3);
  color: var(--muted);
  font-size: var(--ts-small);
  font-weight: 700;
}

.field textarea { resize: vertical; min-height: 104px; }

.field.compact { min-width: 210px; flex: 1; margin-bottom: 0; }

.dropzone {
  border: 1px dashed rgba(41, 37, 106, 0.30);
  background: var(--surface-2);
  border-radius: 12px;
  display: grid;
  gap: 6px;
  padding: var(--space-5);
  margin-bottom: var(--space-3);
}
.dropzone input { width: 100%; }
.drop-title { font-weight: 700; color: var(--ink); }
.drop-note { color: var(--muted); font-size: var(--ts-small); }

.dashboard { display: grid; gap: var(--space-4); }

.summary-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: var(--space-4);
}

/* ---- KPI cards ----------------------------------------------------------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: var(--space-2);
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: var(--space-4);
  min-height: 108px;
}

.kpi-value {
  font-family: var(--danifo-font-display);
  font-weight: 900;
  font-size: 30px;
  color: var(--ink);
}

.kpi-label {
  color: var(--muted);
  font-size: var(--ts-eyebrow);
  line-height: 1.25;
  margin-top: 6px;
}

/* ---- Pills / status ------------------------------------------------------ */
.status-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-3) 0 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  background: var(--danifo-light-gray);
  color: var(--text-primary);
  font-size: var(--ts-eyebrow);
  font-weight: 700;
}

.pill.ready { color: #fff; background: var(--ok); }
.pill.needs_review { color: #fff; background: var(--warn); }
.pill.risk,
.pill.high { color: #fff; background: var(--danger); }
.pill.medium { color: #fff; background: var(--info); }

/* ---- Tables -------------------------------------------------------------- */
.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

.info-table { width: 100%; border-collapse: collapse; }

.info-table th,
.info-table td {
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.info-table th { color: var(--muted); width: 38%; font-size: var(--ts-small); }

/* ---- Lists (tasks / recs / files) ---------------------------------------- */
.task-list,
.rec-list,
.file-list {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.task,
.rec,
.file {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-purple-soft);
  padding: var(--space-3);
}

.task-title { font-weight: 700; margin-bottom: 5px; color: var(--ink); }
.task-meta { color: var(--muted); font-size: var(--ts-small); line-height: 1.4; }

/* ---- Report / raw text --------------------------------------------------- */
.report-box,
.raw-box {
  white-space: pre-wrap;
  background: #1b1840;
  color: #f3f2fa;
  border-radius: 12px;
  padding: var(--space-4);
  line-height: 1.55;
  overflow: auto;
  max-height: 420px;
  font-family: "Futura PT", ui-monospace, SFMono-Regular, Menlo, monospace;
}

.raw-box {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.empty-state {
  background: var(--surface);
  border: 1px dashed rgba(41, 37, 106, 0.28);
  border-radius: 12px;
  padding: var(--space-6);
  min-height: 160px;
}

/* ---- Toast --------------------------------------------------------------- */
.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 360px;
  padding: var(--space-3) var(--space-4);
  color: #fff;
  background: var(--danifo-navy);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  transform: translateY(90px);
  opacity: 0;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show { transform: translateY(0); opacity: 1; }

/* ---- Responsive ---------------------------------------------------------- */
@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 280px minmax(0, 1fr); }
  .kpi-grid { grid-template-columns: repeat(3, minmax(120px, 1fr)); }
  .summary-grid,
  .intake-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { min-height: auto; }
  .case-list { max-height: 260px; }
  .topbar,
  .form-row,
  .topbar-actions { flex-direction: column; align-items: stretch; }
  .two-col,
  .kpi-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
