/* ==========================================================
   Duct Quick Calculator - Main Stylesheet
   Theme: Industrial yellow/orange/green (matches reference)
   ========================================================== */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --color-primary: #e8a02d;        /* warm amber */
  --color-primary-dark: #b87810;
  --color-primary-light: #f8c66c;
  --color-accent: #4caf50;         /* green highlight */
  --color-accent-dark: #357a37;
  --color-accent-light: #d8ecd9;
  --color-danger: #e74c3c;
  --color-info: #2c7fb8;
  --color-text: #2c2c2c;
  --color-text-soft: #555;
  --color-text-muted: #8a8a8a;
  --color-surface: #fff;
  --color-surface-2: #faf6ec;
  --color-surface-3: #f0e9d8;
  --color-line: #d6c9a8;
  --color-line-strong: #b8a772;
  --color-input: #fafde7;          /* light green input */
  --color-input-border: #b9d97c;
  --color-input-focus: #7ac74f;
  --color-header: #fff8ec;
  --color-header-line: #c8a96a;
  --color-grid: #ddd5be;

  --radius-sm: 3px;
  --radius-md: 6px;
  --radius-lg: 10px;

  --shadow-sm: 0 1px 2px rgba(74, 56, 18, .12);
  --shadow-md: 0 4px 10px rgba(74, 56, 18, .18);
  --shadow-lg: 0 10px 25px rgba(74, 56, 18, .24);

  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, "Source Han Sans SC", monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}

html, body {
  height: 100%;
}

body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background:
    linear-gradient(180deg, #fef9ed 0%, #fff7e3 100%);
  line-height: 1.5;
  font-size: 14px;
  overflow-x: hidden;
}

a {
  color: var(--color-info);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ---------- TOP HEADER ---------- */
.app-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
  background: linear-gradient(180deg, #fff 0%, var(--color-header) 100%);
  border-bottom: 2px solid var(--color-header-line);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 30;
}

.header-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 13px;
  border: 1px solid var(--color-line-strong);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  transition: all .15s ease;
  white-space: nowrap;
}

.header-btn:hover {
  background: var(--color-surface-2);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.header-btn-home {
  background: linear-gradient(180deg, #fff 0%, #f3e6c4 100%);
  border-color: var(--color-primary);
  color: var(--color-primary-dark);
}

.header-btn-mail {
  background: linear-gradient(180deg, #fff 0%, #d6ecda 100%);
  border-color: var(--color-accent);
  color: var(--color-accent-dark);
}

.btn-icon { font-size: 16px; }

.app-title {
  text-align: left;
  line-height: 1.15;
}

.header-spacer {
  min-width: 0;
}

.title-main {
  display: block;
  font-size: 20px;
  font-weight: 800;
  color: var(--color-primary-dark);
  letter-spacing: 1px;
}

.title-sub {
  display: block;
  font-size: 11px;
  color: var(--color-text-soft);
  letter-spacing: .5px;
  margin-top: 2px;
}

.header-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  align-items: center;
}

.lang-picker {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-md);
  background: var(--color-surface);
  border: 1px solid var(--color-line-strong);
}

.lang-select {
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  cursor: pointer;
  outline: none;
}

/* ---------- MAIN LAYOUT ---------- */
.app-main {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 460px;
  gap: 12px;
  padding: 12px;
  align-items: start;
  min-height: calc(100vh - 110px);
}

/* ---------- COMPONENT CATALOG ---------- */
.component-catalog {
  position: sticky;
  top: 84px;
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 10px;
  max-height: calc(100vh - 110px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.catalog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--color-line);
}

.catalog-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-primary-dark);
  letter-spacing: .4px;
}

.catalog-rail {
  display: none;
}

.catalog-toggle {
  display: none;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 4px;
}

.toggle-bar {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--color-primary-dark);
  margin: 3px 0;
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  overflow-y: auto;
  padding-right: 4px;
}

.comp-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: linear-gradient(180deg, #fefcf4 0%, #fbf6e3 100%);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  padding: 6px 4px;
  cursor: pointer;
  transition: all .15s ease;
  position: relative;
}

.comp-card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.comp-card.active {
  background: linear-gradient(180deg, #f1e2b6 0%, #e8d39b 100%);
  border-color: var(--color-primary-dark);
  box-shadow: 0 0 0 2px var(--color-primary-light);
}

.comp-card-num {
  font-size: 10px;
  font-weight: 700;
  color: var(--color-primary-dark);
  position: absolute;
  top: 3px;
  left: 5px;
  letter-spacing: .5px;
}

.comp-card-svg {
  width: 100%;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.comp-card-svg svg {
  max-height: 100%;
  max-width: 100%;
}

.comp-card-name {
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  color: var(--color-text);
  line-height: 1.2;
  word-break: keep-all;
}

/* ---------- WORKSPACE ---------- */
.workspace {
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 12px;
  min-height: 600px;
}

.workspace-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 10px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--color-line);
}

.back-btn {
  padding: 6px 14px;
  background: linear-gradient(180deg, #fff 0%, #f3e6c4 100%);
  border: 1px solid var(--color-primary);
  color: var(--color-primary-dark);
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.back-btn:hover {
  background: linear-gradient(180deg, #f3e6c4 0%, #e7d39b 100%);
}

.workspace-title {
  font-size: 16px;
  color: var(--color-primary-dark);
  font-weight: 700;
}

.component-number {
  margin-left: auto;
  font-size: 11px;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
}

.workspace-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 1100px) {
  .workspace-body {
    grid-template-columns: 1fr;
  }
}

/* ---------- FORM AREA ---------- */
.form-area {
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  padding: 12px;
}

.calc-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.calc-table tr {
  border-bottom: 1px solid var(--color-line);
}

.calc-table tr:last-child {
  border-bottom: none;
}

.calc-table td {
  padding: 6px 8px;
  vertical-align: middle;
}

.calc-table td.label-cell {
  width: 40%;
  font-size: 13px;
  color: var(--color-text);
  font-weight: 500;
}

.calc-table td.label-cell .label-suffix {
  color: var(--color-text-muted);
  font-size: 11px;
  margin-left: 4px;
}

.calc-table td.input-cell {
  width: 60%;
}

.input-field {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--color-input-border);
  border-radius: var(--radius-sm);
  background: var(--color-input);
  color: #1c5210;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  outline: none;
  transition: all .15s;
}

.input-field:focus {
  border-color: var(--color-input-focus);
  box-shadow: 0 0 0 2px rgba(122, 199, 79, .25);
  background: #f6ffd6;
}

.input-field:disabled,
.input-field[readonly] {
  background: #eef3e8;
  color: #4a6b3f;
  cursor: not-allowed;
}

.input-field.dim {
  background: #f4f0e2;
  color: var(--color-text-soft);
  border-color: var(--color-line);
}

.input-field.with-suffix {
  padding-right: 32px;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-suffix {
  position: absolute;
  right: 8px;
  font-size: 11px;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  pointer-events: none;
}

.composite-input {
  display: flex;
  align-items: center;
  gap: 4px;
}

.composite-input .input-field {
  flex: 1;
  min-width: 0;
  text-align: center;
}

.composite-input .composite-symbol {
  font-weight: 700;
  color: var(--color-text-soft);
  font-size: 14px;
  padding: 0 2px;
}

/* ---------- NOTES ---------- */
.form-notes {
  margin-top: 12px;
  padding: 10px;
  background: var(--color-surface-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-line);
}

.notes-title {
  font-size: 12px;
  color: var(--color-primary-dark);
  font-weight: 700;
  margin-bottom: 4px;
}

.notes-list {
  margin-left: 20px;
  font-size: 12px;
  color: var(--color-text-soft);
}

.notes-list li {
  margin: 2px 0;
}

/* ---------- FORM ACTIONS ---------- */
.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--color-line);
}

.form-hint {
  font-size: 12px;
  color: var(--color-info);
}

.form-hint::before {
  content: "\2713";
  color: var(--color-accent);
  margin-right: 4px;
  font-weight: 700;
}

.action-buttons {
  display: flex;
  gap: 8px;
}

.primary-btn {
  padding: 8px 18px;
  background: linear-gradient(180deg, #f4c563 0%, var(--color-primary) 100%);
  color: #fff;
  border: 1px solid var(--color-primary-dark);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .5px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all .15s;
}

.primary-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  background: linear-gradient(180deg, #f5cb74 0%, #de9626 100%);
}

.primary-btn:active {
  transform: translateY(0);
}

.secondary-btn {
  padding: 8px 14px;
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-line-strong);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}

.secondary-btn:hover {
  background: var(--color-surface-2);
  border-color: var(--color-primary);
}

/* ---------- PREVIEW AREA ---------- */
.preview-area {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.preview-svg {
  width: 100%;
  flex: 1;
  min-height: 280px;
  background: linear-gradient(135deg, #fdf6e3 0%, #f7ebcc 100%);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.preview-svg svg {
  max-width: 100%;
  max-height: 320px;
  filter: drop-shadow(2px 4px 4px rgba(74, 56, 18, .15));
}

.preview-caption {
  padding: 8px 12px;
  background: var(--color-surface-3);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--color-text-soft);
  line-height: 1.5;
}

/* ---------- BILL PANEL ---------- */
.bill-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 10px;
  position: sticky;
  top: 84px;
  max-height: calc(100vh - 110px);
  display: flex;
  flex-direction: column;
}

.bill-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--color-line);
}

.bill-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-primary-dark);
  letter-spacing: .4px;
}

.bill-actions {
  display: flex;
  gap: 6px;
}

.bill-actions .primary-btn,
.bill-actions .secondary-btn {
  padding: 5px 10px;
  font-size: 12px;
}

.bill-table-wrap {
  overflow: auto;
  flex: 1;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
}

.bill-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.bill-table th,
.bill-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--color-grid);
  border-right: 1px solid var(--color-grid);
  text-align: left;
  white-space: nowrap;
}

.bill-table thead th {
  background: linear-gradient(180deg, #fff6df 0%, #f0e2bb 100%);
  color: var(--color-primary-dark);
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 2;
}

.bill-table tfoot th {
  background: var(--color-accent-light);
  font-weight: 700;
  color: var(--color-accent-dark);
}

.bill-total-label {
  text-align: right !important;
}

.bill-total-value {
  color: var(--color-accent-dark);
  font-family: var(--font-mono);
  font-weight: 700;
  text-align: right;
  font-size: 12px;
}

.bill-table tbody tr:hover {
  background: var(--color-surface-3);
}

.bill-row-action {
  display: inline-flex;
  gap: 4px;
}

.bill-del-btn {
  padding: 3px 8px;
  background: var(--color-danger);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
}

.bill-del-btn:hover {
  opacity: .9;
}

.bill-empty {
  padding: 30px 12px;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 12px;
  font-style: italic;
}

/* ---------- MODAL ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 12, 0, .55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  width: min(520px, 90%);
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-title {
  padding: 14px 20px;
  background: linear-gradient(180deg, var(--color-primary-light) 0%, var(--color-primary) 100%);
  color: #fff;
  font-size: 16px;
}

.modal-body {
  padding: 20px;
  font-size: 13px;
  color: var(--color-text);
  line-height: 1.6;
  max-height: 60vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 12px 20px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--color-line);
}

/* ---------- FOOTER ---------- */
.app-footer {
  padding: 14px 20px;
  text-align: center;
  background: var(--color-header);
  border-top: 1px solid var(--color-header-line);
  color: var(--color-text-soft);
  font-size: 12px;
  line-height: 1.7;
}

.footer-meta {
  color: var(--color-text-muted);
  font-family: var(--font-mono);
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 1280px) {
  .app-main {
    grid-template-columns: 240px 1fr 320px;
  }
  .title-main { font-size: 17px; }
}

@media (max-width: 1024px) {
  .app-main {
    grid-template-columns: 1fr;
  }
  .component-catalog,
  .bill-panel {
    position: relative;
    top: 0;
    max-height: 400px;
  }
}

@media (max-width: 768px) {
  .app-header {
    grid-template-columns: 1fr;
    text-align: center;
    gap: 10px;
  }
  .header-actions {
    justify-content: center;
  }
  .workspace-header {
    flex-wrap: wrap;
  }
  .form-actions {
    flex-wrap: wrap;
  }
}

@media (max-width: 600px) {
  .catalog-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .bill-table { font-size: 10px; }
  .bill-table th,
  .bill-table td { padding: 4px 6px; }
}

/* ---------- SCROLLBAR ---------- */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--color-surface-3);
}

::-webkit-scrollbar-thumb {
  background: var(--color-line-strong);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-primary);
}

/* ---------- TOAST ---------- */
.toast {
  position: fixed;
  left: 50%;
  top: 80px;
  transform: translateX(-50%);
  padding: 10px 18px;
  background: var(--color-accent-dark);
  color: #fff;
  font-size: 13px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s;
}

.toast.show {
  opacity: 1;
}

.toast.error {
  background: var(--color-danger);
}

/* ---------- PHASE 2: live estimate + extended BOM columns ---------- */
.bill-table {
  min-width: 1120px;
}

.bill-table .col-seq,
.bill-table .col-qty,
.bill-table .col-thickness {
  text-align: center;
  font-family: var(--font-mono);
}

.bill-table .col-engQty,
.bill-table .col-weight,
.bill-table .col-flangeWt,
.bill-table .col-bolts,
.bill-table .col-insArea,
.bill-table .col-insVol {
  text-align: right;
  font-family: var(--font-mono);
  white-space: nowrap;
}

.bill-table tfoot .bill-total-label {
  text-align: left !important;
}

.bill-edit-btn {
  padding: 3px 8px;
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 10px;
  cursor: pointer;
  margin-right: 4px;
}
.bill-edit-btn:hover { filter: brightness(0.94); }

/* Live estimate box under the form */
.live-extras {
  margin: 10px 0 4px;
  padding: 10px 12px;
  background: var(--color-accent-light);
  border: 1px dashed var(--color-accent);
  border-radius: var(--radius-sm);
}
.live-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-accent-dark);
  margin-bottom: 6px;
}
.live-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}
.live-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
}
.live-label {
  font-size: 10px;
  color: var(--color-muted);
  letter-spacing: .3px;
}
.live-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-primary-dark);
  font-family: var(--font-mono);
}
.live-unit {
  font-size: 10px;
  font-weight: 500;
  color: var(--color-muted);
  margin-left: 2px;
}

@media (max-width: 1280px) {
  .live-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 600px) {
  .live-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- PHASE 3: unit picker, std warning, cost, group subtotal ---------- */
.bill-table { min-width: 1240px; }

.unit-picker {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
}
.unit-picker-icon { font-size: 14px; }
.unit-select {
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  cursor: pointer;
  outline: none;
}

.std-warn {
  margin: 8px 0 4px;
  padding: 8px 12px;
  background: #fff4e5;
  border: 1px solid #e8a02d;
  border-left: 4px solid #e8a02d;
  border-radius: var(--radius-sm);
  font-size: 12px;
}
.std-warn-title {
  font-weight: 700;
  color: #b5640a;
  margin-bottom: 4px;
}
.std-warn-item {
  color: #7a4a12;
  line-height: 1.6;
}

.bill-table .col-cost {
  text-align: right;
  font-family: var(--font-mono);
  white-space: nowrap;
  font-weight: 700;
  color: var(--color-primary-dark);
}
.bill-table tfoot .col-cost { font-weight: 700; }

.group-sub { background: var(--color-accent-light); }
.group-sub td {
  font-size: 11px;
  font-weight: 700;
  color: var(--color-accent-dark);
  border-top: 1px solid var(--color-accent);
}
.group-sub-label { text-align: left; }

/* ---------- PHASE 4: cost split view, project bar, price modal ---------- */
.bill-actions { flex-wrap: wrap; }

.cost-view {
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 6px;
  cursor: pointer;
  outline: none;
}

.project-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 6px 0 8px;
  border-bottom: 1px solid var(--color-line);
  margin-bottom: 8px;
}
.project-bar-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-primary-dark);
}
.project-select {
  flex: 1;
  min-width: 90px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  font-size: 12px;
  padding: 4px 6px;
  background: var(--color-surface);
  outline: none;
}
.mini-btn {
  border: 1px solid var(--color-line);
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  font-size: 11px;
  padding: 4px 8px;
  cursor: pointer;
  color: var(--color-text);
}
.mini-btn:hover { background: var(--color-primary-light); }

.bill-table { min-width: 1240px; }
.bill-table.cost-split { min-width: 1540px; }
.bill-table .cost-split-cell {
  text-align: right;
  font-family: var(--font-mono);
  white-space: nowrap;
  color: var(--color-primary-dark);
}
.bill-table tfoot .cost-split-cell { font-weight: 700; }
.bill-table:not(.cost-split) .cost-split-cell { display: none; }

.live-title-sub { margin-top: 8px; }

/* price settings modal */
.price-note {
  font-size: 11px;
  color: var(--color-muted);
  margin: 0 0 10px;
  line-height: 1.5;
}
.price-group { margin-bottom: 10px; }
.price-group h4 {
  font-size: 12px;
  margin: 0 0 6px;
  color: var(--color-primary-dark);
  border-left: 3px solid var(--color-primary);
  padding-left: 6px;
}
.price-row {
  display: grid;
  grid-template-columns: 1fr 120px;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.price-label { font-size: 12px; color: var(--color-text); }
.price-input {
  width: 100%;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  font-size: 12px;
  text-align: right;
}
.price-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

/* ---------- PHASE 5: row expand, copy dialog, quotation ---------- */
/* inline cost-breakdown expand */
.row-caret {
  background: none;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  color: var(--color-primary-dark);
  font-size: 9px;
  line-height: 1;
  padding: 2px 4px;
  margin-right: 4px;
  cursor: pointer;
  vertical-align: middle;
}
.row-caret:hover { background: var(--color-primary-light); }
.bill-detail-row td {
  background: #fffdf4;
  border-bottom: 1px dashed var(--color-line);
  padding: 8px 12px;
}
.bill-detail-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(110px, 1fr));
  gap: 8px;
}
.bd-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
}
.bd-label { font-size: 10px; color: var(--color-muted); }
.bd-value {
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--color-primary-dark);
}
.bd-total { border-color: var(--color-primary); background: #fff6df; }

/* copy-items dialog */
.copy-list {
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  margin: 8px 0;
}
.copy-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--color-grid);
  cursor: pointer;
  font-size: 12px;
}
.copy-row:hover { background: var(--color-surface-3); }
.copy-name { font-weight: 600; }
.copy-meta { color: var(--color-muted); font-size: 11px; margin-left: auto; white-space: nowrap; }
.copy-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }

/* quotation overlay */
.quote-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(30, 24, 10, .45);
  z-index: 1000;
  padding: 24px;
  overflow: auto;
}
.quote-overlay.active { display: block; }
.quote-modal {
  background: #fff;
  color: #222;
  border-radius: var(--radius-md);
  max-width: 1100px;
  margin: 0 auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .3);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 48px);
}
.quote-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-line);
  background: #fff6df;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}
.quote-bar-title { color: var(--color-primary-dark); font-size: 14px; }
.quote-bar-actions { display: flex; gap: 8px; }
.quote-doc {
  padding: 24px 28px;
  overflow: auto;
  flex: 1;
  font-size: 13px;
  line-height: 1.5;
}
/* quotation document internals */
.quote-head { text-align: center; margin-bottom: 14px; }
.quote-title { font-size: 22px; font-weight: 800; color: #b8860b; letter-spacing: 2px; }
.quote-sub { font-size: 14px; color: #666; margin-top: 2px; }
.quote-meta { width: 100%; border-collapse: collapse; margin-bottom: 14px; }
.quote-meta td {
  border: 1px solid #ddd;
  padding: 6px 10px;
  font-size: 12px;
}
.quote-meta td:nth-child(odd) { background: #faf6ea; font-weight: 600; color: #7a5b00; width: 110px; }
.quote-meta td:nth-child(even) { color: #333; }
.quote-items { width: 100%; border-collapse: collapse; margin-bottom: 14px; }
.quote-items th, .quote-items td {
  border: 1px solid #ddd;
  padding: 6px 8px;
  font-size: 12px;
}
.quote-items thead th { background: #f5ead0; color: #7a5b00; font-weight: 700; }
.quote-items td.r, .quote-items th.r { text-align: right; }
.quote-grand { font-weight: 800; color: #b8860b; }
.quote-sum td { background: #fff6df; font-weight: 700; }
.quote-sum-label { text-align: right; }
.quote-foot { border-top: 2px solid #e6d9b8; padding-top: 10px; font-size: 11px; color: #666; }
.quote-note { margin-top: 4px; font-style: italic; }
.quote-sign { margin-top: 8px; text-align: right; font-size: 12px; color: #333; }

/* ---------- PRINT ---------- */
@media print {
  .app-header, .component-catalog, .form-actions, .form-notes,
  .modal-overlay, .app-footer, .bill-actions { display: none !important; }
  .workspace { box-shadow: none; border: none; }
  .app-main { display: block; }
  .bill-panel { position: static; }
}

/* quotation-only printing (active while the quotation is open) */
@media print {
  body.quote-print * { visibility: hidden !important; }
  body.quote-print .quote-overlay.active,
  body.quote-print .quote-overlay.active * { visibility: visible !important; }
  body.quote-print .quote-overlay.active {
    position: absolute;
    inset: 0;
    padding: 0;
    background: #fff;
    overflow: visible;
  }
  body.quote-print .quote-modal {
    box-shadow: none;
    max-height: none;
    border-radius: 0;
    width: 100%;
  }
  body.quote-print .quote-bar { display: none !important; }
  body.quote-print .quote-doc { padding: 12px 6px; overflow: visible; }
  body.quote-print .quote-items th,
  body.quote-print .quote-items td,
  body.quote-print .quote-meta td { font-size: 11px; padding: 4px 6px; }
}

