/* ProQuote — minimal in-house stylesheet (Tailwind build lands in M7 polish). */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --ink: #11151c;
  --ink-soft: #5a606b;
  --ink-muted: #8c92a0;
  --border: #e3e5ea;
  --accent: #3b5bdb;
  --accent-ink: #ffffff;
  --warn: #c13a3a;
  --warn-bg: #fdecec;
  --ok: #13562b;
  --ok-bg: #c8f5d5;
  --info-bg: #d6e4ff;
  --locked-bg: #fff6c2;
  --locked-ink: #7a5a00;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(17,21,28,.05), 0 1px 3px rgba(17,21,28,.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
em { font-style: normal; color: var(--warn); }
.muted { color: var(--ink-muted); font-size: 12px; }

/* -------- Layout -------- */
.app-body { min-height: 100vh; display: grid; grid-template-columns: 240px 1fr; }
.sidebar { background: #0d1017; color: #fff; padding: 20px 16px; display: flex; flex-direction: column; gap: 16px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 700; letter-spacing: .5px; margin-bottom: 8px; }
.brand-logo { font-size: 18px; color: #7aa2ff; }
.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; flex: 1; }
.nav-item { color: #d1d5de; padding: 8px 10px; border-radius: var(--radius); font-weight: 500; }
.nav-item:hover { background: #1a2030; text-decoration: none; color: #fff; }
.nav-item.active { background: #1a2030; color: #fff; }
.nav-cta { margin-top: 8px; color: #fff; background: var(--accent); text-align: center; }
.nav-cta:hover { background: #3049c6; }
.user-chip { margin-top: auto; padding: 10px; background: #161b26; border-radius: var(--radius); display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.user-name { font-weight: 600; font-size: 13px; }
.user-role { color: #8d93a2; font-size: 11px; text-transform: uppercase; letter-spacing: .4px; }
.link-btn { background: none; border: none; color: #7aa2ff; padding: 0; cursor: pointer; font: inherit; }
.link-btn:hover { text-decoration: underline; }
.link-danger { color: var(--warn); }
.logout-form { margin: 4px 0 0; }
.env-badge { font-size: 10px; background: #2b1b11; color: #ffbe7a; padding: 4px 6px; border-radius: 4px; letter-spacing: .5px; text-align: center; }
.main { padding: 28px 32px 60px; max-width: 1280px; }

/* -------- Page headers -------- */
.page-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; }
.page-title { font-size: 22px; margin: 0; }
.page-sub { color: var(--ink-soft); margin: 4px 0 0; font-size: 13px; }
.page-actions { display: flex; gap: 8px; align-items: center; }
.breadcrumb { font-size: 12px; color: var(--ink-muted); margin-bottom: 2px; }
.breadcrumb a { color: var(--ink-muted); }

/* -------- Panels -------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 18px 20px; margin-bottom: 18px; box-shadow: var(--shadow); }
.panel-slim { padding: 14px 18px; }
.panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 12px; }
.panel-title { font-size: 14px; text-transform: uppercase; letter-spacing: .5px; color: var(--ink-soft); margin: 0 0 12px 0; font-weight: 600; }
.empty { color: var(--ink-muted); font-style: italic; padding: 8px 0; }

/* -------- KPIs -------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.kpi-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 16px 18px; box-shadow: var(--shadow); }
.kpi-label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--ink-muted); }
.kpi-value { font-size: 28px; font-weight: 700; margin-top: 4px; }

/* -------- Tables -------- */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { text-align: left; font-weight: 600; color: var(--ink-soft); font-size: 11px; text-transform: uppercase; letter-spacing: .4px; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.data-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); }
.data-table tr:hover td { background: #fafbfc; }
.data-table td.num, .data-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.line-items td { vertical-align: middle; }
.row-auto td { background: #f6f9ff; }
.row-auto td:first-child { border-left: 3px solid var(--accent); }
.row-warn td { background: var(--warn-bg); }
.text-warn { color: var(--warn); font-weight: 600; }

/* -------- Forms -------- */
.form-stack { display: flex; flex-direction: column; gap: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-grid-tight { grid-template-columns: repeat(6, 1fr); gap: 10px 12px; }
.form-grid-tight label:nth-child(2) { grid-column: span 2; }
.col-span-2 { grid-column: span 2; }
.label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 4px; }
.input { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px; background: #fff; color: var(--ink); }
.input:focus { outline: 2px solid rgba(59,91,219,.35); border-color: var(--accent); }
.input-sm { width: 110px; padding: 6px 8px; font-size: 13px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.inline-form { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }

/* -------- Buttons -------- */
.btn { display: inline-block; padding: 8px 14px; border-radius: var(--radius); font-size: 13px; font-weight: 600; border: 1px solid transparent; cursor: pointer; text-align: center; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:hover { background: #3049c6; text-decoration: none; color: #fff; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--ink); }
.btn-ghost:hover { background: #f0f2f6; text-decoration: none; }
.btn-danger-ghost { background: transparent; border-color: var(--warn); color: var(--warn); }
.btn-danger-ghost:hover { background: var(--warn-bg); text-decoration: none; }

/* -------- Status chips -------- */
.status { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; background: #eef1f5; color: #333; }
.status-draft { background: var(--locked-bg); color: var(--locked-ink); }
.status-in_se_review { background: var(--info-bg); color: #1e3a8a; }
.status-se_approved { background: #e2f3ff; color: #0b4a82; }
.status-sent { background: #dfd7ff; color: #3a1e82; }
.status-won { background: var(--ok-bg); color: var(--ok); }
.status-lost { background: #ffd5d5; color: #8d1616; }

.pill { display: inline-block; font-size: 10px; padding: 1px 7px; border-radius: 9px; background: #eef1f5; color: var(--ink-soft); margin-left: 6px; vertical-align: middle; text-transform: uppercase; letter-spacing: .3px; font-weight: 600; }
.pill-auto { background: #e3ecff; color: #2240aa; }
.pill-locked { background: var(--locked-bg); color: var(--locked-ink); }

/* -------- Cost tracker totals -------- */
.totals { display: flex; gap: 8px; flex-wrap: wrap; }
.total-chip { background: #f3f4f7; padding: 6px 10px; border-radius: var(--radius); font-size: 12px; }
.total-chip span { color: var(--ink-muted); display: block; text-transform: uppercase; font-size: 10px; letter-spacing: .4px; }
.total-chip strong { font-size: 14px; font-variant-numeric: tabular-nums; }
.total-chip-margin strong { color: var(--ok); }

.warnings { list-style: none; padding: 0; margin: 0 0 14px 0; display: flex; flex-direction: column; gap: 6px; }
.warning { padding: 8px 10px; border-radius: var(--radius); font-size: 13px; }
.warning-info { background: #eef3ff; color: #234; }
.warning-warn { background: var(--warn-bg); color: var(--warn); }
.warning-error, .warning-block { background: var(--warn); color: #fff; }

.tech-tabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tech-tab { padding: 8px 14px; font-size: 13px; color: var(--ink-soft); border-bottom: 2px solid transparent; cursor: pointer; text-decoration: none; }
.tech-tab:hover { color: var(--ink); text-decoration: none; }
.tech-tab.active { border-bottom-color: var(--accent); color: var(--ink); font-weight: 600; }
.tech-tab-disabled { color: var(--ink-muted); font-style: italic; cursor: not-allowed; }
.tech-tab-add { color: var(--accent); }

/* Wizard breadcrumb */
.wizard-crumbs { display: flex; gap: 8px; list-style: none; padding: 0; margin: 0 0 18px 0; font-size: 12px; color: var(--ink-muted); }
.wizard-crumbs li { padding: 4px 10px; background: #eef1f5; border-radius: 999px; }
.wizard-crumbs li.active { background: var(--accent); color: #fff; font-weight: 600; }

/* Tech selection grid */
.tech-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.tech-option { display: grid; grid-template-columns: 22px 1fr; align-items: flex-start; gap: 10px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; background: #fff; transition: border-color .1s, background .1s; }
.tech-option:hover { border-color: var(--accent); background: #fafbff; }
.tech-option.selected { border-color: var(--accent); background: #eef3ff; box-shadow: 0 0 0 1px var(--accent) inset; }
.tech-option input[type="checkbox"] { margin: 3px 0 0 0; width: 16px; height: 16px; accent-color: var(--accent); }
.tech-option-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tech-option-label { font-weight: 600; font-size: 13px; color: var(--ink); }
.tech-option-sub { font-size: 11px; color: var(--ink-muted); line-height: 1.35; }

.tech-group { padding-bottom: 18px; }
.tech-group .panel-header { margin-bottom: 10px; }

/* Inline bool label */
.inline-bool { display: flex; align-items: center; gap: 8px; padding: 8px 0; }
.inline-bool input { margin: 0; }

/* -------- Modal -------- */
.modal { position: fixed; inset: 0; display: none; z-index: 500; }
.modal.open { display: block; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(11,15,25,.55); }
.modal-panel { position: relative; margin: 40px auto; background: var(--surface); border-radius: 10px; width: min(1100px, 92vw); max-height: calc(100vh - 80px); display: flex; flex-direction: column; box-shadow: 0 24px 48px rgba(0,0,0,.25); }
.modal-header { display: flex; justify-content: space-between; align-items: flex-start; padding: 18px 22px; border-bottom: 1px solid var(--border); gap: 12px; }
.modal-title { margin: 0; font-size: 18px; }
.modal-body { overflow: auto; padding: 16px 22px 22px; flex: 1; }

/* Catalog modal specifics */
.catalog-filters { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 12px; margin-bottom: 14px; align-items: end; }
.catalog-table { font-size: 12.5px; }
.catalog-table td { vertical-align: middle; padding: 6px 8px; }
.catalog-table .small { font-size: 11px; margin-top: 2px; }
.catalog-table .input-sm { width: 60px; padding: 4px 6px; font-size: 12px; margin-right: 6px; }

/* Review / approvals cards */
.review-card { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 12px; }
.review-card:first-child { border-top: none; padding-top: 0; margin-top: 0; }
.review-actions { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 10px; }
.review-actions .input { min-width: 260px; }
.small { font-size: 12px; }

/* Timeline for SE review history */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline-item { padding: 8px 12px; border-left: 3px solid var(--border); margin-bottom: 6px; background: #fafbfc; border-radius: 0 4px 4px 0; font-size: 13px; }
.timeline-item strong { margin-right: 8px; }
.timeline-item .muted { margin-right: 8px; font-size: 12px; }
.timeline-approve { border-left-color: var(--ok); }
.timeline-reject { border-left-color: var(--warn); }
.timeline-note { border-left-color: var(--accent); }

/* Status chips for approval / split */
.status-pending { background: var(--locked-bg); color: var(--locked-ink); }
.status-approved { background: var(--ok-bg); color: var(--ok); }
.status-rejected { background: #ffd5d5; color: #8d1616; }
.status-denied { background: #ffd5d5; color: #8d1616; }

/* SOW editor + body */
.sow-editor { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 13px; line-height: 1.5; min-height: 360px; white-space: pre; }
.sow-body { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 13px; white-space: pre-wrap; background: #fafbfc; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; line-height: 1.55; }

/* Admin tables — dense grid editor. Forms use display:contents so the form
   wrapper does not break the <tr> grid. */
.admin-tabs { margin-bottom: 18px; }
.admin-table { font-size: 12.5px; }
.admin-table th { font-size: 10.5px; }
.admin-table td { vertical-align: middle; padding: 4px 6px; }
.admin-table .input-xs { padding: 4px 6px; font-size: 12px; width: 92px; }
.admin-table .input-sm { padding: 4px 6px; font-size: 12px; }
.contents { display: contents; }

/* Integrations (admin) — 2-column form grid with helper text per field */
.integrations-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; }
.integration-field { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px; background: #fafbfc; }
.integration-bool { flex-direction: row; align-items: flex-start; gap: 10px; }
.integration-bool input { margin: 3px 0 0 0; }
.integration-label { font-weight: 600; font-size: 13px; color: var(--ink); }
.integration-help { font-size: 11.5px; line-height: 1.4; }
.integration-key { font-size: 10px; color: var(--ink-muted); font-family: ui-monospace, Menlo, monospace; letter-spacing: .2px; text-transform: uppercase; }
@media (max-width: 820px) { .integrations-grid { grid-template-columns: 1fr; } }

/* Notification bell + drawer */
.notif-wrap { position: relative; padding: 4px 6px; }
.notif-bell { background: #161b26; border: 1px solid #1a2030; border-radius: 6px; color: #d1d5de; padding: 6px 10px; font-size: 13px; width: 100%; text-align: left; cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
.notif-bell:hover { background: #1a2030; color: #fff; }
.notif-badge { background: var(--warn); color: #fff; font-size: 10px; padding: 1px 6px; border-radius: 9px; font-weight: 700; margin-left: 6px; }
.notif-drawer { display: none; position: absolute; left: 100%; bottom: 0; margin-left: 10px; width: 340px; max-height: 480px; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 12px 28px rgba(0,0,0,.2); z-index: 400; }
.notif-drawer.open { display: block; }
.notif-header { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.notif-header h3 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--ink-soft); }
.notif-list { list-style: none; margin: 0; padding: 0; }
.notif-item a { display: block; padding: 10px 14px; border-bottom: 1px solid var(--border); color: var(--ink); text-decoration: none; }
.notif-item a:hover { background: #f6f9ff; text-decoration: none; }
.notif-item.unread a { background: #eef3ff; }
.notif-title { font-weight: 600; font-size: 13px; }
.notif-body { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.notif-meta { font-size: 11px; color: var(--ink-muted); margin-top: 3px; }

/* -------- Flash -------- */
.flash-stack { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.flash { padding: 10px 14px; border-radius: var(--radius); font-size: 13px; border: 1px solid transparent; }
.flash-success { background: var(--ok-bg); border-color: #9cd9b0; color: var(--ok); }
.flash-error { background: var(--warn-bg); border-color: #e9a9a9; color: var(--warn); }
.flash-info { background: var(--info-bg); border-color: #a9c5ff; color: #1e3a8a; }

/* -------- Login -------- */
.login-wrap { min-height: 80vh; display: flex; align-items: center; justify-content: center; }
.login-card { background: var(--surface); padding: 32px 40px; border-radius: 10px; border: 1px solid var(--border); width: 420px; box-shadow: var(--shadow); }
.login-title { margin: 0 0 6px 0; font-size: 22px; }
.login-sub { color: var(--ink-soft); margin: 0 0 18px 0; font-size: 13px; }
.btn-google { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 10px 14px; font-size: 14px; }
.google-g { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; background: #fff; color: #4285F4; font-weight: 700; font-family: "Product Sans", Arial, sans-serif; font-size: 14px; }

/* -------- Errors page -------- */
.error-wrap { padding: 80px 0; text-align: center; max-width: 560px; margin: 0 auto; }
.error-wrap h1 { font-size: 24px; margin: 0 0 10px 0; color: var(--ink); }
.error-wrap p { color: var(--ink-soft); margin-bottom: 20px; }
.error-code { font-size: 64px; font-weight: 700; color: var(--ink-muted); letter-spacing: -2px; line-height: 1; margin-bottom: 12px; }
.error-actions { display: flex; gap: 10px; justify-content: center; }

/* -------- Session warning banner -------- */
.session-warning { position: fixed; top: 0; left: 0; right: 0; z-index: 900; background: var(--locked-bg); color: var(--locked-ink); border-bottom: 1px solid #e0c770; font-size: 13px; text-align: center; }
.session-warning-inner { padding: 8px 14px; }
.session-warning-inner.expired { background: var(--warn); color: #fff; border-color: var(--warn); }
.session-warning-inner.expired a { color: #fff; text-decoration: underline; }

/* -------- Sidebar toggle (mobile) -------- */
.sidebar-toggle { display: none; position: fixed; top: 10px; left: 12px; z-index: 700; background: #0d1017; color: #fff; border: 1px solid #1a2030; border-radius: 6px; width: 38px; height: 38px; font-size: 16px; cursor: pointer; }

/* -------- Mobile breakpoints -------- */
@media (max-width: 820px) {
  .app-body { grid-template-columns: 1fr; }
  .sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: 240px; transform: translateX(-100%); transition: transform .18s ease-out; z-index: 800; }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-toggle { display: block; }
  .main { padding: 58px 16px 40px; max-width: 100%; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .col-span-2 { grid-column: span 1; }
  .page-header { flex-direction: column; align-items: stretch; gap: 10px; }
  .page-actions { flex-wrap: wrap; }
  .catalog-filters { grid-template-columns: 1fr; }
  .tech-grid { grid-template-columns: 1fr; }

  /* Tables: allow horizontal scroll to keep data intact */
  .panel { overflow-x: auto; }
  .data-table { min-width: 640px; }
  .admin-table { min-width: 760px; }
  .notif-drawer { left: 10px; right: 10px; bottom: 60px; margin-left: 0; width: auto; }
}

@media (max-width: 520px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .error-code { font-size: 48px; }
}
