html {
  font-size: 14px;
}

:root {
  --k3-blue: #005ea8;
  --k3-blue-dark: #003e70;
  --k3-blue-soft: #e8f2fb;
  --k3-black: #121821;
  --k3-gray-700: #49566b;
  --k3-gray-200: #dbe3ee;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
}

.app-shell {
  min-height: calc(100vh - 140px);
}

.brand-logo {
  height: 32px;
  width: auto;
}

.signature-wrapper {
  border: 1px solid #ced4da;
  border-radius: 0.375rem;
  background: #f8f9fa;
  height: 180px;
  position: relative;
}

.signature-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

.signature-wrapper.disabled .signature-canvas {
  pointer-events: none;
  opacity: 0.5;
}

.signature-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.9);
  pointer-events: none;
}

.signature-overlay.hidden {
  display: none;
}

.dashboard-page {
  color: var(--k3-black);
}

.dashboard-title {
  color: var(--k3-blue-dark);
  font-weight: 700;
}

.dashboard-subtitle,
.dashboard-generated-at {
  color: var(--k3-gray-700) !important;
}

.dashboard-kpi-card,
.dashboard-card,
.dashboard-link-card {
  border: 1px solid var(--k3-gray-200) !important;
  box-shadow: 0 0.5rem 1.25rem rgba(18, 24, 33, 0.07) !important;
}

.dashboard-kpi-card {
  background: linear-gradient(160deg, #ffffff 0%, var(--k3-blue-soft) 100%);
}

.dashboard-kpi-label {
  color: var(--k3-gray-700) !important;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  font-weight: 600;
}

.dashboard-kpi-value {
  color: var(--k3-blue-dark);
}

.dashboard-card .card-title {
  color: var(--k3-blue-dark);
  font-weight: 700;
}

.dashboard-table thead th {
  color: var(--k3-blue-dark);
  border-bottom-color: var(--k3-gray-200);
}

.dashboard-table tbody td {
  border-bottom-color: #edf2f8;
}

.dashboard-top-box {
  border-color: var(--k3-gray-200) !important;
  background: var(--k3-blue-soft) !important;
}

.dashboard-link-card {
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.dashboard-link-card:hover {
  transform: translateY(-2px);
  border-color: rgba(0, 94, 168, 0.35) !important;
  box-shadow: 0 0.75rem 1.5rem rgba(0, 62, 112, 0.16) !important;
}

.dashboard-link-card .card-title {
  color: var(--k3-blue-dark);
  font-weight: 700;
}

.dashboard-link-text {
  color: var(--k3-gray-700) !important;
}

.dashboard-chart-container {
  min-height: 260px;
}

.photo-preview-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.photo-thumb-item img,
#nachweisImagesPreview img,
#workTimeImagesPreview img {
  max-width: 100%;
}

.weekly-time-table {
  min-width: 860px;
}

.weekly-time-table th:first-child,
.weekly-time-table td:first-child {
  position: sticky;
  left: 0;
  background: #fff;
  z-index: 1;
}

.weekly-time-table thead th:first-child {
  z-index: 2;
}

.dashboard-list-page {
  color: var(--k3-black);
}

.dashboard-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.dashboard-list-title {
  margin-bottom: 0.15rem;
  color: var(--k3-blue-dark);
  font-weight: 700;
}

.dashboard-list-subtitle {
  margin-bottom: 0;
  color: var(--k3-gray-700);
}

.dashboard-list-card {
  border: 1px solid var(--k3-gray-200);
  border-radius: 0.75rem;
  box-shadow: 0 0.5rem 1.25rem rgba(18, 24, 33, 0.07);
  background-color: #fff;
}

.dashboard-list-table {
  margin-bottom: 0;
}

.dashboard-list-table thead th {
  color: var(--k3-blue-dark);
  border-bottom-color: var(--k3-gray-200);
  font-weight: 700;
}

.dashboard-list-table thead th.sortable-column {
  cursor: pointer;
  position: relative;
  user-select: none;
  padding-right: 1.5rem;
}

.dashboard-list-table thead th.sortable-column::after {
  content: "↕";
  position: absolute;
  right: 0.45rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.85rem;
  color: #7a8799;
}

.dashboard-list-table thead th.sortable-column.sorted-asc::after {
  content: "↑";
  color: var(--k3-blue-dark);
}

.dashboard-list-table thead th.sortable-column.sorted-desc::after {
  content: "↓";
  color: var(--k3-blue-dark);
}

.dashboard-list-table thead th.sortable-column:focus-visible {
  outline: 2px solid rgba(37, 140, 251, 0.65);
  outline-offset: -2px;
}

.dashboard-list-table tbody td {
  border-bottom-color: #edf2f8;
  vertical-align: middle;
}

.table-text-clamp-2 {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  white-space: normal;
  line-height: 1.35;
  max-height: calc(1.35em * 2);
  overflow-wrap: anywhere;
}

.dashboard-list-table tbody tr:hover {
  background-color: rgba(0, 94, 168, 0.04);
}

.dashboard-list-table tbody tr.worktime-overtime-warning {
  background-color: rgba(255, 193, 7, 0.18);
}

.dashboard-list-table tbody tr.worktime-overtime-warning:hover {
  background-color: rgba(255, 193, 7, 0.28);
}

.dashboard-actions {
  white-space: nowrap;
}

.dashboard-actions .btn {
  margin-left: 0.35rem;
}

.dashboard-monteur-action-btn {
  min-height: 44px;
  font-weight: 600;
}

.detail-page,
.delete-page {
  color: var(--k3-black);
}

.detail-title {
  color: var(--k3-blue-dark);
  font-weight: 700;
  margin-bottom: 1rem;
}

.detail-card,
.confirm-card {
  border: 1px solid var(--k3-gray-200);
  border-radius: 0.9rem;
  padding: 1rem;
  background: #fff;
  box-shadow: 0 0.5rem 1.25rem rgba(18, 24, 33, 0.07);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.9rem;
}

.detail-item {
  padding: 0.9rem;
  border: 1px solid #edf2f8;
  border-radius: 0.75rem;
  background: #fbfdff;
}

.detail-item-full {
  grid-column: 1 / -1;
}

.detail-label,
.detail-section-title {
  margin-bottom: 0.35rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--k3-gray-700);
}

.detail-value {
  white-space: pre-line;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.detail-mobile-table {
  margin-bottom: 0;
}

.detail-mobile-table thead th {
  color: var(--k3-blue-dark);
}

.danger-zone-card {
  border: 2px solid #dc3545;
  background: linear-gradient(180deg, rgba(220, 53, 69, 0.08) 0%, rgba(255, 255, 255, 0.98) 100%);
}

.danger-zone-alert {
  border-width: 1px;
}

.danger-zone-card code {
  color: #b02a37;
  font-weight: 700;
}

.danger-zone-card #confirmationText {
  border-color: rgba(220, 53, 69, 0.45);
}

.danger-zone-card #confirmationText:focus {
  border-color: #dc3545;
  box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.15);
}

.danger-zone-card #resetDatabaseButton[disabled] {
  opacity: 0.75;
  cursor: not-allowed;
}

@media (max-width: 767.98px) {
  body {
    margin-bottom: 0;
  }

  .mobile-form .form-control,
  .mobile-form .form-select,
  .mobile-form .btn {
    min-height: 44px;
  }

  .form-check-input[type="checkbox"],
  .form-check-input[type="radio"] {
    width: 1.2rem;
    height: 1.2rem;
    min-height: 0;
    flex: 0 0 auto;
  }

  .mobile-form .form-check {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding-left: 0;
    min-height: 1.5rem;
  }

  .mobile-form .form-check .form-check-input {
    float: none;
    margin-left: 0;
    margin-top: 0.15rem;
  }

  .mobile-form .form-check .form-check-label {
    flex: 1 1 auto;
    margin-bottom: 0;
  }

  .mobile-form textarea.form-control {
    min-height: 96px;
  }

  .mobile-form .form-label {
    margin-bottom: 0.35rem;
    font-weight: 600;
  }

  .mobile-form .text-muted {
    font-size: 0.82rem;
  }

  .mobile-form .row {
    --bs-gutter-y: 0.75rem;
  }

  .form-action-bar {
    position: sticky;
    bottom: 0;
    z-index: 20;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.85rem 0 calc(0.85rem + env(safe-area-inset-bottom));
    margin-top: 1rem;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(6px);
    border-top: 1px solid var(--k3-gray-200);
  }

  .form-action-bar .btn,
  .form-action-bar a.btn {
    flex: 1 1 220px;
  }

  .signature-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .signature-actions .btn {
    width: 100%;
  }

  .photo-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
    gap: 0.5rem;
  }

  .photo-thumb-item,
  .photo-preview-grid > div {
    width: 100%;
  }

  .photo-thumb-item img,
  .photo-preview-grid img,
  #nachweisImagesPreview img,
  #workTimeImagesPreview img {
    width: 100%;
    height: 92px !important;
    object-fit: cover;
  }

  .nachweis-form #deleteAllPhotosBtn {
    width: 100%;
  }

  .monteur-table,
  .material-entry-table {
    min-width: 100%;
  }

  .monteur-table thead,
  .material-entry-table thead {
    display: none;
  }

  .monteur-table tbody tr,
  .material-entry-table tbody tr {
    display: grid;
    gap: 0.5rem;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    border: 1px solid var(--k3-gray-200);
    border-radius: 0.75rem;
    background: #fff;
    box-shadow: 0 0.25rem 0.75rem rgba(18, 24, 33, 0.05);
  }

  .monteur-table tbody td,
  .material-entry-table tbody td {
    display: block;
    border: 0;
    padding: 0;
  }

  .monteur-table tbody td::before,
  .material-entry-table tbody td::before {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--k3-gray-700);
  }

  .monteur-table tbody td:nth-child(1)::before { content: "Monteur"; }
  .monteur-table tbody td:nth-child(2)::before { content: "MA"; }
  .monteur-table tbody td:nth-child(3)::before { content: "Aktion"; }

  .material-entry-table tbody td:nth-child(1)::before { content: "Menge"; }
  .material-entry-table tbody td:nth-child(2)::before { content: "ME"; }
  .material-entry-table tbody td:nth-child(3)::before { content: "Bezeichnung"; }
  .material-entry-table tbody td:nth-child(4)::before { content: "Art.-Nr."; }
  .material-entry-table tbody td:nth-child(5)::before { content: "Aktion"; }

  .worktime-form .material-entry-table tbody td:nth-child(1)::before { content: "Artikel"; }
  .worktime-form .material-entry-table tbody td:nth-child(2)::before { content: "Menge"; }
  .worktime-form .material-entry-table tbody td:nth-child(3)::before { content: "Aktion"; }

  .monteur-table .btn,
  .material-entry-table .btn {
    width: 100%;
  }

  .brand-logo {
    height: 28px;
  }

  .dashboard-page {
    padding-bottom: 1rem;
  }

  .dashboard-title {
    font-size: 1.5rem;
    line-height: 1.2;
  }

  .dashboard-subtitle,
  .dashboard-generated-at {
    font-size: 0.875rem;
  }

  .dashboard-kpi-card .card-body,
  .dashboard-card .card-body,
  .dashboard-link-card .card-body,
  .dashboard-list-card {
    padding: 0.9rem;
  }

  .dashboard-kpi-label {
    font-size: 0.72rem;
    line-height: 1.2;
  }

  .dashboard-kpi-value {
    font-size: 1.6rem !important;
    line-height: 1.1;
  }

  .dashboard-card .card-title,
  .dashboard-link-card .card-title,
  .dashboard-list-title {
    font-size: 1rem;
  }

  .dashboard-table,
  .dashboard-list-table {
    font-size: 0.9rem;
  }

  .dashboard-table thead th,
  .dashboard-table tbody td,
  .dashboard-list-table thead th,
  .dashboard-list-table tbody td {
    padding: 0.55rem 0.4rem;
  }

  .dashboard-chart-container {
    min-height: 200px;
  }

  .dashboard-link-card {
    min-height: 100%;
  }

  .dashboard-link-card .card-body {
    min-height: 88px;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .dashboard-actions {
    white-space: normal;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
  }

  .dashboard-actions .btn {
    margin-left: 0;
    min-height: 42px;
  }

  .dashboard-monteur-actions {
    width: 100%;
  }

  .dashboard-monteur-action-btn {
    width: 100%;
    min-height: 52px;
    font-size: 1.05rem;
    padding: 0.8rem 1rem;
  }

  .list-header-actions,
  .list-filter-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .list-header-actions > .btn,
  .list-filter-actions > .btn,
  .list-filter-actions > a,
  .list-primary-action {
    flex: 1 1 100%;
  }

  .list-filter-form .form-label {
    margin-bottom: 0.35rem;
  }

  .list-filter-form .form-control,
  .list-filter-form .form-select {
    min-height: 2.75rem;
  }

  .mobile-list-table thead {
    display: none;
  }

  .mobile-list-table,
  .mobile-list-table tbody,
  .mobile-list-table tr,
  .mobile-list-table td {
    display: block;
    width: 100%;
  }

  .mobile-list-table tbody {
    display: grid;
    gap: 1rem;
  }

  .mobile-list-table tr {
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 1rem;
    padding: 0.9rem;
    background: #fff;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  }

  .mobile-list-table td {
    border: 0;
    padding: 0.35rem 0;
    text-align: left !important;
  }

  .mobile-list-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 0.15rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: #64748b;
  }

  .mobile-list-table .dashboard-actions {
    margin-top: 0.5rem;
    padding-top: 0.6rem;
    border-top: 1px solid rgba(15, 23, 42, 0.08);
    justify-content: stretch;
  }

  .mobile-list-table .dashboard-actions > .btn {
    flex: 1 1 calc(50% - 0.5rem);
  }

  .worktimes-mobile-table td[data-label="Auswahl"]::before {
    content: none;
  }

  .worktimes-mobile-table td[data-label="Auswahl"] {
    padding-bottom: 0.6rem;
  }

  .worktimes-mobile-table td[data-label="Auswahl"] .form-check-input {
    margin: 0;
  }

  .detail-card,
  .confirm-card {
    padding: 0.9rem;
  }

  .detail-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .detail-item {
    padding: 0.8rem;
  }

  .detail-actions > .btn,
  .detail-actions > a,
  .detail-actions > button {
    flex: 1 1 100%;
  }

  .detail-mobile-table thead {
    display: none;
  }

  .detail-mobile-table,
  .detail-mobile-table tbody,
  .detail-mobile-table tr,
  .detail-mobile-table td {
    display: block;
    width: 100%;
  }

  .detail-mobile-table tbody {
    display: grid;
    gap: 0.75rem;
  }

  .detail-mobile-table tr {
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 0.8rem;
    padding: 0.75rem;
    background: #fff;
  }

  .detail-mobile-table td {
    border: 0;
    padding: 0.2rem 0;
  }

  .detail-mobile-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 0.15rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #64748b;
  }

  .signature-wrapper {
    height: 150px;
  }
}

@media (max-width: 575.98px) {
  html {
    font-size: 14px;
  }

  .mobile-form .card-body,
  .mobile-form .border.rounded,
  .mobile-form .table-responsive {
    border-radius: 0.75rem;
  }

  .mobile-form .position-relative .dropdown-menu {
    max-height: 40vh;
    overflow-y: auto;
  }

  .weekly-time-table {
    min-width: 760px;
    font-size: 0.85rem;
  }

  .weekly-time-table .form-control {
    min-width: 76px;
    padding-left: 0.35rem;
    padding-right: 0.35rem;
  }

  .dashboard-kpi-value {
    font-size: 1.4rem !important;
  }

  .dashboard-chart-container {
    min-height: 180px;
  }

  .dashboard-table thead {
    display: none;
  }

  .dashboard-table tbody tr {
    display: block;
    padding: 0.55rem 0;
    border-bottom: 1px solid #edf2f8;
  }

  .dashboard-table tbody td {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    border-bottom: 0;
    padding: 0.25rem 0;
  }

  .dashboard-table tbody td:first-child::before {
    content: "Tabelle";
    font-weight: 600;
    color: var(--k3-gray-700);
  }

  .dashboard-table tbody td:last-child::before {
    content: "Einträge";
    font-weight: 600;
    color: var(--k3-gray-700);
  }

  .mobile-list-table .dashboard-actions > .btn {
    flex-basis: 100%;
  }
}

.btn-k3-primary {
  color: #fff;
  background-color: var(--k3-blue);
  border-color: var(--k3-blue);
}

.btn-k3-primary:hover,
.btn-k3-primary:focus {
  color: #fff;
  background-color: var(--k3-blue-dark);
  border-color: var(--k3-blue-dark);
}

.btn-k3-accent {
  color: #fff;
  background-color: var(--k3-black);
  border-color: var(--k3-black);
}

.btn-k3-accent:hover,
.btn-k3-accent:focus {
  color: #fff;
  background-color: #060a12;
  border-color: #060a12;
}

#btnNachweisGenerieren:not(:disabled) {
  color: #fff;
  background-color: var(--k3-blue);
  border-color: var(--k3-blue);
}

#btnNachweisGenerieren:not(:disabled):hover,
#btnNachweisGenerieren:not(:disabled):focus {
  color: #fff;
  background-color: var(--k3-blue-dark);
  border-color: var(--k3-blue-dark);
}