:root {
  --bg-canvas: #F4F6F8;
  --bg-surface: #FFFFFF;
  --bg-secondary: #E9EDF1;
  --text-primary: #292D32;
  --text-secondary: #77818D;
  --brand-red: #D71920;
  --brand-red-hover: #B8141A;
  --border-subtle: #E3E7EB;
  --bs-body-bg: #F4F6F8;
  --bs-body-color: #292D32;
  --bs-border-color: #E3E7EB;
  --bs-primary: #D71920;
  --bs-font-sans-serif: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --bs-font-monospace: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  max-width: 100%;
  overflow-x: hidden;
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--bs-font-sans-serif);
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  margin: 0;
  max-width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  overflow-x: clip;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(215, 25, 32, 0.08);
}

.bg-canvas {
  background-color: var(--bg-canvas) !important;
}

.bg-soft {
  background-color: #F8FAFC !important;
}

.bg-secondary-soft {
  background-color: var(--bg-secondary) !important;
}

.text-ink {
  color: var(--text-primary) !important;
}

.text-muted-soft {
  color: var(--text-secondary) !important;
}

.border-subtle {
  border-color: var(--border-subtle) !important;
}

.font-mono {
  font-family: var(--bs-font-monospace) !important;
}

.tabular-nums {
  font-variant-numeric: tabular-nums;
}

.min-w-0 {
  min-width: 0 !important;
}

/* Butonlar */
.btn-brand {
  background-color: var(--brand-red);
  border-color: var(--brand-red);
  color: #FFFFFF;
}

.btn-brand:hover,
.btn-brand:focus {
  background-color: var(--brand-red-hover);
  border-color: var(--brand-red-hover);
  color: #FFFFFF;
}

.btn-soft {
  background-color: var(--bg-secondary);
  border-color: var(--border-subtle);
  color: var(--text-primary);
}

.btn-soft:hover {
  background-color: #DCE2E8;
  color: var(--text-primary);
}

/* Formlar */
.form-control,
.form-select {
  border-color: var(--border-subtle);
  color: var(--text-primary);
  font-size: 0.875rem;
  max-width: 100%;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--brand-red);
  box-shadow: 0 0 0 0.15rem rgba(215, 25, 32, 0.12);
}

/* Kartlar ve Tablolar */
.card {
  border-color: var(--border-subtle);
  border-radius: 0.5rem;
}

.panel-card {
  background-color: #FFFFFF;
  border: 1px solid var(--border-subtle);
  border-radius: 0.5rem;
  max-width: 100%;
}

.table-responsive {
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

.table {
  margin-bottom: 0;
}

.table > thead > tr > th {
  background-color: #F8FAFC;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.65rem 1rem;
  white-space: nowrap;
}

.table > tbody > tr > td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.table-hover > tbody > tr:hover > * {
  background-color: #F8FAFC;
}

/* Durum Etiketleri (Klasik Masaustu Yazilimi Tarzi) */
.status-tag {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 4px;
  white-space: nowrap;
}

.status-ok {
  background-color: #ECFDF5;
  color: #16A34A;
  border: 1px solid #BBF7D0;
}

.status-warn {
  background-color: #FFFBEB;
  color: #D97706;
  border: 1px solid #FDE68A;
}

.status-danger {
  background-color: #FEF2F2;
  color: #DC2626;
  border: 1px solid #FECACA;
}

/* Sabit Sol Menu & Tam Ekran Masaustu Yerlesimi */
.app-sidebar {
  width: 260px;
  background-color: #FFFFFF;
  border-right: 1px solid var(--border-subtle);
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 1035;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.app-main-wrap {
  margin-left: 260px;
  width: calc(100% - 260px);
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

@media (min-width: 992px) and (max-width: 1399.98px) {
  .app-sidebar {
    width: 236px;
  }

  .app-main-wrap {
    margin-left: 236px;
    width: calc(100% - 236px);
  }
}

.app-topbar {
  background-color: #FFFFFF;
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 1020;
  padding-top: calc(0.5rem + env(safe-area-inset-top, 0px)) !important;
}

.app-page-title {
  font-size: clamp(0.98rem, 0.55vw + 0.78rem, 1.22rem);
  font-weight: 700;
  line-height: 1.25;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-page-subtitle {
  font-size: 0.78rem;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-main-content {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

/* Kart & Panel Baslik Hizalama */
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 0.75rem;
  flex-wrap: wrap;
  min-width: 0;
}

.panel-head-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  flex: 1 1 auto;
  font-size: clamp(0.84rem, 0.25vw + 0.76rem, 0.9rem);
  font-weight: 600;
  line-height: 1.3;
}

.panel-head-title i {
  flex-shrink: 0;
}

.panel-head-action {
  flex-shrink: 0;
  white-space: nowrap;
  font-size: 0.82rem;
  font-weight: 500;
}

.kpi-title {
  font-size: clamp(0.78rem, 0.2vw + 0.72rem, 0.875rem);
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.modal {
  overscroll-behavior: contain;
}

.modal-content {
  display: flex;
  flex-direction: column;
  width: 100%;
  background-color: #FFFFFF;
  overflow: hidden;
}

.modal-content > form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  overflow: hidden;
  margin: 0;
}

.modal-header {
  flex-shrink: 0;
  gap: 0.75rem;
  align-items: flex-start;
}

.modal-header > div:first-child {
  min-width: 0;
  flex: 1 1 auto;
}

.modal-header .btn-close {
  flex-shrink: 0;
  margin-top: 2px;
}

.modal-title {
  font-size: clamp(0.95rem, 0.35vw + 0.82rem, 1.05rem);
  line-height: 1.35;
}

.modal-content > form > .modal-body,
.modal-content > .modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.modal-content > form > .modal-footer,
.modal-content > .modal-footer {
  flex-shrink: 0;
  position: relative;
  z-index: 2;
  background-color: #FFFFFF;
  border-top: 1px solid var(--border-subtle);
}

@media (min-width: 576px) {
  .modal-dialog {
    max-height: calc(100vh - 3.5rem);
    max-height: calc(100dvh - 3.5rem);
  }

  .modal-dialog .modal-content {
    max-height: calc(100vh - 3.5rem);
    max-height: calc(100dvh - 3.5rem);
  }

  #quickVehicleModal .modal-dialog {
    max-width: 460px;
  }
}

@media (max-width: 575.98px) {
  .modal-fullscreen-sm-down,
  .modal-fullscreen-sm-down.modal-dialog-centered {
    display: flex;
    align-items: stretch;
    width: 100%;
    max-width: none !important;
    height: 100%;
    min-height: 100%;
    max-height: 100%;
    margin: 0;
  }

  .modal-fullscreen-sm-down .modal-content {
    flex: 1 1 auto;
    height: 100%;
    max-height: 100%;
    border: 0;
    border-radius: 0;
    padding-top: env(safe-area-inset-top, 0px);
  }

  .modal-fullscreen-sm-down .modal-body {
    padding-bottom: 1.5rem;
  }

  .modal-fullscreen-sm-down .modal-footer {
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
  }
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.625rem 0.875rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.sidebar-link:hover {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}

.sidebar-link.active {
  background-color: var(--brand-red);
  color: #FFFFFF;
}

.sidebar-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.8;
}

.sidebar-link.active svg {
  opacity: 1;
}

.app-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1030;
}

/* Mobil Alt Uygulama Gezinti Cubugu */
.mobile-bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 100%;
  z-index: 1025;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  background-color: #FFFFFF;
  border-top: 1px solid var(--border-subtle);
  box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.06);
  padding: 0.25rem 0.25rem calc(0.25rem + env(safe-area-inset-bottom, 0px));
}

body.modal-open .mobile-bottom-nav,
body.has-open-modal .mobile-bottom-nav {
  display: none !important;
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 48px;
  padding: 4px 2px;
  border-radius: 0.375rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.15;
  min-width: 0;
}

.mobile-nav-item i {
  font-size: 1.15rem;
  line-height: 1;
}

.mobile-nav-item span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-nav-item.active {
  color: var(--brand-red);
  font-weight: 700;
  background-color: #FEF2F2;
}

/* Filtre Cubuklari (Masaustu ve Mobil Uyumlu) */
.filter-bar-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.filter-search-wrap {
  flex: 1 1 240px;
  min-width: 0;
  max-width: 340px;
}

.filter-control-auto {
  flex: 0 1 auto;
  width: auto;
  min-width: 0;
}

@media (max-width: 991.98px) {
  .app-sidebar {
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    width: min(286px, 84vw);
  }

  .app-sidebar.open {
    transform: translateX(0);
  }

  .app-backdrop.open {
    display: block;
  }

  .app-main-wrap {
    margin-left: 0;
    width: 100%;
    padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  }

  .pwa-offline-banner {
    bottom: calc(74px + env(safe-area-inset-bottom, 0px)) !important;
  }
}

@media (max-width: 767.98px) {
  .filter-search-wrap {
    flex: 1 1 100%;
    max-width: 100%;
  }

  .filter-control-auto {
    flex: 1 1 calc(50% - 0.25rem);
    width: 100%;
  }

  .form-control,
  .form-select {
    font-size: 16px;
  }

  .form-control-sm,
  .form-select-sm {
    font-size: 15px;
  }

  /* Mobilde Tablolari Kart Gorunumune Cevir (Sifir Yatay Kaydirma) */
  .table-mobile-cards {
    display: block;
    width: 100%;
  }

  .table-mobile-cards thead {
    display: none;
  }

  .table-mobile-cards tbody,
  .table-mobile-cards tfoot {
    display: block;
    width: 100%;
  }

  .table-mobile-cards tbody tr {
    display: block;
    width: 100%;
    padding: 0.75rem 0.9rem;
    border-bottom: 1px solid var(--border-subtle);
    background-color: #FFFFFF;
  }

  .table-mobile-cards tbody tr:last-child {
    border-bottom: 0;
  }

  .table-mobile-cards tbody td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
    max-width: 100% !important;
    padding: 0.3rem 0 !important;
    border: 0 !important;
    text-align: right !important;
    white-space: normal !important;
    word-break: break-word;
  }

  .table-mobile-cards tbody td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    max-width: 42%;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
    padding-top: 2px;
  }

  .table-mobile-cards tbody td:first-child {
    padding-top: 0.1rem !important;
  }

  .table-mobile-cards tbody td[data-mobile-actions="1"] {
    margin-top: 0.4rem;
    padding-top: 0.55rem !important;
    border-top: 1px dashed var(--border-subtle) !important;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
  }

  .table-mobile-cards tbody td[data-mobile-actions="1"] > .d-inline-flex {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .table-mobile-cards tbody td > div,
  .table-mobile-cards tbody td > span,
  .table-mobile-cards tbody td > a {
    min-width: 0;
    max-width: 100%;
  }

  .table-mobile-cards tfoot tr {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 0.9rem;
    border-top: 1px solid var(--border-subtle);
  }

  .table-mobile-cards tfoot td {
    display: block;
    width: auto;
    padding: 0 !important;
    border: 0 !important;
  }
}

/* Aranabilir Arac Plaka Secici ve Hizli Ekleme Modali */
.vehicle-picker {
  min-width: 0;
  max-width: 100%;
}

.vp-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 1055;
  margin-top: 4px;
  background-color: #FFFFFF;
  border: 1px solid var(--border-subtle);
  border-radius: 0.375rem;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.12);
  overflow: hidden;
  max-width: 100%;
}

.vp-list {
  max-height: 230px;
  max-height: min(230px, 34dvh);
  overflow-y: auto;
}

.vp-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 0;
  border-bottom: 1px solid #F1F5F9;
  background-color: #FFFFFF;
  text-align: left;
  cursor: pointer;
  font-size: 0.85rem;
}

.vp-option > .min-w-0 {
  flex: 1 1 auto;
  min-width: 0;
}

.vp-option:last-child {
  border-bottom: 0;
}

.vp-option:hover,
.vp-option.is-active {
  background-color: #F8FAFC;
}

.vp-option.is-selected {
  background-color: #FEF2F2;
}

.vp-quick-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 0;
  border-top: 1px solid var(--border-subtle);
  background-color: #F8FAFC;
  color: var(--brand-red);
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
  text-align: left;
}

.vp-quick-footer:hover {
  background-color: #FEF2F2;
}

#quickVehicleModal {
  z-index: 1070;
}

.modal-backdrop.qv-stacked-backdrop {
  z-index: 1065;
}

/* PWA Cevrimdisi Bildirim Cubugu */
.pwa-offline-banner {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 1080;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background-color: #FEF2F2;
  color: #991B1B;
  border: 1px solid #FECACA;
  border-radius: 6px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
  font-size: 0.82rem;
  font-weight: 500;
  max-width: calc(100vw - 32px);
}

/* Yazdirma Stilleri */
.print-only {
  display: none;
}

@media print {
  body {
    background-color: #FFFFFF !important;
    color: #111827 !important;
  }

  .no-print,
  .app-sidebar,
  .app-topbar,
  .app-backdrop,
  .mobile-bottom-nav {
    display: none !important;
  }

  .app-main-wrap {
    margin-left: 0 !important;
    width: 100% !important;
    padding-bottom: 0 !important;
  }

  .print-only {
    display: block !important;
  }

  .panel-card,
  .card {
    border: none !important;
    box-shadow: none !important;
  }

  .table-mobile-cards {
    display: table !important;
  }

  .table-mobile-cards thead {
    display: table-header-group !important;
  }

  .table-mobile-cards tbody {
    display: table-row-group !important;
  }

  .table-mobile-cards tfoot {
    display: table-footer-group !important;
  }

  .table-mobile-cards tr {
    display: table-row !important;
    padding: 0 !important;
  }

  .table-mobile-cards th,
  .table-mobile-cards td {
    display: table-cell !important;
    width: auto !important;
    text-align: left !important;
    padding: 5px 7px !important;
    border: 1px solid #D1D5DB !important;
  }

  .table-mobile-cards td::before {
    display: none !important;
    content: none !important;
  }

  table {
    font-size: 11px !important;
  }
}
