/* ==========================================================================
   Ondol.co.nz - IBM Enterprise Design System Stylesheet (2026)
   Carbon Blue & Neutral Enterprise Palette
   ========================================================================== */

:root {
  /* IBM Carbon Palette */
  --ibm-blue-60: #0f62fe;        /* Primary interactive blue */
  --ibm-blue-70: #0043ce;        /* Primary hover / active */
  --ibm-blue-10: #edf5ff;        /* Blue background tint */
  --ibm-blue-20: #d0e2ff;        /* Blue border / badge highlight */
  --ibm-blue-80: #002d9c;        /* Deep enterprise blue */
  --ibm-blue-90: #001d6c;        /* Dark navy header accent */

  --primary: var(--ibm-blue-60);
  --primary-hover: var(--ibm-blue-70);
  --primary-light: var(--ibm-blue-10);
  --primary-border: var(--ibm-blue-20);
  --primary-dark: var(--ibm-blue-80);

  /* Semantic Feedback (IBM Carbon spec) */
  --success: #198038;            /* Green 60 */
  --success-light: #defbe6;      /* Green 10 */
  --danger: #da1e28;             /* Red 60 */
  --danger-light: #fff1f1;       /* Red 10 */
  --warning: #f1c21b;            /* Yellow 30 */
  --warning-dark: #b28600;       /* Yellow 60 */
  --warning-light: #fcf4d6;      /* Yellow 10 */

  /* Neutral Backgrounds & Layers (IBM Gray 10/White theme) */
  --bg-app: #f4f4f4;             /* Carbon Gray 10 page background */
  --bg-card: #ffffff;            /* Pure white layer */
  --bg-inset: #e0e0e0;           /* Carbon Gray 20 layer */
  --bg-dark: #161616;            /* Carbon Gray 100 banner/header */

  /* Enterprise Typography Grays (IBM Carbon Gray 100/70/50) */
  --text-main: #161616;          /* Carbon Gray 100 */
  --text-muted: #525252;         /* Carbon Gray 70 */
  --text-dim: #8d8d8d;           /* Carbon Gray 50 */
  --text-on-dark: #f4f4f4;       /* Text on Gray 90/100 */

  /* Enterprise Structural Borders & Focus Rings */
  --border-color: #e0e0e0;       /* Carbon Gray 20 */
  --border-subtle: #c6c6c6;      /* Carbon Gray 30 */
  --border-focus: var(--ibm-blue-60); /* 2px IBM focus ring */

  /* IBM Carbon Geometry: Precise square/minimal radii (2px / 4px) */
  --radius-xs: 2px;
  --radius-sm: 3px;
  --radius-md: 4px;
  --radius-lg: 6px;

  /* Subtle Crisp Elevation */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.08);
  --shadow-md: 0 2px 6px 0 rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 4px 16px 0 rgba(0, 0, 0, 0.16);

  /* IBM Diagnostic Console Colors */
  --log-info: #78a9ff;           /* IBM Blue 40 */
  --log-warn: #f1c21b;           /* IBM Yellow 30 */
  --log-error: #ff8389;          /* IBM Red 40 */
  --log-success: #42be65;        /* IBM Green 40 */

  /* IBM Carbon Role & Status Tags */
  --tag-purple: #6929c4;         /* Purple 70 */
  --tag-cyan: #1192e8;           /* Cyan 50 */
  --tag-blue: #0072c3;           /* Blue 60 */
  --tag-teal: #005d5d;           /* Teal 70 */

  --font-sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'IBM Plex Mono', 'JetBrains Mono', ui-monospace, monospace;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 14px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* App Container */
.app-container {
  max-width: 1360px;
  width: 100%;
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  background: var(--bg-card);
  padding: 1rem 1.5rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
  gap: 1rem;
}

.header-branding {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.logo-badge {
  background: var(--primary);
  color: #fff;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}

.app-title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.app-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

/* Project Config Bar */
.project-config-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1rem 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}

.config-grid {
  display: grid;
  grid-template-columns: 1.8fr 1.6fr 1.8fr 1.2fr 1.2fr;
  gap: 1rem;
  align-items: flex-end;
}

@media (max-width: 1120px) {
  .config-grid {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

@media (max-width: 720px) {
  .config-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 480px) {
  .config-grid {
    grid-template-columns: 1fr;
  }
}

/* Radio Pill Group */
.radio-toggle-group {
  display: flex;
  background: var(--bg-inset);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  gap: 4px;
}

.radio-pill {
  flex: 1;
  text-align: center;
  cursor: pointer;
}

.radio-pill input {
  display: none;
}

.radio-pill span {
  display: block;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: all 0.15s ease;
}

.radio-pill input:checked + span {
  background: var(--bg-card);
  color: var(--primary);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* Metric Badge */
.metric-badge {
  background: var(--primary-light);
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-md);
  padding: 0.65rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.metric-badge.secondary-badge {
  background: var(--bg-inset);
  border-color: var(--border-color);
}

.metric-badge.secondary-badge .metric-label {
  color: var(--text-muted);
}

.metric-badge.secondary-badge .metric-val {
  color: var(--text-main);
}

.metric-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--primary);
  letter-spacing: 0.04em;
}

.metric-val {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary-hover);
  font-family: var(--font-mono);
}

/* Tabs Navigation */
.tabs-nav {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.25rem;
  overflow-x: auto;
}

.tab-btn {
  background: transparent;
  border: none;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  transition: all 0.15s ease;
  position: relative;
  white-space: nowrap;
}

.tab-step {
  display: inline-flex;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-inset);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 700;
  align-items: center;
  justify-content: center;
}

.tab-btn:hover {
  color: var(--text-main);
  background: rgba(0, 0, 0, 0.02);
}

.tab-btn.active {
  color: var(--primary);
  font-weight: 600;
}

.tab-btn.active .tab-step {
  background: var(--primary);
  color: #fff;
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -0.25rem;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary);
  border-radius: 3px 3px 0 0;
}

/* Panes */
.tabs-content {
  flex: 1;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

/* Data Entry Layout */
.data-entry-layout {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 1.25rem;
}

@media (max-width: 960px) {
  .data-entry-layout {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.35rem 1.5rem;
  box-shadow: var(--shadow-sm);
}

.panel-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.4rem;
}

.panel-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* Form Styles */
.form-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 0.9rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.flex-1 { flex: 1; }
.flex-2 { flex: 2; }

label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-main);
}

.required {
  color: var(--danger);
}

.form-input, .form-select {
  padding: 0.55rem 0.75rem;
  font-family: inherit;
  font-size: 0.88rem;
  color: var(--text-main);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input:focus, .form-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(15, 98, 254, 0.2);
}

/* Number Stepper */
.number-stepper {
  display: flex;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.number-stepper .form-input {
  border: none;
  border-radius: 0;
  width: 100%;
}

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

.step-btn {
  background: var(--bg-inset);
  border: none;
  width: 44px;
  min-height: 40px;
  cursor: pointer;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s;
}

@media (hover: none) or (pointer: coarse) {
  .step-btn {
    min-height: 44px;
    min-width: 44px;
  }
}

.step-btn:hover {
  background: #e2e8f0;
  color: var(--text-main);
}

/* Connection Box */
.connection-box {
  background: var(--bg-inset);
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.1rem;
  border: 1px solid var(--border-color);
}

.section-subtitle {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.5rem;
  letter-spacing: 0.03em;
}

.radio-choice-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.radio-choice {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  cursor: pointer;
}

.shared-room-row {
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px dashed var(--border-color);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* Form Buttons */
.form-btn-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover {
  background: #15803d;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover {
  background: #b91c1c;
}

.btn-secondary {
  background: #64748b;
  color: #fff;
}
.btn-secondary:hover {
  background: #475569;
}

.btn-outline {
  background: #fff;
  border-color: var(--border-color);
  color: var(--text-main);
}
.btn-outline:hover {
  background: var(--bg-inset);
  border-color: #cbd5e1;
}

.btn-danger-outline {
  background: #ffffff;
  border-color: var(--danger);
  color: var(--danger);
}
.btn-danger-outline:hover {
  background: var(--danger);
  color: #ffffff;
  border-color: var(--danger);
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.78rem;
  cursor: pointer;
  text-decoration: underline;
}

/* List Panel */
.panel-header-with-count {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.badge {
  background: var(--bg-inset);
  color: var(--text-muted);
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-xs);
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--border-color);
}

.room-list-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 310px;
  overflow-y: auto;
  margin-bottom: 1rem;
  padding-right: 4px;
}

.room-item-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: #fff;
  cursor: pointer;
  transition: all 0.15s ease;
}

.room-item-card:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.room-item-card.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 1px var(--primary);
}

.room-item-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.room-item-name {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text-main);
}

.room-item-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.room-item-stats {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.room-item-pipe {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--primary);
}

.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-inset);
}

/* Diagnostics / Log Window */
.calc-log-wrapper {
  margin-top: auto;
  border-top: 1px solid var(--border-color);
  padding-top: 0.75rem;
}

.calc-log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  letter-spacing: 0.03em;
}

.calc-window {
  background: #0f172a;
  color: #e2e8f0;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  height: 120px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.log-entry.info { color: var(--log-info); }
.log-entry.warn { color: var(--log-warn); }
.log-entry.error { color: var(--log-error); }
.log-entry.success { color: var(--log-success); }

/* Worksheet Panel */
.worksheet-header, .materials-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.quick-totals {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.total-pill {
  background: var(--bg-inset);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  border: 1px solid var(--border-color);
}

.total-pill.highlight {
  background: var(--primary-light);
  border-color: var(--primary-border);
  color: var(--primary-hover);
}

/* Tables */
.table-responsive {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.table th {
  background: var(--bg-inset);
  color: var(--text-muted);
  font-weight: 600;
  text-align: left;
  padding: 0.65rem 0.85rem;
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
}

.table td {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
}

.table tbody tr:hover {
  background: var(--bg-inset);
}

.empty-table {
  color: var(--text-muted);
  padding: 2.5rem !important;
}

/* Materials Tools */
.materials-tools {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.checkbox-toggle {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
}

.qty-control {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.qty-control input {
  width: 60px;
  text-align: center;
  padding: 0.25rem 0.4rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-weight: 600;
}

/* Modal */
/* Modal System (Viewport Aware & Responsive) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: clamp(0.75rem, 2vh, 1.5rem);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-card {
  background: #fff;
  border-radius: var(--radius-lg);
  max-width: 520px;
  width: 100%;
  max-height: min(92vh, calc(100dvh - 2rem));
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  margin: auto;
  position: relative;
}

.modal-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  background: #ffffff;
}

.modal-header h3 {
  font-size: 1.12rem;
  font-weight: 700;
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.35rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  padding: 0.25rem;
  border-radius: var(--radius-xs);
  transition: color 0.15s ease, background 0.15s ease;
}
.modal-close:hover {
  color: var(--text-main);
  background: var(--bg-inset);
}

.modal-body {
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1 1 auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* Custom sleek scrollbar for modal bodies */
.modal-body::-webkit-scrollbar {
  width: 6px;
}
.modal-body::-webkit-scrollbar-track {
  background: var(--bg-inset);
}
.modal-body::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}
.modal-body::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.about-icon-circle {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
}

.modal-body h4 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.text-muted {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: 0.85rem;
}

.about-specs {
  background: var(--bg-inset);
  padding: 0.85rem;
  border-radius: var(--radius-md);
  margin-top: 1rem;
  text-align: left;
  font-size: 0.82rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.modal-footer {
  padding: 0.85rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  align-items: center;
  background: var(--bg-inset);
  flex-shrink: 0;
  gap: 0.5rem;
}

/* Footer */
.app-footer {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: 0.5rem;
}

.footer-link {
  color: var(--primary);
  text-decoration: none;
}
.footer-link:hover {
  text-decoration: underline;
}

/* User Account & Enterprise Header Elements */
.user-auth-badge {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: var(--bg-inset);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  font-size: 0.82rem;
}

.user-role-tag {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-xs);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.role-owner { background: var(--tag-purple); color: #ffffff; }     /* Purple 70 */
.role-founder { background: var(--tag-cyan); color: #ffffff; }   /* Cyan 50 */
.role-team_lead { background: var(--tag-blue); color: #ffffff; } /* Blue 60 */
.role-user { background: var(--tag-teal); color: #ffffff; }      /* Teal 70 */

.sub-status-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-xs);
  font-size: 0.78rem;
  font-weight: 700;
}
.sub-active { background: var(--success-light); color: var(--success); border: 1px solid rgba(25, 128, 56, 0.3); }
.sub-required { background: var(--danger-light); color: var(--danger); border: 1px solid rgba(218, 30, 40, 0.3); }

/* Enterprise Modals & Panels */
.modal-card-large {
  max-width: 840px !important;
  max-height: min(88vh, calc(100dvh - 2.5rem)) !important;
}

.modal-card-xl {
  max-width: 960px !important;
  max-height: min(90vh, calc(100dvh - 2rem)) !important;
}

/* Scrollable table container with sticky header for modals */
.modal-table-wrapper {
  max-height: min(260px, 32vh);
  overflow-y: auto;
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: #ffffff;
  margin-bottom: 1rem;
}
.modal-table-wrapper table {
  margin-bottom: 0;
}
.modal-table-wrapper thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg-inset);
  box-shadow: 0 1px 0 var(--border-color);
}

/* Compact responsive grid for security & persistence cards */
.account-metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 0.85rem;
  margin-top: 1rem;
}
.account-metrics-grid .security-metrics-card {
  margin-top: 0 !important;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.account-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  text-align: left;
  margin-top: 1rem;
}

.invoice-preview-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1.5rem;
  font-family: var(--font-sans);
  color: var(--text-main);
  text-align: left;
}

.invoice-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 2px solid var(--text-main);
  padding-bottom: 1rem;
  margin-bottom: 1.25rem;
}

.invoice-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25rem 0;
}
.invoice-table th, .invoice-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border-color);
}
.invoice-table th {
  background: var(--bg-inset);
  font-weight: 600;
}

.artifact-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: #ffffff;
  margin-bottom: 0.5rem;
  transition: all 0.15s ease;
}
.artifact-item:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

/* ==========================================================================
   Enterprise Authentication Gateway & Security Shield Styles
   ========================================================================== */
.login-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(22, 22, 22, 0.88);
  backdrop-filter: blur(6px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 99999;
  padding: clamp(0.75rem, 2vh, 1.5rem);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.login-card {
  background: #ffffff;
  width: 100%;
  max-width: 480px;
  max-height: min(92vh, calc(100dvh - 2rem));
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-md);
  border: 2px solid var(--ibm-blue-60);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  animation: fadeIn 0.2s ease-out;
  margin: auto;
}

.login-header {
  background: var(--gray-100);
  color: #ffffff;
  padding: 1.25rem 1.75rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  border-bottom: 3px solid var(--ibm-blue-60);
  flex-shrink: 0;
}

.login-header-icon {
  width: 44px;
  height: 44px;
  background: var(--ibm-blue-60);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  flex-shrink: 0;
}

.login-header-text h2 {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0;
  color: #ffffff;
}
.login-header-text p {
  font-size: 0.88rem;
  color: var(--gray-30);
  margin: 0.2rem 0 0 0;
}

.login-body {
  padding: 1.5rem 1.75rem;
  overflow-y: auto;
  flex: 1 1 auto;
  overscroll-behavior: contain;
}

.security-shield-banner {
  background: var(--primary-light);
  border: 1px solid var(--primary-border);
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.78rem;
  color: var(--primary-dark);
  line-height: 1.45;
  border-radius: var(--radius-sm);
}

.security-shield-banner strong {
  display: block;
  font-weight: 700;
  margin-bottom: 0.2rem;
  color: var(--ibm-blue-60);
}

.login-alert {
  background: var(--danger-light);
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  margin-bottom: 1rem;
  display: none;
}

.login-lock-banner {
  background: var(--warning-light);
  border: 1px solid var(--warning-dark);
  color: #161616;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 1rem;
  display: none;
}


/* Security Diagnostics Card in Account Modal */
.security-metrics-card {
  margin-top: 1.25rem;
  background: var(--bg-inset);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1rem;
  font-size: 0.8rem;
}
.security-metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-top: 0.5rem;
}
.security-metric-item {
  background: #ffffff;
  border: 1px solid var(--border-color);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-xs);
}
.security-metric-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
}
.security-metric-val {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary);
  margin-top: 0.2rem;
}

/* ==========================================================================
   Print to PDF Stylesheet - A4 Landscape Mode (No Horizontal Scrollbars)
   ========================================================================== */
@page {
  size: A4 landscape;
  margin: 10mm 10mm 12mm 10mm;
}

@media print {
  html, body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 8.5pt !important;
    line-height: 1.3 !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    height: auto !important;
  }

  .app-container {
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* Hide interactive controls, navigation, forms, buttons */
  .app-header .header-actions,
  .user-auth-badge,
  .tabs-nav,
  .form-panel,
  .calc-log-wrapper,
  .materials-tools,
  .app-footer,
  .step-btn,
  .btn,
  .modal-backdrop,
  #tab-data-entry .panel:first-child,
  .room-list-container,
  .panel-header-with-count {
    display: none !important;
  }

  /* Header Branding on Print */
  .app-header {
    border: none !important;
    box-shadow: none !important;
    padding: 0 0 8px 0 !important;
    margin-bottom: 8px !important;
    border-bottom: 2px solid #000 !important;
  }
  .app-title {
    font-size: 14pt !important;
    color: #000 !important;
  }
  .app-subtitle {
    font-size: 8.5pt !important;
    color: #444 !important;
  }

  /* Force display of print sections */
  .tabs-content {
    display: block !important;
  }

  .tab-pane {
    display: block !important;
    page-break-after: always;
  }
  .tab-pane:last-child {
    page-break-after: avoid;
  }

  .panel {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin-bottom: 12px !important;
  }

  .panel-title {
    font-size: 11pt !important;
    margin-bottom: 4px !important;
    color: #000 !important;
  }

  .panel-desc {
    font-size: 8pt !important;
    margin-bottom: 8px !important;
    color: #555 !important;
  }

  .project-config-card {
    border: 1px solid #ccc !important;
    box-shadow: none !important;
    padding: 6px 10px !important;
    margin-bottom: 10px !important;
  }

  /* Ensure Table View spans full landscape width with ZERO horizontal scroll */
  .table-responsive {
    overflow: visible !important;
    overflow-x: visible !important;
    display: block !important;
    width: 100% !important;
  }

  .table {
    width: 100% !important;
    table-layout: fixed !important; /* Forces strict containment within page margins */
    border-collapse: collapse !important;
    font-size: 8pt !important;
    page-break-inside: auto !important;
  }

  .table tr {
    page-break-inside: avoid !important;
    page-break-after: auto !important;
  }

  .table th, .table td {
    border: 1px solid #777 !important;
    padding: 3px 5px !important;
    vertical-align: middle !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    white-space: normal !important; /* Allow wrapping so columns fit neatly */
  }

  .table th {
    background-color: #f0f0f0 !important;
    color: #000 !important;
    font-weight: 700 !important;
    font-size: 7.8pt !important;
  }

  /* Worksheet Column Distribution for A4 Landscape (sum = 100%) */
  .worksheet-table th:nth-child(1), .worksheet-table td:nth-child(1) { width: 15%; font-weight: bold; } /* Room */
  .worksheet-table th:nth-child(2), .worksheet-table td:nth-child(2) { width: 8%; }                     /* Usage */
  .worksheet-table th:nth-child(3), .worksheet-table td:nth-child(3) { width: 6%; text-align: center; } /* Temp */
  .worksheet-table th:nth-child(4), .worksheet-table td:nth-child(4) { width: 13%; }                    /* Covering */
  .worksheet-table th:nth-child(5), .worksheet-table td:nth-child(5) { width: 9%; }                     /* Design Output */
  .worksheet-table th:nth-child(6), .worksheet-table td:nth-child(6) { width: 10%; }                    /* Spacing VA */
  .worksheet-table th:nth-child(7), .worksheet-table td:nth-child(7) { width: 6%; text-align: right; }  /* Area */
  .worksheet-table th:nth-child(8), .worksheet-table td:nth-child(8) { width: 6%; text-align: right; }  /* Coil */
  .worksheet-table th:nth-child(9), .worksheet-table td:nth-child(9) { width: 6%; text-align: right; }  /* Feeder */
  .worksheet-table th:nth-child(10), .worksheet-table td:nth-child(10) { width: 6%; text-align: right; font-weight: bold; } /* Total Pipe */
  .worksheet-table th:nth-child(11), .worksheet-table td:nth-child(11) { width: 5%; text-align: center; } /* Circuits */
  .worksheet-table th:nth-child(12), .worksheet-table td:nth-child(12) { width: 10%; font-size: 7pt; }  /* Cutting Notes */
}

/* ==========================================================================
   Accessibility: Motion Sensitivity (WCAG 2.1 AA §2.3.3)
   Intentional reduced-motion alternative that preserves state change & clarity
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .login-card, .modal-card, .toast {
    animation: none !important;
    transform: none !important;
  }
  .btn, .tab-btn, .radio-pill span, .form-input, .form-select, .step-btn {
    transition: opacity 0.05s ease, background-color 0.05s ease, color 0.05s ease, border-color 0.05s ease !important;
    transform: none !important;
  }
}
