:root {
  --app-bg: #f4f6f8;
  --app-border: #dfe3e7;
  --timeline-line: #cbd3da;
}

body {
  background: var(--app-bg);
  min-height: 100vh;
}

.app-navbar {
  position: sticky;
  top: 0;
  z-index: 1030;
}

.app-shell {
  max-width: 1180px;
}

.summary-card,
.panel-card,
.login-card {
  border: 0;
  border-radius: 1rem;
}

.quick-action {
  min-height: 78px;
  border-radius: 1rem;
  font-weight: 600;
}

.timeline {
  position: relative;
  padding-left: 1.65rem;
}

.timeline::before {
  content: "";
  position: absolute;
  left: .38rem;
  top: .5rem;
  bottom: .5rem;
  width: 2px;
  background: var(--timeline-line);
}

.timeline-item {
  position: relative;
  margin-bottom: 1rem;
}

.timeline-marker {
  position: absolute;
  left: -1.65rem;
  top: .9rem;
  width: .78rem;
  height: .78rem;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--timeline-line);
}

.timeline-card {
  border: 1px solid var(--app-border);
  border-radius: 1rem;
  background: #fff;
}

.filter-strip {
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}

.filter-strip::-webkit-scrollbar {
  display: none;
}

.mobile-fab {
  position: fixed;
  z-index: 1020;
  right: 1rem;
  bottom: 1rem;
  border-radius: 999px;
  min-width: 58px;
  min-height: 58px;
  box-shadow: 0 .5rem 1rem rgba(0,0,0,.18);
}

.connection-pill {
  font-size: .78rem;
}

.table-responsive {
  border-radius: .75rem;
}

.org-node {
  border-left: 4px solid var(--bs-secondary);
}

.org-level-1 {
  margin-left: 1.25rem;
}

.org-level-2 {
  margin-left: 2.5rem;
}

pre.audit-json {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: .78rem;
  margin: 0;
}

@media (min-width: 768px) {
  .mobile-fab {
    display: none;
  }
}


/* Gemensam tabellstil */
.app-table-wrap {
  background: #fff;
  border: 1px solid var(--app-border);
  border-radius: 1rem;
  overflow: auto;
}

.app-table {
  --bs-table-bg: transparent;
}

.app-table thead th {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--bs-secondary-color);
  border-bottom-width: 1px;
  white-space: nowrap;
}

.app-table th,
.app-table td {
  white-space: nowrap;
  vertical-align: middle;
  padding: .75rem .85rem;
}

.app-table .table-text-wrap,
.app-table td.table-text-wrap,
.table-text-wrap {
  white-space: normal !important;
  min-width: 14rem;
  max-width: 30rem;
}

.app-table tbody tr:last-child td {
  border-bottom: 0;
}

.package-apply-group {
  min-width: min(100%, 360px);
}

.gap-x-3 {
  column-gap: 1rem;
}

.org-node {
  border-left: 4px solid var(--bs-secondary) !important;
}

@media (max-width: 767.98px) {
  .app-table th,
  .app-table td {
    padding: .65rem .7rem;
  }

  .package-apply-group {
    width: 100%;
  }
}


.task-sort-select {
  width: auto;
  min-width: 9.5rem;
}


/* Sidfot och säker bottenmarginal för flytande mobilknapp */
.app-footer {
  margin-top: 3rem;
  border-top: 1px solid var(--app-border);
  background: rgba(255, 255, 255, .72);
  padding: 1.25rem 0 calc(6.5rem + env(safe-area-inset-bottom));
}

.mobile-fab {
  bottom: calc(1rem + env(safe-area-inset-bottom));
}

@media (min-width: 768px) {
  .app-footer {
    padding-bottom: 1.5rem;
  }
}


/* Fast footermeny för insatsvyn */
.incident-bottom-spacer {
  height: 5.5rem;
}

.incident-bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1035;
  background: var(--bs-dark);
  border-top: 1px solid rgba(255, 255, 255, .12);
  box-shadow: 0 -.4rem 1rem rgba(0, 0, 0, .16);
  padding-bottom: env(safe-area-inset-bottom);
}

.incident-bottom-nav-inner {
  display: grid !important;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: stretch;
  flex-wrap: nowrap !important;
  padding-left: .25rem;
  padding-right: .25rem;
}

.incident-nav-item {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 4.1rem;
  width: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .2rem;
  padding: .45rem .2rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: rgba(255, 255, 255, .62);
  text-decoration: none;
  line-height: 1.1;
}

.incident-nav-item i {
  font-size: 1.05rem;
}

.incident-nav-item span {
  max-width: 100%;
  overflow: hidden;
  font-size: .66rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.incident-nav-item:hover,
.incident-nav-item:focus-visible {
  color: #fff;
  background: rgba(255, 255, 255, .06);
}

.incident-nav-item.active {
  color: #fff;
  box-shadow: inset 0 3px 0 var(--bs-danger);
}

.incident-nav-item.active i {
  color: var(--bs-danger);
}

.incident-nav-more {
  position: relative;
  min-width: 0;
}

.incident-nav-more > .incident-nav-item {
  height: 100%;
}

.incident-nav-more .dropdown-menu {
  min-width: 13rem;
  border-radius: .85rem;
  box-shadow: 0 .5rem 1.5rem rgba(0, 0, 0, .2);
}

.incident-page #incidentTabContent {
  scroll-margin-top: 5rem;
}

.incident-page .mobile-fab {
  z-index: 1040;
  bottom: calc(5.15rem + env(safe-area-inset-bottom));
}

.incident-page .app-footer {
  padding-bottom: calc(5.5rem + env(safe-area-inset-bottom));
}

@media (min-width: 768px) {
  .incident-bottom-nav-inner {
    max-width: 760px;
  }

  .incident-nav-item span {
    font-size: .72rem;
  }

  .incident-page .app-footer {
    padding-bottom: 5.5rem;
  }
}

/* Kompakt insatshuvud – inspirerat av prototypens sammanfattningskort */
.min-w-0 {
  min-width: 0;
}

.incident-navbar-brand {
  max-width: min(68vw, 520px);
  line-height: 1.05;
}

.incident-navbar-icon {
  flex: 0 0 auto;
  font-size: 1.15rem;
}

.incident-navbar-kicker {
  font-size: .65rem;
  font-weight: 500;
  margin-bottom: .08rem;
}

.incident-navbar-title {
  font-size: .92rem;
}

.incident-summary-card .card-body {
  padding: .85rem 1rem !important;
}

.status-dot {
  width: .62rem;
  height: .62rem;
  flex: 0 0 .62rem;
  border-radius: 50%;
  background: var(--bs-secondary);
}

.status-dot-active {
  background: var(--bs-success);
  box-shadow: 0 0 0 .18rem rgba(25, 135, 84, .13);
}

.status-dot-planned {
  background: var(--bs-warning);
}

.status-dot-closed {
  background: var(--bs-secondary);
}

.incident-status-label {
  font-size: .92rem;
}

.incident-summary-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .2rem .38rem;
  line-height: 1.25;
}

.incident-summary-address {
  line-height: 1.25;
}

.incident-meta-separator {
  color: var(--bs-gray-500);
}

.incident-back-button {
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 2rem;
  padding: 0;
}

.incident-summary-stats {
  margin-left: -.25rem;
  margin-right: -.25rem;
}

.incident-stat-value {
  font-size: 1.05rem;
  line-height: 1.15;
}

.incident-stat-label {
  margin-top: .1rem;
  font-size: .68rem;
  line-height: 1.1;
}

.incident-status-form .form-select {
  max-width: 10rem;
}

.incident-page .quick-action {
  min-height: 60px;
  border-radius: .85rem;
  padding-top: .55rem;
  padding-bottom: .55rem;
}

.incident-page .quick-action i {
  display: inline-block !important;
  margin-right: .35rem;
  margin-bottom: 0 !important;
  font-size: 1rem !important;
}

@media (max-width: 575.98px) {
  .incident-page .app-navbar .container {
    padding-left: .75rem;
    padding-right: .75rem;
  }

  .incident-navbar-brand {
    max-width: calc(100vw - 5.5rem);
    margin-right: .25rem;
  }

  .incident-summary-card .card-body {
    padding: .7rem .8rem !important;
  }

  .incident-summary-meta {
    font-size: .75rem;
  }

  .incident-summary-address {
    font-size: .75rem;
  }

  .connection-pill {
    font-size: .66rem;
  }

  .incident-status-form {
    gap: .4rem !important;
  }

  .incident-status-form > span {
    display: none;
  }

  .incident-status-form .form-select {
    max-width: none;
    flex: 1 1 auto;
  }
}


/* Operativ startsida / insatsöversikt */
.home-overview {
  max-width: 920px;
}

.home-overview-kicker {
  font-size: .68rem;
  letter-spacing: .055em;
}

.home-new-incident {
  min-width: 2.65rem;
  min-height: 2.4rem;
  border-radius: .75rem;
}

.home-filter-card {
  border-radius: .9rem;
  background: rgba(255, 255, 255, .78);
}

.home-filter-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 310px);
  gap: .75rem;
  align-items: center;
}

.home-search .input-group-text,
.home-search .form-control {
  border-color: var(--app-border);
}

.home-incident-list {
  display: grid;
  gap: .65rem;
}

.home-incident-card {
  display: block;
  border-radius: 1rem;
}

.home-incident-card article {
  position: relative;
  overflow: hidden;
  transition: transform .12s ease, box-shadow .12s ease;
}

.home-incident-card:hover article,
.home-incident-card:focus-visible article {
  transform: translateY(-1px);
  box-shadow: 0 .5rem 1.25rem rgba(0, 0, 0, .09) !important;
}

.home-incident-status-bar {
  position: absolute;
  inset: 0 auto 0 0;
  width: .27rem;
}

.home-incident-title {
  font-weight: 700;
  font-size: .98rem;
}

.home-incident-time {
  margin-left: auto;
}

.home-incident-meta {
  min-width: 0;
}

.home-incident-counters {
  color: var(--bs-secondary-color);
  font-size: .72rem;
}

.home-incident-counters > span {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  white-space: nowrap;
}

.home-incident-counters i {
  width: .8rem;
  text-align: center;
  opacity: .7;
}

.home-incident-counters strong {
  color: var(--bs-body-color);
  font-size: .78rem;
}

.home-incident-arrow {
  align-self: center;
  flex: 0 0 auto;
  padding-left: .25rem;
}

.home-empty-state {
  margin-top: 1rem;
}

.home-empty-icon {
  width: 3.3rem;
  height: 3.3rem;
  margin-left: auto;
  margin-right: auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--bs-light);
  color: var(--bs-secondary);
  font-size: 1.35rem;
}

.home-page .app-footer {
  padding-bottom: 1.5rem;
}

@media (max-width: 767.98px) {
  .home-overview {
    padding-left: .75rem;
    padding-right: .75rem;
  }

  .home-filter-layout {
    grid-template-columns: 1fr;
  }

  .home-search {
    width: 100%;
  }

  .home-incident-card .card-body {
    padding: .75rem .85rem !important;
  }

  .home-incident-title {
    font-size: .93rem;
  }

  .home-incident-time {
    margin-left: 0;
  }

  .home-incident-counters {
    gap: .7rem !important;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .home-incident-counters::-webkit-scrollbar {
    display: none;
  }

  .home-incident-counters span span {
    display: none;
  }

  .home-incident-arrow {
    padding-left: 0;
  }
}

@media (min-width: 992px) {
  .home-incident-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .home-incident-card article {
    height: 100%;
  }

  .home-incident-time {
    margin-left: 0;
  }
}


/* Dark mode */
.theme-toggle-button {
  min-width: 2.15rem;
}

.theme-floating-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1050;
  width: 2.5rem;
  height: 2.5rem;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
}

[data-bs-theme="dark"] {
  --app-bg: #0f1216;
  --app-border: #30363d;
  --timeline-line: #46505a;
}

[data-bs-theme="dark"] body {
  background: var(--app-bg);
}

[data-bs-theme="dark"] .timeline-card,
[data-bs-theme="dark"] .app-table-wrap {
  background: var(--bs-body-bg);
}

[data-bs-theme="dark"] .timeline-marker {
  border-color: var(--bs-body-bg);
}

[data-bs-theme="dark"] .app-footer {
  background: rgba(24, 28, 33, .88);
}

[data-bs-theme="dark"] .home-filter-card {
  background: rgba(33, 37, 41, .82);
}

[data-bs-theme="dark"] .home-search .input-group-text {
  background: var(--bs-tertiary-bg) !important;
}

[data-bs-theme="dark"] .home-search .form-control {
  background: var(--bs-body-bg);
  color: var(--bs-body-color);
}

[data-bs-theme="dark"] .bg-white {
  background-color: var(--bs-body-bg) !important;
}

[data-bs-theme="dark"] .text-dark {
  color: var(--bs-body-color) !important;
}

[data-bs-theme="dark"] .btn-outline-dark {
  --bs-btn-color: #dee2e6;
  --bs-btn-border-color: #6c757d;
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: #495057;
  --bs-btn-hover-border-color: #6c757d;
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: #495057;
  --bs-btn-active-border-color: #6c757d;
}

[data-bs-theme="dark"] .btn-dark {
  --bs-btn-bg: #343a40;
  --bs-btn-border-color: #495057;
  --bs-btn-hover-bg: #495057;
  --bs-btn-hover-border-color: #5c636a;
}

[data-bs-theme="dark"] .badge.text-bg-light,
[data-bs-theme="dark"] .text-bg-light {
  color: var(--bs-body-color) !important;
  background-color: var(--bs-tertiary-bg) !important;
}

[data-bs-theme="dark"] .table-light {
  --bs-table-bg: #242a30;
  --bs-table-color: var(--bs-body-color);
  --bs-table-border-color: #343a40;
}

[data-bs-theme="dark"] .modal-content,
[data-bs-theme="dark"] .dropdown-menu {
  border-color: var(--app-border);
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select,
[data-bs-theme="dark"] .input-group-text {
  border-color: #495057;
}

[data-bs-theme="dark"] .card.shadow-sm,
[data-bs-theme="dark"] .home-incident-card article {
  box-shadow: 0 .35rem 1rem rgba(0, 0, 0, .28) !important;
}

[data-bs-theme="dark"] .incident-bottom-nav {
  background: #090b0e;
  border-top-color: rgba(255, 255, 255, .16);
}

[data-bs-theme="dark"] .home-empty-icon {
  background: var(--bs-tertiary-bg);
  color: var(--bs-secondary-color);
}

[data-bs-theme="dark"] pre.audit-json {
  color: var(--bs-body-color);
}

@media (prefers-reduced-motion: reduce) {
  .home-incident-card article {
    transition: none;
  }
}


/* Förfinad toppmeny v4.7 */
.app-navbar {
  min-height: 3.75rem;
}

.app-navbar-inner {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: .5rem;
}

.app-navbar-desktop-links {
  gap: .15rem;
}

.app-navbar-desktop-links .nav-link {
  color: rgba(255, 255, 255, .68);
  border-radius: .7rem;
  padding: .45rem .7rem;
  font-size: .84rem;
  font-weight: 500;
  transition: color .15s ease, background-color .15s ease;
}

.app-navbar-desktop-links .nav-link:hover,
.app-navbar-desktop-links .nav-link:focus-visible {
  color: #fff;
  background: rgba(255, 255, 255, .07);
}

.app-navbar-desktop-links .nav-link.active {
  color: #fff;
  background: rgba(255, 255, 255, .1);
}

.app-user-menu-toggle {
  max-width: 15rem;
  padding: .28rem .5rem .28rem .32rem;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: .85rem;
  color: #fff;
  background: rgba(255, 255, 255, .055);
}

.app-user-menu-toggle:hover,
.app-user-menu-toggle:focus,
.app-user-menu-toggle.show {
  color: #fff;
  border-color: rgba(255, 255, 255, .24);
  background: rgba(255, 255, 255, .1);
}

.app-user-menu-toggle::after {
  margin-left: .1rem;
  opacity: .65;
}

.app-user-avatar {
  display: grid;
  width: 2rem;
  height: 2rem;
  flex: 0 0 2rem;
  place-items: center;
  border-radius: .65rem;
  background: var(--bs-danger);
  color: #fff;
  font-size: .76rem;
  font-weight: 700;
}

.app-user-menu-text {
  max-width: 9.75rem;
  line-height: 1.05;
}

.app-user-name {
  color: #fff;
  font-size: .78rem;
  font-weight: 600;
}

.app-user-call-sign {
  margin-top: .16rem;
  color: rgba(255, 255, 255, .55);
  font-size: .66rem;
}

.app-user-menu {
  width: min(19rem, calc(100vw - 1rem));
  margin-top: .55rem !important;
  padding: .45rem;
  border-radius: 1rem;
}

.app-user-menu .dropdown-item {
  border-radius: .7rem;
  padding: .62rem .72rem;
  font-size: .88rem;
}

.app-user-menu .dropdown-item.active,
.app-user-menu .dropdown-item:active {
  color: var(--bs-body-color);
  background: var(--bs-tertiary-bg);
}

.app-user-menu .dropdown-item.text-danger:active {
  color: #fff !important;
  background: var(--bs-danger);
}

.app-user-menu-header {
  min-width: 0;
}

.app-user-menu .dropdown-divider {
  margin: .35rem 0;
}

[data-bs-theme="dark"] .app-user-menu {
  border-color: #343a40;
}

@media (max-width: 575.98px) {
  .app-navbar {
    min-height: 3.35rem;
  }

  .app-navbar-inner {
    padding-left: .7rem;
    padding-right: .7rem;
  }

  .app-brand-label {
    font-size: .93rem;
  }

  .app-user-menu-toggle {
    padding: .26rem;
    border-radius: .7rem;
  }

  .app-user-menu-toggle::after {
    display: none;
  }

  .app-user-avatar {
    width: 1.95rem;
    height: 1.95rem;
    flex-basis: 1.95rem;
  }

  .incident-navbar-brand {
    max-width: calc(100vw - 4.5rem);
  }
}

@media (min-width: 576px) and (max-width: 991.98px) {
  .app-user-menu-text {
    max-width: 8rem;
  }
}
