:root {
  --navy: #1b2a4a;
  --navy-dark: #121d33;
  --accent: #c0392b;
  --gray-50: #f7f8fa;
  --gray-100: #eef0f3;
  --gray-200: #dfe3e8;
  --gray-400: #9aa4b2;
  --gray-600: #5b6472;
  --gray-800: #2b323c;
  --green: #1e7a46;
  --radius: 6px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--gray-50);
  color: var(--gray-800);
  font-size: 14px;
  line-height: 1.4;
}

.topbar {
  background: var(--navy);
  color: white;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.topbar-title strong { font-size: 17px; margin-right: 10px; }
.topbar-sub { color: #b9c2d6; font-size: 13px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.topbar-actions .pill {
  background: rgba(255,255,255,0.12);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  color: #dbe2f0;
}
.topbar-actions .pill-locked {
  background: #c0392b;
  color: white;
  font-weight: 600;
}

.search-wrap { position: relative; width: 240px; }
.search-input { width: 100%; padding: 7px 10px; font-size: 13px; border-radius: var(--radius); }
.search-results {
  position: absolute; top: calc(100% + 4px); left: 0; width: 320px; max-width: 80vw;
  background: white; border: 1px solid var(--gray-200); border-radius: var(--radius);
  box-shadow: 0 6px 20px rgba(0,0,0,0.18); z-index: 50; overflow: hidden; text-align: left;
}
.search-result-row { padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--gray-100); color: var(--gray-800); font-size: 13px; }
.search-result-row:last-child { border-bottom: none; }
.search-result-row:hover { background: var(--gray-50); }
.search-note { padding: 8px 12px; font-size: 11.5px; color: var(--gray-600); }
.search-cust-link { color: var(--navy); text-decoration: none; cursor: pointer; }
.search-cust-link:hover { text-decoration: underline; }

.app { max-width: 980px; margin: 0 auto; padding: 24px; }

.app-footer {
  text-align: center;
  color: var(--gray-400);
  font-size: 11.5px;
  padding: 18px;
}

h1 { font-size: 21px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 18px 0 8px; color: var(--navy); }
.subtitle { color: var(--gray-600); margin: 0 0 20px; }

.card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 18px;
}

.card-tight { padding: 16px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--gray-200);
  background: white;
  color: var(--gray-800);
  padding: 9px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  cursor: pointer;
  font-weight: 500;
}
.btn:hover { background: var(--gray-100); }
.btn-primary { background: var(--navy); border-color: var(--navy); color: white; }
.btn-primary:hover { background: var(--navy-dark); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-danger { color: var(--accent); border-color: #f0c7c2; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

.grid-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin: 18px 0;
}
.action-tile {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 18px;
  background: white;
  cursor: pointer;
  text-align: left;
}
.action-tile:hover { border-color: var(--navy); box-shadow: 0 2px 8px rgba(27,42,74,0.08); }
.action-tile h3 { margin: 0 0 6px; color: var(--navy); font-size: 15px; }
.action-tile p { margin: 0; color: var(--gray-600); font-size: 12.5px; }
.action-tile[disabled] { opacity: 0.45; cursor: not-allowed; }

label { display: block; font-size: 12.5px; font-weight: 600; color: var(--gray-600); margin-bottom: 4px; }
input[type=text], input[type=number], input[type=date], textarea, select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 13.5px;
  font-family: inherit;
  background: white;
}
textarea { resize: vertical; min-height: 60px; }
.field { margin-bottom: 14px; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.field-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.checkbox-field { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.checkbox-field input { width: auto; }
.checkbox-field label { margin: 0; }

table.li-table { width: 100%; border-collapse: collapse; margin-top: 6px; }
table.li-table th, table.li-table td { border: 1px solid var(--gray-200); padding: 6px; font-size: 12.5px; }
table.li-table th { background: var(--gray-100); text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--gray-600); }
table.li-table input, table.li-table textarea { border: none; padding: 4px; font-size: 12.5px; font-family: inherit; }
table.li-table td.num input { text-align: right; }
table.li-table textarea.li-desc { min-height: 34px; height: 34px; resize: vertical; }
table.li-table td.readonly { background: var(--gray-50); color: var(--gray-600); }
.remove-row-btn { color: var(--accent); background: none; border: none; cursor: pointer; font-size: 15px; }

.li-image-preview { margin-top: 4px; padding-top: 4px; border-top: 1px dashed var(--gray-200); }
.li-image-thumb { display: block; max-width: 120px; max-height: 80px; border: 1px solid var(--gray-200); border-radius: 3px; margin-bottom: 4px; }
.li-image-remove { color: var(--accent); background: none; border: none; cursor: pointer; font-size: 11px; padding: 0; text-decoration: underline; }

.qi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin-top: 16px; }
.qi-card { border: 1px solid var(--gray-200); border-radius: var(--radius); background: white; overflow: hidden; cursor: pointer; }
.qi-card:hover { border-color: var(--navy); box-shadow: 0 2px 8px rgba(27,42,74,0.08); }
.qi-thumb-wrap { width: 100%; height: 120px; background: var(--gray-100); display: flex; align-items: center; justify-content: center; }
.qi-thumb-wrap img { max-width: 100%; max-height: 100%; display: block; }
.qi-thumb-loading { color: var(--gray-400); font-size: 11px; }
.qi-card-body { padding: 8px 10px; }
.qi-card-body strong { display: block; font-size: 13px; color: var(--navy); }
.qi-card-meta { color: var(--gray-600); font-size: 11.5px; margin-top: 2px; }
.qi-card-desc { color: var(--gray-800); font-size: 12px; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

.total-line { text-align: right; margin-top: 10px; font-size: 15px; font-weight: 700; }

.banner { padding: 10px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 16px; }
.banner-info { background: #e8eef7; color: var(--navy); }
.banner-success { background: #e6f4ea; color: var(--green); }
.banner-error { background: #fbe9e7; color: var(--accent); }
.banner-warn { background: #fff6e0; color: #8a6100; }

.breadcrumb { font-size: 12.5px; color: var(--gray-600); margin-bottom: 10px; }
.breadcrumb a { color: var(--navy); text-decoration: none; cursor: pointer; }
.breadcrumb a:hover { text-decoration: underline; }

.doc-list { border: 1px solid var(--gray-200); border-radius: var(--radius); overflow: hidden; }
.doc-list-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid var(--gray-200); font-size: 13px;
}
.doc-list-row:last-child { border-bottom: none; }
.doc-list-row:nth-child(even) { background: var(--gray-50); }
.doc-list-meta { color: var(--gray-600); font-size: 12px; }
.doc-list-row-left { display: flex; align-items: center; }

.cl-changes { margin: 6px 0 0; padding-left: 18px; color: var(--gray-600); font-size: 12px; }
.cl-changes li { margin: 2px 0; }

.btn-view-pdf {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; flex: none;
  border: 1px solid var(--gray-200); background: white; border-radius: var(--radius);
  color: var(--gray-600); cursor: pointer; margin-right: 10px;
}
.btn-view-pdf:hover { background: var(--gray-100); color: var(--navy); border-color: var(--gray-400); }
.btn-view-pdf svg { width: 15px; height: 15px; }
.status-badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; font-weight: 600; }
.status-open { background: #e8eef7; color: var(--navy); }
.status-converted { background: #e6f4ea; color: var(--green); }
.status-closed { background: var(--gray-100); color: var(--gray-600); }
.status-expired { background: #fbe9e7; color: var(--accent); }
/* Invoice-only status: yellow "Printed" (generated, not yet mailed) vs. the
   shared green .status-converted reused for "Mailed [date]" once the Mailed
   button is clicked - same green already used for a Closed/Converted state
   elsewhere, so a mailed invoice reads as "done" at a glance. */
.status-printed { background: #fff6e0; color: #8a6100; }
.rev-badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; font-weight: 600; background: #fdf0d5; color: #8a5a00; }
/* Material Inventory row id (e.g. "M-7") - shown mainly so it's easy to
   read at a glance and match against a physical tag out in the shop.
   Monospace + a distinct border (rather than the pill-shaped status/rev
   badges above) so it reads as an id/label, not a status. */
.material-id-badge { font-family: 'Courier New', Courier, monospace; font-size: 12px; font-weight: 700; padding: 2px 7px; border-radius: var(--radius); border: 1px solid var(--gray-200); background: var(--gray-50); color: var(--navy); margin-right: 10px; flex: none; }

/* ---- Job Notes: internal-only, never printed on any PDF ---- */
.internal-notes { background: #fffdf3; border-color: #f0e0a0; }
.internal-notes h3 { margin-top: 0; }
.internal-notes .hint-inline { font-weight: 400; color: var(--gray-400); font-size: 11.5px; }
.internal-notes textarea { width: 100%; margin-top: 8px; }
.job-note-list { margin-bottom: 4px; }
.job-note-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid #f0e6c0; font-size: 13px;
}
.job-note-row:last-child { border-bottom: none; }
.job-note-meta { color: var(--gray-400); font-size: 11px; width: 68px; flex: none; padding-top: 2px; }
.job-note-text { flex: 1; white-space: pre-wrap; }
.job-note-delete { flex: none; }
.note-indicator {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; color: #8a6100; margin-left: 4px; vertical-align: -3px;
  background: none; border: none; padding: 0; cursor: pointer; border-radius: 3px;
}
.note-indicator:hover { background: #fdf0d5; }
.note-indicator svg { width: 13px; height: 13px; }

/* Inline notes panel, expanded directly under a row via the note-indicator
   button - same amber palette as .internal-notes, sized for insertion within
   a .doc-list instead of as a standalone .card. */
.job-notes-inline {
  background: #fffdf3; border-bottom: 1px solid var(--gray-200);
  padding: 12px 14px;
}
.job-notes-inline h3 { margin-top: 0; }

.hint { font-size: 11.5px; color: var(--gray-400); margin-top: 4px; }
.empty-state { text-align: center; color: var(--gray-400); padding: 30px 10px; font-size: 13px; }
