/* =============================================
   HPP CALCULATOR — MINIMALIST WORKSPACE v3
   Inspired by Notion, Linear, Raycast
   ============================================= */

/* === Google Fonts === */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;450;500;550;600;700&display=swap');

/* === Design Tokens === */
:root {
  /* Neutral grayscale */
  --white:       #ffffff;
  --gray-50:     #fafafa;
  --gray-100:    #f5f5f5;
  --gray-150:    #efefef;
  --gray-200:    #e8e8e8;
  --gray-300:    #d4d4d4;
  --gray-400:    #a3a3a3;
  --gray-500:    #737373;
  --gray-600:    #525252;
  --gray-700:    #404040;
  --gray-800:    #262626;
  --gray-900:    #171717;

  /* Accent — minimal */
  --accent:      #171717;        /* black */
  --accent-hover:#2d2d2d;
  --accent-soft: #f0f0f0;

  /* Semantic */
  --success:     #16a34a;
  --success-bg:  #f0fdf4;
  --danger:      #dc2626;
  --danger-bg:   #fef2f2;
  --warning:     #d97706;
  --warning-bg:  #fffbeb;
  --info:        #2563eb;
  --info-bg:     #eff6ff;

  /* Category colors — muted */
  --cat-produksi: #ea580c;
  --cat-manpower: #7c3aed;
  --cat-variabel: #2563eb;
  --cat-tetap:    #dc2626;

  /* Spacing (8px grid) */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;

  /* Radii */
  --r-sm:  6px;
  --r-md:  8px;
  --r-lg:  12px;
  --r-xl:  16px;

  /* Borders */
  --border:       1px solid var(--gray-200);
  --border-hover: 1px solid var(--gray-300);

  /* Shadows — very subtle */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.1);

  /* Typography */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --fw-normal: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;

  /* Layout */
  --sidebar-w: 320px;
  --topbar-h:  52px;
  --transition: 0.12s ease;
}

/* === Reset === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--white);
  color: var(--gray-800);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input, select, textarea {
  font-family: var(--font);
}

/* =============================================
   APP SHELL — Sidebar + Content layout
   ============================================= */
.app-shell {
  display: flex;
  min-height: 100vh;
  background: var(--white);
}

/* =============================================
   SIDEBAR
   ============================================= */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--gray-50);
  border-right: var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  overflow: hidden;
}

/* Sidebar Header */
.sidebar-header {
  padding: var(--space-4) var(--space-4) var(--space-3);
  border-bottom: var(--border);
  flex-shrink: 0;
}

.workspace-brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-2);
  border-radius: var(--r-md);
  cursor: default;
  transition: background var(--transition);
}

.workspace-brand:hover { background: var(--gray-150); }

.workspace-icon {
  width: 28px;
  height: 28px;
  background: var(--gray-900);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.workspace-name {
  font-size: 13px;
  font-weight: var(--fw-semibold);
  color: var(--gray-900);
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.workspace-sub {
  font-size: 11px;
  color: var(--gray-500);
  line-height: 1.2;
}

/* Sidebar Sections */
.sidebar-section {
  padding: var(--space-4) var(--space-3) var(--space-2);
}

.sidebar-section-label {
  font-size: 11px;
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--gray-400);
  padding: 0 var(--space-2);
  margin-bottom: var(--space-2);
}

/* Sidebar Nav Items */
.sidebar-nav {
  padding: 0 var(--space-3);
  flex: 1;
  overflow-y: auto;
}

.sidebar-nav::-webkit-scrollbar { display: none; }

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px var(--space-2);
  border-radius: var(--r-md);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: var(--fw-medium);
  color: var(--gray-600);
  transition: all var(--transition);
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  text-decoration: none;
  user-select: none;
  margin-bottom: 1px;
}

.nav-item:hover {
  background: var(--gray-150);
  color: var(--gray-900);
}

.nav-item.active {
  background: var(--gray-200);
  color: var(--gray-900);
  font-weight: var(--fw-semibold);
}

.nav-item-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  opacity: 0.65;
}

.nav-item.active .nav-item-icon { opacity: 1; }

.nav-item-label { flex: 1; }

.nav-item-badge {
  font-size: 10px;
  font-weight: var(--fw-semibold);
  background: var(--gray-200);
  color: var(--gray-500);
  padding: 1px 5px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

/* Sidebar divider */
.sidebar-divider {
  height: 1px;
  background: var(--gray-200);
  margin: var(--space-2) var(--space-3);
}

/* Sidebar Footer (HPP Summary) */
.sidebar-summary {
  border-top: var(--border);
  padding: var(--space-4);
  flex-shrink: 0;
}

.sidebar-summary-title {
  font-size: 10px;
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-400);
  margin-bottom: var(--space-3);
}

.sidebar-stat {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 4px 0;
}

.sidebar-stat-label {
  font-size: 12px;
  color: var(--gray-500);
}

.sidebar-stat-value {
  font-size: 12px;
  font-weight: var(--fw-semibold);
  color: var(--gray-800);
  font-variant-numeric: tabular-nums;
}

.sidebar-stat-value.primary { color: var(--gray-900); font-size: 13px; }
.sidebar-stat-value.positive { color: var(--success); }
.sidebar-stat-value.negative { color: var(--danger); }

/* =============================================
   MAIN AREA
   ============================================= */
.main-area {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* =============================================
   TOPBAR
   ============================================= */
.topbar {
  height: var(--topbar-h);
  border-bottom: var(--border);
  background: var(--white);
  display: flex;
  align-items: center;
  padding: 0 var(--space-6);
  gap: var(--space-3);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: 13px;
  color: var(--gray-500);
  flex: 1;
}

.topbar-breadcrumb span { color: var(--gray-800); font-weight: var(--fw-medium); }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* =============================================
   PAGE HEADER (inside content)
   ============================================= */
.page-header {
  padding: var(--space-8) var(--space-8) var(--space-6);
  border-bottom: var(--border);
}

.page-eyebrow {
  font-size: 11px;
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-400);
  margin-bottom: var(--space-2);
}

.page-title {
  font-size: 26px;
  font-weight: var(--fw-bold);
  color: var(--gray-900);
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: var(--space-2);
}

.page-description {
  font-size: 13.5px;
  color: var(--gray-500);
  line-height: 1.5;
}

/* =============================================
   CONTENT AREA
   ============================================= */
.page-content {
  flex: 1;
  padding: var(--space-6) var(--space-8);
  width: 100%;
  max-width: none;
  box-sizing: border-box;
  min-width: 0;
}

/* =============================================
   TAB PANELS
   ============================================= */
.tab-panel { display: none !important; }
@keyframes slideUpFade {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.tab-panel.active {
  display: block !important;
  animation: slideUpFade 200ms ease-out forwards;
}

/* =============================================
   SECTION
   ============================================= */
.ws-section { margin-bottom: var(--space-8); }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.section-title {
  font-size: 13px;
  font-weight: var(--fw-semibold);
  color: var(--gray-800);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.section-meta {
  font-size: 12px;
  color: var(--gray-400);
}

/* Category indicator dot */
.cat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.cat-dot-orange { background: var(--cat-produksi); }
.cat-dot-purple { background: var(--cat-manpower); }
.cat-dot-blue   { background: var(--cat-variabel); }
.cat-dot-red    { background: var(--cat-tetap); }

/* =============================================
   TABLE (Notion/Airtable style)
   ============================================= */
.ws-table {
  width: 100%;
  border: var(--border);
  border-radius: var(--r-lg);
  overflow: auto;
  background: var(--white);
}

.ws-table-head {
  display: grid;
  grid-template-columns: 1.5fr 80px 160px 2.5fr 32px;
  background: var(--gray-50);
  border-bottom: var(--border);
  padding: 0 var(--space-4);
  min-width: 800px;
  gap: var(--space-4);
}

.ws-table-head.head-tetap {
  grid-template-columns: 24px 24px 1.5fr 1.5fr 130px 1.2fr 120px 32px;
  gap: var(--space-4);
}

.ws-th {
  padding: var(--space-2) var(--space-2);
  font-size: 11px;
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--gray-400);
  white-space: nowrap;
}

.ws-table-body { min-width: 800px; }

.ws-row {
  display: grid;
  grid-template-columns: 1.5fr 80px 160px 2.5fr 32px;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-2) var(--space-4);
  border-bottom: var(--border);
  position: relative;
  transition: background var(--transition);
}

.ws-row.row-tetap {
  grid-template-columns: 24px 24px 1.5fr 1.5fr 130px 1.2fr 120px 32px;
  gap: var(--space-4);
}

.ws-table-head.head-draggable {
  grid-template-columns: 24px 1.5fr 80px 160px 2.5fr 32px;
  gap: var(--space-4);
}

.ws-row.row-draggable {
  grid-template-columns: 24px 1.5fr 80px 160px 2.5fr 32px;
  gap: var(--space-4);
}

.direct-cost-table {
  overflow-x: auto;
  overflow-y: visible;
  background: var(--white);
  border-color: var(--gray-100);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.04);
  -webkit-overflow-scrolling: touch;
}

.direct-cost-table .ws-table-head.head-draggable,
.direct-cost-table .ws-row.row-direct-cost {
  grid-template-columns: 18px minmax(230px, 1.35fr) 64px 124px 124px minmax(170px, 0.85fr) 36px;
  gap: 8px;
  min-width: 920px;
}

.direct-cost-table .ws-table-head.head-draggable {
  padding: 8px 12px;
  background: #fafbfc;
  border-bottom: 1px solid var(--gray-100);
}

.direct-cost-table .ws-th {
  padding: 0;
  color: var(--gray-500);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.055em;
}

.direct-cost-table .ws-row.row-direct-cost {
  align-items: center;
  padding: 7px 12px;
  background: var(--white);
  border-bottom: 0;
  border-radius: 10px;
  cursor: text;
  transition: background 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.direct-cost-table .items-container {
  display: grid;
  gap: 2px;
  padding: 5px 6px;
}

.direct-cost-table .items-container .ws-row.row-direct-cost:nth-child(even) {
  background: #fcfdff;
}

.direct-cost-table .ws-row.row-direct-cost:hover {
  background: #f8fbff;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.05);
}

.direct-cost-table .ws-row.row-direct-cost:focus-within {
  background: #f8fbff;
  box-shadow: 0 0 0 1px rgba(147, 197, 253, 0.55), 0 10px 24px rgba(15, 23, 42, 0.06);
}

.direct-cost-table .row-direct-cost .drag-handle {
  width: 18px;
  height: 34px;
  opacity: 0;
  color: var(--gray-300);
  transition: opacity 150ms ease, color 150ms ease;
}

.direct-cost-table .row-direct-cost:hover .drag-handle,
.direct-cost-table .row-direct-cost:focus-within .drag-handle {
  opacity: 1;
}

.direct-cost-table .row-direct-cost .drag-handle:hover {
  color: var(--gray-500);
}

.product-name-cell {
  position: relative;
  min-width: 0;
}

.product-name-input,
.product-description-input,
.direct-cost-table .row-direct-cost .item-qty,
.direct-cost-table .row-direct-cost .item-price {
  height: 34px;
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  font-size: 13px;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.product-name-input:hover,
.product-description-input:hover,
.direct-cost-table .row-direct-cost .item-qty:hover,
.direct-cost-table .row-direct-cost .item-price:hover {
  background: rgba(248, 250, 252, 0.9);
  border-color: var(--gray-150);
}

.product-description-input {
  color: var(--gray-500);
  padding: 0 8px;
  font-family: inherit;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-description-input::placeholder {
  color: var(--gray-350, #cbd5e1);
  font-weight: 600;
}

.product-name-input:focus,
.product-description-input:focus,
.direct-cost-table .row-direct-cost .item-qty:focus,
.direct-cost-table .row-direct-cost .item-price:focus {
  outline: none;
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.10);
  background: var(--white);
}

.direct-cost-table .row-direct-cost .item-qty,
.direct-cost-table .row-direct-cost .item-price {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.direct-cost-table .row-direct-cost .ws-input-prefix-wrapper {
  background: transparent;
}

.direct-cost-table .row-direct-cost .ws-input-prefix-wrapper:focus-within {
  z-index: 2;
}

.product-library-pill {
  display: none;
  align-items: center;
  gap: 5px;
  width: fit-content;
  margin-top: 5px;
  padding: 3px 8px;
  color: var(--gray-500);
  background: #f8fafc;
  border: 1px solid var(--gray-150);
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 750;
  cursor: pointer;
  transition: color 150ms ease, border-color 150ms ease, background 150ms ease;
}

.product-library-pill:hover {
  color: #2563eb;
  background: #eff6ff;
  border-color: #bfdbfe;
}

.direct-cost-table .row-direct-cost.library-local .product-library-pill {
  display: inline-flex;
}

.direct-cost-table .row-direct-cost.library-saved .product-library-pill {
  display: none;
}

.direct-cost-table .row-direct-cost .row-library-hover-card {
  display: none;
}

.sr-only-control {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.product-row-total {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  color: var(--gray-900);
  font-size: 13px;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.direct-cost-table .row-direct-cost .btn-remove {
  width: 30px;
  height: 30px;
  margin-top: 0;
  color: var(--gray-350, #cbd5e1);
  background: transparent;
  border: 1px solid transparent;
}

.direct-cost-table .row-direct-cost .btn-remove:hover {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: #fecaca;
}

.product-row-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  margin: 4px 6px 6px;
  background: #fafbfc;
  border: 1px solid var(--gray-100);
  border-radius: 12px;
}

.product-row-actions .btn-add-row {
  width: auto;
  border: 1px solid var(--gray-200);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 800;
  box-shadow: none;
}

.btn-add-row-secondary {
  color: var(--gray-600);
  background: var(--white);
}

.btn-add-row-secondary:hover {
  color: var(--gray-900);
  background: var(--gray-50);
}

.btn-add-row-primary {
  color: #1d4ed8;
  background: #eff6ff;
  border-color: #bfdbfe !important;
}

.btn-add-row-primary:hover {
  color: #1e40af;
  background: #dbeafe;
}

/* Drag and Drop classes */
.drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  color: var(--gray-400);
  width: 24px;
  height: 32px;
  user-select: none;
}
.drag-handle:active {
  cursor: grabbing;
  color: var(--gray-700);
}
.ws-row.dragging {
  opacity: 0.35;
  background: var(--gray-50);
  border: 1px dashed var(--gray-400);
}
.ws-row.is-dragging {
  transform: rotate(0.8deg) scale(1.015);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.08);
  border: 1px solid var(--primary) !important;
  background: white !important;
  z-index: 9999;
}
.category-group.group-dragging-active {
  transform: rotate(0.8deg) scale(1.015);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.08);
  border: 1px solid var(--primary) !important;
  background: white !important;
  z-index: 9999;
}

.ws-row:last-child { border-bottom: none; }
.ws-row:hover { background: var(--gray-50); }

/* Notes input inside rows */
.item-notes {
  font-size: 12px;
  color: var(--gray-500);
  padding: 4px 8px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  width: 100%;
  transition: border-color 0.15s, background 0.15s;
  font-family: inherit;
  resize: none;
  height: 32px;
  overflow: hidden;
  line-height: 1.4;
}
.item-notes:hover {
  border-color: var(--gray-200);
  background: var(--white);
}
.item-notes:focus {
  outline: none;
  border-color: var(--primary-light, #a5b4fc);
  background: var(--white);
  color: var(--gray-800);
}

.direct-cost-table .row-direct-cost .product-description-input {
  height: 30px;
  min-height: 30px;
  width: 100%;
  min-width: 0;
  padding: 0 8px;
  color: var(--gray-500);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  font-size: 13px;
  line-height: 1.4;
}

.direct-cost-table .row-direct-cost .product-description-input:hover {
  background: rgba(248, 250, 252, 0.9);
  border-color: var(--gray-150);
}

.direct-cost-table .row-direct-cost .product-description-input:focus {
  outline: none;
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.10);
  background: var(--white);
  color: var(--gray-800);
  min-width: 260px;
  z-index: 3;
}

/* Add row */
.btn-add-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-2) var(--space-4);
  border: none;
  background: transparent;
  color: var(--gray-400);
  font-size: 13px;
  font-weight: var(--fw-medium);
  cursor: pointer;
  transition: all var(--transition);
  border-top: var(--border);
  text-align: left;
}

.btn-add-row:hover {
  color: var(--gray-800);
  background: var(--gray-50);
}

/* Section total row */
.table-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) var(--space-4);
  background: var(--gray-50);
  border-top: 1px solid var(--gray-200);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}

.table-total-label {
  font-size: 12px;
  font-weight: var(--fw-semibold);
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.table-total-value {
  font-size: 14px;
  font-weight: var(--fw-bold);
  font-variant-numeric: tabular-nums;
  color: var(--gray-900);
}

/* =============================================
   FORM CONTROLS
   ============================================= */
.ws-input {
  width: 100%;
  padding: 5px 10px;
  border: var(--border);
  border-radius: var(--r-sm);
  font-family: var(--font);
  font-size: 13.5px;
  color: var(--gray-800);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
  appearance: none;
}

.ws-input:focus {
  outline: none;
  border-color: var(--gray-400);
  box-shadow: 0 0 0 3px rgba(0,0,0,0.06);
}

.ws-input::placeholder { color: var(--gray-300); }

.ws-input-prefix-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.ws-input-prefix-wrapper .ws-input { padding-left: 30px; }
.ws-input-prefix-wrapper .ws-input-suffix-right { padding-right: 36px; }

.ws-input-prefix {
  position: absolute;
  left: 10px;
  font-size: 12px;
  color: var(--gray-400);
  pointer-events: none;
  font-weight: var(--fw-medium);
}

.ws-input-suffix {
  position: absolute;
  right: 10px;
  font-size: 11px;
  color: var(--gray-400);
  pointer-events: none;
}

select.ws-input { cursor: pointer; }

/* Custom select wrapper for handling "Lainnya" inline custom inputs */
.custom-select-wrapper {
  display: flex;
  gap: var(--space-2);
  width: 100%;
  position: relative;
  align-items: flex-start;
}

.custom-select-wrapper .library-autocomplete {
  flex: 1;
  min-width: 120px;
}

.custom-select-wrapper .item-desc {
  flex: 1;
}

.custom-select-wrapper .item-desc-custom {
  flex: 1;
}

.library-name-stack {
  flex: 1;
  display: grid;
  gap: 4px;
  min-width: 0;
  position: relative;
}

.direct-cost-suggestions {
  position: absolute;
  z-index: 80;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 236px;
  overflow-y: auto;
  padding: 6px;
  background: var(--white);
  border: 1px solid var(--gray-150);
  border-radius: 12px;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.14);
}

.direct-cost-suggestion {
  width: 100%;
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--gray-800);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.direct-cost-suggestion:hover,
.direct-cost-suggestion.is-active {
  background: #eff6ff;
}

.direct-cost-suggestion-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
  font-weight: 750;
}

.direct-cost-suggestion-context {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--gray-400);
  font-size: 11px;
  font-weight: 600;
}

.library-name-controls {
  display: flex;
  gap: var(--space-2);
  min-width: 0;
}

.row-library-indicator {
  display: none;
}

.ws-row.library-saved .row-library-indicator {
  color: #16a34a;
}

.row-library-hover-card {
  position: absolute;
  left: 36px;
  top: calc(100% - 2px);
  z-index: 40;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 170ms ease-out, transform 170ms ease-out, visibility 170ms ease-out;
  pointer-events: none;
}

.ws-row.library-local:hover .row-library-hover-card,
.ws-row.library-local:focus-within .row-library-hover-card {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.ws-row.library-saved .row-library-hover-card {
  display: none;
}

.ws-row:not(.library-local) .row-library-hover-card,
.ws-row:not(.library-local) .row-overflow-item.save-row-library {
  display: none;
}

.row-library-add-action {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: min(360px, 70vw);
  padding: 9px 12px;
  color: var(--gray-700);
  background: var(--white);
  border: 1px solid var(--gray-150);
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.14);
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.row-library-add-action:hover {
  color: var(--gray-900);
  border-color: var(--gray-200);
}

.row-library-plus {
  color: #2563eb;
  font-size: 16px;
  font-weight: 900;
  line-height: 1;
}

.row-overflow {
  display: none;
  position: relative;
  flex: 0 0 auto;
}

.row-overflow-btn {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-400);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  cursor: pointer;
}

.row-overflow-btn:hover {
  color: var(--gray-700);
  background: var(--gray-100);
  border-color: var(--gray-150);
}

.row-overflow-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 50;
  min-width: 190px;
  padding: 6px;
  background: var(--white);
  border: var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.14);
}

.row-overflow-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 9px;
  color: var(--gray-700);
  background: transparent;
  border: 0;
  border-radius: var(--r-sm);
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.row-overflow-item:hover {
  background: var(--gray-50);
}

.ws-row.library-saved .row-overflow-item.save-row-library {
  display: none;
}

.directory-picker-modal {
  max-width: 760px;
  max-height: min(760px, 88vh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.directory-picker-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
}

.directory-picker-close {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-500);
  background: var(--gray-50);
  border: 1px solid var(--gray-150);
  border-radius: var(--r-md);
  cursor: pointer;
}

.directory-picker-close:hover {
  color: var(--gray-900);
  background: var(--gray-100);
}

.directory-picker-close svg {
  width: 16px;
  height: 16px;
}

.directory-picker-body {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.directory-picker-toolbar {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 10px;
}

.directory-picker-list {
  min-height: 260px;
  max-height: 420px;
  overflow: auto;
  display: grid;
  gap: 8px;
  padding: 2px;
}

.directory-picker-group-grid {
  display: grid;
  gap: 10px;
}

.directory-picker-group-card {
  width: 100%;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 18px;
  gap: 12px;
  align-items: center;
  padding: 14px;
  color: var(--gray-900);
  background: var(--white);
  border: 1px solid var(--gray-150);
  border-radius: 14px;
  text-align: left;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.directory-picker-group-card:hover {
  background: #fbfdff;
  border-color: #bfdbfe;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
}

.directory-picker-group-icon {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-50);
  border: 1px solid var(--gray-150);
  border-radius: 10px;
  color: var(--gray-600);
}

.directory-picker-group-icon svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
}

.directory-picker-group-main {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.directory-picker-group-main strong {
  overflow: hidden;
  color: var(--gray-900);
  font-size: 14px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.directory-picker-group-main small {
  color: var(--gray-500);
  font-size: 12px;
  font-weight: 650;
}

.directory-picker-group-card svg {
  width: 16px;
  height: 16px;
  color: var(--gray-400);
  justify-self: end;
}

.directory-picker-detail-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 2px 10px;
  background: var(--white);
}

.directory-picker-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  color: var(--gray-600);
  background: var(--gray-50);
  border: 1px solid var(--gray-150);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.directory-picker-back:hover {
  color: var(--gray-900);
  background: var(--gray-100);
}

.directory-picker-back svg {
  width: 14px;
  height: 14px;
}

.directory-picker-selected-group {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--gray-800);
  font-size: 13px;
  font-weight: 800;
}

.directory-picker-rate-list {
  display: grid;
  gap: 8px;
}

.directory-picker-rate-item {
  width: 100%;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  color: var(--gray-900);
  background: var(--white);
  border: 1px solid var(--gray-150);
  border-radius: 12px;
  text-align: left;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.directory-picker-rate-item:hover {
  background: #fbfdff;
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.08);
}

.directory-picker-radio {
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--gray-300);
  border-radius: 999px;
  background: var(--white);
}

.directory-picker-rate-item:hover .directory-picker-radio {
  border-color: var(--primary);
  box-shadow: inset 0 0 0 3px var(--white);
  background: var(--primary);
}

.directory-picker-item {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 11px 12px;
  background: var(--white);
  border: 1px solid var(--gray-150);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.directory-picker-item:hover {
  background: #fbfdff;
  border-color: #bfdbfe;
}

.directory-picker-item.is-selected {
  background: #eff6ff;
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.08);
}

.directory-picker-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--primary);
}

.directory-picker-main {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.directory-picker-main strong {
  color: var(--gray-900);
  font-size: 13px;
  font-weight: 800;
}

.directory-picker-main small,
.directory-picker-main span {
  color: var(--gray-500);
  font-size: 11px;
  line-height: 1.35;
}

.directory-picker-price {
  color: var(--gray-700);
  font-size: 13px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.directory-picker-empty {
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-400);
  background: var(--gray-50);
  border: 1px dashed var(--gray-200);
  border-radius: 12px;
  font-size: 13px;
}

.directory-picker-foot {
  justify-content: flex-end;
}

.ws-input[readonly] {
  background: var(--gray-50);
  color: var(--gray-500);
  cursor: default;
}

.item-qty.ws-input {
  text-align: center;
  padding-left: 8px !important;
  padding-right: 24px !important;
}

/* =============================================
   BUTTONS
   ============================================= */

/* Primary — black */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 6px 12px;
  border-radius: var(--r-md);
  font-family: var(--font);
  font-size: 13px;
  font-weight: var(--fw-medium);
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid transparent;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
}

.btn-primary {
  background: var(--gray-900);
  color: var(--white);
  border-color: var(--gray-900);
}
.btn-primary:hover {
  background: var(--gray-800);
  border-color: var(--gray-800);
}

.btn-secondary {
  background: var(--white);
  color: var(--gray-700);
  border-color: var(--gray-300);
}
.btn-secondary:hover {
  background: var(--gray-50);
  border-color: var(--gray-400);
  color: var(--gray-900);
}

.btn-ghost {
  background: transparent;
  color: var(--gray-500);
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--gray-100);
  color: var(--gray-800);
}

.btn-danger {
  background: var(--white);
  color: var(--danger);
  border-color: #fca5a5;
}
.btn-danger:hover {
  background: var(--danger-bg);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: var(--r-sm);
}

.btn-lg {
  padding: 8px 16px;
  font-size: 14px;
}

/* Remove row button */
.btn-remove {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--gray-300);
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}

.btn-remove:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

/* =============================================
   INFO BOXES
   ============================================= */
.info-box {
  padding: var(--space-4);
  background: var(--gray-50);
  border: var(--border);
  border-radius: var(--r-lg);
  font-size: 13px;
  color: var(--gray-600);
  line-height: 1.6;
}

.info-box.info-blue {
  background: var(--info-bg);
  border-color: #bfdbfe;
  color: #1e40af;
}

.info-box strong { color: var(--gray-800); }
.info-box.info-blue strong { color: #1d4ed8; }

.info-box-title {
  font-size: 12px;
  font-weight: var(--fw-semibold);
  margin-bottom: var(--space-1);
  color: var(--gray-700);
}

.info-example {
  margin-top: var(--space-2);
  font-size: 12px;
  color: var(--gray-500);
  font-style: italic;
  padding-left: var(--space-3);
  border-left: 2px solid var(--gray-200);
}

/* =============================================
   FORMULA HINT
   ============================================= */
.formula-banner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--gray-50);
  border: var(--border);
  border-radius: var(--r-lg);
  margin-bottom: var(--space-4);
}

.formula-banner-icon {
  width: 30px;
  height: 30px;
  background: var(--gray-900);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 13px;
  flex-shrink: 0;
}

.formula-banner-text {
  font-size: 12.5px;
  color: var(--gray-600);
  line-height: 1.5;
}

.formula-banner-text strong {
  display: block;
  font-size: 13px;
  color: var(--gray-800);
  margin-bottom: 1px;
}

/* Target input inline */
.inline-field {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--white);
  border-bottom: var(--border);
}

.inline-field-label {
  font-size: 13px;
  font-weight: var(--fw-medium);
  color: var(--gray-700);
  white-space: nowrap;
}

.inline-field-help {
  font-size: 12px;
  color: var(--gray-400);
  flex: 1;
}

.alokasi-result {
  font-size: 12.5px;
  font-weight: var(--fw-semibold);
  color: var(--success);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* =============================================
   STAT CARDS (horizontal)
   ============================================= */
.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.stat-card {
  padding: var(--space-4);
  background: var(--white);
  border: var(--border);
  border-radius: var(--r-lg);
  transition: box-shadow var(--transition);
}

.stat-card:hover { box-shadow: var(--shadow-sm); }

.stat-card-label {
  font-size: 11px;
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--gray-400);
  margin-bottom: var(--space-2);
}

.stat-card-value {
  font-size: 20px;
  font-weight: var(--fw-bold);
  color: var(--gray-900);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.stat-card-sub {
  font-size: 11px;
  color: var(--gray-400);
  margin-top: 4px;
}

/* =============================================
   BREAKDOWN SECTION
   ============================================= */
.breakdown-layout {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: var(--space-6);
  align-items: center;
}

.chart-wrap {
  width: 160px;
  height: 160px;
  position: relative;
}

.chart-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.chart-center-label {
  font-size: 10px;
  color: var(--gray-400);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chart-center-val {
  font-size: 13px;
  font-weight: var(--fw-bold);
  color: var(--gray-800);
}

.legend-list { display: flex; flex-direction: column; gap: var(--space-3); }

.legend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.legend-left {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 13px;
  color: var(--gray-600);
}

.legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

.legend-pct {
  font-size: 13px;
  font-weight: var(--fw-semibold);
  color: var(--gray-700);
  font-variant-numeric: tabular-nums;
}

/* =============================================
   MARGIN SECTION
   ============================================= */
.margin-switcher {
  display: flex;
  gap: 2px;
  background: var(--gray-100);
  padding: 2px;
  border-radius: var(--r-md);
  margin-bottom: var(--space-4);
}

.margin-tab {
  flex: 1;
  padding: 5px var(--space-3);
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  font-family: var(--font);
  font-size: 12.5px;
  font-weight: var(--fw-medium);
  color: var(--gray-500);
  cursor: pointer;
  transition: all var(--transition);
}

.margin-tab.active {
  background: var(--white);
  color: var(--gray-900);
  box-shadow: var(--shadow-xs);
}

.margin-tab-content { display: none; }
.margin-tab-content.active { display: block; }

/* Slider */
.ws-slider {
  width: 100%;
  height: 4px;
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.ws-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--gray-900);
  border: 2px solid var(--white);
  box-shadow: 0 0 0 1px var(--gray-300);
  cursor: pointer;
}

.slider-display {
  font-size: 12px;
  color: var(--gray-500);
  text-align: right;
  margin-top: var(--space-1);
  font-variant-numeric: tabular-nums;
}

/* Result box */
.result-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.result-item {
  padding: var(--space-4);
  background: var(--gray-50);
  border: var(--border);
  border-radius: var(--r-lg);
}

.result-item.primary-result {
  grid-column: 1 / -1;
  background: var(--gray-900);
  border-color: var(--gray-900);
}

.result-label {
  font-size: 11px;
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--gray-400);
  margin-bottom: var(--space-2);
}

.result-item.primary-result .result-label { color: rgba(255,255,255,0.5); }

.result-value {
  font-size: 18px;
  font-weight: var(--fw-bold);
  color: var(--gray-900);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.result-item.primary-result .result-value {
  font-size: 22px;
  color: var(--white);
}

/* Status badge */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: var(--fw-semibold);
  border: 1px solid;
  margin-top: var(--space-3);
}

.status-badge.status-low     { background: var(--danger-bg);  color: var(--danger);  border-color: #fca5a5; }
.status-badge.status-ok      { background: var(--success-bg); color: var(--success); border-color: #bbf7d0; }
.status-badge.status-premium { background: var(--warning-bg); color: var(--warning); border-color: #fde68a; }
.status-badge.status-neutral { background: var(--gray-100); color: var(--gray-500); border-color: var(--gray-200); }

/* Sidebar compact status badges */
.status-badge-sm {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid transparent;
}
.status-badge-sm.status-healthy {
  background-color: var(--success-bg);
  color: var(--success);
  border-color: #bbf7d0;
}
.status-badge-sm.status-thin {
  background-color: var(--warning-bg);
  color: var(--warning);
  border-color: #fde68a;
}
.status-badge-sm.status-loss {
  background-color: var(--danger-bg);
  color: var(--danger);
  border-color: #fca5a5;
}
.status-badge-sm.status-neutral-sm {
  background-color: var(--gray-100);
  color: var(--gray-500);
  border-color: var(--gray-200);
}

/* =============================================
   BEP SECTION
   ============================================= */
.toggle-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}

.toggle-wrap {
  position: relative;
  width: 32px;
  height: 18px;
  flex-shrink: 0;
}

.toggle-wrap input { opacity: 0; width: 0; height: 0; position: absolute; }

.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--gray-300);
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle-thumb {
  position: absolute;
  width: 14px;
  height: 14px;
  background: var(--white);
  border-radius: 50%;
  bottom: 2px;
  left: 2px;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  pointer-events: none;
}

.toggle-wrap input:checked ~ .toggle-track  { background: var(--gray-800); }
.toggle-wrap input:checked ~ .toggle-thumb  { transform: translateX(14px); }

.toggle-text {
  font-size: 12px;
  color: var(--gray-500);
  font-weight: var(--fw-medium);
}

.bep-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  margin: var(--space-4) 0;
}

.bep-card {
  padding: var(--space-4);
  border: var(--border);
  border-radius: var(--r-lg);
  background: var(--white);
}

.bep-card-label {
  font-size: 11px;
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--gray-400);
  margin-bottom: var(--space-2);
}

.bep-card-value {
  font-size: 20px;
  font-weight: var(--fw-bold);
  color: var(--gray-900);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.bep-card-sub {
  font-size: 11px;
  color: var(--gray-400);
  margin-top: 3px;
}

.step5-details {
  margin: 0 0 var(--space-4);
  border: var(--border);
  border-radius: var(--r-lg);
  background: var(--gray-50);
  overflow: hidden;
}

.step5-details summary {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 11px 14px;
  color: var(--gray-700);
  font-size: 12px;
  font-weight: var(--fw-semibold);
  cursor: pointer;
  list-style: none;
}

.step5-details summary::-webkit-details-marker { display: none; }
.step5-details summary svg { width: 14px; height: 14px; color: var(--gray-500); }
.step5-details[open] summary { border-bottom: var(--border); background: var(--white); }
.step5-sim-table { border: 0; border-radius: 0; }

.step5-target-profit {
  padding: 12px 14px;
  gap: 12px;
}

/* BEP input pulse */
.pulse-update { animation: pulseRing 0.4s ease; }

@keyframes pulseRing {
  0%   { box-shadow: 0 0 0 0 rgba(0,0,0,0.1); }
  70%  { box-shadow: 0 0 0 6px rgba(0,0,0,0); }
  100% { box-shadow: 0 0 0 0 rgba(0,0,0,0); }
}

/* BEP simulation table */
.sim-table-wrap {
  border: var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.sim-table-title {
  padding: var(--space-3) var(--space-4);
  font-size: 11px;
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--gray-400);
  background: var(--gray-50);
  border-bottom: var(--border);
}

.sim-table {
  width: 100%;
  border-collapse: collapse;
}

.sim-table th {
  padding: var(--space-2) var(--space-4);
  font-size: 11px;
  font-weight: var(--fw-semibold);
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--gray-50);
  border-bottom: var(--border);
  text-align: right;
}

.sim-table th:first-child { text-align: left; }

.sim-table td {
  padding: var(--space-2) var(--space-4);
  font-size: 13px;
  color: var(--gray-600);
  text-align: right;
  border-bottom: 1px solid var(--gray-100);
  font-variant-numeric: tabular-nums;
}

.sim-table td:first-child {
  text-align: left;
  color: var(--gray-400);
  font-size: 12px;
}

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

.sim-table .profit-row td {
  font-weight: var(--fw-semibold);
  background: var(--gray-50);
}

.sim-table td.positive { color: var(--success); }
.sim-table td.negative { color: var(--danger); }

/* Target profit */
.inline-calc {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--gray-50);
  border: var(--border);
  border-radius: var(--r-lg);
  margin-top: var(--space-4);
  flex-wrap: wrap;
}

.inline-calc-label {
  font-size: 13px;
  font-weight: var(--fw-medium);
  color: var(--gray-700);
  white-space: nowrap;
}

.inline-calc-result {
  font-size: 13px;
  color: var(--gray-500);
  white-space: nowrap;
}

.inline-calc-result strong { color: var(--gray-800); font-weight: var(--fw-semibold); }

/* =============================================
   ACCORDION
   ============================================= */
.accordion {
  border: var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.accordion-item { border-bottom: var(--border); }
.accordion-item:last-child { border-bottom: none; }

.accordion-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  background: var(--white);
  border: none;
  cursor: pointer;
  font-family: var(--font);
  font-size: 13px;
  font-weight: var(--fw-medium);
  color: var(--gray-700);
  text-align: left;
  transition: background var(--transition);
}

.accordion-trigger:hover { background: var(--gray-50); }

.accordion-trigger.open {
  color: var(--gray-900);
  background: var(--gray-50);
}

.accordion-icon {
  font-size: 11px;
  color: var(--gray-400);
  transition: transform 0.2s;
}

.accordion-trigger.open .accordion-icon { transform: rotate(180deg); }

.accordion-body {
  display: none;
  padding: var(--space-5);
  background: var(--white);
  border-top: var(--border);
}

.accordion-body.open { display: block; }

/* =============================================
   REPORT
   ============================================= */
.report-actions {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
}

.report-export-mode {
  display: grid;
  gap: 5px;
  min-width: 210px;
}

.report-export-mode > span {
  color: var(--gray-500);
  font-size: 11px;
  font-weight: var(--fw-semibold);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.report-panel {
  background: var(--white);
  border: var(--border);
  border-radius: var(--r-xl);
  overflow: hidden;
}

.report-header {
  padding: var(--space-6);
  border-bottom: var(--border);
}

.report-header h2 {
  font-size: 18px;
  font-weight: var(--fw-bold);
  color: var(--gray-900);
  letter-spacing: -0.02em;
  margin-bottom: 2px;
}

.report-header p {
  font-size: 12.5px;
  color: var(--gray-400);
}

.report-section {
  padding: var(--space-6);
  border-bottom: var(--border);
}

.report-section:last-child { border-bottom: none; }

.report-section-title {
  font-size: 11px;
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-400);
  margin-bottom: var(--space-4);
}

.report-appendix-section {
  padding: 0;
}

.report-accordion-trigger {
  width: 100%;
  min-height: 64px;
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  border: 0;
  background: transparent;
  color: var(--gray-800);
  text-align: left;
  cursor: pointer;
}

.report-accordion-trigger:hover {
  background: var(--gray-50);
}

.report-accordion-trigger:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.report-appendix-trigger {
  min-height: 76px;
  padding: var(--space-5) var(--space-6);
}

.report-accordion-heading {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.report-accordion-title {
  color: var(--gray-800);
  font-size: 13px;
  font-weight: var(--fw-semibold);
}

.report-appendix-trigger .report-accordion-title {
  font-size: 14px;
  font-weight: var(--fw-bold);
}

.report-accordion-meta {
  color: var(--gray-500);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.report-count {
  color: var(--gray-500);
  font-weight: var(--fw-medium);
}

.report-accordion-chevron {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  color: var(--gray-400);
  transition: transform 225ms ease;
}

.report-appendix-section.is-open > .report-appendix-trigger .report-accordion-chevron,
.report-drill-group.is-open > .report-accordion-trigger .report-accordion-chevron {
  transform: rotate(180deg);
}

.report-accordion-panel {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition: grid-template-rows 225ms ease, opacity 180ms ease;
}

.report-accordion-panel-inner {
  min-height: 0;
  overflow: hidden;
}

.report-appendix-section.is-open > .report-accordion-panel,
.report-drill-group.is-open > .report-accordion-panel {
  grid-template-rows: 1fr;
  opacity: 1;
}

#report-item-detail-section {
  padding: 0 var(--space-6) var(--space-6);
}

.report-drill-group {
  overflow: hidden;
  border: 1px solid var(--gray-200);
  border-radius: var(--r-lg);
  background: var(--white);
}

.report-drill-group + .report-drill-group {
  margin-top: var(--space-2);
}

.report-drill-level-2 {
  margin: 0 var(--space-3) var(--space-2);
  border-color: var(--gray-100);
  background: var(--gray-50);
}

.report-drill-level-2:first-child {
  margin-top: var(--space-2);
}

.report-drill-level-2 .report-accordion-trigger {
  min-height: 58px;
}

.report-detail-table-wrap {
  overflow-x: auto;
  padding: 0 var(--space-3) var(--space-3);
}

.report-detail-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  background: var(--white);
  font-size: 12px;
}

.report-detail-table th,
.report-detail-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-600);
  text-align: right;
  vertical-align: top;
}

.report-detail-table th {
  color: var(--gray-400);
  background: var(--gray-50);
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.report-detail-table th:first-child,
.report-detail-table td:first-child {
  width: 42%;
  text-align: left;
}

.report-detail-table em {
  color: var(--gray-400);
  font-size: 10.5px;
  font-style: normal;
}

.report-detail-table tfoot td {
  color: var(--gray-800);
  background: var(--gray-50);
  font-weight: var(--fw-bold);
}

/* Report summary box */
.report-summary-box {
  background: var(--gray-900);
  border-radius: var(--r-lg);
  padding: var(--space-5);
}

.report-summary-label {
  font-size: 11px;
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: rgba(255,255,255,0.4);
  margin-bottom: var(--space-1);
}

.report-summary-value {
  font-size: 28px;
  font-weight: var(--fw-bold);
  color: var(--white);
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  margin-bottom: var(--space-4);
}

.report-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid rgba(255,255,255,0.08);
}

.rs-item-label {
  font-size: 11px;
  color: rgba(255,255,255,0.4);
  margin-bottom: 3px;
}

.rs-item-value {
  font-size: 14px;
  font-weight: var(--fw-semibold);
  color: var(--white);
  font-variant-numeric: tabular-nums;
}

/* Report table */
.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.report-table th {
  padding: var(--space-2) var(--space-3);
  text-align: right;
  font-size: 11px;
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray-400);
  background: var(--gray-50);
  border-bottom: var(--border);
}

.report-table th:first-child { text-align: left; }

.report-table td {
  padding: var(--space-3);
  text-align: right;
  color: var(--gray-600);
  border-bottom: 1px solid var(--gray-100);
  font-variant-numeric: tabular-nums;
}

.report-table td:first-child { text-align: left; color: var(--gray-700); }
.report-table tr:last-child td { border-bottom: none; }

.report-table tfoot td {
  font-weight: var(--fw-semibold);
  color: var(--gray-800);
  background: var(--gray-50);
  border-top: var(--border);
}

/* Bundling Package */
.package-mode-card {
  margin-bottom: var(--space-6);
  padding: var(--space-4);
  background: var(--white);
  border: var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
}

.package-mode-header,
.bundling-section-header,
.bundling-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.package-mode-copy {
  margin: 4px 0 0;
  color: var(--gray-500);
  font-size: 12px;
  line-height: 1.5;
}

.package-mode-select {
  width: 220px;
  flex: 0 0 auto;
}

.bundling-section {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: var(--border);
}

.bundling-title {
  color: var(--gray-800);
  font-size: 14px;
  font-weight: 800;
}

.bundling-subprojects {
  display: grid;
  gap: var(--space-4);
  margin-top: var(--space-4);
}

.bundling-card {
  padding: var(--space-4);
  background: var(--gray-50);
  border: var(--border);
  border-radius: var(--r-lg);
}

.bundling-service-fields {
  display: flex;
  gap: var(--space-2);
  min-width: 280px;
}

.bundling-card-total {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  margin-left: auto;
}

.bundling-card-total span {
  color: var(--gray-400);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.bundling-card-total > strong {
  color: var(--gray-900);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.bundling-card-total span strong {
  color: var(--gray-600);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.bundling-project-notes {
  margin-top: var(--space-3);
  width: 100%;
}

.bundling-cost-groups {
  display: grid;
  gap: var(--space-3);
  margin-top: var(--space-3);
}

.bundling-cost-group {
  overflow: hidden;
  background: var(--white);
  border: var(--border);
  border-radius: var(--r-md);
}

.bundling-cost-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-3);
  background: var(--gray-100);
  color: var(--gray-700);
  font-size: 12px;
  font-weight: 800;
}

.bundling-add-row {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  color: var(--gray-600);
  background: transparent;
  border: 1px solid var(--gray-200);
  border-radius: var(--r-sm);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.bundling-add-row svg {
  width: 12px;
  height: 12px;
}

.bundling-rows {
  display: grid;
  gap: 1px;
}

.bundling-cost-row {
  display: grid;
  grid-template-columns: minmax(160px, 1.3fr) 72px minmax(150px, 1fr) minmax(160px, 1fr) 36px;
  gap: var(--space-2);
  align-items: center;
  padding: var(--space-2) var(--space-3);
  border-top: 1px solid var(--gray-100);
}

.bundling-summary {
  margin-top: var(--space-4);
}

.bundling-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: var(--space-3);
}

.bundling-summary-item {
  padding: var(--space-3);
  background: #171717;
  border: 1px solid #303030;
  border-radius: var(--r-md);
}

.bundling-summary-item span {
  display: block;
  margin-bottom: 4px;
  color: #8a8a8a;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.bundling-summary-item strong {
  color: var(--white);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.comp-package-indicator {
  margin-top: 3px;
  color: var(--gray-400);
  font-size: 11px;
  font-weight: 600;
}

/* Master Directory / Price Library */
.library-layout {
  display: grid;
  gap: var(--space-5);
}

.library-list-card {
  padding: var(--space-5);
  background: var(--white);
  border: var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
}

.library-card-title {
  margin-bottom: var(--space-3);
  color: var(--gray-800);
  font-size: 14px;
  font-weight: 800;
}

.library-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.library-toolbar-controls {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 130px 130px;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.library-breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: var(--space-4);
  color: var(--gray-500);
  font-size: 13px;
  font-weight: 650;
}

.library-breadcrumb strong {
  color: var(--gray-800);
}

.library-breadcrumb-btn {
  padding: 0;
  color: var(--gray-600);
  background: transparent;
  border: 0;
  font: inherit;
  cursor: pointer;
}

.library-breadcrumb-btn:hover {
  color: var(--gray-900);
}

.library-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}

.library-browser-card {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto auto 18px;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 62px;
  padding: 12px 14px;
  text-align: left;
  background: var(--white);
  border: 1px solid var(--gray-150);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease, background 160ms ease;
}

.library-browser-card:hover {
  border-color: #bfdbfe;
  background: #f8fbff;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
}

.library-browser-card.is-selected {
  border-color: #93c5fd;
  background: #eff6ff;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.10);
}

.library-browser-icon {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-50);
  border: 1px solid var(--gray-150);
  border-radius: 10px;
  color: var(--gray-600);
  font-size: 18px;
}

.library-browser-icon svg {
  width: 21px;
  height: 21px;
  stroke-width: 2;
}

.library-browser-main {
  min-width: 0;
  display: flex;
  align-items: center;
}

.library-browser-main strong {
  color: var(--gray-900);
  font-size: 15px;
  font-weight: 850;
}

.library-browser-count {
  min-width: 28px;
  padding: 3px 8px;
  color: var(--gray-700);
  background: var(--gray-100);
  border: 1px solid var(--gray-150);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.library-browser-card svg {
  color: var(--gray-400);
}

.library-card-chevron,
.library-accordion-chevron {
  transition: transform 180ms ease;
}

.library-browser-card.is-selected .library-card-chevron,
.library-accordion-group.is-open .library-accordion-chevron {
  transform: rotate(180deg);
}

.library-card-menu-btn {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-500);
  background: var(--white);
  border: 1px solid var(--gray-150);
  border-radius: 9px;
  cursor: pointer;
}

.library-card-menu-btn:hover {
  color: var(--gray-900);
  border-color: var(--gray-300);
}

.library-card-menu {
  position: absolute;
  top: 44px;
  right: 12px;
  z-index: 50;
  min-width: 190px;
  padding: 6px;
  background: var(--white);
  border: 1px solid var(--gray-150);
  border-radius: 12px;
  box-shadow: 0 16px 34px rgba(15, 23, 42, 0.14);
}

.library-card-menu button {
  width: 100%;
  padding: 9px 10px;
  color: var(--gray-700);
  background: transparent;
  border: 0;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.library-card-menu button:hover {
  background: var(--gray-50);
  color: var(--gray-900);
}

.library-detail-panel {
  margin-top: var(--space-4);
  padding: var(--space-4);
  background: #fbfdff;
  border: 1px solid var(--gray-150);
  border-radius: var(--r-lg);
}

.library-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.library-detail-head span {
  display: block;
  margin-bottom: 2px;
  color: var(--gray-400);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.library-detail-head strong {
  color: var(--gray-900);
  font-size: 18px;
  font-weight: 850;
}

.library-child-actions {
  position: relative;
  display: flex;
  justify-content: center;
}

.library-child-menu {
  top: 36px;
  right: 0;
}

.library-item-modal-box {
  max-width: 720px;
}

.library-item-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

.library-item-form label {
  display: grid;
  gap: 6px;
}

.library-item-form label span {
  color: var(--gray-600);
  font-size: 12px;
  font-weight: 800;
}

.library-item-form-wide {
  grid-column: 1 / -1;
}

.library-explorer-section {
  margin-top: var(--space-4);
  padding: var(--space-4);
  background: #fbfdff;
  border: 1px solid var(--gray-150);
  border-radius: var(--r-lg);
}

.library-explorer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.library-explorer-head span {
  display: block;
  color: var(--gray-400);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.library-explorer-head strong {
  color: var(--gray-900);
  font-size: 18px;
  font-weight: 850;
}

.library-accordion-list {
  display: grid;
  gap: 10px;
}

.library-accordion-group {
  position: relative;
  background: var(--white);
  border: 1px solid var(--gray-150);
  border-radius: 14px;
  overflow: visible;
  transition: transform 180ms ease, border-color 160ms ease, box-shadow 160ms ease, background 160ms ease, opacity 160ms ease;
}

.library-accordion-group.is-open {
  border-color: #93c5fd;
  background: #f8fbff;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.08);
}

.library-accordion-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto 20px;
  align-items: center;
  gap: 12px;
  padding: 14px;
  cursor: pointer;
}

.library-accordion-main {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.library-accordion-main strong {
  color: var(--gray-900);
  font-size: 14px;
  font-weight: 850;
}

.library-accordion-main small {
  color: var(--gray-500);
  font-size: 12px;
  font-weight: 650;
}

.library-child-list {
  display: grid;
  gap: 8px;
  padding: 0 14px 14px 70px;
}

.library-child-card {
  position: relative;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  background: var(--white);
  border: 1px solid var(--gray-150);
  border-radius: 12px;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease, opacity 160ms ease, background 160ms ease;
}

.library-child-card.is-selected {
  border-color: #93c5fd;
  background: #eff6ff;
}

.library-child-card:hover {
  border-color: var(--gray-200);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.library-child-card.dragging,
.library-nested-group.dragging,
.library-accordion-group.dragging {
  opacity: 0.9;
  transform: rotate(1deg) scale(1.02);
  box-shadow: 0 20px 46px rgba(15, 23, 42, 0.18);
  cursor: grabbing;
}

.library-child-card.is-drop-target,
.library-nested-group.is-drop-target,
.library-accordion-group.is-drop-target,
.library-child-list.is-drop-target,
.library-nested-group-body.is-drop-target {
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.13);
}

.library-child-card.is-keyboard-dragging {
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.library-child-card.is-insert-before,
.library-nested-group.is-insert-before,
.library-accordion-group.is-insert-before {
  margin-top: 10px;
}

.library-child-card.is-insert-before::before,
.library-nested-group.is-insert-before::before,
.library-accordion-group.is-insert-before::before,
.library-child-list.is-insert-end::after,
.library-nested-group-body.is-insert-end::after,
.library-nested-group-list.is-insert-end::after,
.library-accordion-list.is-insert-end::after {
  content: "";
  display: block;
  height: 3px;
  border-radius: 999px;
  background: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.library-child-card.is-insert-before::before,
.library-nested-group.is-insert-before::before,
.library-accordion-group.is-insert-before::before {
  position: absolute;
  top: -8px;
  left: 10px;
  right: 10px;
}

.library-child-card.is-inactive {
  opacity: 0.62;
}

.library-child-leading {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.library-child-drag-handle,
.library-group-drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-300);
  cursor: grab;
}

.library-child-select {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(1px);
  transition: opacity 150ms ease, transform 150ms ease;
  cursor: pointer;
}

.library-child-card:hover .library-child-select,
.library-child-card:focus-within .library-child-select,
.library-child-card.is-selected .library-child-select {
  opacity: 1;
  transform: translateY(0);
}

.library-child-select input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.library-child-select span {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 5px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.library-child-select input:checked + span {
  background: #2563eb;
  border-color: #2563eb;
}

.library-child-select input:checked + span::after {
  content: "";
  width: 7px;
  height: 4px;
  border-left: 2px solid var(--white);
  border-bottom: 2px solid var(--white);
  transform: rotate(-45deg) translateY(-1px);
}

.library-child-drag-handle svg,
.library-group-drag-handle svg {
  width: 16px;
  height: 16px;
}

.library-child-card:hover .library-child-drag-handle,
.library-nested-group-head:hover .library-group-drag-handle {
  color: var(--gray-500);
}

.library-child-main {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.library-child-title,
.library-child-title-input,
.library-child-notes,
.library-child-notes-input {
  width: 100%;
  padding: 0;
  background: transparent;
  border: 0;
  color: var(--gray-900);
  font-family: inherit;
}

.library-child-title,
.library-child-title-input {
  font-size: 13px;
  font-weight: 850;
  line-height: 1.25;
}

.library-child-notes,
.library-child-notes-input {
  color: var(--gray-500);
  font-size: 12px;
}

.library-child-title-input.is-editable,
.library-child-notes-input.is-editable {
  height: 36px;
  padding: 0 10px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 9px;
}

.library-child-title-input:focus,
.library-child-notes-input:focus {
  outline: none;
  color: var(--gray-900);
}

.library-child-title-input.is-editable:focus,
.library-child-notes-input.is-editable:focus,
.library-child-edit-input:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.10);
}

.library-child-card.is-editing {
  border-color: #93c5fd;
  background: #fbfdff;
}

.library-child-edit-grid {
  display: grid;
  grid-template-columns: 150px;
  gap: 8px;
}

.library-child-edit-input {
  height: 36px;
  min-height: 36px;
  font-size: 12px;
}

.library-child-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--gray-500);
  font-size: 11px;
  font-weight: 650;
}

.library-child-meta span {
  padding: 2px 7px;
  background: var(--gray-50);
  border: 1px solid var(--gray-150);
  border-radius: 999px;
}

.library-bulk-action-bar {
  position: sticky;
  bottom: 14px;
  z-index: 45;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 14px 12px 70px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid #bfdbfe;
  border-radius: 14px;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.14);
  backdrop-filter: blur(8px);
}

.library-bulk-action-bar strong {
  display: block;
  color: var(--gray-900);
  font-size: 13px;
  font-weight: 850;
}

.library-bulk-action-bar span {
  display: block;
  margin-top: 2px;
  color: var(--gray-500);
  font-size: 11px;
  font-weight: 650;
}

.library-bulk-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.library-bulk-actions .btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.library-create-group-modal-box,
.library-bulk-group-modal-box {
  max-width: 460px;
}

.library-create-group-form,
.library-bulk-group-form {
  display: grid;
  gap: var(--space-3);
}

.library-create-group-form label,
.library-bulk-group-form label {
  display: grid;
  gap: 6px;
}

.library-create-group-form label span,
.library-bulk-group-form label span {
  color: var(--gray-600);
  font-size: 12px;
  font-weight: 800;
}

.library-nested-group-list {
  display: grid;
  gap: 10px;
  padding: 0 14px 14px 70px;
}

.library-nested-group {
  position: relative;
  overflow: visible;
  background: #f8fafc;
  border: 1px solid var(--gray-150);
  border-radius: 14px;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease, background 180ms ease, opacity 160ms ease;
}

.library-nested-group-head {
  display: grid;
  grid-template-columns: 18px 26px minmax(0, 1fr) auto 30px;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  cursor: grab;
}

.library-nested-group-title {
  min-width: 0;
  color: var(--gray-900);
  font-size: 13px;
  font-weight: 850;
}

.library-group-toggle {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-500);
  background: var(--white);
  border: 1px solid var(--gray-150);
  border-radius: 8px;
  cursor: pointer;
}

.library-group-toggle svg {
  width: 16px;
  height: 16px;
  transition: transform 200ms ease;
}

.library-nested-group.is-collapsed .library-group-toggle svg {
  transform: rotate(-90deg);
}

.library-nested-group-body {
  display: grid;
  gap: 7px;
  padding: 0 10px 10px 34px;
  max-height: 2000px;
  opacity: 1;
  transition: max-height 220ms ease, opacity 180ms ease, padding 220ms ease;
}

.library-nested-group.is-collapsed .library-nested-group-body {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
  overflow: hidden;
}

.library-group-menu {
  top: 34px;
  right: 8px;
}

.library-empty-group {
  padding: 12px;
  color: var(--gray-500);
  background: var(--white);
  border: 1px dashed var(--gray-200);
  border-radius: 12px;
  font-size: 12px;
  line-height: 1.5;
}

@media (max-width: 720px) {
  .library-child-list,
  .library-nested-group-list {
    padding-left: 12px;
    padding-right: 12px;
  }

  .library-child-card {
    grid-template-columns: 54px minmax(0, 1fr) 34px;
    min-height: 58px;
    touch-action: manipulation;
  }

  .library-child-select {
    opacity: 1;
  }

  .library-bulk-action-bar {
    margin-left: 12px;
    margin-right: 12px;
    bottom: 10px;
    align-items: flex-start;
    flex-direction: column;
  }

  .library-bulk-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .library-nested-group-head {
    grid-template-columns: 24px 30px minmax(0, 1fr) auto 34px;
    min-height: 54px;
    touch-action: manipulation;
  }

  .library-child-drag-handle,
  .library-group-drag-handle {
    color: var(--gray-500);
  }

  .library-card-menu-btn,
  .library-group-toggle {
    min-width: 34px;
    min-height: 34px;
  }
}

.library-subgroup-add-item {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 2px 0 0;
  padding: 6px 9px;
  color: var(--gray-700);
  background: transparent;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}

.library-subgroup-add-item svg {
  width: 14px;
  height: 14px;
}

.library-subgroup-add-item:hover {
  color: var(--gray-900);
  background: var(--gray-50);
  border-color: var(--gray-300);
}

.library-subgroup-add-item.is-disabled,
.library-subgroup-add-item[aria-disabled="true"] {
  color: var(--gray-400);
  background: var(--gray-50);
  border-color: var(--gray-200);
  cursor: default;
}

.library-subgroup-add-item.is-disabled:hover,
.library-subgroup-add-item[aria-disabled="true"]:hover {
  color: var(--gray-400);
  background: var(--gray-50);
  border-color: var(--gray-200);
}

.library-subgroup-add-item:focus-visible {
  outline: 2px solid var(--gray-400);
  outline-offset: 2px;
}

.library-child-title-input.has-error {
  border-color: #ef4444;
}

.library-inline-validation {
  margin: 4px 0 0;
  color: #dc2626;
  font-size: 11px;
  font-weight: 600;
}

.library-child-card.is-draft-focus {
  animation: libraryDraftFocusPulse 500ms ease-out;
}

@keyframes libraryDraftFocusPulse {
  0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.28); }
  100% { box-shadow: 0 0 0 8px rgba(59, 130, 246, 0); }
}

.library-table {
  overflow-x: auto;
  border: var(--border);
  border-radius: var(--r-md);
}

.library-table-head,
.library-item {
  display: grid;
  grid-template-columns: 42px 190px minmax(220px, 1.2fr) 76px 150px 100px minmax(190px, 1fr) 112px 64px;
  gap: 8px;
  align-items: center;
  min-width: 1260px;
}

.library-table-head {
  padding: 10px 12px;
  color: var(--gray-500);
  background: var(--gray-100);
  border-bottom: var(--border);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.library-list,
.library-table-body {
  display: grid;
}

.library-item {
  padding: 10px 12px;
  background: var(--white);
  border-bottom: var(--border);
  transition: background 0.16s ease, opacity 0.16s ease;
}

.library-item:last-child {
  border-bottom: 0;
}

.library-item:hover {
  background: var(--gray-50);
}

.library-item.dragging {
  opacity: 0.45;
  background: #fff7ed;
}

.library-item.is-inactive {
  opacity: 0.62;
}

.library-drag-handle {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-400);
  background: transparent;
  border: 0;
  border-radius: var(--r-sm);
  cursor: grab;
}

.library-drag-handle:active {
  cursor: grabbing;
}

.library-category-cell {
  display: grid;
  gap: 6px;
}

.library-inline-input {
  height: 34px;
  min-height: 34px;
  font-size: 12px;
}

.library-custom-category {
  height: 30px;
  min-height: 30px;
}

.library-delete-btn {
  width: 34px;
  height: 34px;
  justify-content: center;
  padding: 0;
}

.library-empty {
  padding: var(--space-6);
  color: var(--gray-400);
  text-align: center;
  background: var(--gray-50);
  border: 1px dashed var(--gray-200);
  border-radius: var(--r-md);
}

/* =============================================
   NAV BETWEEN PANELS
   ============================================= */
.panel-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: var(--space-6);
  border-top: var(--border);
  margin-top: var(--space-8);
}

/* =============================================
   TOPBAR PRESET CONTROLS
   ============================================= */
.preset-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.preset-select {
  padding: 5px 10px;
  border: var(--border);
  border-radius: var(--r-md);
  font-family: var(--font);
  font-size: 12.5px;
  font-weight: var(--fw-medium);
  color: var(--gray-700);
  background: var(--white);
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition);
  min-width: 150px;
}

.preset-select:focus { border-color: var(--gray-400); }

/* Icon-only button */
.icon-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: var(--border);
  border-radius: var(--r-md);
  background: var(--white);
  color: var(--gray-500);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 12px;
}

.icon-btn:hover {
  background: var(--gray-50);
  color: var(--gray-800);
}

.icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.icon-btn.icon-btn-danger:hover {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: #fca5a5;
}

/* Dropdown menu */
.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--white);
  border: var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  z-index: 200;
  min-width: 180px;
  overflow: hidden;
  padding: var(--space-1) 0;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-2) var(--space-4);
  border: none;
  background: transparent;
  font-family: var(--font);
  font-size: 13px;
  color: var(--gray-700);
  cursor: pointer;
  transition: background var(--transition);
  text-align: left;
}

.dropdown-item:hover { background: var(--gray-50); }

.dropdown-item-icon {
  width: 16px;
  color: var(--gray-400);
  font-size: 12px;
  text-align: center;
}

.dropdown-divider { height: 1px; background: var(--gray-100); margin: var(--space-1) 0; }

.dropdown-header {
  padding: var(--space-2) var(--space-4);
  font-size: 11px;
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--gray-400);
}

/* Demo dropdown */
.demo-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: var(--white);
  border: var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  z-index: 200;
  min-width: 200px;
  overflow: hidden;
  padding: var(--space-1) 0;
}

.demo-dropdown-header {
  padding: var(--space-2) var(--space-4);
  font-size: 11px;
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--gray-400);
}

.demo-dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-2) var(--space-4);
  border: none;
  background: transparent;
  font-family: var(--font);
  font-size: 13px;
  color: var(--gray-700);
  cursor: pointer;
  transition: background var(--transition);
  text-align: left;
}

.demo-dropdown-item:hover { background: var(--gray-50); color: var(--gray-900); }

/* =============================================
   MODALS
   ============================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--space-4);
}

.modal-box {
  background: var(--white);
  border: var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 440px;
  overflow: hidden;
}

.modal-box.modal-wide { max-width: 560px; }

.modal-head {
  padding: var(--space-5) var(--space-6) var(--space-4);
  border-bottom: var(--border);
}

.modal-head h3 {
  font-size: 15px;
  font-weight: var(--fw-semibold);
  color: var(--gray-900);
  margin-bottom: 2px;
}

.modal-head p {
  font-size: 12.5px;
  color: var(--gray-400);
}

.modal-body {
  padding: var(--space-5) var(--space-6);
}

.modal-foot {
  padding: var(--space-4) var(--space-6);
  border-top: var(--border);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  background: var(--gray-50);
}

/* =============================================
   TOAST
   ============================================= */
#hpp-toast {
  position: fixed;
  bottom: var(--space-5);
  left: 50%;
  transform: translateX(-50%);
  background: var(--gray-900);
  color: var(--white);
  padding: var(--space-2) var(--space-5);
  border-radius: var(--r-lg);
  font-size: 13px;
  font-weight: var(--fw-medium);
  box-shadow: var(--shadow-md);
  z-index: 9999;
  transition: opacity 0.25s;
  white-space: nowrap;
  pointer-events: none;
}

/* =============================================
   PRINT
   ============================================= */
@media (max-width: 640px) {
  .report-actions {
    align-items: stretch;
  }

  .report-export-mode,
  .report-actions .btn {
    width: 100%;
  }

  .report-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .report-summary-grid .rs-item[style*="span 3"] {
    grid-column: span 2 !important;
  }

  .report-appendix-trigger,
  #report-item-detail-section {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }

  .report-accordion-meta {
    line-height: 1.45;
  }
}

.print-only { display: none; }
.app-footer  { display: none !important; }

@media print {
  @page {
    size: A4 portrait;
    margin: 24mm 14mm 18mm;
  }

  html, body {
    background: #fff !important;
    color: #1e293b !important;
    font-family: Arial, Helvetica, sans-serif !important;
    font-size: 9pt;
    height: auto !important;
    overflow: visible !important;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  body > *:not(#print-report) { display: none !important; }
  #print-report {
    display: block !important;
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
  }

  .print-cover-header {
    padding: 7mm 8mm;
    margin-bottom: 8mm;
    border-left: 1.5mm solid #2563eb;
    background: #f8fafc;
  }

  .print-kicker {
    margin-bottom: 2mm;
    color: #2563eb;
    font-size: 7.5pt;
    font-weight: 700;
    letter-spacing: 0.12em;
  }

  .print-cover-header h1 {
    margin: 0 0 2mm;
    color: #0f172a;
    font-size: 20pt;
    line-height: 1.15;
  }

  .print-cover-header h2 {
    margin: 0 0 1.5mm;
    color: #334155;
    font-size: 11pt;
    text-transform: uppercase;
  }

  .print-cover-header p { margin: 0; color: #64748b; }

  .print-section {
    margin: 0 0 8mm;
  }

  .print-section h3 {
    margin: 0 0 3mm;
    padding-bottom: 2mm;
    color: #0f172a;
    border-bottom: 0.4mm solid #cbd5e1;
    font-size: 10pt;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    break-after: avoid-page;
    page-break-after: avoid;
  }

  .print-appendix-title {
    margin: 12mm 0 6mm;
    padding: 4mm 5mm;
    color: #fff;
    background: #0f172a;
    font-size: 14pt;
    font-weight: 700;
    break-after: avoid-page;
    page-break-after: avoid;
  }

  .print-overhead-heading {
    margin: 8mm 0 4mm;
    padding-bottom: 2mm;
    border-bottom: 0.5mm solid #94a3b8;
    color: #0f172a;
    font-size: 11pt;
    font-weight: 700;
    break-after: avoid-page;
    page-break-after: avoid;
  }

  .print-detail-appendix[hidden] {
    display: none !important;
  }

  .print-summary-section,
  .print-business-section {
    break-inside: avoid-page;
    page-break-inside: avoid;
  }

  .print-summary-highlight {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4mm;
    color: #fff;
    background: #0f172a;
  }

  .print-summary-highlight span { font-weight: 600; }
  .print-summary-highlight strong { font-size: 14pt; }

  #print-report table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
  }

  #print-report thead {
    display: table-header-group;
    break-inside: avoid-page;
    page-break-inside: avoid;
  }
  #print-report tfoot { display: table-row-group; }

  #print-report tr {
    break-inside: avoid-page;
    page-break-inside: avoid;
  }

  .print-data-table th,
  .print-data-table td {
    padding: 2.4mm 2.8mm;
    border: 0.25mm solid #dbe3ec;
    vertical-align: top;
    overflow-wrap: anywhere;
  }

  .print-data-table th {
    color: #334155;
    background: #eef2f7;
    font-size: 8pt;
    font-weight: 700;
    text-align: left;
  }

  .print-data-table th:nth-child(1), .print-data-table td:nth-child(1) { width: 38%; }
  .print-data-table th:nth-child(2), .print-data-table td:nth-child(2) { width: 16%; text-align: center; }
  .print-data-table th:nth-child(3), .print-data-table td:nth-child(3) { width: 23%; text-align: right; }
  .print-data-table th:nth-child(4), .print-data-table td:nth-child(4) { width: 23%; text-align: right; }

  .print-data-table tbody tr:nth-child(even) { background: #f8fafc; }
  .print-row-note { color: #64748b; font-size: 7.5pt; }
  .print-data-table tfoot td {
    color: #0f172a;
    background: #e2e8f0;
    font-weight: 700;
  }
  .print-data-table tfoot td:first-child { text-align: right; }

  .print-summary-table td {
    padding: 2.5mm 3mm;
    border-bottom: 0.25mm solid #e2e8f0;
  }
  .print-summary-table td:last-child {
    width: 34%;
    color: #0f172a;
    font-weight: 700;
    text-align: right;
  }
}

/* =============================================
   MOBILE RESPONSIVE
   ============================================= */
@media (max-width: 900px) {
  :root { --sidebar-w: 200px; }
  .page-content { padding: var(--space-5) var(--space-6); }
  .stat-row { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-area { margin-left: 0; }
  .page-content { padding: var(--space-4); }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  /* Allow cost tables to scroll horizontally instead of stacking / hiding */
  .ws-table {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  #tab-4 .ws-table-head, #tab-4 .ws-row, #tab-4 .btn-add-row, #tab-4 .table-total-row {
    min-width: 960px;
  }
  .breakdown-layout { grid-template-columns: 1fr; }
  .report-summary-grid { grid-template-columns: 1fr; }
  .bep-cards { grid-template-columns: 1fr; }
  .result-box { grid-template-columns: 1fr; }
  .step5-target-profit { align-items: stretch; flex-direction: column; }
  .step5-target-profit > div { width: 100%; max-width: none !important; margin-right: 0 !important; }
  .custom-select-wrapper {
    flex-direction: column;
    gap: var(--space-1);
  }
}

/* =============================================
   HIDDEN UTILITY
   ============================================= */
.hidden { display: none !important; }
.text-muted { color: var(--gray-400); }
.fw-bold { font-weight: var(--fw-semibold); }
.text-sm { font-size: 12px; }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }

/* Preset manager list items */
.pm-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-6);
  border-bottom: var(--border);
  transition: background var(--transition);
}

.pm-item:last-child { border-bottom: none; }
.pm-item:hover { background: var(--gray-50); }

.pm-item-info { flex: 1; }

.pm-item-name {
  font-size: 14px;
  font-weight: var(--fw-medium);
  color: var(--gray-900);
  margin-bottom: 2px;
}

.pm-item-meta {
  font-size: 12px;
  color: var(--gray-400);
  display: flex;
  gap: var(--space-3);
}

.pm-default-badge {
  display: inline-block;
  padding: 1px 6px;
  background: var(--gray-900);
  color: var(--white);
  border-radius: 4px;
  font-size: 10px;
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.pm-item-actions { display: flex; gap: var(--space-2); }

/* ==================== LUCIDE ICON STYLES ==================== */
.lucide, svg.lucide, [data-lucide] {
  width: 16px;
  height: 16px;
  stroke-width: 2px;
  display: inline-block;
  vertical-align: middle;
}

/* Sidebar Nav Icons size adjustment */
.nav-item-icon .lucide, .nav-item-icon svg {
  width: 18px;
  height: 18px;
}

/* Specific icons in info/warning/formula banners */
.formula-banner-icon .lucide, .formula-banner-icon svg {
  width: 20px;
  height: 20px;
}

.info-box-title .lucide, .info-box-title svg,
.info-box-body .lucide, .info-box-body svg {
  width: 16px;
  height: 16px;
}

/* Scenario Title Styling */
.scenario-title-container {
  margin-bottom: var(--space-6);
  background: var(--white);
  border: var(--border);
  border-radius: var(--r-lg);
  padding: var(--space-4) var(--space-5);
}

.scenario-title-label {
  display: block;
  font-size: 11px;
  font-weight: var(--fw-semibold);
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-2);
}

.hpp-scenario-title-input {
  font-size: 16px;
  font-weight: 700;
  padding: var(--space-3) var(--space-4) !important;
  border-radius: var(--r-md) !important;
  color: var(--gray-800);
}

.scenario-title-helper {
  display: block;
  font-size: 11px;
  color: var(--gray-400);
  margin-top: var(--space-2);
}

/* Preset Refactor Layout Rules */
.unsaved-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--warning);
  font-weight: var(--fw-semibold);
  padding: 4px var(--space-2);
  background-color: var(--warning-bg);
  border: 1px solid #fde68a;
  border-radius: var(--r-md);
  margin-right: 2px;
}

.unsaved-indicator .dot {
  width: 6px;
  height: 6px;
  background-color: var(--warning);
  border-radius: 50%;
  display: inline-block;
}

.preset-operations {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.dropdown-item[disabled],
.dropdown-item.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
  color: var(--gray-400) !important;
}

/* Ghost button — subtle, no background */
.btn-ghost {
  background: transparent;
  border: 1px solid var(--gray-300);
  color: var(--gray-500);
}
.btn-ghost:hover {
  background: var(--gray-100);
  color: var(--gray-700);
  border-color: var(--gray-400);
}

/* Typed toast variants */
#hpp-toast.toast-success {
  background: #16a34a;
}
#hpp-toast.toast-error {
  background: #dc2626;
}

/* ================================================
   ASSET DETAILS — Progressive Disclosure Panel
   ================================================ */

/* Toggle button */
.asset-details-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.15s;
  user-select: none;
  color: var(--gray-400);
  height: 32px;
  width: 24px;
}
.asset-details-toggle:hover {
  color: var(--primary);
}
.asset-details-toggle .toggle-chevron {
  width: 16px;
  height: 16px;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}
.asset-details-toggle.expanded .toggle-chevron {
  transform: rotate(90deg);
}

/* Panel container */
.asset-details-panel {
  grid-column: 1 / -1;
  overflow: hidden;
  transition: max-height 0.25s ease, opacity 0.2s ease;
}
.asset-details-panel.collapsed {
  max-height: 0 !important;
  opacity: 0;
  pointer-events: none;
  margin: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}
.asset-details-panel:not(.collapsed) {
  max-height: 600px;
  opacity: 1;
}

/* Panel inner */
.adp-inner {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 10px 14px 14px;
  background: var(--gray-50);
  border: 1px solid var(--gray-150);
  border-radius: var(--r-md);
  margin-bottom: 4px;
}

/* Section groups inside panel */
.adp-section {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
  padding: 10px 0;
}
.adp-section:not(:last-child) {
  border-bottom: 1px solid var(--gray-150);
}
.adp-section:first-child {
  padding-top: 0;
}
.adp-section:last-child {
  padding-bottom: 0;
}

/* Section label */
.adp-section-label {
  width: 100%;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray-400);
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Field container */
.adp-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.adp-field-label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--gray-450, var(--gray-500));
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.2;
}
.adp-field .ws-input,
.adp-field select.ws-input {
  font-size: 12px;
  padding: 5px 8px;
  height: 30px;
  border-radius: var(--r-sm);
}

/* Calculation card */
.adp-calc-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--white);
  border: 1px solid var(--gray-150);
  border-radius: var(--r-md);
  flex-wrap: wrap;
}
.adp-calc-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 70px;
  text-align: center;
}
.adp-calc-step-label {
  font-size: 9.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-400);
  line-height: 1.2;
}
.adp-calc-step-value {
  font-size: 13px;
  font-weight: 700;
  color: var(--gray-700);
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
}
.adp-calc-step-value.text-primary {
  color: var(--primary);
}
.adp-calc-step-value.text-success {
  color: #10B981;
}
.adp-calc-op {
  font-size: 14px;
  color: var(--gray-300);
  font-weight: 300;
  flex-shrink: 0;
  line-height: 1;
  padding-top: 8px;
}

/* Info tooltip trigger */
.adp-info-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--gray-200);
  color: var(--gray-500);
  font-size: 9px;
  font-weight: 700;
  cursor: help;
  flex-shrink: 0;
  position: relative;
  transition: background 0.15s, color 0.15s;
  line-height: 1;
}
.adp-info-trigger:hover {
  background: var(--primary);
  color: white;
}
.adp-info-trigger .adp-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 220px;
  max-width: 300px;
  padding: 8px 10px;
  background: var(--gray-900);
  color: var(--gray-100);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.5;
  border-radius: var(--r-sm);
  text-transform: none;
  letter-spacing: normal;
  z-index: 100;
  pointer-events: none;
  white-space: normal;
  text-align: left;
}
.adp-info-trigger .adp-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--gray-900);
}
.adp-info-trigger:hover .adp-tooltip {
  display: block;
}

/* Asset status badges */
.adp-status-inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}
.adp-status-inline.status-main { background: #dcfce7; color: #15803d; }
.adp-status-inline.status-secondary { background: #dbeafe; color: #1d4ed8; }
.adp-status-inline.status-backup { background: #fef9c3; color: #a16207; }
.adp-status-inline.status-rarely { background: #fed7aa; color: #c2410c; }
.adp-status-inline.status-retired { background: var(--gray-150); color: var(--gray-500); }
.adp-status-inline.status-custom { background: #e9d5ff; color: #7c3aed; }

/* Weight badge in main row */
.adp-weight-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  background: var(--gray-100);
  color: var(--gray-500);
  margin-left: 4px;
  vertical-align: middle;
}
.adp-weight-pill.weight-full { color: #15803d; }
.adp-weight-pill.weight-reduced { color: #a16207; background: #fefce8; }
.adp-weight-pill.weight-zero { color: var(--gray-400); text-decoration: line-through; }

/* Responsive */
@media (max-width: 768px) {
  .adp-section {
    flex-direction: column;
    gap: 8px;
  }
  .adp-calc-card {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
  .adp-calc-step {
    flex-direction: row;
    justify-content: space-between;
    min-width: auto;
  }
  .adp-calc-op {
    text-align: center;
    padding-top: 0;
  }
  .asset-details-panel:not(.collapsed) {
    max-height: 800px;
  }
}

/* Category Groups */
.category-group {
  margin-bottom: var(--space-4);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  overflow: hidden;
  transition: box-shadow 0.22s ease, border-color 0.22s ease;
}

.overhead-group-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-3);
  border-bottom: 1px solid var(--gray-150);
  background: var(--white);
}

.overhead-group-controls-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.overhead-group-controls-copy strong {
  color: var(--gray-700);
  font-size: 12px;
}

.overhead-group-controls-copy span {
  color: var(--gray-400);
  font-size: 11px;
}

.overhead-group-controls-actions {
  display: flex;
  gap: var(--space-2);
}

.overhead-group-controls-actions .btn {
  height: 30px;
  padding: 0 var(--space-3);
  font-size: 11px;
}

.overhead-group-controls-actions .btn svg {
  width: 13px;
  height: 13px;
}

.category-group.hidden {
  display: none !important;
}

.category-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-2) var(--space-3);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-100);
  cursor: pointer;
  user-select: none;
  transition: background 0.2s ease, border-color 0.22s ease;
}

.category-group-header:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--primary) 45%, transparent);
  outline-offset: -2px;
}

.category-group.is-collapsed .category-group-header {
  border-bottom-color: transparent;
}

.category-group-header:hover {
  background: var(--gray-100);
}

.cgh-left {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.cgh-drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  color: var(--gray-400);
  opacity: 0;
  transition: opacity 0.2s ease;
  width: 16px;
  height: 16px;
}

.cgh-drag-handle svg {
  width: 12px;
  height: 12px;
}

.category-group-header:hover .cgh-drag-handle {
  opacity: 0.5;
}

.cgh-drag-handle:hover {
  opacity: 1 !important;
  color: var(--gray-700);
}

.group-dragging {
  opacity: 0.4;
  border: 1px dashed var(--primary);
}

.cgh-icon-svg {
  width: 14px;
  height: 14px;
  stroke-width: 2px;
  color: var(--gray-500);
  display: inline-block;
  vertical-align: middle;
}

.cgh-name {
  font-weight: var(--fw-semibold);
  color: var(--gray-700);
  font-size: 13px;
}

.cgh-badge {
  font-size: 10px;
  color: var(--gray-400);
  background: none;
  border: 1px solid var(--gray-200);
  padding: 1px 6px;
  border-radius: var(--radius-full);
  font-weight: var(--fw-medium);
}

.cgh-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.cgh-subtotal {
  font-size: 12px;
  color: #10B981;
  font-weight: var(--fw-bold);
}

.cgh-add-btn {
  background: none;
  border: none;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  color: var(--primary);
  font-size: 11px;
  font-weight: var(--fw-semibold);
  display: flex;
  align-items: center;
  gap: var(--space-1);
  cursor: pointer;
  opacity: 0.7;
  transition: opacity var(--transition), background var(--transition);
}

.cgh-add-btn svg {
  width: 10px;
  height: 10px;
}

.cgh-add-btn:hover {
  opacity: 1;
  background: var(--gray-200);
}

.cgh-chevron {
  color: var(--gray-400);
  flex: 0 0 auto;
  transition: transform 0.22s cubic-bezier(0.2, 0, 0, 1);
  width: 12px;
  height: 12px;
}

.category-group.is-collapsed .cgh-chevron {
  transform: rotate(-90deg);
}

.category-group-items {
  display: grid;
  grid-template-rows: 1fr;
  opacity: 1;
  background: #ffffff;
  transition: grid-template-rows 0.22s cubic-bezier(0.2, 0, 0, 1), opacity 0.18s ease;
}

.category-group-items.collapsed {
  grid-template-rows: 0fr;
  opacity: 0;
}

.category-group-content {
  min-height: 0;
  overflow: hidden;
}

.category-group-rows {
  display: block;
}

@media (max-width: 768px) {
  .overhead-group-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .overhead-group-controls-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .overhead-group-controls-actions .btn {
    justify-content: center;
  }

  .category-group-header {
    align-items: flex-start;
    gap: var(--space-2);
  }

  .cgh-left {
    min-width: 0;
    flex-wrap: wrap;
  }

  .cgh-name-input {
    max-width: 130px;
  }

  .cgh-right {
    gap: var(--space-2);
  }

  .cgh-subtotal {
    max-width: 110px;
    text-align: right;
  }
}

/* =============================================
   PACKAGE COMPARISON DASHBOARD STYLE
   ============================================= */
.comp-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.comp-summary-card {
  background: var(--white);
  border: var(--border);
  border-radius: var(--r-md);
  padding: var(--space-4);
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--space-2);
}

.comp-summary-label {
  font-size: 11px;
  font-weight: var(--fw-semibold);
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: 1.2;
}

.comp-summary-val {
  font-size: 20px;
  font-weight: var(--fw-bold);
  color: var(--gray-900);
  line-height: 1.1;
}

.comp-summary-sub {
  font-size: 11px;
  color: var(--gray-400);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.comp-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  background: var(--gray-50);
  border: var(--border);
  border-radius: var(--r-md) var(--r-md) 0 0;
  padding: var(--space-4);
  align-items: flex-end;
}

.comp-search-bar {
  padding: var(--space-4);
}

.comp-search-bar .filter-group {
  max-width: 520px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 150px;
}

.filter-group.flex-1 {
  flex: 1;
  min-width: 250px;
}

.filter-label {
  font-size: 11px;
  font-weight: var(--fw-semibold);
  color: var(--gray-500);
  text-transform: uppercase;
}

.comp-table-container {
  overflow-x: auto;
  border-left: var(--border);
  border-right: var(--border);
  border-bottom: var(--border);
  border-radius: 0 0 var(--r-md) var(--r-md);
  background: var(--white);
  position: relative;
}

.comp-empty-state {
  padding: 4rem 2rem;
  text-align: center;
  color: var(--gray-400);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  background: var(--gray-50);
}

.comp-empty-state[hidden] {
  display: none !important;
}

.comp-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.comp-table .comp-package-col {
  position: sticky;
  left: 0;
  min-width: 300px;
  max-width: 380px;
  background: var(--white);
  z-index: 3;
  white-space: nowrap;
}

.comp-table th.comp-package-col {
  background: var(--gray-100);
  z-index: 5;
}

.comp-table-container.is-scrolled-x .comp-table .comp-package-col {
  box-shadow: 10px 0 18px -16px rgba(0, 0, 0, 0.45);
}

.comp-table-container.is-scrolled-x .comp-table .comp-package-col::after {
  content: "";
  position: absolute;
  top: 0;
  right: -1px;
  bottom: 0;
  width: 1px;
  background: rgba(0, 0, 0, 0.08);
  pointer-events: none;
}

.comp-table th, .comp-table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: var(--border);
  white-space: nowrap;
}

.comp-table th {
  background: var(--gray-100);
  font-weight: var(--fw-semibold);
  color: var(--gray-700);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  user-select: none;
}

.comp-table th.sortable {
  cursor: pointer;
}

.comp-table th.sortable:hover {
  background: var(--gray-200);
  color: var(--gray-900);
}

.comp-table th.sortable.comp-package-col:hover {
  background: var(--gray-200);
}

.comp-table tr:hover td {
  background: var(--gray-50);
}

.comp-table tr:hover td.comp-package-col {
  background: var(--gray-50);
}

.comp-table tr.selected td {
  background: var(--gray-100);
}

.comp-table tr.selected td.comp-package-col {
  background: var(--gray-100);
}

.comp-table tr.sim-active td {
  background: #fffaf0;
}

.comp-table tr.sim-active:hover td {
  background: #fff6df;
}

.comp-table tr.sim-active td.comp-package-col {
  background: #fffaf0;
}

.comp-table tr.sim-active:hover td.comp-package-col {
  background: #fff6df;
}

.comp-table tr.selected.sim-active td,
.comp-table tr.selected.sim-active td.comp-package-col {
  background: #fff4d8;
}

.comp-package-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.comp-package-name-row > span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
}

.comp-by-fusuy-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 7px;
  color: var(--gray-500);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0;
  text-transform: none;
  white-space: normal;
  cursor: pointer;
}

.comp-by-fusuy-toggle input {
  width: 13px;
  height: 13px;
  margin: 0;
  accent-color: var(--gray-900);
  cursor: pointer;
}

.comp-sim-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  color: #b45309;
  background: #fef3c7;
  border: 1px solid #fde68a;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.2;
}

.comp-sim-cell {
  background-image: linear-gradient(90deg, rgba(245, 158, 11, 0.07), rgba(245, 158, 11, 0));
}

.comp-original-value {
  display: block;
  margin-top: 2px;
  color: var(--gray-400);
  font-size: 10px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}

.sort-icon {
  display: inline-flex;
  align-items: center;
  margin-left: var(--space-1);
  opacity: 0.5;
}

.sort-icon svg {
  width: 10px;
  height: 10px;
}

.text-right {
  text-align: right;
}

/* Selection action bar */
.comp-selection-bar {
  position: fixed;
  left: calc(var(--sidebar-w) + ((100vw - var(--sidebar-w)) / 2));
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 900;
  display: flex;
  align-items: center;
  gap: var(--space-5);
  min-width: 480px;
  padding: 10px 12px 10px 18px;
  color: var(--white);
  background: #171717;
  border: 1px solid #303030;
  border-radius: var(--r-lg);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.24);
}

.comp-selection-count {
  flex: 1;
  font-size: 13px;
  font-weight: var(--fw-semibold);
}

.comp-selection-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.comp-compare-btn {
  background: var(--white);
  color: #171717;
  border: 1px solid var(--white);
}

.comp-compare-btn:hover {
  background: var(--gray-100);
}

.comp-clear-btn {
  background: transparent;
  color: var(--white);
  border: 1px solid #444;
}

/* Wide comparison modal */
.comp-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background: rgba(10, 10, 10, 0.72);
  backdrop-filter: blur(4px);
}

.comp-modal-panel {
  width: min(1180px, 100%);
  max-height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: #f5f5f5;
  background: #151515;
  border: 1px solid #303030;
  border-radius: var(--r-xl);
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.48);
}

.comp-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
  padding: 20px 24px;
  border-bottom: 1px solid #303030;
}

.comp-modal-eyebrow {
  margin-bottom: 4px;
  color: #8a8a8a;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.comp-modal-header h2 {
  margin: 0;
  color: var(--white);
  font-size: 20px;
}

.comp-modal-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.comp-modal-clear-btn {
  color: #d4d4d4;
  background: #222;
  border: 1px solid #3a3a3a;
}

.comp-modal-close {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #d4d4d4;
  background: #222;
  border: 1px solid #3a3a3a;
  border-radius: var(--r-md);
  cursor: pointer;
}

.comp-modal-close:hover {
  color: var(--white);
  background: #303030;
}

.comp-modal-close svg {
  width: 18px;
  height: 18px;
}

.comp-modal-body {
  overflow: auto;
  padding: 24px;
}

.comp-matrix-desktop {
  overflow-x: auto;
  border: 1px solid #303030;
  border-radius: var(--r-lg);
}

.comp-matrix-table {
  width: 100%;
  min-width: 720px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.comp-matrix-table th,
.comp-matrix-table td {
  min-width: 170px;
  padding: 14px 16px;
  text-align: right;
  white-space: nowrap;
  border-right: 1px solid #2b2b2b;
  border-bottom: 1px solid #2b2b2b;
}

.comp-matrix-table th:last-child,
.comp-matrix-table td:last-child {
  border-right: 0;
}

.comp-matrix-table tbody tr:last-child th,
.comp-matrix-table tbody tr:last-child td {
  border-bottom: 0;
}

.comp-matrix-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--white);
  background: #202020;
  font-size: 12px;
  font-weight: 700;
}

.comp-matrix-table thead th:first-child,
.comp-matrix-table tbody th {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 160px;
  text-align: left;
}

.comp-matrix-table thead th:first-child {
  z-index: 3;
}

.comp-matrix-table tbody th {
  color: #a3a3a3;
  background: #191919;
  font-weight: 600;
}

.comp-matrix-table tbody td {
  color: #ededed;
  background: #151515;
  font-variant-numeric: tabular-nums;
}

.comp-matrix-value {
  display: inline-block;
  padding: 4px 7px;
  border-radius: 5px;
  font-weight: 650;
}

.comp-price-input {
  width: 100%;
  min-width: 140px;
  max-width: 190px;
  display: inline-block;
  padding: 4px 7px;
  color: #ededed;
  background: #1d1d1d;
  border: 1px solid #343434;
  border-radius: 5px;
  font: inherit;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  text-align: right;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.comp-price-input:hover {
  border-color: #4a4a4a;
  background: #222;
}

.comp-price-input:focus {
  color: var(--white);
  background: #242424;
  border-color: #737373;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08);
}

.comp-price-input.comp-value-best,
.comp-price-input.comp-value-worst {
  border-color: transparent;
}

.comp-value-best {
  color: #86efac !important;
  background: rgba(34, 197, 94, 0.13) !important;
}

.comp-value-worst {
  color: #fca5a5 !important;
  background: rgba(239, 68, 68, 0.12) !important;
}

.comp-matrix-value.comp-sim-value {
  color: #fed7aa;
  background: rgba(245, 158, 11, 0.14);
}

.comp-matrix-value .comp-original-value {
  color: #a3a3a3;
  text-align: inherit;
}

.comp-mobile-cards {
  display: none;
}

body.comp-modal-open {
  overflow: hidden;
}

/* Status badging */
.comp-status-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: var(--fw-bold);
  text-align: center;
  text-transform: uppercase;
}

.comp-status-badge.healthy {
  background: var(--success-bg);
  color: var(--success);
}

.comp-status-badge.warning {
  background: var(--warning-bg);
  color: var(--warning);
}

.comp-status-badge.loss {
  background: var(--danger-bg);
  color: var(--danger);
}

/* Highlight stylings */
.comp-highlight-high {
  background: var(--success-bg) !important;
  color: var(--success) !important;
  border-radius: var(--r-sm);
  padding: 2px 6px;
  margin: -2px -6px;
}

.comp-highlight-low {
  background: var(--danger-bg) !important;
  color: var(--danger) !important;
  border-radius: var(--r-sm);
  padding: 2px 6px;
  margin: -2px -6px;
}

@media (max-width: 768px) {
  .package-mode-header,
  .bundling-section-header,
  .bundling-card-header {
    align-items: stretch;
    flex-direction: column;
  }

  .package-mode-select,
  .bundling-service-fields {
    width: 100%;
    min-width: 0;
  }

  .bundling-service-fields {
    flex-direction: column;
  }

  .bundling-card-total {
    align-items: flex-start;
    margin-left: 0;
  }

  .bundling-cost-row {
    grid-template-columns: 1fr;
  }

  .custom-select-wrapper {
    flex-direction: column;
  }

  .library-name-controls {
    flex-direction: column;
  }

  .row-library-hover-card {
    display: none;
  }

  .direct-cost-table {
    overflow: visible;
    background: transparent;
    border: 0;
    box-shadow: none;
  }

  .direct-cost-table .ws-table-head.head-draggable {
    display: none;
  }

  .direct-cost-table .items-container {
    display: grid;
    gap: 10px;
  }

  .direct-cost-table .ws-row.row-direct-cost {
    min-width: 0;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    padding: 12px;
    background: var(--white);
    border: 1px solid var(--gray-150);
    border-radius: 12px;
    box-shadow: var(--shadow-xs);
  }

  .direct-cost-table .ws-row.row-direct-cost:hover {
    background: var(--white);
  }

  .direct-cost-table .row-direct-cost .drag-handle {
    display: none;
  }

  .direct-cost-table .row-direct-cost .product-name-cell,
  .direct-cost-table .row-direct-cost .product-description-input {
    grid-column: 1 / -1;
  }

  .direct-cost-table .row-direct-cost .product-name-input,
  .direct-cost-table .row-direct-cost .product-description-input,
  .direct-cost-table .row-direct-cost .item-qty,
  .direct-cost-table .row-direct-cost .item-price {
    height: 40px;
    min-height: 40px;
  }

  .direct-cost-table .row-direct-cost .product-row-total {
    justify-content: flex-start;
    min-height: 34px;
    font-size: 12px;
  }

  .direct-cost-table .row-direct-cost .btn-remove {
    justify-self: end;
    width: 32px;
    height: 32px;
    margin-top: 0;
  }

  .product-row-actions {
    flex-wrap: wrap;
    padding: 12px 0 0;
    border-top: 0;
  }

  .product-row-actions .btn-add-row {
    flex: 1 1 150px;
    justify-content: center;
    min-height: 38px;
  }

  .directory-picker-modal {
    width: 100%;
    max-height: 92vh;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
  }

  .directory-picker-toolbar {
    grid-template-columns: 1fr;
  }

  .directory-picker-item {
    grid-template-columns: 18px minmax(0, 1fr);
  }

  .directory-picker-rate-item {
    grid-template-columns: 18px minmax(0, 1fr);
  }

  .directory-picker-price {
    grid-column: 2;
    justify-self: start;
  }

  .directory-picker-detail-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .row-overflow {
    display: block;
    position: absolute;
    top: 8px;
    right: 8px;
  }

  .custom-select-wrapper {
    padding-right: 36px;
  }

  .library-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .library-toolbar-controls {
    grid-template-columns: 1fr;
  }

  .library-list-card {
    padding: var(--space-4);
  }

  .library-detail-head {
    flex-direction: column;
    align-items: stretch;
  }

  .library-item-form {
    grid-template-columns: 1fr;
  }

  .library-table-head,
  .library-item {
    min-width: 1120px;
    grid-template-columns: 38px 170px minmax(200px, 1fr) 70px 140px 90px minmax(170px, 1fr) 106px 56px;
  }

  .comp-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .comp-search-bar .filter-group {
    min-width: 0;
    max-width: none;
  }

  .comp-table .comp-package-col {
    min-width: 220px;
    max-width: 260px;
  }

  .comp-selection-bar {
    left: 12px;
    right: 12px;
    bottom: 12px;
    min-width: 0;
    transform: none;
    gap: var(--space-3);
  }

  .comp-selection-actions {
    gap: 6px;
  }

  .comp-selection-actions .btn {
    padding: 7px 9px;
    font-size: 11px;
  }

  .comp-modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .comp-modal-panel {
    width: 100%;
    max-height: 92vh;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
  }

  .comp-modal-header {
    padding: 16px;
  }

  .comp-modal-header h2 {
    font-size: 17px;
  }

  .comp-modal-clear-btn {
    padding: 7px 9px;
    font-size: 11px;
  }

  .comp-modal-body {
    padding: 14px;
  }

  .comp-matrix-desktop {
    display: none;
  }

  .comp-mobile-cards {
    display: grid;
    gap: 12px;
  }

  .comp-mobile-card {
    overflow: hidden;
    background: #191919;
    border: 1px solid #303030;
    border-radius: var(--r-lg);
  }

  .comp-mobile-card h3 {
    margin: 0;
    padding: 14px 16px;
    color: var(--white);
    background: #222;
    border-bottom: 1px solid #303030;
    font-size: 14px;
  }

  .comp-mobile-metric {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 16px;
    border-bottom: 1px solid #292929;
    font-size: 12px;
  }

  .comp-mobile-metric:last-child {
    border-bottom: 0;
  }

  .comp-mobile-metric span {
    color: #9b9b9b;
  }

  .comp-mobile-metric strong {
    padding: 3px 6px;
    color: #ededed;
    text-align: right;
    border-radius: 5px;
  }

  .comp-mobile-price-input {
    max-width: 150px;
    min-width: 120px;
  }
}
body.auth-locked .app-shell { display: none !important; }
body.auth-ready .auth-gate { display: none; }

.auth-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--gray-50, #f8fafc);
  color: var(--gray-900, #111827);
}
.auth-card {
  width: min(100%, 380px);
  padding: 32px;
  border: 1px solid var(--gray-200, #e5e7eb);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 18px 45px rgba(15, 23, 42, .10);
}
.auth-mark {
  width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: 12px; background: var(--gray-100, #f1f5f9); color: var(--gray-700, #334155);
}
.auth-mark svg { width: 20px; height: 20px; }
.auth-eyebrow { margin: 20px 0 8px; color: var(--gray-500, #64748b); font-size: 11px; font-weight: 700; letter-spacing: .12em; }
.auth-card h1 { margin: 0; font-size: 24px; line-height: 1.2; }
.auth-copy { margin: 10px 0 24px; color: var(--gray-500, #64748b); font-size: 14px; }
.auth-label { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 600; }
.auth-card input { width: 100%; box-sizing: border-box; height: 44px; padding: 0 13px; border: 1px solid var(--gray-300, #cbd5e1); border-radius: 9px; font: inherit; outline: none; }
.auth-card input:focus { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.auth-error { margin: 10px 0 0; color: #b42318; font-size: 13px; }
.auth-submit { width: 100%; height: 44px; margin-top: 18px; border: 0; border-radius: 9px; background: #111827; color: #fff; font: inherit; font-weight: 700; cursor: pointer; }
.auth-submit:disabled { opacity: .65; cursor: wait; }
.auth-logout { margin-left: auto; border: 1px solid var(--gray-200, #e5e7eb); border-radius: 8px; background: transparent; color: var(--gray-600, #475569); padding: 6px 9px; font-size: 12px; cursor: pointer; }
.auth-logout:hover { background: var(--gray-100, #f1f5f9); }
.backup-history-card { background: var(--white); border: var(--border); border-radius: var(--r-lg); padding: var(--space-5); }
.backup-history-toolbar { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:16px; }
.backup-history-status { color:var(--gray-500); font-size:12px; margin-left:6px; }
.backup-history-list { display:grid; gap:8px; }
.backup-history-row { display:flex; align-items:center; justify-content:space-between; gap:16px; padding:14px 0; border-top:1px solid var(--gray-150); }
.backup-history-row strong { display:block; font-size:14px; text-transform:capitalize; }
.backup-history-row small { display:block; color:var(--gray-500); font-size:12px; margin-top:4px; }
.backup-history-actions { display:flex; gap:6px; flex-wrap:wrap; }
.backup-history-actions button { border:1px solid var(--gray-200); border-radius:7px; background:var(--white); color:var(--gray-700); padding:6px 9px; font-size:12px; cursor:pointer; }
.backup-history-actions button:hover { background:var(--gray-50); border-color:var(--gray-300); }
.backup-history-empty { padding:36px 12px; text-align:center; color:var(--gray-500); font-size:13px; }
.backup-preference { display:flex; align-items:center; gap:8px; margin:0 0 16px; color:var(--gray-600); font-size:13px; }
.backup-confirm-overlay { position:fixed; inset:0; z-index:3000; display:grid; place-items:center; padding:20px; background:rgba(15,23,42,.35); }
.backup-confirm-overlay.hidden { display:none; }
.backup-confirm-card { width:min(100%, 390px); padding:24px; border:1px solid var(--gray-200); border-radius:14px; background:var(--white); box-shadow:0 20px 55px rgba(15,23,42,.2); }
.backup-confirm-card h2 { margin:0 0 8px; font-size:18px; }
.backup-confirm-card p { margin:0 0 16px; color:var(--gray-500); font-size:13px; }
.backup-confirm-card label { display:flex; align-items:center; gap:8px; color:var(--gray-700); font-size:13px; }
.backup-confirm-actions { display:flex; justify-content:flex-end; gap:8px; margin-top:22px; }
