/* ============================================================
   Wireframe shared styles · sketch-mockup aesthetic
   ============================================================
   All wireframe pages link this file. The look-and-feel matches
   the preferred reference layout (see estimate-review-chat-original.html):
     - Outer thick black frame with simple title bar (no browser chrome)
     - Inner panels nested with their own borders
     - Three-column panel headers (title | italic label | actions)
     - Warmer ecru palette for table/header backgrounds
     - Floating side panels (Financial Metrics & Grading Table style)
     - Chat panels with dark-tan header + window controls
     - Clean rectangular buttons
   Production styling will live in the React app's design system later.
   ============================================================ */

* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: #f4f1ea;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: #1a1a1a;
  font-size: 13px;
}
body { padding: 32px; }

/* ─── Page-level header (above the wireframe itself) ───── */
.doc-title { font-size: 20px; font-weight: 600; margin: 0 0 4px; }
.doc-sub {
  font-size: 13px; color: #666;
  margin: 0 0 18px; max-width: 720px; line-height: 1.5;
}
.view-label {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
  color: #888; margin-bottom: 10px;
}
.views { display: flex; gap: 40px; align-items: flex-start; flex-wrap: wrap; }
.spacer { height: 16px; }
.muted { color: #888; }
.center { text-align: center; }
code { background: #fff8d4; padding: 0 4px; border-radius: 2px; font-size: 11px; }

/* ─── Wireframe-level nav (yellow sticky note) ────────── */
.wireframe-nav {
  background: #fffbe6;
  border: 1.5px dashed #d4a000;
  padding: 8px 14px;
  margin-bottom: 24px;
  font-size: 12px;
  border-radius: 4px;
  max-width: 1180px;
}
.wireframe-nav strong { margin-right: 8px; color: #1a1a1a; }
.wireframe-nav a {
  color: #1a1a1a;
  margin-right: 12px;
  text-decoration: none;
  border-bottom: 1px solid #1a1a1a;
}
.wireframe-nav a:hover { background: #fff8d4; }
.wireframe-nav a.active {
  font-weight: 700;
  background: #1a1a1a;
  color: #fff;
  padding: 0 4px;
  border-bottom: none;
}

/* ─── Outer frame (replaces browser chrome) ───────────── */
.frame {
  background: #fff;
  border: 2.5px solid #1a1a1a;
  box-shadow: 6px 6px 0 #d4cfc2;
  max-width: 1180px;
}

/* Title bar: bold brand + page title on the left, optional nav + user on the right */
.title-bar {
  padding: 12px 18px;
  border-bottom: 2px solid #1a1a1a;
  font-size: 16px;
  font-weight: 700;
  background: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.title-bar .brand-title { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.title-bar .brand-title strong { font-weight: 700; }
.title-bar .right-cluster {
  display: flex; align-items: center; gap: 18px;
  font-size: 12px; font-weight: 400;
}
.title-bar .url-meta {
  color: #888;
  font-size: 11px;
  font-weight: 400;
  margin-left: 8px;
}

/* Inline nav inside the title bar */
.app-nav {
  display: flex; gap: 18px;
  font-size: 12px; font-weight: 600;
}
.app-nav a {
  color: #555; text-decoration: none;
  padding: 4px 0;
  border-bottom: 2px solid transparent;
}
.app-nav a.active { color: #1a1a1a; border-color: #1a1a1a; }
.app-nav a:hover { color: #1a1a1a; }

.user-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 10px;
  border: 1.5px solid #1a1a1a;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  background: #fff;
}
.user-pill .av {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #1a1a1a; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700;
}
.org-switcher {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 600;
  padding: 4px 10px;
  border: 1.5px solid #1a1a1a;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
}

/* ─── Inner panel (nested in the outer frame) ─────────── */
.inner-panel {
  margin: 14px;
  border: 2px solid #1a1a1a;
  background: #fff;
  position: relative;
}

/* Three-column panel header: title left | italic label center | actions right */
.panel-header {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1.5px solid #1a1a1a;
  background: #fff;
  gap: 12px;
}
.panel-header .est-title {
  font-weight: 700;
  font-size: 14px;
  flex: 1;
  min-width: 0;
}
.panel-header .est-title small {
  display: block;
  font-size: 11px;
  color: #666;
  font-weight: 400;
  margin-top: 2px;
}
.panel-header .view-label-mid {
  font-style: italic;
  color: #555;
  font-size: 13px;
  flex: 1;
  text-align: center;
}
.panel-header .actions {
  flex-shrink: 0;
  text-align: right;
}

/* Single-row simple panel header (page-header style) */
.page-header {
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1.5px solid #1a1a1a;
  background: #fff;
}
.page-header h2 { margin: 0; font-size: 18px; font-weight: 700; }

/* ─── Section primitives (use sparingly) ──────────────── */
.section {
  border: 1.5px dashed #888;
  margin: 10px;
  padding: 10px 12px;
  background: #fff;
  position: relative;
}
.section.solid { border-style: solid; border-color: #1a1a1a; border-width: 1.5px; }
.section.tight { padding: 6px 8px; }
.section-label {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.6px;
  color: #888; margin-bottom: 6px;
}
.row { display: flex; gap: 10px; }
.col { flex: 1; }

/* ─── Sub-tab nav (inside an estimate) ────────────────── */
.tab-bar {
  display: flex;
  border-bottom: 1.5px solid #1a1a1a;
  background: #d8d4c7;
}
.tab-bar .tab {
  padding: 10px 18px;
  font-size: 12px; font-weight: 600;
  color: #444;
  border-right: 1.5px solid #1a1a1a;
  cursor: pointer;
  text-decoration: none;
  background: #d8d4c7;
}
.tab-bar .tab:hover { background: #ece8db; }
.tab-bar .tab.active {
  background: #fff;
  color: #1a1a1a;
  border-bottom: 2px solid #fff;
  margin-bottom: -2px;
}

/* Settings sidebar */
.side-nav { width: 200px; padding: 10px 0; }
.side-nav a {
  display: block;
  padding: 8px 14px;
  font-size: 12px; color: #555;
  text-decoration: none;
  border-left: 3px solid transparent;
  font-weight: 600;
}
.side-nav a.active {
  background: #fff;
  color: #1a1a1a;
  border-left-color: #1a1a1a;
}
.side-nav a:hover { background: #ece8db; }

/* ─── Buttons + chips + badges ────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border: 1.5px solid #1a1a1a;
  border-radius: 999px;
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
  background: #fffbe6;
}
.badge.green { background: #d6f5d6; }
.badge.yellow { background: #fff3cd; }
.badge.red { background: #ffd6d6; }
.badge.gray { background: #ece8db; color: #555; }
.badge.blue { background: #d4e8ff; }

.btn {
  border: 1.5px solid #1a1a1a;
  background: #fff;
  padding: 4px 14px;
  font-size: 12px; font-weight: 600;
  border-radius: 3px;
  cursor: pointer;
  margin-left: 6px;
  text-decoration: none;
  color: #1a1a1a;
  display: inline-block;
  font-family: inherit;
}
.btn.primary { background: #1a1a1a; color: #fff; }
.btn.subtle { background: #fff; border-color: #888; color: #555; }
.btn.green { background: #1a7a1a; border-color: #1a7a1a; color: #fff; }
.btn.danger { border-color: #a00; color: #a00; }
.btn.lg { padding: 8px 20px; font-size: 13px; }

.chip {
  display: inline-block;
  border: 1.5px solid #1a1a1a;
  background: #fff;
  border-radius: 3px;
  padding: 4px 12px;
  font-size: 11px; font-weight: 600;
  cursor: pointer;
  margin-right: 4px;
  text-decoration: none;
  color: #1a1a1a;
}
.chip:hover { background: #ece8db; }
.chip.cta {
  background: #1a7a1a;
  border-color: #1a7a1a;
  color: #fff;
}
.chip.active {
  background: #1a1a1a;
  color: #fff;
}

/* ─── Tables ──────────────────────────────────────────── */
table.data, table.lines {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
table.data thead tr,
table.lines thead tr {
  background: #ece8db;
}
table.data th, table.lines th {
  text-align: left;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 700;
  border-bottom: 1.5px solid #1a1a1a;
  border-right: 1px solid #aaa;
  color: #1a1a1a;
}
table.data th:last-child, table.lines th:last-child { border-right: none; }
table.data td, table.lines td {
  padding: 8px 10px;
  border-bottom: 1px solid #d8d4c7;
  border-right: 1px solid #ece8db;
  vertical-align: top;
}
table.data td:last-child, table.lines td:last-child { border-right: none; }
table.data td.num, table.lines td.num {
  text-align: right; font-variant-numeric: tabular-nums;
}
table.data tr:hover { background: #fafaf6; cursor: pointer; }
table.lines tr.changed {
  background: #fff8d4;
  animation: flash 1.2s ease-out;
}
table.lines tr.changed td:first-child::before {
  content: '●';
  color: #d4a000;
  margin-right: 4px;
}
table.lines tr.empty td { color: #aaa; }
@keyframes flash {
  0% { background: #ffeb80; }
  100% { background: #fff8d4; }
}
.pencil { color: #555; cursor: pointer; margin-right: 6px; }

/* ─── Stat cards (dashboards) ─────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat-card {
  border: 1.5px solid #1a1a1a;
  background: #fff;
  padding: 12px 14px;
}
.stat-card label {
  font-size: 10px; color: #555;
  text-transform: uppercase; letter-spacing: 0.5px;
  font-weight: 700;
}
.stat-card .v {
  font-size: 22px; font-weight: 700;
  margin: 4px 0 0;
  font-variant-numeric: tabular-nums;
}
.stat-card .delta { font-size: 11px; color: #555; margin-top: 2px; }
.stat-card .delta.up { color: #1a7a1a; }
.stat-card .delta.down { color: #a00; }

/* ─── Forms ───────────────────────────────────────────── */
.form-field { margin-bottom: 14px; }
.form-field label {
  display: block;
  font-size: 11px; font-weight: 700;
  color: #1a1a1a; margin-bottom: 4px;
  text-transform: uppercase; letter-spacing: 0.4px;
}
.form-field input, .form-field select, .form-field textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1.5px solid #1a1a1a;
  border-radius: 3px;
  font-size: 12.5px;
  font-family: inherit;
  background: #fff;
}
.form-field textarea { resize: vertical; min-height: 80px; }
.form-help { font-size: 11px; color: #666; margin-top: 3px; }
.required { color: #a00; }

.dropzone {
  border: 2px dashed #1a1a1a;
  background: #fafaf6;
  padding: 24px;
  text-align: center;
  font-size: 12px; color: #555;
  cursor: pointer;
  border-radius: 3px;
}
.dropzone strong {
  display: block; font-size: 14px;
  color: #1a1a1a; margin-bottom: 4px;
}

/* ─── Health/metrics blocks ───────────────────────────── */
.totals-strip {
  display: flex; gap: 16px;
  padding: 10px 12px;
  background: #ece8db;
  border-bottom: 1.5px solid #1a1a1a;
}
.totals-strip .stat { flex: 1; }
.totals-strip .stat label {
  display: block;
  font-size: 10px; color: #555;
  text-transform: uppercase; letter-spacing: 0.5px;
  font-weight: 700;
}
.totals-strip .stat strong {
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

/* Floating side panel (Financial Metrics & Grading Table style) */
.floating-panel {
  position: absolute;
  background: #fff;
  border: 1.5px solid #1a1a1a;
  box-shadow: 3px 3px 0 #d4cfc2;
  z-index: 2;
}
.floating-panel-title {
  background: #d8d4c7;
  padding: 7px 12px;
  font-size: 11.5px;
  font-weight: 700;
  text-align: center;
  border-bottom: 1.5px solid #1a1a1a;
}

/* Inline metrics table (used inside floating panel or sidebar card) */
table.metrics {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
}
table.metrics tr { border-bottom: 1px solid #d8d4c7; }
table.metrics tr:last-child { border-bottom: none; }
table.metrics td {
  padding: 6px 12px;
  border-right: 1px solid #d8d4c7;
}
table.metrics td:first-child {
  background: #fafaf6;
  color: #444;
  font-size: 11px;
  width: 50%;
  font-weight: 600;
}
table.metrics td:last-child {
  border-right: none;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
table.metrics .recalc {
  color: #888;
  font-style: italic;
  font-weight: 400;
  font-size: 10.5px;
}
table.metrics tr.grade td:last-child {
  color: #1a7a1a;
  font-weight: 700;
}
table.metrics tr.grade.warning td:last-child { color: #b06000; }
table.metrics tr.grade.below td:last-child { color: #a00; }

/* Health grade callout (centered card with status word) */
.health-grade {
  text-align: center;
  padding: 12px;
  border: 2px solid #1a1a1a;
  margin-bottom: 10px;
  background: #d6f5d6;
}
.health-grade.warning { background: #fff3cd; }
.health-grade.below-floor { background: #ffd6d6; }
.health-grade .label {
  font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.8px; color: #555;
  font-weight: 700;
}
.health-grade .grade {
  font-size: 22px; font-weight: 700; margin: 4px 0 2px;
}
.health-grade small { color: #555; font-size: 11px; }

.metric-row {
  display: flex; justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px solid #ece8db;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}
.metric-row.recalc { color: #888; font-style: italic; }
.metric-row label { color: #555; font-weight: 600; }
.metric-row strong { font-weight: 700; }
.ref-list { margin-top: 8px; font-size: 11px; color: #555; padding-left: 16px; }
.ref-list li { margin: 3px 0; }

/* ─── Window controls (chat / modal headers) ──────────── */
.window-controls {
  display: inline-flex;
  gap: 6px;
}
.window-controls span {
  width: 18px; height: 14px;
  border: 1px solid #1a1a1a;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  background: #fff;
  cursor: pointer;
  font-family: monospace;
}

/* ─── Chat panel ──────────────────────────────────────── */
.chat {
  margin: 0 14px 14px;
  border: 2px solid #1a1a1a;
  background: #fff;
}
.chat-header {
  background: #d8d4c7;
  padding: 8px 12px;
  border-bottom: 1.5px solid #1a1a1a;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
}
.messages {
  padding: 14px 16px;
  max-height: 240px;
  overflow-y: auto;
  background: #fff;
}
.msg {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  align-items: flex-start;
}
.msg .avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: #fff;
  border: 1.5px solid #1a1a1a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
}
.msg.user { flex-direction: row-reverse; }
.bubble {
  max-width: 75%;
  padding: 8px 12px;
  background: #fff;
  border: 1.5px solid #1a1a1a;
  border-radius: 3px;
  font-size: 12px;
  line-height: 1.5;
}
.bubble small {
  display: block;
  font-size: 10px;
  color: #888;
  margin-top: 4px;
  font-weight: 400;
}
.bubble strong { font-weight: 700; }

.typing { display: inline-flex; gap: 3px; padding: 4px 0; }
.typing span {
  width: 6px; height: 6px; background: #1a1a1a;
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}

.chat-input {
  display: flex; gap: 8px;
  padding: 10px 14px;
  border-top: 1.5px solid #1a1a1a;
  background: #fafaf6;
}
.chat-input input {
  flex: 1;
  padding: 8px 12px;
  border: 1.5px solid #1a1a1a;
  border-radius: 3px;
  font-size: 12px;
  font-family: inherit;
  background: #fff;
}
.chat-input .btn { margin-left: 0; }

.quick-actions {
  display: flex; gap: 6px;
  padding: 8px 14px 12px;
  flex-wrap: wrap;
  background: #fafaf6;
  border-top: 1px dashed #aaa;
}

/* ─── Modal ───────────────────────────────────────────── */
.modal-backdrop {
  background: rgba(0,0,0,0.55);
  padding: 60px 20px;
}
.modal-card {
  width: 480px;
  margin: 0 auto;
  background: #fff;
  border: 2px solid #1a1a1a;
  box-shadow: 4px 4px 0 #d4cfc2;
  border-radius: 0;
}
.modal-card .head {
  padding: 10px 14px;
  background: #d8d4c7;
  border-bottom: 1.5px solid #1a1a1a;
  font-weight: 700;
  font-size: 12px;
  display: flex; justify-content: space-between; align-items: center;
}
.modal-card .body { padding: 16px; }
.modal-card .foot {
  padding: 10px 16px;
  border-top: 1.5px solid #1a1a1a;
  display: flex; justify-content: flex-end; gap: 6px;
  background: #fafaf6;
}

/* ─── Mobile frame ────────────────────────────────────── */
.mobile-frame {
  width: 360px;
  border-radius: 28px;
  overflow: hidden;
  border: 6px solid #1a1a1a;
  background: #fff;
  box-shadow: 6px 6px 0 #d4cfc2;
}
.mobile-notch {
  height: 24px; background: #1a1a1a;
  display: flex; justify-content: center; align-items: center;
}
.mobile-notch::after {
  content: ''; width: 100px; height: 6px;
  background: #444; border-radius: 3px;
}
.mobile-app { height: 720px; display: flex; flex-direction: column; }
.mobile-tabs {
  display: flex;
  border-bottom: 1.5px solid #1a1a1a;
  background: #d8d4c7;
}
.mobile-tabs .tab {
  flex: 1; text-align: center;
  padding: 8px 0;
  font-size: 11px; font-weight: 600;
  border-right: 1.5px solid #1a1a1a;
  cursor: pointer; color: #444;
  text-decoration: none;
  background: #d8d4c7;
}
.mobile-tabs .tab.active {
  background: #fff; color: #1a1a1a;
  border-bottom: 2px solid #fff;
  margin-bottom: -2px;
}
.mobile-summary {
  padding: 10px 12px;
  border-bottom: 1.5px solid #1a1a1a;
  background: #ece8db;
  font-size: 11px;
}
.mobile-summary .row { justify-content: space-between; }
.mobile-chat-region {
  flex: 1;
  background: #fff;
  display: flex; flex-direction: column;
}

/* ─── Annotations ─────────────────────────────────────── */
.annotations {
  margin-top: 16px;
  font-size: 11px;
  color: #555;
  max-width: 1180px;
  line-height: 1.5;
}
.annotations h3 {
  font-size: 12px;
  margin: 12px 0 4px;
  color: #1a1a1a;
}
.annotations ul { margin: 0 0 0 18px; padding: 0; }
.annotations li { margin: 3px 0; }
.annotations .key {
  display: inline-block;
  background: #fff8d4;
  border: 1px solid #d4a000;
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 700;
  margin-right: 4px;
}

/* ─── Wireframe-index page grid ───────────────────────── */
.wf-index-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  max-width: 1180px;
}
.wf-index-card {
  border: 1.5px solid #1a1a1a;
  background: #fff;
  padding: 14px 16px;
  text-decoration: none;
  color: #1a1a1a;
  display: block;
  box-shadow: 3px 3px 0 #d4cfc2;
}
.wf-index-card:hover {
  background: #fff8d4;
  border-color: #d4a000;
  box-shadow: 4px 4px 0 #d4a000;
}
.wf-index-card h3 { margin: 0 0 4px; font-size: 14px; }
.wf-index-card p { margin: 0; font-size: 12px; color: #666; }
.wf-index-card .meta {
  margin-top: 8px;
  font-size: 10px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

/* ─── Timeline (history page) ─────────────────────────── */
.timeline { position: relative; padding-left: 28px; }
.timeline::before {
  content: ''; position: absolute;
  left: 10px; top: 0; bottom: 0;
  width: 2px; background: #1a1a1a;
}
.timeline-card {
  position: relative;
  background: #fff;
  border: 1.5px solid #1a1a1a;
  padding: 12px 14px;
  margin-bottom: 14px;
  box-shadow: 3px 3px 0 #d4cfc2;
}
.timeline-card::before {
  content: '';
  position: absolute;
  left: -22px; top: 14px;
  width: 14px; height: 14px;
  background: #fff;
  border: 2px solid #1a1a1a;
  border-radius: 50%;
}
.timeline-card.approved::before { background: #1a7a1a; border-color: #1a7a1a; }
.timeline-card .head {
  display: flex; justify-content: space-between;
  font-weight: 700;
  margin-bottom: 6px;
}
.timeline-card .diff {
  font-size: 11.5px;
  font-family: 'SF Mono', Menlo, monospace;
  background: #fafaf6;
  padding: 8px 10px;
  border: 1px solid #1a1a1a;
  margin: 6px 0;
}
.timeline-card .diff .add { color: #1a7a1a; font-weight: 700; }
.timeline-card .diff .rem { color: #a00; font-weight: 700; }

/* ─── Visual flow arrow (wireframe-only hint) ─────────── */
.flow-arrow {
  position: absolute;
  color: #888;
  font-size: 18px;
  font-weight: 700;
  pointer-events: none;
}
.flow-arrow.up-right { right: -2px; top: -22px; }
.flow-arrow.down-left { left: -2px; bottom: -22px; }
