/* ============================================================
   PR316 Budget / Cost-to-Complete Engine — Styles
   All selectors scoped to .pr316-* prefix
   ============================================================ */

/* ── Root container ──────────────────────────────────────────── */
.pr316-root {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  color: #1A1A2E;
  background: #F7F8FA;
  padding: 16px;
  box-sizing: border-box;
}

/* ── Page header ─────────────────────────────────────────────── */
.pr316-header {
  margin-bottom: 16px;
}

.pr316-header__title {
  font-size: 22px;
  font-weight: 700;
  color: #1A1A2E;
  margin: 0 0 4px 0;
}

.pr316-header__subtitle {
  font-size: 13px;
  color: #555;
  margin: 0 0 8px 0;
}

/* Orange tab ribbon */
.pr316-tab-ribbon {
  display: inline-flex;
  align-items: center;
  background: #E87722;
  border-radius: 4px 4px 0 0;
  padding: 4px 16px;
  margin-top: 4px;
}

.pr316-tab-ribbon__label {
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* ── Lily bar ────────────────────────────────────────────────── */
.pr316-lily-bar {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: #EDE7F6;
  border-left: 4px solid #7B1FA2;
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 16px;
}

.pr316-lily-bar[data-health="amber"] {
  background: #FFF8E1;
  border-left-color: #F59E0B;
}

.pr316-lily-bar[data-health="red"] {
  background: #FFEBEE;
  border-left-color: #D32F2F;
}

.pr316-lily-bar[data-health="green"] {
  background: #E8F5E9;
  border-left-color: #2E7D32;
}

.pr316-lily-bar__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #7B1FA2;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 2px;
}

.pr316-lily-bar__texts {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pr316-lily-bar__title {
  font-size: 11px;
  font-weight: 600;
  color: #7B1FA2;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.pr316-lily-bar__insight {
  font-size: 13px;
  color: #333;
}

/* ── Stats row ───────────────────────────────────────────────── */
.pr316-stats-row {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.pr316-stat-pill {
  flex: 1 1 140px;
  background: #fff;
  border: 1px solid #E0E0E0;
  border-radius: 8px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 120px;
}

.pr316-stat-pill__label {
  font-size: 11px;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.pr316-stat-pill__val {
  font-size: 18px;
  font-weight: 700;
  color: #1A1A2E;
}

/* Health badges inside stat pill */
.pr316-health {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  border-radius: 4px;
  padding: 2px 8px;
  letter-spacing: 0.5px;
}

.pr316-health--green {
  background: #E8F5E9;
  color: #2E7D32;
}

.pr316-health--amber {
  background: #FFF8E1;
  color: #B45309;
}

.pr316-health--red {
  background: #FFEBEE;
  color: #C62828;
}

/* ── Action bar ──────────────────────────────────────────────── */
.pr316-action-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.pr316-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  border: none;
  border-radius: 6px;
  padding: 7px 16px;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  outline: none;
  background: #E0E0E0;
  color: #333;
}

.pr316-btn:hover {
  background: #BDBDBD;
}

.pr316-btn--primary {
  background: #1A1A2E;
  color: #fff;
}

.pr316-btn--primary:hover {
  background: #2D2D4E;
}

.pr316-btn--secondary {
  background: #E3F2FD;
  color: #1565C0;
}

.pr316-btn--secondary:hover {
  background: #BBDEFB;
}

.pr316-btn--export {
  background: #E8F5E9;
  color: #2E7D32;
}

.pr316-btn--export:hover {
  background: #C8E6C9;
}

.pr316-btn--save {
  background: #E87722;
  color: #fff;
}

.pr316-btn--save:hover {
  background: #C86010;
}

.pr316-btn--add {
  background: #F3E5F5;
  color: #6A1B9A;
}

.pr316-btn--add:hover {
  background: #E1BEE7;
}

.pr316-btn--cancel {
  background: #FAFAFA;
  color: #666;
  border: 1px solid #CCC;
}

.pr316-btn--cancel:hover {
  background: #EFEFEF;
}

.pr316-btn--import {
  background: #FFF3E0;
  color: #E65100;
}

.pr316-btn--import:hover {
  background: #FFE0B2;
}

/* Two-tap orange pulse animation */
.pr316-btn--pulse {
  animation: pr316-pulse 0.4s ease-in-out;
  background: #E87722 !important;
  color: #fff !important;
}

@keyframes pr316-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(232, 119, 34, 0.6); }
  70%  { box-shadow: 0 0 0 10px rgba(232, 119, 34, 0); }
  100% { box-shadow: 0 0 0 0 rgba(232, 119, 34, 0); }
}

/* ── Category badges ─────────────────────────────────────────── */
.pr316-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  padding: 2px 7px;
  letter-spacing: 0.3px;
  text-transform: capitalize;
}

.pr316-badge--labor {
  background: #E3F2FD;
  color: #1565C0;
}

.pr316-badge--materials {
  background: #E8F5E9;
  color: #2E7D32;
}

.pr316-badge--subcontractor {
  background: #FFF8E1;
  color: #B45309;
}

.pr316-badge--equipment {
  background: #F3E5F5;
  color: #6A1B9A;
}

.pr316-badge--overhead {
  background: #ECEFF1;
  color: #455A64;
}

.pr316-badge--other {
  background: #FBE9E7;
  color: #BF360C;
}

/* ── Budget table ────────────────────────────────────────────── */
.pr316-table-wrap {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid #E0E0E0;
  margin-bottom: 16px;
}

.pr316-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  min-width: 900px;
}

.pr316-table__head {
  background: #1A1A2E;
}

.pr316-table__th {
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 10px 12px;
  text-align: left;
  white-space: nowrap;
  letter-spacing: 0.3px;
}

.pr316-table__th:nth-child(n+5) {
  text-align: right;
}

.pr316-table__row {
  border-bottom: 1px solid #F0F0F0;
  transition: background 0.1s;
}

.pr316-table__row:hover {
  background: #FAFAFA;
}

.pr316-table__row--over {
  background: #FFF5F5;
}

.pr316-table__row--over:hover {
  background: #FFEBEB;
}

.pr316-table__td {
  padding: 9px 12px;
  font-size: 13px;
  color: #333;
  vertical-align: middle;
}

.pr316-table__td--code {
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: #555;
  white-space: nowrap;
}

.pr316-table__td--num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.pr316-table__td--override {
  font-style: italic;
  color: #7B1FA2;
}

/* Variance coloring */
.pr316-var--pos {
  color: #2E7D32;
  font-weight: 600;
}

.pr316-var--neg {
  color: #C62828;
  font-weight: 600;
}

/* Totals row */
.pr316-table__totals {
  background: #F0F0F4;
  border-top: 2px solid #1A1A2E;
}

.pr316-table__totals .pr316-table__td {
  font-weight: 700;
  color: #1A1A2E;
  padding: 10px 12px;
}

/* Contingency row */
.pr316-table__contingency {
  background: #FFFDE7;
  border-top: 1px dashed #F59E0B;
}

.pr316-table__contingency .pr316-table__td {
  font-size: 12px;
  color: #7B5E00;
  padding: 8px 12px;
}

/* ── Progress bars ───────────────────────────────────────────── */
.pr316-progress {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 100px;
}

.pr316-progress__fill {
  display: inline-block;
  height: 8px;
  border-radius: 4px;
  min-width: 2px;
  transition: width 0.3s;
}

.pr316-progress__fill--green {
  background: #4CAF50;
}

.pr316-progress__fill--amber {
  background: #F59E0B;
}

.pr316-progress__fill--red {
  background: #EF5350;
}

.pr316-progress__label {
  font-size: 12px;
  color: #555;
  white-space: nowrap;
}

/* ── Inline inputs (edit mode) ───────────────────────────────── */
.pr316-input {
  border: 1px solid #BDBDBD;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 13px;
  color: #1A1A2E;
  background: #fff;
  width: 90px;
  text-align: right;
  transition: border-color 0.15s;
}

.pr316-input:focus {
  border-color: #E87722;
  outline: none;
  box-shadow: 0 0 0 2px rgba(232, 119, 34, 0.2);
}

.pr316-input--contingency {
  width: 70px;
}

/* Edit bar */
.pr316-edit-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  padding: 12px;
  background: #FFF3E0;
  border-radius: 6px;
  border: 1px solid #FFB74D;
  margin-bottom: 16px;
}

/* ── Access denied ───────────────────────────────────────────── */
.pr316-access-denied {
  background: #FFEBEE;
  border: 1px solid #FFCDD2;
  border-radius: 8px;
  padding: 32px 24px;
  text-align: center;
  margin: 24px 0;
}

.pr316-access-denied__title {
  font-size: 18px;
  font-weight: 700;
  color: #B71C1C;
  margin: 0 0 8px 0;
}

.pr316-access-denied__msg {
  font-size: 14px;
  color: #555;
  margin: 0;
}

/* ── SOV preview modal ───────────────────────────────────────── */
.pr316-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9990;
}

.pr316-sov-preview {
  background: #fff;
  border-radius: 10px;
  padding: 24px;
  max-width: 520px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.pr316-sov-preview__title {
  font-size: 16px;
  font-weight: 700;
  color: #1A1A2E;
  margin: 0 0 12px 0;
}

.pr316-sov-preview__list {
  list-style: none;
  padding: 0;
  margin: 0 0 16px 0;
  max-height: 240px;
  overflow-y: auto;
}

.pr316-sov-preview__list li {
  padding: 6px 0;
  border-bottom: 1px solid #F0F0F0;
  font-size: 13px;
  color: #333;
}

/* ── Responsive: <768px stacks to card list ──────────────────── */
@media (max-width: 767px) {
  .pr316-stats-row {
    flex-direction: column;
  }

  .pr316-stat-pill {
    flex: none;
    width: 100%;
  }

  .pr316-table-wrap {
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .pr316-table {
    min-width: unset;
  }

  .pr316-table thead {
    display: none;
  }

  .pr316-table__row {
    display: block;
    margin-bottom: 10px;
    border: 1px solid #E0E0E0;
    border-radius: 8px;
    padding: 10px;
  }

  .pr316-table__td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: right;
    padding: 5px 4px;
    font-size: 12px;
    border-bottom: 1px solid #F5F5F5;
  }

  .pr316-table__td:last-child {
    border-bottom: none;
  }

  .pr316-table__td::before {
    content: attr(data-label);
    font-weight: 600;
    color: #888;
    font-size: 11px;
    text-transform: uppercase;
    text-align: left;
    flex: 0 0 40%;
  }

  .pr316-action-bar {
    flex-direction: column;
  }

  .pr316-btn {
    width: 100%;
    justify-content: center;
  }

  .pr316-lily-bar {
    flex-direction: column;
    gap: 8px;
  }
}
