/* ═══════════════════════════════════════════════════════════════════════════
   SIDEBAR LAYOUT SYSTEM
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --sidebar-width:       240px;
  --sidebar-bg:          var(--color-neutral-950);
  --sidebar-border:      var(--color-neutral-800);
  --sidebar-text:        var(--color-neutral-400);
  --sidebar-text-hover:  var(--color-neutral-100);
  --sidebar-text-active: var(--color-primary-300);
  --sidebar-active-bg:   rgba(59, 130, 246, 0.12);
  --sidebar-accent:      var(--color-primary-500);

  /* Slightly darker primary for better contrast on white backgrounds */
  --bs-primary:     #0b5ed7;
  --bs-primary-rgb: 11, 94, 215;

  /* System font stack — matches token layer */
  --bs-font-sans-serif: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

/* ─── Body / page shell ─────────────────────────────────────────────────────── */
.app-body {
  margin: 0;
  background: var(--color-neutral-100);
}

/* Desktop: content sits to the right of the fixed sidebar */
@media (min-width: 992px) {
  .app-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
  }
}

.app-main {
  padding-bottom: 2rem;
}

/* ─── Sidebar ───────────────────────────────────────────────────────────────── */
.app-sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  width: var(--sidebar-width);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none; /* Firefox */
}
.app-sidebar::-webkit-scrollbar { display: none; }

/* Desktop: fixed left panel */
@media (min-width: 992px) {
  .app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1040;
  }
}

/* Mobile: slide-in drawer */
@media (max-width: 991.98px) {
  .app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1055;
    transform: translateX(-100%);
    transition: transform 180ms var(--ease);
    box-shadow: 6px 0 32px rgba(0, 0, 0, 0.28);
  }
  .app-sidebar.is-open {
    transform: translateX(0);
  }
}

/* ─── Sidebar backdrop (mobile only) ───────────────────────────────────────── */
.sidebar-backdrop {
  display: none;
}
@media (max-width: 991.98px) {
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.48);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 1050;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
  }
  .sidebar-backdrop.is-visible {
    opacity: 1;
    pointer-events: auto;
  }
}

/* ─── Mobile close row ───────────────────────────────────────────────────────── */
.sidebar-close-row {
  display: flex;
  justify-content: flex-end;
  padding: var(--space-2) var(--space-2) 0;
  flex-shrink: 0;
}

.sidebar-close-btn {
  background: none;
  border: none;
  color: var(--color-neutral-500);
  padding: var(--space-1);
  cursor: pointer;
  border-radius: var(--radius-md);
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast), background-color var(--transition-fast);
}
.sidebar-close-btn:hover {
  color: var(--color-neutral-50);
  background-color: var(--color-neutral-800);
}

/* ─── Sidebar navigation ────────────────────────────────────────────────────── */
.sidebar-nav {
  padding: 0.5rem 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

.sidebar-section-label {
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-neutral-500);
  padding-inline: var(--space-3);
  margin-top: var(--space-5);
  margin-bottom: var(--space-2);
}

.sidebar-nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  height: 40px;
  padding-inline: var(--space-3);
  margin: 1px var(--space-2);
  border-radius: var(--radius-md);
  color: var(--color-neutral-300);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  transition: color var(--transition-fast), background-color var(--transition-fast);
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-nav-item i {
  font-size: 18px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  color: var(--color-neutral-400);
  transition: color var(--transition-fast);
}
.sidebar-nav-item:hover {
  color: var(--color-neutral-100);
  background-color: var(--color-neutral-900);
  text-decoration: none;
}
.sidebar-nav-item:hover i {
  color: var(--color-neutral-200);
}
.sidebar-nav-item.is-active {
  color: var(--color-primary-300);
  background-color: var(--sidebar-active-bg);
}
.sidebar-nav-item.is-active i {
  color: var(--color-primary-400);
}
.sidebar-nav-item.is-active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 20%;
  height: 60%;
  width: 2px;
  background: var(--color-primary-500);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* Logout ghost button */
.sidebar-logout {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  height: 36px;
  padding-inline: var(--space-3);
  margin: var(--space-1) var(--space-2) var(--space-2);
  border-radius: var(--radius-md);
  color: var(--color-neutral-500);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  border: 1px solid transparent;
  transition: color var(--transition-fast), background-color var(--transition-fast), border-color var(--transition-fast);
}
.sidebar-logout i {
  font-size: 16px;
  flex-shrink: 0;
}
.sidebar-logout:hover {
  color: #f87171;
  background-color: rgba(248, 113, 113, 0.08);
  border-color: rgba(248, 113, 113, 0.2);
  text-decoration: none;
}

/* ─── Sidebar footer / user ─────────────────────────────────────────────────── */
.sidebar-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--sidebar-border);
  padding: var(--space-2) 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-3) var(--space-2);
  overflow: hidden;
}

.sidebar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-primary-700);
  color: #fff;
  font-size: var(--text-xs);
  font-weight: var(--fw-bold);
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-user-name {
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  color: var(--color-neutral-100);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: var(--text-xs);
  color: var(--color-neutral-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── Mobile top bar ────────────────────────────────────────────────────────── */
.mobile-topbar {
  position: sticky;
  top: 0;
  z-index: 1020;
  background: var(--sidebar-bg);
  color: var(--color-neutral-50);
  display: flex;
  align-items: center;
  height: 56px;
  padding: 0 var(--space-2);
  border-bottom: 1px solid var(--sidebar-border);
}

.topbar-hamburger {
  background: none;
  border: none;
  color: var(--color-neutral-300);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: color var(--transition-fast), background-color var(--transition-fast);
}
.topbar-hamburger:hover {
  color: var(--color-neutral-50);
  background-color: var(--color-neutral-800);
}

.topbar-title {
  flex: 1;
  text-align: center;
  font-size: var(--text-base);
  font-weight: var(--fw-semibold);
  color: var(--color-neutral-50);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-inline: var(--space-2);
}

.topbar-actions {
  width: 40px;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════════════════
   FORM PAGE — MOBILE ACTION BAR
   ═══════════════════════════════════════════════════════════════════════════ */

.form-actionbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1035;
  background: var(--bs-body-bg);
  border-top: 2px solid var(--bs-primary);
  padding: 0.625rem 0.875rem;
  padding-bottom: calc(0.625rem + env(safe-area-inset-bottom));
  display: none; /* shown as flex via JS when form is active */
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.09);
}

.form-actionbar-label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--bs-secondary-color);
  line-height: 1;
  margin-bottom: 2px;
}

/* Mobile form: bottom padding so the action bar never covers content */
@media (max-width: 991.98px) {
  #rapport-form-page {
    padding-bottom: calc(88px + env(safe-area-inset-bottom));
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   MOBILE FORM POLISH
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 991.98px) {
  /* Cards get a soft shadow and rounded corners */
  .card {
    border: none;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.04);
    border-radius: 0.75rem !important;
  }
  .card-header {
    border-radius: 0.75rem 0.75rem 0 0 !important;
    background: #fff;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  }

  /* Wrap the entire accordion in one card surface */
  #rapportAccordion {
    background: #fff;
    border-radius: 0.75rem;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.04);
    overflow: hidden;
  }
  .accordion-item {
    border-left: none;
    border-right: none;
    border-radius: 0 !important;
  }
  .accordion-item + .accordion-item {
    border-top: 1px solid rgba(0, 0, 0, 0.06);
  }
  .accordion-button {
    background: #fff;
    font-size: 0.95rem;
  }
  .accordion-button:not(.collapsed) {
    background: #fff;
    color: var(--bs-primary);
    box-shadow: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  }

  /* Row cards */
  #labor-cards .card,
  #material-cards .card {
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    border-radius: 0.625rem !important;
  }
  #labor-cards .card-body,
  #material-cards .card-body {
    padding: 0.75rem;
  }

  /* Add-row buttons: dashed border signals "tap to add" */
  #add-labor-row,
  #add-material-row {
    border-style: dashed;
    border-radius: 0.5rem;
    font-size: 1rem;
    padding: 0.625rem 1rem;
    color: var(--bs-primary);
    border-color: var(--bs-primary);
    background: transparent;
  }
  #add-labor-row:hover,  #add-labor-row:focus,
  #add-material-row:hover, #add-material-row:focus {
    background-color: rgba(11, 94, 215, 0.06);
  }

  .accordion-body .form-label {
    font-weight: 500;
  }
  .section-progress {
    font-size: 0.75rem;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   FORM INPUTS
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Labels ─────────────────────────────────────────────────────────────────── */
.form-label {
  font-size: var(--text-xs);
  font-weight: var(--fw-medium);
  color: var(--color-neutral-700);
  margin-bottom: var(--space-1);
}
/* Neutralise .small stacking on top of our already-small label */
.form-label.small { font-size: var(--text-xs); }

/* ─── Input height ───────────────────────────────────────────────────────────── */
.form-control,
.form-select {
  min-height: 40px;
}
@media (pointer: coarse) {
  .form-control,
  .form-select { min-height: 44px; }
}
/* Compact for desktop table rows */
#labor-table .form-control,
#material-table .form-control {
  min-height: 34px;
  font-size: var(--text-sm);
  padding-block: var(--space-1);
}

/* ─── Input groups ───────────────────────────────────────────────────────────── */
.input-group-text {
  background-color: var(--color-neutral-100);
  color: var(--color-neutral-600);
  border-color: var(--color-neutral-300);
  font-size: var(--text-sm);
}

/* ─── Helper text ────────────────────────────────────────────────────────────── */
.form-text {
  font-size: var(--text-xs);
  color: var(--color-neutral-500);
  margin-top: var(--space-1);
}

/* ─── Validation ─────────────────────────────────────────────────────────────── */
.form-control.is-invalid,
.form-select.is-invalid {
  border-color: var(--color-danger-fg);
}
.invalid-feedback {
  font-size: var(--text-xs);
  color: var(--color-danger-fg);
  margin-top: var(--space-1);
}

/* ─── Add-row buttons ────────────────────────────────────────────────────────── */
#add-labor-row,
#add-material-row {
  border-style: dashed;
  color: var(--color-primary-600);
  border-color: var(--color-primary-400);
}
#add-labor-row:hover,    #add-labor-row:focus,
#add-material-row:hover, #add-material-row:focus {
  border-style: solid;
  background-color: var(--color-primary-50);
  color: var(--color-primary-700);
  border-color: var(--color-primary-500);
}

/* ─── Signature pad (form) ───────────────────────────────────────────────────── */
.sig-container {
  position: relative;
  border: 1.5px solid var(--color-neutral-300);
  border-radius: var(--radius-md);
  background: var(--color-neutral-50);
  touch-action: none;
  overflow: hidden;
}
.sig-container:focus-within {
  border-color: var(--color-primary-400);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}
.sig-clear-btn {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  z-index: 1;
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
  line-height: 1.4;
  opacity: 0.6;
  transition: opacity var(--transition-fast);
}
.sig-clear-btn:hover { opacity: 1; }
.sig-name-input { margin-top: var(--space-2); }

/* ═══════════════════════════════════════════════════════════════════════════
   DASHBOARD
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── KPI cards ─────────────────────────────────────────────────────────────── */
.kpi-card {
  transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}
.kpi-card .card-body {
  padding: var(--space-4) var(--space-4) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* Hover elevation only on link-wrapped cards */
.kpi-link:hover .kpi-card {
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.kpi-link { cursor: pointer; }

.kpi-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.kpi-icon--drafts  { background: var(--color-primary-100);  color: var(--color-primary-600); }
.kpi-icon--progress{ background: var(--color-warning-bg);   color: var(--color-warning-fg); }
.kpi-icon--done    { background: var(--color-success-bg);   color: var(--color-success-fg); }
.kpi-icon--revenue { background: rgba(139, 92, 246, 0.12);  color: #7c3aed; }

.kpi-value {
  font-size: var(--text-3xl);
  font-weight: var(--fw-semibold);
  line-height: var(--leading-tight);
  color: var(--color-neutral-900);
  letter-spacing: -0.02em;
}
.kpi-value--sm { font-size: var(--text-xl); }

.kpi-label {
  font-size: var(--text-sm);
  color: var(--color-neutral-600);
  font-weight: var(--fw-regular);
}

.kpi-trend {
  font-size: var(--text-xs);
  font-weight: var(--fw-medium);
}
.kpi-trend--up   { color: var(--color-success-fg); }
.kpi-trend--down { color: var(--color-danger-fg); }

/* ─── Status chip strip ──────────────────────────────────────────────────────── */
.status-strip {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px; /* prevent shadow clip */
}
.status-strip::-webkit-scrollbar { display: none; }

.status-strip-meta {
  margin-left: auto;
  flex-shrink: 0;
  font-size: var(--text-xs);
  color: var(--color-neutral-500);
  white-space: nowrap;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  height: 28px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--fw-medium);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  transition: opacity var(--transition-fast);
}
.status-chip:hover { opacity: 0.75; text-decoration: none; }

.status-chip-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: var(--fw-semibold);
  padding: 0 3px;
}

.status-chip--draft       { background: var(--color-neutral-200); color: var(--color-neutral-700); }
.status-chip--draft       .status-chip-count { background: var(--color-neutral-400); color: #fff; }
.status-chip--in-progress { background: var(--color-primary-100); color: var(--color-primary-700); }
.status-chip--in-progress .status-chip-count { background: var(--color-primary-400); color: #fff; }
.status-chip--completed   { background: var(--color-success-bg);  color: var(--color-success-fg); }
.status-chip--completed   .status-chip-count { background: #22c55e; color: #fff; }
.status-chip--invoiced    { background: var(--color-info-bg);     color: var(--color-info-fg); }
.status-chip--invoiced    .status-chip-count { background: var(--color-primary-400); color: #fff; }
.status-chip--archived    { background: var(--color-neutral-200); color: var(--color-neutral-600); }
.status-chip--archived    .status-chip-count { background: var(--color-neutral-400); color: #fff; }

/* ─── Recent rapporte card ───────────────────────────────────────────────────── */
.card > .card-header {
  background: #fff;
}

.btn-link-icon {
  display: inline-flex;
  align-items: center;
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--color-primary-600);
  text-decoration: none;
  gap: 2px;
}
.btn-link-icon:hover { color: var(--color-primary-700); text-decoration: none; }

/* Desktop table head */
.dash-thead th {
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-neutral-500);
  background: var(--color-neutral-50);
  border-bottom-color: var(--color-neutral-200);
  padding-block: var(--space-3);
}

/* Mobile rows */
.dash-row {
  display: block;
  padding: var(--space-3) var(--space-4);
  text-decoration: none;
  color: inherit;
  border-top: 1px solid var(--color-neutral-100);
  transition: background-color var(--transition-fast);
}
.dash-row:first-child { border-top: none; }
.dash-row:hover { background-color: var(--color-neutral-50); text-decoration: none; color: inherit; }

.dash-row__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}
.dash-row__nr {
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  color: var(--color-neutral-900);
}
.dash-row__customer {
  font-size: var(--text-sm);
  color: var(--color-neutral-700);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-row__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 3px;
}
.dash-row__date   { font-size: var(--text-xs); color: var(--color-neutral-500); }
.dash-row__amount { font-size: var(--text-sm); font-weight: var(--fw-medium); color: var(--color-neutral-700); }

/* Empty state */
.dash-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-12) var(--space-4);
  text-align: center;
}
.dash-empty__icon {
  font-size: 2.5rem;
  color: var(--color-neutral-300);
  margin-bottom: var(--space-3);
}
.dash-empty__title {
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--color-neutral-500);
}

/* ═══════════════════════════════════════════════════════════════════════════
   RAPPORT VIEW
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Page header ────────────────────────────────────────────────────────────── */
.rp-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}
.rp-page-header__left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}
.rp-back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-neutral-200);
  color: var(--color-neutral-600);
  background: #fff;
  text-decoration: none;
  flex-shrink: 0;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}
.rp-back-btn:hover {
  background: var(--color-neutral-100);
  color: var(--color-neutral-900);
  text-decoration: none;
}
.rp-title-block { min-width: 0; }
.rp-title-label {
  display: block;
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-neutral-500);
  line-height: 1;
  margin-bottom: var(--space-1);
}
.rp-title-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: nowrap;
}
.rp-title-nr {
  font-size: var(--text-2xl);
  font-weight: var(--fw-semibold);
  color: var(--color-neutral-900);
  line-height: var(--leading-tight);
  white-space: nowrap;
}
.rp-page-header__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}
@media (max-width: 479.98px) {
  .rp-page-header__actions { width: 100%; }
  .rp-action--wide { display: none !important; }
}
@media (min-width: 480px) {
  .rp-overflow { display: none !important; }
}

/* ─── Overflow "…" menu (<details>) ─────────────────────────────────────────── */
.rp-overflow { position: relative; }
.rp-overflow > summary {
  list-style: none;
  cursor: pointer;
}
.rp-overflow > summary::-webkit-details-marker { display: none; }
.rp-overflow__menu {
  position: absolute;
  top: calc(100% + var(--space-1));
  right: 0;
  z-index: 100;
  background: #fff;
  border: 1px solid var(--color-neutral-200);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  min-width: 160px;
  overflow: hidden;
}
.rp-overflow__item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--fw-regular);
  color: var(--color-neutral-700);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  transition: background-color var(--transition-fast);
}
.rp-overflow__item:hover {
  background: var(--color-neutral-50);
  color: var(--color-neutral-900);
  text-decoration: none;
}

/* ─── Section card headers ───────────────────────────────────────────────────── */
.rp-section-header {
  display: flex;
  align-items: center;
  height: 48px;
  gap: var(--space-3);
  padding-inline: var(--space-4);
  background: #fff;
  /* overrides bootstrap-overrides .card>.card-header background already #fff */
}
.rp-section-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-md);
  background: var(--color-neutral-100);
  color: var(--color-neutral-600);
  font-size: 16px;
  flex-shrink: 0;
}
.rp-section-title {
  font-size: var(--text-base);
  font-weight: var(--fw-semibold);
  color: var(--color-neutral-900);
}
.rp-card-body {
  padding: var(--space-4) var(--space-5);
}

/* ─── Label / value grid (definition list) ───────────────────────────────────── */
.rp-info-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}
.rp-info-label {
  font-size: var(--text-xs);
  font-weight: var(--fw-medium);
  color: var(--color-neutral-500);
  margin-bottom: 2px;
  line-height: var(--leading-normal);
}
.rp-info-value {
  font-size: var(--text-sm);
  color: var(--color-neutral-900);
  margin: 0;
  line-height: var(--leading-normal);
}
@media (min-width: 768px) {
  .rp-info-grid {
    display: grid;
    grid-template-columns: 180px 1fr;
    align-items: baseline;
    row-gap: var(--space-3);
    column-gap: var(--space-4);
  }
  .rp-info-item { display: contents; }
  .rp-info-label { margin-bottom: 0; }
}

/* ─── Tables (Arbeitszeit, Material) ─────────────────────────────────────────── */
.rp-table thead th {
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-neutral-500);
  background: var(--color-neutral-50);
  border-bottom-color: var(--color-neutral-200);
  padding-block: var(--space-3);
}
.rp-table tfoot td {
  background: var(--color-neutral-50);
  border-top: 1px solid var(--color-neutral-200) !important;
  font-weight: var(--fw-semibold);
}

/* ─── Pauschalen subtotal row ────────────────────────────────────────────────── */
.rp-subtotal-row td {
  background: var(--color-neutral-50);
  font-weight: var(--fw-semibold);
  border-top: 1px solid var(--color-neutral-200) !important;
}

/* ─── Totals sidebar ─────────────────────────────────────────────────────────── */
.rp-totals-table td { padding-block: var(--space-2); }
.rp-totals-grand td {
  font-size: var(--text-lg);
  font-weight: var(--fw-bold);
  background: var(--color-primary-50);
  border-top: 2px solid var(--color-primary-200) !important;
}

/* ─── Signatures ─────────────────────────────────────────────────────────────── */
.rp-sig-heading {
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--color-neutral-500);
  margin-bottom: var(--space-2);
}
.rp-sig-pad {
  border: 1px solid var(--color-neutral-200);
  border-radius: var(--radius-md);
  background: var(--color-neutral-50);
  padding: var(--space-2);
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.rp-sig-pad img {
  width: 100%;
  max-height: 80px;
  object-fit: contain;
  display: block;
}
.rp-sig-pad--empty {
  font-size: var(--text-xs);
  color: var(--color-neutral-400);
  font-style: italic;
}
.rp-sig-meta { margin-top: var(--space-2); }
.rp-sig-name {
  display: block;
  font-size: var(--text-xs);
  font-weight: var(--fw-medium);
  color: var(--color-neutral-700);
}
.rp-sig-date {
  display: block;
  font-size: var(--text-xs);
  color: var(--color-neutral-500);
}

/* ═══════════════════════════════════════════════════════════════════════════
   LIST VIEWS
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Touch-target safety net ────────────────────────────────────────────────── */
.pagination .page-link {
  min-height: 44px;
  min-width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lv-table .dropdown-toggle { min-height: 44px; min-width: 44px; }

/* ─── Sticky filter bar ──────────────────────────────────────────────────────── */
.filter-bar {
  position: sticky;
  top: 56px;         /* clears the 56px mobile topbar */
  z-index: 99;
}
@media (min-width: 992px) { .filter-bar { top: 0; } }

/* ─── Mobile integrated search / filter bar ─────────────────────────────────── */
.search-filter-bar {
  background: var(--color-neutral-100);
  padding-block: var(--space-2);
}

.search-bar-group {
  border-radius: var(--radius-md);
  border: 1px solid var(--color-neutral-300);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
  height: 44px;
}

.search-bar-group .input-group-text,
.search-bar-group .form-control,
.search-bar-group .btn {
  border: none;
  border-radius: 0;
  box-shadow: none !important;
}

.search-bar-icon {
  background: #fff;
  color: var(--color-neutral-400);
  padding-right: var(--space-1);
}

.search-bar-input {
  background: #fff;
  color: var(--color-neutral-900);
  font-size: var(--text-sm);
  padding-left: var(--space-2);
}

.search-bar-input:focus {
  background: #fff;
  color: var(--color-neutral-900);
  box-shadow: none !important;
  outline: none;
}

.search-bar-filter-btn {
  background: var(--color-neutral-100);
  color: var(--color-neutral-600);
  border-left: 1px solid var(--color-neutral-200) !important;
  padding-inline: var(--space-4);
  position: relative;
  min-width: 48px;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.search-bar-filter-btn:hover,
.search-bar-filter-btn:focus-visible {
  background: var(--color-neutral-200);
  color: var(--color-neutral-800);
}

.filter-active-dot {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--color-primary-500);
}

.search-filter-meta {
  display: flex;
  justify-content: flex-end;
  padding-top: var(--space-1);
  font-size: var(--text-sm);
}

/* ─── Desktop data table ─────────────────────────────────────────────────────── */
.lv-table {
  border-collapse: collapse;
  width: 100%;
}
.lv-table thead th {
  background: var(--color-neutral-50);
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-neutral-500);
  /* box-shadow instead of border-bottom: border-collapse:collapse shares the border
     between thead and tbody, so it disappears when the header is position:sticky */
  box-shadow: inset 0 -2px 0 var(--color-neutral-200);
  padding-block: var(--space-3);
  white-space: nowrap;
}
@media (min-width: 992px) {
  .lv-table thead th {
    position: sticky;
    top: 88px; /* fallback — overridden by list-ux.js ResizeObserver */
    z-index: 1;
  }
}
/* Card-like wrapper for the desktop list table. Unlike .card + .overflow-hidden
   + .table-responsive, this creates no scrolling ancestor, so the sticky thead
   resolves against the page viewport. overflow:clip rounds the corners without
   establishing a scroll container. */
.lv-table-card {
  background: #fff;
  border: 1px solid var(--color-neutral-200);
  border-radius: var(--radius-lg);
  overflow: clip;
  box-shadow: var(--shadow-xs);
}
.lv-table tbody tr[data-href] { cursor: pointer; }
.lv-table tbody tr:hover      { background-color: var(--color-neutral-50); }
.lv-table tbody td {
  border-bottom: 1px solid var(--color-neutral-100);
  padding-block: 0.6875rem;
  vertical-align: middle;
}
.lv-table tbody tr:focus-visible { outline: 2px solid var(--color-primary-400); outline-offset: -2px; }

/* ─── Mobile list cards ──────────────────────────────────────────────────────── */
.lv-card-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding-bottom: var(--space-2);
}
.lv-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: #fff;
  border: 1px solid var(--color-neutral-200);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: inherit;
  min-height: 72px;
  transition: background-color var(--transition-fast), box-shadow var(--transition-fast);
  box-shadow: var(--shadow-xs);
}
.lv-card:hover  { background-color: var(--color-neutral-50); box-shadow: var(--shadow-sm); }
.lv-card:active { background-color: var(--color-neutral-100); }
.lv-card__body  { flex: 1; min-width: 0; }
.lv-card__title {
  font-weight: var(--fw-semibold);
  color: var(--color-neutral-900);
  font-size: var(--text-base);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: var(--space-1);
}
.lv-card__meta {
  font-size: var(--text-sm);
  color: var(--color-neutral-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lv-card__aside {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-1);
  min-width: max-content;
}
.lv-card__amount {
  font-weight: var(--fw-semibold);
  font-size: var(--text-sm);
  color: var(--color-neutral-800);
  font-variant-numeric: tabular-nums;
}
.lv-card__unit {
  font-size: var(--text-xs);
  color: var(--color-neutral-400);
}
.lv-card__chevron {
  color: var(--color-neutral-300);
  font-size: 0.875rem;
  flex-shrink: 0;
}

/* ─── Empty state ─────────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 4rem var(--space-4);
}
.empty-state__icon {
  font-size: 3.5rem;
  color: var(--color-neutral-300);
  margin-bottom: var(--space-4);
  line-height: 1;
}
.empty-state__title {
  font-size: var(--text-base);
  font-weight: var(--fw-semibold);
  color: var(--color-neutral-700);
  margin-bottom: var(--space-2);
}
.empty-state__sub {
  font-size: var(--text-sm);
  color: var(--color-neutral-500);
  margin-bottom: var(--space-5);
  max-width: 30ch;
}

/* ─── Skeleton shimmer ─────────────────────────────────────────────────────────── */
@keyframes skeleton-shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position:  400px 0; }
}
.skeleton {
  display: inline-block;
  width: 100%;
  height: 0.8rem;
  border-radius: var(--radius-sm);
  background: linear-gradient(
    90deg,
    var(--color-neutral-100) 25%,
    var(--color-neutral-200) 50%,
    var(--color-neutral-100) 75%
  );
  background-size: 800px 0.8rem;
  animation: skeleton-shimmer 1.6s ease-in-out infinite;
}
.skeleton-row td { padding-block: 1rem; }
.skeleton-row:nth-child(odd)  .skeleton { width: 80%; }
.skeleton-row:nth-child(even) .skeleton { width: 55%; }

/* ═══════════════════════════════════════════════════════════════════════════
   FLOATING ACTION BUTTON (mobile only)
   ═══════════════════════════════════════════════════════════════════════════ */

.page-fab {
  position: fixed;
  bottom: calc(16px + env(safe-area-inset-bottom));
  right: 1.25rem;
  z-index: 1030;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--color-primary-600);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  line-height: 1;
  text-decoration: none;
  box-shadow: var(--shadow-md), 0 0 0 4px rgba(59, 130, 246, 0.08);
  transition: transform 0.14s ease, box-shadow 0.14s ease, background-color 0.14s ease;
  -webkit-tap-highlight-color: transparent;
}
.page-fab:hover,
.page-fab:focus {
  background-color: var(--color-primary-700);
  color: #fff;
  transform: scale(1.06);
  box-shadow: var(--shadow-md), 0 0 0 6px rgba(59, 130, 246, 0.14);
  text-decoration: none;
}
.page-fab:active {
  transform: scale(0.95);
}

/* When a FAB exists, add bottom padding so it never covers the last row */
@media (max-width: 991.98px) {
  body:has(.page-fab) .app-main {
    padding-bottom: calc(88px + env(safe-area-inset-bottom));
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   SHARED COMPONENTS
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Prevent iOS zoom-on-focus (all inputs ≥16px) ─────────────────────────── */
input, select, textarea {
  font-size: 16px !important;
}

/* ─── Hide number input spinners (thumb-hostile) ────────────────────────────── */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { display: none; }
input[type="number"] { -moz-appearance: textfield; }

/* ─── Signature canvas ──────────────────────────────────────────────────────── */
.signature-canvas {
  touch-action: none;
  cursor: crosshair;
  width: 100%;
  aspect-ratio: 3 / 1;
  display: block;
}
@media (max-width: 991.98px) {
  .signature-canvas { aspect-ratio: 2 / 1; }
}

/* ─── Sticky totals sidebar (desktop) ───────────────────────────────────────── */
@media (min-width: 992px) {
  .totals-sidebar { position: sticky; top: 1rem; }
}

/* ─── Row delete button (min touch target) ──────────────────────────────────── */
.btn-row-delete { min-height: 44px; min-width: 44px; }

/* Status badge colors live in bootstrap-overrides.css */

/* ─── Loading button spinner ────────────────────────────────────────────────── */
.btn-loading { position: relative; pointer-events: none; opacity: 0.8; }
.btn-loading::after {
  content: '';
  position: absolute;
  right: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1rem;
  height: 1rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: btn-spin 0.6s linear infinite;
}
@keyframes btn-spin { to { transform: translateY(-50%) rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .btn-loading::after { animation: none; }
  .accordion-collapse { transition: none !important; }
  .modal.fade .modal-dialog { transition: none !important; }
  .app-sidebar { transition: none !important; }
  .sidebar-backdrop { transition: none !important; }
}

/* ─── Accordion button ──────────────────────────────────────────────────────── */
.accordion-button { font-weight: 600; }

/* ─── Autocomplete dropdown ─────────────────────────────────────────────────── */
.autocomplete-wrapper { position: relative; }
.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 1050;
  max-height: 260px;
  overflow-y: auto;
}

/* ─── Accordion progress bar ────────────────────────────────────────────────── */
.section-progress { font-size: 0.8rem; }

/* ─── Print-only ────────────────────────────────────────────────────────────── */
.print-only { display: none; }
@media print { .print-only { display: block; } }

/* ─── Whitespace preserve ───────────────────────────────────────────────────── */
.ws-pre-wrap { white-space: pre-wrap; }

/* ─── Offline warning banner ────────────────────────────────────────────────── */
.offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2000;
  background: #ffc107;
  color: #000;
  text-align: center;
  padding: 0.4rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
}

/* ═══════════════════════════════════════════════════════════════════════════
   PRINT
   ═══════════════════════════════════════════════════════════════════════════ */
/* ═══════════════════════════════════════════════════════════════════════════
   UTILITY CLASSES
   ═══════════════════════════════════════════════════════════════════════════ */

.u-hidden         { display: none; }
.u-cursor-pointer { cursor: pointer; }
.u-cursor-default { cursor: default; }
.u-font-mono      { font-family: monospace; }
.u-meta-text      { font-size: var(--text-xs); color: var(--color-neutral-500); }
.u-touch-target   { min-height: 44px; }

/* Max-width caps for form containers and truncated cells */
.u-mw-640 { max-width: 640px; }
.u-mw-600 { max-width: 600px; }
.u-mw-480 { max-width: 480px; }
.u-mw-220 { max-width: 220px; }
.u-mw-200 { max-width: 200px; }
.u-mw-150 { max-width: 150px; }

/* Fixed-width table columns */
.u-w-52  { width: 52px; }
.u-w-50  { width: 50px; }
.u-w-80  { width: 80px; }
.u-w-90  { width: 90px; }
.u-w-110 { width: 110px; }
.u-w-120 { width: 120px; }
.u-w-130 { width: 130px; }

@media print {
  .app-sidebar,
  .sidebar-backdrop,
  .mobile-topbar,
  .form-actionbar,
  .page-fab,
  .btn,
  [data-remove-row],
  .modal,
  .no-print { display: none !important; }

  .app-content { margin-left: 0 !important; }

  .card {
    border: 1px solid #dee2e6 !important;
    break-inside: avoid;
    margin-bottom: 0.5rem !important;
  }
  .card-header {
    background-color: #f8f9fa !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  body { font-size: 10pt; background: #fff; }
  main { padding-bottom: 0 !important; }
  .signature-canvas { border: 1px solid #000 !important; }
  .signature-preview { display: block !important; }
}
