/* CE Pricing Tool — styles
 * Brand palette: orange accent on near-black header.
 */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --brand: #E8531E;
  --brand-dk: #C0421A;
  --brand-tint: #fff3ec;       /* warm hover/pill background */
  --header-bg: #141517;        /* near-black for app header */
  --green: #2e7d32;
  --red: #c62828;
  --amber: #e65100;
  --border: #dde1e7;
  --bg: #f5f6f8;
  --bg2: #ffffff;
  --text: #1a1d23;
  --text2: #5a6270;
  --radius: 6px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
body { font-family: var(--font); font-size: 14px; color: var(--text); background: var(--bg); }

/* Header */
#app-header {
  background: var(--header-bg);
  color: white;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
.hdr-left { display: flex; align-items: center; gap: 12px; }
.hdr-logo { height: 32px; width: auto; object-fit: contain; display: block; }
.hdr-right { display: flex; align-items: center; gap: 10px; }
#app-header h1 { font-size: 15px; font-weight: 600; }
#save-status { font-size: 12px; opacity: .85; }
.hdr-btn {
  background: rgba(255,255,255,.2); border: 1px solid rgba(255,255,255,.3);
  color: white; padding: 5px 12px; border-radius: var(--radius);
  cursor: pointer; font-size: 13px; font-weight: 500;
}
.hdr-btn:hover { background: rgba(255,255,255,.3); }

/* Job info bar */
#job-bar {
  background: white; border-bottom: 1px solid var(--border);
  padding: 10px 20px; display: flex; gap: 24px; flex-wrap: wrap; align-items: center;
}
.job-field { display: flex; flex-direction: column; gap: 1px; }
.job-field .lbl { font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text2); }
.job-field .val { font-size: 13px; font-weight: 500; }
.status-pill {
  display: inline-block; padding: 2px 8px; border-radius: 12px;
  font-size: 11px; font-weight: 600; background: var(--brand-tint); color: var(--brand);
  text-transform: capitalize;
}

/* Loading / error state */
#load-state {
  display: flex; align-items: center; justify-content: center;
  min-height: 300px; font-size: 15px; color: var(--text2);
}
.spinner {
  width: 24px; height: 24px; border: 3px solid var(--border);
  border-top-color: var(--brand); border-radius: 50%;
  animation: spin .7s linear infinite; margin-right: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Main content */
#main { max-width: 1200px; margin: 0 auto; padding: 20px; display: flex; flex-direction: column; gap: 20px; }

/* Section */
.section { background: white; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.section-header {
  padding: 12px 16px; background: #f8f9fb; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.section-title { font-size: 13px; font-weight: 600; color: var(--text); }
.section-meta { font-size: 12px; color: var(--text2); }

/* Add line item form */
#add-form { padding: 12px 16px; border-bottom: 1px solid var(--border); background: #fafbfc; }
.form-row { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.form-group { display: flex; flex-direction: column; gap: 3px; }
.form-group label { font-size: 11px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: .04em; }
.form-group select, .form-group input {
  font-size: 13px; padding: 6px 8px; border: 1px solid var(--border);
  border-radius: var(--radius); background: white; color: var(--text);
  min-width: 120px;
}
.form-group select:focus, .form-group input:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 2px rgba(232,83,30,.18);
}
.fg-wide { min-width: 220px; flex: 1; }
.fg-sm { max-width: 80px; }

/* Searchable dropdown */
.sd-wrap { position: relative; }
.sd-input {
  width: 100%; font-size: 13px; padding: 6px 28px 6px 8px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: white; color: var(--text); cursor: pointer;
}
.sd-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 2px rgba(232,83,30,.18); }
.sd-caret { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-size: 10px; color: var(--text2); pointer-events: none; }
.sd-list {
  position: absolute; z-index: 500; left: 0; right: 0; top: calc(100% + 2px);
  background: white; border: 1px solid var(--border); border-radius: var(--radius);
  max-height: 240px; overflow-y: auto; display: none;
  box-shadow: 0 4px 16px rgba(0,0,0,.1);
}
.sd-wrap.open .sd-list { display: block; }
.sd-wrap.open .sd-caret { transform: translateY(-50%) rotate(180deg); }
.sd-opt { padding: 7px 10px; font-size: 13px; cursor: pointer; }
.sd-opt:hover, .sd-opt.focused { background: var(--brand-tint); color: var(--brand); }
.sd-opt.selected { font-weight: 600; }
.sd-empty { padding: 8px 10px; font-size: 12px; color: var(--text2); font-style: italic; }

/* Buttons */
.btn {
  padding: 7px 14px; font-size: 13px; font-weight: 500; border-radius: var(--radius);
  cursor: pointer; border: 1px solid var(--border); background: white; color: var(--text);
  white-space: nowrap;
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: white; }
.btn-primary:hover { background: var(--brand-dk); border-color: var(--brand-dk); }
.btn-success { background: var(--green); border-color: var(--green); color: white; }
.btn-success:hover { background: #1b5e20; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Line items table */
.items-table { width: 100%; border-collapse: collapse; }
.items-table th {
  text-align: left; padding: 8px 12px; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em; color: var(--text2);
  background: #f8f9fb; border-bottom: 1px solid var(--border);
}
.items-table td { padding: 9px 12px; border-bottom: 1px solid #f0f1f3; vertical-align: middle; }
.items-table tr:last-child td { border-bottom: none; }
.items-table tr:hover td { background: #fff9f4; }
.td-name { font-weight: 500; max-width: 260px; }
.td-area { color: var(--text2); font-size: 12px; }
.td-num { text-align: right; font-variant-numeric: tabular-nums; }
.td-gm { text-align: center; }
.gm-pill { display: inline-block; padding: 2px 7px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.gm-good { background: #e8f5e9; color: #2e7d32; }
.gm-warn { background: #fff3e0; color: #e65100; }
.gm-low  { background: #ffebee; color: #c62828; }
.totals-row td { font-weight: 600; background: #f8f9fb; border-top: 2px solid var(--border); }
.empty-state { padding: 32px; text-align: center; color: var(--text2); }

/* Billing items */
.billing-item {
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  display: grid; grid-template-columns: 1fr auto; gap: 10px;
}
.billing-item:last-child { border-bottom: none; }
.bi-left { display: flex; flex-direction: column; gap: 8px; }
.bi-area { font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--brand); }
.bi-desc { width: 100%; font-size: 13px; padding: 6px 8px;
  border: 1px solid var(--border); border-radius: var(--radius);
  resize: vertical; min-height: 60px; font-family: var(--font); color: var(--text); }
.bi-desc:focus { outline: none; border-color: var(--brand); }
.bi-fields { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.bi-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.bi-total { font-size: 15px; font-weight: 700; color: var(--brand); }
.bi-gm { font-size: 11px; }

/* Billing section footer */
#billing-footer {
  padding: 14px 16px; background: #f8f9fb; border-top: 2px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
#billing-total { font-size: 15px; font-weight: 700; }

/* Toast */
#toast {
  position: fixed; bottom: 20px; right: 20px; z-index: 9999;
  background: #323232; color: white; padding: 10px 18px;
  border-radius: var(--radius); font-size: 13px; font-weight: 500;
  opacity: 0; transition: opacity .2s; pointer-events: none;
}
#toast.show { opacity: 1; }
#toast.success { background: var(--green); }
#toast.error { background: var(--red); }
