/* ==========================================================================
   Manual Structural Estimator & Combination Engine Styles
   Standard IS:456 / IS:2911 / IS:1077 / IS:383 / CPWD Benchmark
   ========================================================================== */

.manual-estimator-workspace {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background-color: #f8fafc;
  color: #0f172a;
  min-height: calc(100vh - 120px);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

.manual-setup-panel {
  min-width: 0;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-top: 3px solid #3b82f6;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .04);
}

.manual-setup-panel .manual-header-card,
.manual-setup-panel .manual-combination-bar {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.manual-setup-panel .manual-header-card { padding: 10px 14px; }
.manual-setup-panel .manual-combination-bar { border-top: 1px solid #f1f5f9; padding: 8px 14px; }

.manual-takeoff-form {
  display: grid;
  grid-template-columns: minmax(200px, 2fr) minmax(150px, 1fr) minmax(90px, .6fr) auto;
  align-items: end;
  gap: 8px;
}

.manual-inline-takeoff-form {
  min-width: 0;
  grid-template-columns: minmax(170px, 1.8fr) minmax(115px, .75fr) minmax(65px, .4fr) auto;
}

.manual-inline-takeoff-form .manual-input { height: 34px; }

.manual-takeoff-form label { display: grid; gap: 3px; color: #475569; font-size: 11.5px; font-weight: 600; }
.manual-takeoff-form .manual-input { width: 100%; min-width: 0; box-sizing: border-box; }
.manual-takeoff-form button { min-height: 32px; justify-content: center; }
.manual-takeoff-note {
  margin: 0;
  color: #0369a1;
  background: #f0f9ff;
  border: 1px solid #e0f2fe;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 11.5px;
  line-height: 1.4;
}


.manual-empty-compact {
  padding: 10px 12px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  color: #64748b;
  background: #fff;
  font-size: 12.5px;
}

.manual-takeoff-trace {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid #f1f5f9;
}

.manual-takeoff-trace label { display: grid; gap: 3px; min-width: 165px; color: #64748b; font-size: 11px; font-weight: 600; }
.manual-takeoff-trace .manual-input { min-width: 0; }
.manual-takeoff-source { margin-left: auto; color: #475569; font-size: 11.5px; }

@media (max-width: 1100px) {
  .manual-takeoff-form { grid-template-columns: repeat(2, minmax(150px, 1fr)); }
}

@media (max-width: 640px) {
  .manual-takeoff-form { grid-template-columns: 1fr; }
}

/* 1. Top Executive Header */
.manual-header-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  background: #ffffff;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.manual-title-wrap h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 8px;
}

.manual-title-wrap p {
  margin: 1px 0 0 0;
  font-size: 12.5px;
  color: #64748b;
  max-width: 650px;
  line-height: 1.4;
}

.manual-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.manual-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: 7px;
  border: 1px solid #cbd5e1;
  background-color: #ffffff;
  color: #1e293b;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}

.manual-btn:hover {
  background-color: #f1f5f9;
  border-color: #94a3b8;
  color: #1e293b;
}

.manual-btn-primary {
  background-color: #2563eb;
  color: #ffffff;
  border-color: #1d4ed8;
}

.manual-btn-primary:hover {
  background-color: #1d4ed8;
  border-color: #1e40af;
  color: #ffffff;
}

.manual-btn-success {
  background-color: #059669;
  color: #ffffff;
  border-color: #047857;
}

.manual-btn-success:hover {
  background-color: #047857;
  color: #ffffff;
}

.manual-btn-danger {
  background-color: #ef4444;
  color: #ffffff;
  border-color: #dc2626;
}

.manual-btn-danger:hover {
  background-color: #dc2626;
  color: #ffffff;
}

.manual-btn-sm {
  padding: 5px 10px;
  font-size: 11.5px;
}

.manual-btn-xs {
  padding: 3px 7px;
  font-size: 11px;
}

/* 2. Master Combination Controls Bar */
.manual-combination-bar {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: #ffffff;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.03);
}

.manual-comb-top-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.manual-comb-name-wrap {
  flex: 1 1 300px;
  min-width: 220px;
}
.manual-comb-name-wrap input {
  flex: 1;
}

.manual-comb-structure-wrap { flex: 0 1 315px; min-width: 220px; }
.manual-comb-structure-wrap .manual-comb-select { flex: 1; min-width: 0; width: 100%; }
.manual-header-units { white-space: nowrap; }
.manual-comb-top-row > .manual-btn { min-height: 35px; justify-content: center; }

.manual-comb-input-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.manual-comb-input-group label {
  font-size: 12px;
  font-weight: 600;
  color: #475569;
}

.manual-comb-name-input {
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  min-width: 0;
  width: 100%;
  height: 36px;
  box-sizing: border-box;
}

.manual-comb-select {
  padding: 6px 10px;
  font-size: 12.5px;
  color: #334155;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  height: 36px;
}

.manual-unit-toggle {
  display: inline-flex;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  overflow: hidden;
  background: #f1f5f9;
}

.manual-unit-btn {
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 600;
  border: none;
  background: transparent;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s ease;
}

.manual-unit-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.manual-unit-btn.active {
  background: #2563eb;
  color: #ffffff;
  font-weight: 700;
}

/* 3. Master KPI Metric Cards */
.manual-kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

@media (max-width: 1200px) {
  .manual-kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .manual-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .manual-setup-panel .manual-header-card,
  .manual-setup-panel .manual-combination-bar { padding: 10px; }
}

@media (max-width: 440px) {
  .manual-kpi-grid { grid-template-columns: minmax(0, 1fr); }
}

.manual-kpi-card {
  min-height: 68px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: #ffffff;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  padding: 8px 10px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
  position: relative;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.manual-kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
}

.manual-kpi-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}

.manual-kpi-card.kpi-steel::before { background: #6366f1; }
.manual-kpi-card.kpi-concrete::before { background: #0284c7; }
.manual-kpi-card.kpi-cement::before { background: #ea580c; }
.manual-kpi-card.kpi-sand::before { background: #d97706; }
.manual-kpi-card.kpi-aggregate::before { background: #64748b; }
.manual-kpi-card.kpi-bricks::before { background: #b45309; }

.manual-kpi-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
}

.manual-kpi-head .title {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  color: #64748b;
  letter-spacing: 0.4px;
}

.manual-kpi-head .icon {
  font-size: 14px;
}

.manual-kpi-value {
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.1;
  margin-bottom: 1px;
}

.manual-kpi-sub {
  font-size: 10px;
  color: #64748b;
  display: flex;
  justify-content: space-between;
}

/* 4. Elements Container */
.manual-elements-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
  container: takeoff-list / inline-size;
  --takeoff-columns: 42px minmax(100px, 1fr) minmax(130px, 1.2fr) minmax(90px, .85fr) minmax(190px, 1.65fr) 68px 92px 82px 48px 18px;
}

.manual-elements-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid #f1f5f9;
}

.manual-elements-header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.manual-elements-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.manual-elements-icon-pill {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #eff6ff;
  border: 1px solid #dbeafe;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}

.manual-elements-title {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.manual-elements-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.manual-elements-title h3,
.manual-elements-title-row h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.01em;
}

.manual-elements-subtitle {
  margin: 0;
  font-size: 11.5px;
  color: #64748b;
  line-height: 1.3;
}

.manual-count-badge {
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 9999px;
  white-space: nowrap;
}

.manual-takeoff-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 5px 10px;
  flex-wrap: wrap;
}

.manual-takeoff-composer-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  flex-wrap: wrap;
}

.manual-takeoff-composer-label {
  font-size: 11.5px;
  font-weight: 700;
  color: #334155;
  white-space: nowrap;
}

.manual-takeoff-toolbar > .manual-btn {
  align-self: center;
  min-height: 32px;
}

/* Blank / Empty State */
.manual-empty-state {
  background: #ffffff;
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  padding: 36px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.manual-empty-icon {
  font-size: 38px;
  opacity: 0.85;
}

.manual-empty-title {
  font-size: 15px;
  font-weight: 700;
  color: #1e293b;
  margin: 0;
}

.manual-empty-desc {
  font-size: 12.5px;
  color: #64748b;
  max-width: 500px;
  line-height: 1.5;
  margin: 0;
}

/* 5. Compact Element Row Card (Clean Tabular Row) */
.manual-element-row-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 9px;
  padding: 0;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
  display: flex;
  flex-direction: column;
  gap: 0;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.manual-element-row-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
}

.manual-element-row-card.is-expanded { border-color: #93c5fd; }

.manual-takeoff-list-head {
  display: grid;
  grid-template-columns: var(--takeoff-columns);
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  color: #475569;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 7px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.manual-takeoff-list-head > span { min-width: 0; }

.manual-takeoff-summary {
  display: grid;
  grid-template-columns: var(--takeoff-columns);
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 43px;
  padding: 6px 14px;
  border: 0;
  background: #fff;
  color: #334155;
  --btn-hover-color: #334155;
  text-align: left;
  cursor: pointer;
  border-radius: 9px 9px 0 0;
}

.manual-takeoff-summary:hover, .manual-takeoff-summary[aria-expanded="true"] { background: #f8fbff; color: #334155; box-shadow: none; transform: none; }
.manual-takeoff-summary:focus-visible { outline: 2px solid #2563eb; outline-offset: -3px; }
.manual-summary-cell { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; }
.manual-summary-index { width: fit-content; padding: 3px 6px; background: #eff6ff; color: #1d4ed8; border-radius: 5px; font-size: 11px; font-weight: 700; }
.manual-summary-name { color: #0f172a; font-size: 13px; }
.manual-summary-count, .manual-summary-concrete, .manual-summary-steel { font-weight: 700; }
.manual-summary-chevron { color: #2563eb; font-size: 20px; line-height: 1; transition: transform .15s ease; }
.manual-takeoff-summary[aria-expanded="true"] .manual-summary-chevron { transform: rotate(180deg); }

@container takeoff-list (max-width: 1120px) {
  .manual-takeoff-list-head { display: none; }
  .manual-takeoff-summary { display: flex; flex-wrap: wrap; gap: 5px 12px; }
  .manual-summary-cell { flex: 0 1 auto; max-width: 100%; overflow: visible; text-overflow: clip; white-space: normal; }
  .manual-summary-cell::before { content: attr(data-label) ': '; color: #64748b; font-weight: 600; }
  .manual-summary-index::before { display: none; }
  .manual-summary-chevron { margin-left: auto; }
}

.manual-element-details { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px 10px; border-top: 1px solid #e2e8f0; container: takeoff-details / inline-size; min-width: 0; width: 100%; box-sizing: border-box; }
.manual-element-details[hidden] { display: none; }

.manual-element-quick-fields {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
  min-width: 0;
}

.manual-element-quick-fields .manual-takeoff-trace,
.manual-element-quick-fields .manual-row-dims-strip { display: contents; }
.manual-element-quick-fields .manual-takeoff-trace label { flex: 1 1 135px; min-width: 105px; }
.manual-element-quick-fields .manual-col-dim { flex: 1 1 90px; width: auto; min-width: 74px; }
.manual-element-quick-fields .manual-col-nos { flex: .8 1 75px; width: auto; min-width: 72px; }
.manual-element-quick-fields .manual-col-rmc { flex: 1 1 125px; width: auto; min-width: 120px; }
.manual-element-quick-fields .manual-col-unit-vol { flex: 0 0 auto; margin-left: 0; }
.manual-element-quick-fields .manual-input { height: 32px; min-width: 0; }
.manual-element-details .manual-respective-total { margin-top: 2px; padding: 6px 10px; gap: 8px; }

/* Top Row: Category, Dimensions, Units (Nos), RMC Grade, Actions */
.manual-row-header-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding-bottom: 6px;
  border-bottom: 1px solid #f1f5f9;
}

.manual-row-header-left {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  flex: 1;
}

.manual-row-main-grid {
  display: flex;
  align-items: flex-end;
  gap: 7px;
  flex-wrap: wrap;
}

.manual-col-index {
  display: flex;
  align-items: center;
  padding-bottom: 2px;
}

.manual-row-num {
  background: #2563eb;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 5px;
}

.manual-col-cat {
  width: 190px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.manual-col-dim {
  width: 110px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.manual-col-nos {
  width: 100px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.manual-col-name {
  width: 140px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.manual-input-bold {
  font-weight: 700;
  color: #1e293b;
}

.manual-col-rmc {
  width: 145px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.manual-col-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

/* Dimensions & Concrete Strip */
.manual-row-dims-strip {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  padding: 8px 0 2px 0;
}

.manual-col-unit-vol {
  margin-left: auto;
  align-self: flex-end;
  padding-bottom: 2px;
}

.manual-unit-vol-badge {
  display: inline-block;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #334155;
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  white-space: nowrap;
}

.manual-row-header-strip label,
.manual-row-dims-strip label,
.manual-row-main-grid label,
.manual-sub-header strong {
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.manual-input {
  padding: 5px 8px;
  font-size: 12px;
  color: #0f172a;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  background: #ffffff;
  outline: none;
  transition: border-color 0.15s ease;
  width: 100%;
  box-sizing: border-box;
}

.manual-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.manual-input-highlight {
  background-color: #f0fdf4;
  border-color: #86efac;
  font-weight: 700;
  color: #166534;
}

/* Multi-Table Steel Reinforcement Tables Grid (Rebars + Stirrups) */
.manual-element-steel-tables-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 2px;
  min-width: 0;
}

@container takeoff-details (max-width: 1200px) {
  .manual-element-steel-tables-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.manual-steel-sub-panel {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 7px 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  box-sizing: border-box;
}

.manual-steel-sub-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 4px;
  flex-wrap: wrap;
  gap: 6px;
}

.manual-steel-sub-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #1e293b;
  font-weight: 700;
}

.manual-sub-badge {
  font-size: 11px;
  font-weight: 700;
  background: #e0f2fe;
  color: #0369a1;
  padding: 2px 7px;
  border-radius: 4px;
}

.manual-steel-items-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-x: auto;
  min-width: 0;
}

.manual-steel-columns {
  display: grid;
  align-items: center;
  gap: 4px;
  padding: 0 4px 3px;
  border-bottom: 1px solid #dbe3ee;
  color: #475569;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.25;
}

.manual-steel-columns > span {
  display: block;
}

.manual-steel-item-row {
  display: grid;
  align-items: center;
  gap: 4px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 3px 4px;
  transition: border-color 0.15s ease;
  min-width: 0;
  box-sizing: border-box;
}

.manual-rebar-items .manual-steel-columns,
.manual-rebar-items .manual-steel-item-row {
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, .9fr) minmax(0, 1.2fr) minmax(70px, .85fr) 22px;
}

.manual-stirrup-items .manual-steel-columns,
.manual-stirrup-items .manual-steel-item-row {
  grid-template-columns: minmax(0, 1.4fr) minmax(0, .7fr) minmax(0, 1fr) minmax(0, .8fr) minmax(0, .8fr) minmax(86px, .8fr) minmax(66px, .7fr) 22px;
}

.manual-steel-columns > *,
.manual-steel-item-row > * {
  width: auto;
  min-width: 0;
}

.manual-steel-item-row .manual-input-xs,
.manual-steel-item-row .manual-input-with-tag { width: 100%; min-width: 0; box-sizing: border-box; }
.manual-steel-item-row .manual-input-xs { height: 30px; }

@container takeoff-details (max-width: 760px) {
  .manual-steel-columns { display: none; }
  .manual-rebar-items .manual-steel-item-row,
  .manual-stirrup-items .manual-steel-item-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 10px; }
  .manual-steel-item-row > div:not(.manual-steel-cell-del) { display: grid; align-content: start; gap: 3px; text-align: left; }
  .manual-steel-item-row > div:not(.manual-steel-cell-del)::before { color: #64748b; font-size: 10px; font-weight: 700; }
  .manual-rebar-items .manual-steel-cell-label::before { content: "Bar position"; }
  .manual-rebar-items .manual-steel-cell-dia::before { content: "Dia (mm)"; }
  .manual-rebar-items .manual-steel-cell-count::before { content: "Bars (Nos)"; }
  .manual-rebar-items .manual-steel-cell-len::before { content: "Cut length"; }
  .manual-rebar-items .manual-steel-cell-badge::before { content: "Steel (kg)"; }
  .manual-stirrup-items .manual-steel-cell-label::before { content: "Zone / ring"; }
  .manual-stirrup-items .manual-steel-cell-dia::before { content: "Dia (mm)"; }
  .manual-stirrup-items .manual-steel-cell-zone::before { content: "Zone length"; }
  .manual-stirrup-items .manual-steel-cell-len::before { content: "Cut length"; }
  .manual-stirrup-items .manual-steel-cell-spacing::before { content: "Spacing (in)"; }
  .manual-stirrup-items .manual-steel-cell-count::before { content: "Count (Nos)"; }
  .manual-stirrup-items .manual-steel-cell-badge::before { content: "Steel (kg)"; }
  .manual-steel-item-row .manual-steel-cell-del { justify-content: flex-end; align-items: end; }
}

@container takeoff-details (max-width: 480px) {
  .manual-rebar-items .manual-steel-item-row,
  .manual-stirrup-items .manual-steel-item-row { grid-template-columns: minmax(0, 1fr); }
}

.manual-steel-item-row:hover {
  border-color: #cbd5e1;
}

.manual-steel-cell-label {
  flex: 2;
  min-width: 120px;
}
.manual-steel-cell-label .manual-input-xs {
  width: 100%;
}

.manual-steel-cell-dia {
  width: 76px;
}
.manual-steel-cell-dia .manual-input-xs {
  width: 100%;
}

.manual-steel-cell-count {
  width: 90px;
}
.manual-steel-cell-count .manual-input-xs {
  width: 100%;
  text-align: center;
}
.manual-steel-cell-count .manual-input-with-tag .manual-input-xs {
  text-align: left;
  padding-left: 8px;
  padding-right: 34px !important;
  box-sizing: border-box;
}

.manual-steel-cell-len {
  width: 82px;
}
.manual-steel-cell-len .manual-input-xs {
  width: 100%;
}
.manual-total-cut-length { display: block; min-height: 12px; margin-top: 2px; color: #475569; font-size: 10px; white-space: nowrap; }

.manual-steel-cell-spacing {
  width: 78px;
}
.manual-steel-cell-spacing .manual-input-xs {
  width: 100%;
  text-align: center;
}

.manual-steel-cell-badge {
  width: 68px;
  text-align: right;
}

.manual-row-kg-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: #0f766e;
  background: #f0fdfa;
  border: 1px solid #ccfbf1;
  padding: 2px 5px;
  border-radius: 4px;
  white-space: nowrap;
}

.manual-steel-cell-del {
  width: 22px;
  display: flex;
  justify-content: center;
}

.manual-btn-del-mini {
  background: transparent;
  border: none;
  color: #ef4444;
  cursor: pointer;
  font-size: 12px;
  padding: 2px 4px;
  border-radius: 4px;
  line-height: 1;
  transition: all 0.15s ease;
}

.manual-btn-del-mini:hover {
  background: #fee2e2;
  color: #b91c1c;
}

.manual-input-with-tag {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.manual-auto-tag {
  position: absolute;
  right: 4px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  color: #15803d;
  background: #dcfce7;
  padding: 1px 4px;
  border-radius: 3px;
  pointer-events: none;
  letter-spacing: 0.3px;
  line-height: 1.2;
}

.manual-override-tag {
  position: absolute;
  right: 4px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  color: #b45309;
  background: #fef3c7;
  padding: 1px 4px;
  border-radius: 3px;
  pointer-events: none;
  letter-spacing: 0.3px;
  line-height: 1.2;
}

.manual-override-input {
  border-color: #f59e0b !important;
  background-color: #fffbeb !important;
  color: #92400e !important;
  font-weight: 700;
}

/* Bottom Row: Steel Rebars, Stirrups, and Live Multiplied Result Pill */
.manual-row-sub-grid {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #f8fafc;
  border: 1px solid #f1f5f9;
  border-radius: 7px;
  padding: 6px 12px;
  flex-wrap: wrap;
}

.manual-sub-steel-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.manual-sub-header {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  color: #334155;
}

.manual-sub-inputs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.manual-mini-field {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: #475569;
}

.manual-input-xs {
  padding: 3px 6px;
  font-size: 11px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  background: #ffffff;
  width: 65px;
  box-sizing: border-box;
}

.manual-input-xs:focus {
  border-color: #2563eb;
  outline: none;
}

/* Result Strip on the Right */
.manual-sub-result-pill,
.manual-respective-total {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 8px 14px;
  border-radius: 7px;
  font-size: 12px;
  color: #334155;
  flex-wrap: wrap;
  width: 100%;
  box-sizing: border-box;
}

.manual-sub-result-pill .res-tag,
.manual-resp-label {
  font-weight: 700;
  color: #1e40af;
  white-space: nowrap;
}

.manual-sub-result-pill .res-vals,
.manual-resp-vals {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.manual-sub-result-pill .res-vals span,
.manual-resp-vals span {
  color: #64748b;
  white-space: nowrap;
}

.manual-sub-result-pill .res-vals span strong,
.manual-resp-vals strong {
  color: #0f172a;
}

/* 6. Drawing Reference Drawer */
.manual-drawing-drawer {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px 18px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.manual-drawing-drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.manual-preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #f1f5f9;
  padding: 6px 12px;
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 12px;
}

.manual-preview-toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #334155;
  font-weight: 600;
}

.manual-preview-toolbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.manual-preview-canvas-wrap {
  position: relative;
  width: 100%;
  height: 380px;
  background: #0a0f1d;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #1e293b;
  display: flex;
  align-items: center;
  justify-content: center;
}

.manual-preview-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.manual-drawing-preview-img {
  max-width: 100%;
  max-height: 420px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  object-fit: contain;
  background: #0f172a;
}

/* 7. Modals */
.manual-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 16px;
}

.manual-modal-card {
  background: #ffffff;
  border-radius: 12px;
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.15);
  overflow: hidden;
}

.manual-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.manual-modal-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
}

.manual-modal-body {
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.manual-modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
}

/* ==========================================================================
   Structural Schedules Master & Drawing Presets Styles
   ========================================================================== */

.manual-schedules-modal-card {
  width: min(1360px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100dvh - 32px);
  min-height: 0;
}

.manual-sch-modal-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 12px 16px;
  overflow-y: auto;
}

/* Schedule Tab Bar */
.manual-sch-tab-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  background: #f1f5f9;
  padding: 6px 12px;
  border-bottom: 1px solid #e2e8f0;
  gap: 4px;
  flex: 0 0 auto;
}

.manual-sch-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  font-size: 11.5px;
  font-weight: 600;
  color: #64748b;
  background: transparent;
  border: none;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.manual-sch-tab-btn:hover {
  background: #e2e8f0;
  color: #1e293b;
}

.manual-sch-tab-btn.active {
  background: #ffffff;
  color: #2563eb;
  font-weight: 700;
  box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.03);
}

.manual-sch-tab-count {
  background: #e2e8f0;
  color: #475569;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 10px;
}

.manual-sch-tab-btn.active .manual-sch-tab-count {
  background: #eff6ff;
  color: #2563eb;
  font-weight: 700;
}

/* Header Strip & Filters */
.manual-sch-header-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  background: #f8fafc;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  margin-bottom: 12px;
}

.manual-sch-filter-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.manual-filter-pill {
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 20px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s ease;
}

.manual-filter-pill:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.manual-filter-pill.active {
  background: #2563eb;
  color: #ffffff;
  border-color: #1d4ed8;
}

/* Schedule Table */
.manual-sch-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #ffffff;
}

.manual-sch-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  text-align: left;
}

.manual-sch-table th {
  background: #f8fafc;
  padding: 9px 12px;
  font-weight: 700;
  color: #475569;
  border-bottom: 1px solid #e2e8f0;
  text-transform: uppercase;
  font-size: 10.5px;
  letter-spacing: 0.3px;
}

.manual-sch-table td {
  padding: 9px 12px;
  border-bottom: 1px solid #f1f5f9;
  color: #1e293b;
  vertical-align: middle;
}

.manual-sch-table tr:last-child td {
  border-bottom: none;
}

.manual-sch-table tr:hover {
  background: #f8fafc;
}

.manual-sch-table tr.sch-row-terminated {
  background: #fff1f2;
  opacity: 0.85;
}

.manual-sch-table tr.sch-row-terminated td {
  color: #9f1239;
}

/* Badges */
.manual-rebar-pill {
  display: inline-block;
  background: #f5f3ff;
  color: #6d28d9;
  border: 1px solid #ddd6fe;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
}

.manual-rmc-badge {
  display: inline-block;
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}

.manual-floor-badge {
  display: inline-block;
  background: #f1f5f9;
  color: #334155;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
}

.manual-status-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
}

.manual-status-badge.badge-active {
  background: #dcfce7;
  color: #166534;
}

.manual-status-badge.badge-term {
  background: #fee2e2;
  color: #991b1b;
}

/* Preset Picker in Element Row */
.manual-col-preset {
  flex: 1.6;
  min-width: 180px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.manual-preset-select {
  border-color: #93c5fd;
  background-color: #f8faff;
  font-weight: 600;
  color: #1e40af;
}

.manual-preset-select:focus {
  border-color: #2563eb;
  background-color: #ffffff;
}

.manual-row-sch-pill {
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 4px;
  margin-left: 4px;
}

/* Schedule Inline Editor Card */
.manual-sch-editor-card {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 12px 14px;
  min-width: 0;
}

.manual-sch-editor-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px 12px;
}

.manual-sch-editor-grid-single-row {
  grid-template-columns: repeat(var(--sch-basic-fields), minmax(0, 1fr));
}

.manual-sch-editor-grid .manual-input { width: 100%; min-width: 0; box-sizing: border-box; }

.manual-form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.manual-form-group label {
  font-size: 11px;
  font-weight: 600;
  color: #475569;
  text-transform: uppercase;
}

/* Schedule Editor Sub-Sections (Multiple Rebar Rows & Stirrup Zones) */
.manual-sch-sub-panel {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 10px;
}

.manual-sch-sub-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 7px;
  flex-wrap: wrap;
  gap: 8px;
}

.manual-sch-sub-head strong { color: #0f172a; font-size: 12.5px; }
.manual-sch-sub-head span { color: #64748b; font-size: 11px; }

.manual-sch-input-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 11px;
}

.manual-sch-input-table th {
  padding: 5px 6px;
  text-align: left;
  color: #475569;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  font-weight: 700;
}

.manual-sch-input-table td {
  padding: 5px 6px;
  border-bottom: 1px solid #edf2f7;
  vertical-align: middle;
}

.manual-sch-input-table tr:last-child td { border-bottom: 0; }
.manual-sch-input-table .manual-input-xs { width: 100%; min-width: 0; height: 31px; box-sizing: border-box; font-size: 11.5px; }
.manual-sch-rebar-table th:nth-child(1) { width: 38%; }
.manual-sch-rebar-table th:nth-child(2) { width: 12%; }
.manual-sch-rebar-table th:nth-child(3) { width: 10%; }
.manual-sch-rebar-table th:nth-child(4) { width: 28%; }
.manual-sch-rebar-table th:nth-child(5) { width: 12%; }
.manual-sch-stirrup-table th:nth-child(1) { width: 23%; }
.manual-sch-stirrup-table th:nth-child(2) { width: 9%; }
.manual-sch-stirrup-table th:nth-child(3) { width: 12%; }
.manual-sch-stirrup-table th:nth-child(4) { width: 19%; }
.manual-sch-stirrup-table th:nth-child(5) { width: 10%; }
.manual-sch-stirrup-table th:nth-child(6) { width: 17%; }
.manual-sch-stirrup-table th:nth-child(7) { width: 10%; }

.manual-sch-row-actions { display: flex; align-items: center; gap: 5px; }
.manual-sch-row-add, .manual-sch-row-actions .manual-btn-del-mini {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 5px;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}
.manual-sch-row-add { border: 1px solid #93c5fd; background: #eff6ff; color: #1d4ed8; font-weight: 700; }
.manual-sch-row-add:hover { background: #dbeafe; }

.manual-sch-editor-actions {
  position: sticky;
  bottom: -12px;
  z-index: 2;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: 12px -14px -12px;
  padding: 9px 14px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
}

@media (max-width: 1200px) {
  .manual-sch-editor-grid-single-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 1000px) {
  .manual-sch-editor-grid, .manual-sch-editor-grid-single-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .manual-sch-input-table thead { display: none; }
  .manual-sch-input-table, .manual-sch-input-table tbody { display: block; }
  .manual-sch-input-table tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; padding: 8px 0; border-bottom: 1px solid #e2e8f0; }
  .manual-sch-input-table td { display: grid; gap: 3px; padding: 0; border: 0; min-width: 0; }
  .manual-sch-input-table td::before { content: attr(data-label); color: #64748b; font-size: 10px; font-weight: 700; }
  .manual-sch-input-table td:last-child { grid-column: 1 / -1; }
}

@media (max-width: 600px) {
  .manual-modal-overlay { padding: 8px; }
  .manual-schedules-modal-card { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
  .manual-sch-editor-grid, .manual-sch-editor-grid-single-row, .manual-sch-input-table tr { grid-template-columns: 1fr; }
  .manual-sch-modal-body { padding: 8px; }
  .manual-sch-editor-card { padding: 10px; }
}

.manual-sch-items-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.manual-sch-item-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: #f8fafc;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid #edf2f7;
  flex-wrap: wrap;
}

.manual-sch-tab-del-icon {
  margin-left: 4px;
  font-size: 14px;
  color: #94a3b8;
  padding: 0 4px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.manual-sch-tab-del-icon:hover {
  color: #ef4444;
  background: #fee2e2;
}

.manual-unsaved-overlay {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(15, 23, 42, .52);
}

.manual-unsaved-dialog {
  position: relative;
  width: min(100%, 440px);
  padding: 22px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 20px 48px rgba(15, 23, 42, .2);
  color: #0f172a;
}

.manual-unsaved-dialog h3 { margin: 0 0 8px; font-size: 18px; }
.manual-unsaved-dialog p { margin: 0 0 18px; color: #475569; line-height: 1.5; }
.manual-unsaved-close { position: absolute; top: 10px; right: 12px; border: 0; background: transparent; color: #475569; font-size: 24px; cursor: pointer; }
.manual-unsaved-close:hover { color: #0f172a; }
.manual-unsaved-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.manual-unsaved-actions .manual-btn { color: #0f172a; }
.manual-unsaved-actions .manual-btn-success { color: #fff; }


/* ─── KPI Cards — Clickable ────────────────────────────────────────────────── */
.manual-kpi-card[data-action] {
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  position: relative;
}
.manual-kpi-card[data-action]:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.10);
}
.manual-kpi-card[data-action]:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

.kpi-click-hint {
  display: block;
  margin-top: 6px;
  font-size: 10px;
  color: #94a3b8;
  letter-spacing: 0.03em;
  opacity: 0.8;
}
.manual-kpi-card[data-action]:hover .kpi-click-hint {
  color: #3b82f6;
  opacity: 1;
}

/* ─── KPI Detail Overlay ───────────────────────────────────────────────────── */
.kpi-detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 15000;
  background: rgba(15, 23, 42, 0.45);
  display: grid;
  place-items: center;
  padding: 16px;
  animation: kpiOverlayIn 0.18s ease;
}
@keyframes kpiOverlayIn { from { opacity: 0; } to { opacity: 1; } }

.kpi-detail-modal {
  width: min(100%, 760px);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
  overflow: hidden;
  animation: kpiModalIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes kpiModalIn { from { transform: scale(0.95) translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Header */
.kpi-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
}
.kpi-detail-header-left {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.kpi-detail-icon {
  font-size: 26px;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 2px;
}
.kpi-detail-title {
  margin: 0 0 2px;
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.3;
}
.kpi-detail-subtitle {
  margin: 0;
  font-size: 12px;
  color: #64748b;
}
.kpi-detail-header-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}
.kpi-detail-grand {
  text-align: right;
}
.kpi-detail-grand-label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
}
.kpi-detail-grand-val {
  display: block;
  font-size: 20px;
  font-weight: 800;
  line-height: 1.1;
}
.kpi-detail-close {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: #f1f5f9;
  color: #64748b;
  font-size: 13px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.15s;
  flex-shrink: 0;
}
.kpi-detail-close:hover { background: #e2e8f0; color: #0f172a; }

/* Body / Table */
.kpi-detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}
.kpi-detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.kpi-detail-table thead th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  color: #475569;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 8px 10px;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
}
.kpi-detail-table tbody td {
  padding: 9px 10px;
  vertical-align: top;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
}
.kpi-detail-row.even td { background: #fff; }
.kpi-detail-row.odd td { background: #fafafa; }
.kpi-detail-row:hover td { background: #f0f9ff; }

/* Column widths */
.kpi-col-sr  { width: 32px; text-align: center; color: #94a3b8; font-size: 11px; }
.kpi-col-name { min-width: 160px; }
.kpi-col-floor { width: 100px; font-size: 12px; color: #64748b; }
.kpi-col-qty { width: 70px; text-align: center; font-size: 12px; color: #64748b; }
.kpi-col-val { width: 160px; }
.kpi-col-pct { width: 100px; }

.kpi-el-mark {
  display: block;
  font-weight: 700;
  color: #0f172a;
  font-size: 13px;
}
.kpi-el-cat {
  display: block;
  font-size: 11px;
  color: #64748b;
  margin-top: 1px;
}
.kpi-val-main {
  display: inline;
  font-weight: 700;
  font-size: 14px;
  color: #0f172a;
}
.kpi-val-unit {
  margin-left: 2px;
  font-size: 11px;
  color: #64748b;
}
.kpi-val-sub {
  display: block;
  font-size: 11px;
  color: #94a3b8;
  margin-top: 1px;
}

/* Percentage bar */
.kpi-pct-bar-wrap {
  height: 4px;
  background: #f1f5f9;
  border-radius: 2px;
  margin-bottom: 3px;
  overflow: hidden;
}
.kpi-pct-bar {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s ease;
}
.kpi-pct-label {
  font-size: 11px;
  color: #64748b;
  font-weight: 600;
}

/* Detail pills */
.kpi-detail-split {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.kpi-detail-pill {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  background: #f1f5f9;
  color: #475569;
  margin-top: 3px;
}
.kpi-pill-rebar { background: #eff6ff; color: #2563eb; }
.kpi-pill-stirrup { background: #f5f3ff; color: #7c3aed; }

.kpi-detail-dia-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 4px;
}
.kpi-dia-tag {
  padding: 1px 5px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 600;
  background: #fef3c7;
  color: #92400e;
}

/* Footer */
.kpi-detail-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
  flex-shrink: 0;
  gap: 10px;
}
.kpi-detail-scale-note {
  font-size: 11px;
  color: #64748b;
}
.kpi-detail-close-btn {
  font-size: 12px;
  padding: 6px 16px;
}

/* Footer total row */
.kpi-detail-total-row td {
  background: #f8fafc !important;
  border-top: 2px solid #e2e8f0;
  font-weight: 700;
  padding: 10px;
}
.kpi-detail-total-label {
  color: #475569;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Empty state */
.kpi-detail-empty {
  text-align: center;
  padding: 40px 16px;
  color: #94a3b8;
  font-size: 14px;
}

/* ─── KPI Detail Summary Banners (Modern & Compact) ────────────────────────── */
.kpi-summary-banner {
  padding: 14px 18px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.kpi-summary-banner-title {
  font-size: 13px;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 10px;
}

/* Steel Diameter Summary Header & Splits */
.kpi-dia-summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.kpi-dia-summary-title {
  font-size: 13px;
  font-weight: 700;
  color: #1e293b;
}

.kpi-dia-summary-splits {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* Steel Diameter Cards Grid */
.kpi-dia-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px;
}

.kpi-dia-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.kpi-dia-card-label {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.kpi-dia-card-kg {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.2;
}

.kpi-dia-card-unit {
  font-size: 11px;
  font-weight: 500;
  color: #64748b;
}

.kpi-dia-card-mt {
  font-size: 11px;
  color: #64748b;
}

.kpi-dia-card-bar-wrap {
  width: 100%;
  height: 4px;
  background: #f1f5f9;
  border-radius: 2px;
  margin-top: 4px;
  overflow: hidden;
}

.kpi-dia-card-bar {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s ease;
}

.kpi-dia-card-pct {
  font-size: 10px;
  color: #64748b;
  font-weight: 600;
  align-self: flex-end;
  margin-top: 1px;
}

/* KPI Summary Stat Row (3 mini cards) */
.kpi-stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.kpi-stat-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.kpi-stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
}

.kpi-stat-val {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.2;
}

.kpi-stat-unit {
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
}

.kpi-stat-sub {
  font-size: 11px;
  color: #94a3b8;
}

/* Breakdown section (bars) */
.kpi-bdown-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 14px;
}

.kpi-bdown-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kpi-bdown-col-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #475569;
  margin-bottom: 2px;
}

.kpi-bdown-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.kpi-bdown-label {
  min-width: 90px;
  font-weight: 600;
  color: #334155;
  white-space: nowrap;
}

.kpi-bdown-bar-wrap {
  flex: 1;
  height: 6px;
  background: #f1f5f9;
  border-radius: 3px;
  overflow: hidden;
}

.kpi-bdown-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}

.kpi-bdown-val {
  font-weight: 600;
  color: #0f172a;
  min-width: 60px;
  text-align: right;
  white-space: nowrap;
}

.kpi-bdown-pct {
  min-width: 42px;
  text-align: right;
  color: #64748b;
  font-weight: 500;
  font-size: 11px;
}

.kpi-bdown-empty {
  font-size: 12px;
  color: #94a3b8;
}

/* Info note below stats */
.kpi-info-note {
  margin-top: 8px;
  padding: 6px 10px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  font-size: 11px;
  color: #1e40af;
  line-height: 1.4;
}

/* Section label before the table */
.kpi-table-section-label {
  padding: 10px 18px 6px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #475569;
  background: #ffffff;
}

.kpi-empty-hint {
  font-size: 12px;
  color: #94a3b8;
  padding: 6px 0;
}
