/* ============================================
   MODERN CSS FOR KNEGARE - MOBILE FIRST
   ============================================ */

/* Design System Variables */
:root {
  /* Colors */
  --primary: #197146;
  --primary-rgb: 25, 113, 70;
  --primary-dark: #125434;
  --primary-light: #1f8d57;
  --accent: #1f8d57;
  --danger: #ef4444;
  --warning: #f59e0b;

  /* Grays */
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

  /* Radius */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;

  /* Transitions */
  --transition: all 0.2s ease;
  --transition-fast: all 0.15s ease;

  /* NEW: content padding (för full-bleed-utilityn) */
  --content-pad: 1rem;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.file-input-hidden {
  position: absolute;
  width: 0.1px;
  height: 0.1px;
  padding: 0;
  margin: 0;
  opacity: 0;
  overflow: hidden;
  border: 0;
  clip: rect(0, 0, 0, 0);
}

/* ============================================
   HEADER & NAVIGATION
   ============================================ */
header {
  background: var(--gray-900);
  color: white;
  padding: 0.875rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 50;
}

.emblem {
  font-size: 1.125rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.home-button, .settings, .logout {
  color: white;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.home-button:hover, .settings:hover, .logout:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Search Bar */
.searchbar {
  padding: 0.875rem 1rem;
  background: white;
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 50px;
  z-index: 40;
}

.searchbar input {
  width: 100%;
  padding: 0.625rem 1rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-lg);
  font-size: 0.9375rem;
  transition: var(--transition);
}

.searchbar input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.searchbar button {
  margin-left: 0.5rem;
  padding: 0.625rem 1.25rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-lg);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.searchbar button:hover {
  background: var(--primary-dark);
}

/* ============================================
   GRID & CARDS
   ============================================ */
main {
  padding: var(--content-pad); /* CHANGED: tidigare 1rem */
  max-width: 1400px;
  margin: 0 auto;
}

.grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  align-items: stretch;
}

.project-grid,
.record-grid {
  gap: 1.25rem;
  grid-auto-rows: minmax(0, 1fr);
}

.record-card {
  --card-border: rgba(17, 24, 39, 0.08);
  --card-shadow: 0 10px 22px rgba(17, 24, 39, 0.08);
  background: #fff;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(var(--primary-rgb), 0.35);
  box-shadow: none;
  padding: 1.05rem 1.15rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 220px;
  height: 100%;
}

.record-card__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  background: transparent;
}

.record-card__title-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.record-card__subtitle {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  font-size: 0.8rem;
  color: var(--gray-600);
  line-height: 1.35;
  margin-top: 0.1rem;
}

.record-card__subtitle-item {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  white-space: nowrap;
}

.record-card__title {
  font-size: 1.15rem;
  margin: 0;
  color: var(--gray-900);
}

.record-card__subtitle-single {
  margin-top: 0.15rem;
  font-size: 0.9rem;
  color: var(--gray-600);
}

.record-card__badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: capitalize;
  background: var(--gray-100);
  color: var(--gray-700);
  white-space: nowrap;
}

.record-card__badge--ongoing {
  background: rgba(var(--primary-rgb), 0.1);
  color: var(--primary);
}

.record-card__badge--done {
  background: rgba(76, 175, 80, 0.1);
  color: #256029;
}

.record-card__badge--scheduled {
  background: rgba(59, 130, 246, 0.1);
  color: #1d4ed8;
}

.record-card__pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: rgba(245, 158, 11, 0.12);
  color: #b45309;
}

.record-card__details {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: -0.1rem;
}

.record-card__detail {
  display: flex;
  gap: 0.45rem;
  align-items: flex-start;
  font-size: 0.9rem;
  color: var(--gray-700);
  line-height: 1.3;
}

.record-card__icon {
  font-size: 1rem;
  line-height: 1.4;
}

.record-card__cell--description dd {
  display: block;
  white-space: normal;
}

.record-card__text strong {
  color: var(--gray-800);
  font-weight: 600;
}

.record-card__detail:not(.record-card__detail--description) .record-card__text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.record-card__description {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 2.4em;
  max-height: 2.6em;
  line-height: 1.3;
}

.record-card__footer {
  margin-top: auto;
  padding-top: 0.35rem;
  border-top: 1px solid rgba(var(--primary-rgb), 0.2);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  background: transparent;
}

.record-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.record-card__actions form {
  margin: 0;
}

.record-card__actions .button,
.record-card__actions button {
  width: auto;
  min-width: 0;
}

.record-card__done-label {
  font-size: 0.85rem;
  color: #256029;
  font-weight: 600;
}

.material-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.material-form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

.material-form-row > * {
  flex: 1 1 160px;
  min-width: 0;
}

.material-form-row .unit-field {
  flex: 1 1 120px;
  min-width: 120px;
}

.material-form textarea {
  width: 100%;
  min-height: 70px;
  resize: vertical;
}

.material-form-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.material-form-options label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 500;
}

.material-form-actions {
  display: flex;
  justify-content: flex-end;
}

.material-form input[type='file'] {
  flex: 1 1 220px;
}

@media (max-width: 480px) {
  .record-card {
    padding: 1.15rem;
  }

  .record-card__footer {
    flex-direction: column;
    align-items: stretch;
  }

  .record-card__actions {
    width: 100%;
  }

  .record-card__actions .button,
  .record-card__actions button {
    width: 100%;
  }
}

/* Quick Action Cards (Top Row) */
.row-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
  transition: var(--transition);
  text-decoration: none;
  color: var(--gray-900);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.625rem;
  min-height: 110px;
  width: 100%;
}

.project-card-grid {
  grid-auto-rows: 1fr;
}

.project-card-grid .card.project-card {
  border-color: rgba(var(--primary-rgb), 0.35);
  align-items: flex-start;
  text-align: left;
  justify-content: flex-start;
  gap: 0.35rem;
  cursor: pointer;
  min-height: 220px;
  padding: 1rem 1.1rem;
  position: relative;
}

.project-card strong {
  font-size: 1.05rem;
}

.project-card .card-description {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  width: 100%;
  line-height: 1.3;
  margin: 0.15rem 0;
}

.project-card .card-action {
  margin-top: auto;
  width: 100%;
}

.project-card .card-action button {
  width: 100%;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 0.65rem 1rem;
  font-weight: 600;
}

.project-card .card-action button:hover {
  background: var(--primary-dark);
}

.project-card .card-finished {
  margin-top: auto;
  font-size: 0.9rem;
  color: var(--primary);
  font-weight: 600;
}

.servicejobb-new-form,
.stacked-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: stretch;
  justify-content: flex-start;
  text-align: left;
  min-height: auto;
}

.servicejobb-new-form label,
.stacked-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-weight: 600;
}

.servicejobb-new-form input,
.servicejobb-new-form select,
.servicejobb-new-form textarea,
.stacked-form input,
.stacked-form select,
.stacked-form textarea {
  width: 100%;
}

.servicejobb-new-form small,
.stacked-form small {
  font-weight: 400;
  line-height: 1.4;
}

.stacked-form label.stacked-checkbox {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
}

.stacked-form label.stacked-checkbox span {
  font-weight: 500;
}

.servicejobb-new-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.sj-mobile-accordion {
  display: block;
  padding: 0;
  align-items: stretch;
  justify-content: flex-start;
  text-align: left;
  gap: 0;
  min-height: auto;
}

.sj-mobile-accordion > summary {
  list-style: none;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  cursor: pointer;
}

.sj-mobile-accordion > summary::-webkit-details-marker {
  display: none;
}

.sj-accordion-title {
  flex: 1 1 auto;
  min-width: 0;
}

.sj-accordion-title h3 {
  margin: 0;
}

.sj-accordion-meta {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  text-align: right;
  font-size: 0.9rem;
  color: var(--gray-600);
}

.sj-accordion-icon {
  flex: 0 0 auto;
  padding-top: 0.15rem;
}

.sj-accordion-icon::before {
  content: '⌄';
  display: inline-block;
  font-size: 1rem;
  transition: transform 0.2s ease;
  color: var(--gray-500);
}

.sj-mobile-accordion[open] .sj-accordion-icon::before {
  transform: rotate(180deg);
}

.sj-mobile-accordion[open] > summary {
  border-bottom: 1px solid var(--gray-200);
}

.sj-mobile-accordion .sj-accordion-content {
  padding: 1rem 1.25rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.sj-mobile-accordion .table-wrapper {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}

.sj-mobile-accordion .table {
  width: 100%;
  min-width: 650px;
  border-collapse: collapse;
}

.sj-mobile-accordion .table th,
.sj-mobile-accordion .table td {
  padding: 0.65rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
  font-size: 0.95rem;
}

.sj-mobile-accordion .table th {
  background: var(--gray-50);
  font-weight: 600;
}

.sj-mobile-accordion .table tbody tr:last-child td {
  border-bottom: none;
}

.sj-accordion-badge {
  background: #ffe599;
  color: #664d03;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}

.card:active {
  transform: translateY(0);
}

/* Icon in Cards */
.row-cards .card span:first-child {
  font-size: 1.75rem;
  line-height: 1;
}

.row-cards .card span:last-child {
  font-weight: 600;
  font-size: 0.875rem;
}

/* ============================================
   CALENDAR CARD
   ============================================ */
.calendar-card {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  min-height: 450px;
}

.equal-tiles > .calendar-card {
  height: auto;
  min-height: 450px;
}

#calendar {
  flex: 1;
  min-height: 350px;
}

/* FullCalendar Customization */
.fc {
  font-family: inherit;
}

.fc .fc-toolbar {
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.fc .fc-toolbar-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--gray-900);
}

.fc .fc-button-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  font-weight: 500;
  padding: 0.4rem 0.875rem;
  border-radius: var(--radius);
  transition: var(--transition);
  text-transform: capitalize;
}

.fc .fc-button-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.fc .fc-button-primary:not(:disabled).fc-button-active,
.fc .fc-button-primary:not(:disabled):active {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.fc-theme-standard td,
.fc-theme-standard th {
  border-color: var(--gray-200);
}

.fc .fc-col-header-cell {
  padding: 0.5rem 0.25rem;
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--gray-600);
}

.fc .fc-daygrid-day-number {
  color: var(--gray-700);
  padding: 0.375rem;
  font-weight: 600;
  font-size: 0.875rem;
}

.fc .fc-day-today {
  background-color: rgba(16, 185, 129, 0.05) !important;
}

.fc .fc-day-today .fc-daygrid-day-number {
  background: var(--primary);
  color: white;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.fc .fc-daygrid-event {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  border-radius: var(--radius-sm);
  padding: 0.125rem 0.375rem;
  margin: 0.125rem 0.125rem 0.25rem;
  font-size: 0.6875rem;
  font-weight: 500;
}

.fc .fc-bg-event {
  background: rgba(16, 185, 129, 0.08);
  opacity: 1;
}

/* Calendar Legend */
.legend {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.875rem;
  padding-top: 0.875rem;
  border-top: 1px solid var(--gray-200);
  font-size: 0.8125rem;
  color: var(--gray-600);
}

.legend .dot {
  width: 14px;
  height: 14px;
  background: rgba(16, 185, 129, 0.08);
  border: 2px solid var(--primary);
  border-radius: 4px;
  flex-shrink: 0;
}

/* ============================================
   MONTH LIST (Denna månad)
   ============================================ */
#monthList {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#monthList > div {
  padding: 1rem;
  background: var(--gray-50);
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  transition: var(--transition);
}

#monthList > div:hover {
  background: white;
  border-color: var(--primary);
  box-shadow: var(--shadow);
}

#monthList > div > div:first-child {
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 0.375rem;
  font-size: 0.9375rem;
}

#monthList > div > div:nth-child(2) {
  font-size: 0.8125rem;
  color: var(--gray-600);
  margin-bottom: 0.625rem;
}

#monthList .edit-link {
  display: inline-block;
  padding: 0.375rem 0.875rem;
  background: var(--primary);
  color: white;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none;
  transition: var(--transition);
  margin-right: 0.5rem;
}

#monthList .edit-link:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

/* ============================================
   FORMS & INPUTS
   ============================================ */
form {
  max-width: 600px;
  margin: 0 auto;
  padding: 1.5rem;
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

label {
  display: block;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 0.375rem;
  font-size: 0.875rem;
}

input, select, textarea {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-family: inherit;
  transition: var(--transition);
  background: white;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

textarea {
  resize: vertical;
  min-height: 100px;
}

button, .button {
  padding: 0.625rem 1.25rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  text-decoration: none;
  white-space: nowrap;
}

button:hover, .button:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

button:active, .button:active {
  transform: translateY(0);
}

.button-secondary {
  background: white;
  color: var(--primary);
  border: 1px solid rgba(var(--primary-rgb), 0.4);
}

.button-secondary:hover {
  background: rgba(var(--primary-rgb), 0.08);
  color: var(--primary-dark);
}

.delete-button, .danger-button {
  background: var(--danger);
}

.delete-button:hover, .danger-button:hover {
  background: #dc2626;
}

/* ============================================
   LINKS & NAVIGATION
   ============================================ */
.back-button {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  margin-bottom: 1rem;
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9375rem;
  transition: var(--transition);
}

.back-button:hover {
  color: var(--primary-dark);
  gap: 0.625rem;
}

.edit-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.875rem;
  transition: var(--transition);
}

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

/* ============================================
   LISTS
   ============================================ */
ul, ol {
  list-style-position: inside;
  padding-left: 0;
}

.control-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.control-item {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

@media (min-width: 640px) {
  .control-item {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}

.control-details {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.control-title {
  font-size: 1rem;
}

.control-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  color: var(--gray-600);
  font-size: 0.875rem;
}

.control-filter {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.control-filter strong {
  color: var(--primary);
}

.control-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.inline-delete-form {
  margin: 0;
}

ul li, ol li {
  margin-bottom: 0.5rem;
}

/* ============================================
   EGENKONTROLL (Self-Inspection Forms)
   ============================================ */
.egenkontroll-form {
  max-width: 700px;
  margin: 1.5rem auto;
  padding: 1.5rem;
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.template-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 1rem auto 0;
  max-width: 900px;
}

.template-header h2 {
  margin: 0;
}

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

.template-actions .inline-delete-form {
  display: inline-flex;
  align-items: center;
}

.existing-controls {
  max-width: 900px;
  margin: 2rem auto;
}

.existing-controls h3 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
  text-align: center;
}

.existing-controls .table-wrapper {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow-x: auto;
}

.existing-controls table {
  width: 100%;
  border-collapse: collapse;
  min-width: 100%;
}

.existing-controls th,
.existing-controls td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
  font-size: 0.9375rem;
}

.existing-controls tbody tr:last-child td {
  border-bottom: none;
}

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

.existing-controls td.actions .inline-delete-form {
  display: inline-flex;
  align-items: center;
}

.existing-controls .empty-state {
  margin-top: 1rem;
  color: var(--gray-600);
  text-align: center;
}

.button-small {
  padding: 0.4rem 0.85rem;
  font-size: 0.875rem;
}

.punkt-rad {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem 1rem;
  margin-bottom: 0.75rem;
  background: var(--gray-50);
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  transition: var(--transition);
}

.punkt-rad:hover {
  background: white;
  border-color: var(--primary);
}

.punkt-rad span {
  flex: 1;
  font-weight: 500;
  font-size: 0.9375rem;
}

.punkt-rad label {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin: 0;
  cursor: pointer;
}

.punkt-rad input[type="radio"] {
  width: auto;
  cursor: pointer;
}

/* ============================================
   FOOTER
   ============================================ */
footer {
  background: var(--gray-900);
  color: var(--gray-300);
  padding: 1rem;
  margin-top: 3rem;
  text-align: center;
}

footer a {
  color: var(--gray-300);
  text-decoration: none;
  padding: 0.5rem 1rem;
  display: inline-block;
  transition: var(--transition);
}

footer a:hover {
  color: white;
}

.site-footer {
  background: var(--gray-900);
  color: var(--gray-300);
  padding: 2rem 1rem;
  margin-top: 3rem;
}

.footer-container {
  max-width: 1200px;
  margin: 0 auto;
}

.footer-section h4 {
  color: var(--primary-light);
  margin-bottom: 0.75rem;
  font-size: 1rem;
}

.footer-section p {
  margin: 0.375rem 0;
  font-size: 0.875rem;
}

.footer-section a {
  color: var(--gray-300);
  text-decoration: none;
  transition: var(--transition);
}

.footer-section a:hover {
  color: var(--primary-light);
}

.footer-bottom {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--gray-700);
  text-align: center;
  font-size: 0.8125rem;
  color: var(--gray-500);
}

/* ============================================
   MOBILE OPTIMIZATIONS (< 640px)
   ============================================ */
@media (max-width: 640px) {
  /* Header */
  header {
    padding: 0.75rem 0.875rem;
    gap: 0.5rem;
  }

  .emblem {
    font-size: 1rem;
  }

  .home-button, .settings, .logout {
    font-size: 0.8125rem;
    padding: 0.25rem 0.5rem;
  }

  /* Main Content */
  main {
    padding: 0.875rem;
  }

  /* Row Cards - Full Width on Mobile */
  .row-cards {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .row-cards .card {
    flex-direction: row;
    justify-content: flex-start;
    text-align: left;
    padding: 1rem;
    min-height: auto;
    gap: 1rem;
  }

  .row-cards .card span:first-child {
    font-size: 1.5rem;
  }

  .row-cards .card span:last-child {
    font-size: 0.9375rem;
  }

  /* Hide <br> in mobile cards */
  .row-cards .card br {
    display: none;
  }

  /* Calendar Card */
  .calendar-card {
    min-height: 400px;
    padding: 0.875rem;
  }

  #calendar {
    min-height: 320px;
  }

  .fc .fc-toolbar {
    font-size: 0.875rem;
  }

  .fc .fc-toolbar-title {
    font-size: 1rem;
  }

  .fc .fc-button-primary {
    padding: 0.375rem 0.625rem;
    font-size: 0.8125rem;
  }

  .fc .fc-col-header-cell {
    font-size: 0.75rem;
    padding: 0.375rem 0.125rem;
  }

  .fc .fc-daygrid-day-number {
    font-size: 0.8125rem;
    padding: 0.25rem;
  }

  .fc .fc-daygrid-event {
    font-size: 0.625rem;
    padding: 0.0625rem 0.25rem;
  }

  /* Forms */
  form {
    padding: 1rem;
  }

  .egenkontroll-form {
    padding: 1rem;
  }

  .punkt-rad {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
  }

  /* Buttons */
  button, .button {
    width: 100%;
    padding: 0.75rem 1rem;
  }

  /* Month List */
  #monthList > div {
    padding: 0.875rem;
  }

  #monthList .edit-link {
    display: block;
    text-align: center;
    margin: 0.25rem 0;
  }

  /* Search Bar */
  .searchbar {
    padding: 0.75rem 0.875rem;
  }

  .searchbar input {
    font-size: 1rem; /* Prevents zoom on iOS */
  }
}

/* ============================================
   TABLET OPTIMIZATIONS (641px - 1024px)
   ============================================ */
@media (min-width: 641px) and (max-width: 1024px) {
  .row-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  }
}

/* ============================================
   DESKTOP OPTIMIZATIONS (> 1024px)
   ============================================ */
@media (min-width: 1025px) {
  .row-cards {
    grid-template-columns: repeat(4, 1fr);
  }

  .grid {
    gap: 1.5rem;
  }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.muted {
  color: var(--gray-500);
  font-size: 0.875rem;
}

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

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

/* NEW: full width sektion som går kant-till-kant i main */
.full-bleed {
  margin-left: calc(-1 * var(--content-pad));
  margin-right: calc(-1 * var(--content-pad));
}

/* ============================================
   ACCESSIBILITY
   ============================================ */
*:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
/* --- Mobilfix: ingen horisontell scroll, kalender staplas --- */
@media (max-width: 640px) {
  .equal-tiles {
    grid-template-columns: 1fr !important; /* en kolumn */
  }

  .calendar-card {
    aspect-ratio: auto !important;  /* släpp kvadrat på mobil */
    height: auto !important;
    min-height: 380px;               /* lagom höjd så hela månaden syns */
  }

  /* Hindra att FC trycker ut bredden */
  .fc, .fc-scrollgrid, .fc-view-harness {
    width: 100% !important;
    min-width: 0 !important;
  }

  /* Säkerställa inget horisontellt overflow */
  body, html, main {
    overflow-x: hidden;
  }
}

.qty-wrap {
  position: relative;
  display: inline-block;
}

.qty-input {
  padding-right: 2.2rem;
}

.qty-suffix {
  position: absolute;
  right: .5rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  opacity: .7;
}

.unit-field {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  background: white;
  transition: var(--transition);
}

.unit-field:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.unit-field__input {
  flex: 1;
  width: 100%;
  min-width: 0;
  padding: 0.625rem 2.5rem 0.625rem 0.875rem;
  border: none;
  border-radius: 0;
  background: transparent;
  font: inherit;
}

.unit-field__input:focus {
  outline: none;
}

.unit-field__suffix {
  position: absolute;
  inset-inline-end: 0.75rem;
  inset-block: 0;
  display: flex;
  align-items: center;
  color: var(--gray-600);
  pointer-events: none;
  font-size: 0.9375rem;
}
