/*
========================================================================
   FLEET MANAGER - supplementary styles
   Builds on the Spark Admin design tokens defined in main.css.
========================================================================
*/

/* Sidebar: keep it scrollable (wheel / touch) but hide the scrollbar itself */
.sidebar-wrapper,
.sidebar-wrapper * {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.sidebar-wrapper::-webkit-scrollbar,
.sidebar-wrapper *::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

/* Uploaded company logo */
.brand-logo {
  width: 36px;
  height: 36px;
  object-fit: contain;
  border-radius: 8px;
  flex-shrink: 0;
}
.footer-logo .brand-logo { width: 20px; height: 20px; border-radius: 4px; vertical-align: middle; }
.sidebar-brand:hover .brand-logo { transform: none; }

/* Desktop top bar: let the centre search box shrink so the bar never overflows the page */
@media (min-width: 1201px) {
  .navbar-custom { grid-template-columns: minmax(max-content, 1fr) minmax(160px, 480px) minmax(max-content, 1fr) !important; }
  .navbar-search-wrapper { min-width: 0; }
}
/* Top bar: keep menu, Quick Add, alerts and profile on ONE row (tablet and phone) */
@media (max-width: 1200px) {
  .navbar-custom {
    flex-wrap: nowrap !important;
    gap: 0.5rem !important;
  }
  .navbar-left { min-width: 0; flex-shrink: 1; }
  .navbar-actions { margin-left: auto; flex-shrink: 0; }
}
@media (max-width: 767.98px) {
  #btn-fullscreen { display: none; }          /* not useful on a phone */
  .navbar-actions .dropdown.ms-2 { margin-left: 0.25rem !important; }
  .navbar-profile-btn { padding-left: 0.25rem; padding-right: 0.25rem; }
}
@media (max-width: 380px) {
  .btn-quick-action span { display: none; }   /* keep only the + icon on very small phones */
}

/* Phone-only bottom tab bar: Fuel, Advance, Dashboard, Drivers, Settings */
.bottom-nav { display: none; }
@media (max-width: 767.98px) {
  .bottom-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1020; /* below the sidebar (1030) and its overlay (1025) */
    gap: 0.15rem;
    padding: 0.4rem 0.4rem calc(0.4rem + env(safe-area-inset-bottom, 0px));
    background-color: var(--brand-forest-dark);
    box-shadow: 0 -8px 24px rgba(5, 28, 18, 0.25);
  }
  .bottom-nav a {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 0.4rem 0.1rem;
    border-radius: var(--radius-lg);
    color: var(--text-sidebar-muted);
    font-size: 0.68rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
  }
  .bottom-nav a i { font-size: 1.3rem; line-height: 1.2; }
  .bottom-nav a:hover { color: #fff; }
  .bottom-nav a.active {
    color: var(--brand-lime);
    background-color: rgba(180, 241, 5, 0.12);
  }
  /* keep content and footer clear of the bar */
  .main-wrapper { padding-bottom: 5.75rem !important; }
}

.text-muted-green { color: var(--text-muted-green); }

/* Image pickers in Settings */
.img-picker { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.img-preview {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-lg);
  border: 1px dashed rgba(11, 19, 15, 0.2);
  background: #F8FAF9 center / contain no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted-green);
  font-size: 1.6rem;
  overflow: hidden;
  flex-shrink: 0;
}
.img-preview.round { border-radius: 50%; border-style: solid; }
.img-preview img { width: 100%; height: 100%; object-fit: cover; }
.img-preview.logo img { object-fit: contain; }
.text-main { color: var(--text-main); }

/* Initials avatar for drivers */
.avatar-initials {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-lg);
  background-color: var(--brand-forest-medium);
  color: var(--brand-lime);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.8rem;
  flex-shrink: 0;
}

/* Page toolbar buttons next to filters */
.fleet-filter {
  padding: 0.5rem 2rem 0.5rem 0.85rem;
  font-size: 0.85rem;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(11, 19, 15, 0.1);
  background-color: #FDFDFD;
  max-width: 190px;
}
.fleet-filter:focus {
  outline: none;
  border-color: var(--brand-forest-medium);
  box-shadow: 0 0 0 3px rgba(7, 47, 31, 0.08);
}
/* iOS Safari / home-screen PWA: native date inputs ignore width:100%, overflow
   their container, centre their text and collapse to zero height when empty. */
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="month"] {
  -webkit-appearance: none;
  appearance: none;
  box-sizing: border-box;
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 2.65rem;
  text-align: left;
  margin: 0;
}
input[type="date"]::-webkit-date-and-time-value,
input[type="time"]::-webkit-date-and-time-value,
input[type="datetime-local"]::-webkit-date-and-time-value,
input[type="month"]::-webkit-date-and-time-value {
  text-align: left;
  min-height: 1.5em;
  margin: 0;
}
.fleet-date {
  width: auto;
  min-height: 2.2rem;
  padding: 0.45rem 0.65rem;
  font-size: 0.85rem;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(11, 19, 15, 0.1);
  background-color: #FDFDFD;
  color: var(--text-main);
}
.fleet-date:focus {
  outline: none;
  border-color: var(--brand-forest-medium);
  box-shadow: 0 0 0 3px rgba(7, 47, 31, 0.08);
}
.fleet-date-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted-green);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Second toolbar row: filters + date range */
.crud-filters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  background-color: #FAFCFB;
  border-bottom: 1px solid rgba(11, 19, 15, 0.06);
}
.table-header-control .table-filter-group { flex-wrap: nowrap; }
@media (max-width: 575.98px) {
  .table-header-control .table-filter-group { flex-wrap: wrap; width: 100%; }
}

/* Table helpers */
.table-custom td.num, .table-custom th.num { text-align: right; }
.table-custom td.wrap { white-space: normal; min-width: 180px; }
.table-empty {
  text-align: center;
  padding: 3rem 1rem !important;
  color: var(--text-muted-green);
}
.table-empty i { font-size: 2.2rem; display: block; margin-bottom: 0.5rem; opacity: 0.6; }

/* Small badges */
.chip {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 50rem;
  background-color: rgba(7, 47, 31, 0.07);
  color: var(--brand-forest-medium);
  white-space: nowrap;
}
.chip.lime { background-color: var(--brand-lime-translucent); color: #4b6b00; }
.chip.orange { background-color: var(--sys-orange-bg); color: #c2410c; }
.chip.red { background-color: var(--sys-red-bg); color: #b91c1c; }
.chip.green { background-color: var(--sys-green-bg); color: #15803d; }

/* Stat cards */
.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-lg);
  background-color: var(--brand-lime-translucent);
  color: var(--brand-forest-medium);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
}
.stat-sub {
  font-size: 0.78rem;
  color: var(--text-muted-green);
  margin-top: 0.25rem;
}
.card-stat .stat-value { font-size: 1.65rem; }

/* Modal polish */
.modal-content {
  border: none;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
}
/* The form wraps header/body/footer, so make it the flex column that scrolls the body.
   This keeps Save / Cancel reachable on short screens such as phones. */
.modal-dialog-scrollable .modal-content > form {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
}
.modal-dialog-scrollable .modal-content > form > .modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}
.modal-header {
  border-bottom: 1px solid rgba(11, 19, 15, 0.06);
  padding: 1.25rem 1.5rem;
}
.modal-title { font-weight: 800; color: var(--text-main); font-size: 1.1rem; }
.modal-body { padding: 1.5rem; }
.modal-footer {
  border-top: 1px solid rgba(11, 19, 15, 0.06);
  padding: 1rem 1.5rem;
}
.field-help { font-size: 0.75rem; color: var(--text-muted-green); margin-top: 0.25rem; }
.lock-note {
  background: var(--sys-orange-bg);
  color: #9a3412;
  border-radius: var(--radius-md);
  padding: 0.6rem 0.9rem;
  font-size: 0.82rem;
  margin-bottom: 1rem;
}

/* Alert / list rows on dashboard */
.alert-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid rgba(11, 19, 15, 0.05);
  text-decoration: none;
  color: var(--text-main);
  font-size: 0.85rem;
}
.alert-row:last-child { border-bottom: none; }
.alert-row .alert-ico {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.alert-row .alert-ico.expired { background: var(--sys-red-bg); color: #b91c1c; }
.alert-row .alert-ico.soon { background: var(--sys-orange-bg); color: #c2410c; }

.mini-bar {
  height: 8px;
  border-radius: 50rem;
  background: #EEF2F0;
  overflow: hidden;
}
.mini-bar > span { display: block; height: 100%; background: var(--brand-forest-medium); border-radius: 50rem; }

.summary-card {
  background: #fff;
  border-radius: var(--radius-xl);
  border: 1px solid rgba(11, 19, 15, 0.06);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.summary-card h3 {
  font-size: 0.95rem;
  font-weight: 800;
  margin: 0;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(11, 19, 15, 0.06);
}

/* Payroll inputs inside table cells */
.cell-input {
  width: 110px;
  padding: 0.35rem 0.5rem;
  font-size: 0.82rem;
  text-align: right;
  border-radius: var(--radius-md);
  border: 1px solid rgba(11, 19, 15, 0.12);
  background: #fff;
}
.cell-input:focus {
  outline: none;
  border-color: var(--brand-forest-medium);
  box-shadow: 0 0 0 3px rgba(7, 47, 31, 0.08);
}
.cell-input.sm { width: 70px; }
.net-pay { font-weight: 800; color: var(--brand-forest-medium); }
.net-pay.neg { color: var(--sys-red); }

.period-btn {
  background: #fff;
  border: 1px solid rgba(11, 19, 15, 0.1);
  border-radius: var(--radius-lg);
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--brand-forest-dark);
}
.period-btn:hover { background: #F8FAF9; border-color: var(--brand-forest-medium); }

.pager-btn {
  min-width: 34px;
  height: 34px;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--brand-forest-dark);
  font-weight: 600;
  font-size: 0.85rem;
}
.pager-btn:hover:not(:disabled) { background: #F8FAF9; }
.pager-btn.active { background: var(--brand-forest-medium); color: #fff; }
.pager-btn:disabled { opacity: 0.4; }

@media print {
  .sidebar-wrapper, .navbar-custom, .footer-custom, .no-print { display: none !important; }
  .main-wrapper { margin: 0 !important; padding: 0 !important; }
}

/* ======================================================================
   PHONE CARD LAYOUT (Option A) - used by pages that supply a card builder
   ====================================================================== */
[hidden] { display: none !important; }
.m-only { display: none; }
.avatar-initials.sm { width: 26px; height: 26px; border-radius: 8px; font-size: 0.62rem; }

/* collapsible summaries (always open on desktop, collapsed on phones) */
.sum-fold > summary { display: none; }
.sum-fold > .row { margin-top: 0; }

@media (max-width: 767.98px) {
  body.has-mcards .page-header { display: none; }

  .crud-mhead {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
  }
  .crud-mtitle { font-size: 1.4rem; font-weight: 800; color: var(--text-main); }
  .crud-madd {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    height: 38px;
    padding: 0 1rem;
    border: 0;
    border-radius: var(--radius-md);
    background: var(--brand-forest-medium);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 700;
  }

  .crud-msum {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
    margin-bottom: 0.75rem;
  }
  .crud-msum > div {
    background: #fff;
    border: 1px solid rgba(11, 19, 15, 0.07);
    border-radius: var(--radius-lg);
    padding: 0.55rem 0.7rem;
    min-width: 0;
  }
  .crud-msum b {
    display: block;
    font-size: clamp(0.78rem, 3.7vw, 0.95rem);
    font-weight: 800;
    color: var(--text-main);
    white-space: nowrap;
  }
  .crud-msum small { font-size: 0.7rem; color: var(--text-muted-green); }

  .crud-mobile #crud-stats { display: none; }

  .crud-mobile .table-card-custom {
    background: transparent;
    border: 0 !important;
    box-shadow: none;
    overflow: visible;
    margin-bottom: 0.75rem !important;
  }
  .crud-mobile .table-header-control {
    background: transparent;
    padding: 0;
    border: 0;
    flex-wrap: nowrap;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
  }
  .crud-mobile .table-search-box { max-width: none; flex: 1 1 auto; min-width: 0; }
  .crud-mobile .table-search-input { height: 40px; }
  .crud-mobile .table-header-control .table-filter-group { display: none; }

  .crud-mfilter {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    height: 40px;
    padding: 0 0.85rem;
    border: 1px solid rgba(11, 19, 15, 0.1);
    border-radius: var(--radius-lg);
    background: #fff;
    color: var(--text-main);
    font-size: 0.85rem;
    font-weight: 700;
    flex-shrink: 0;
  }
  .crud-mfilter b {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--brand-forest-medium);
    color: #fff;
    font-size: 0.68rem;
    display: inline-grid;
    place-items: center;
  }

  .crud-mobile .crud-filters {
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
    background: #fff;
    border: 1px solid rgba(11, 19, 15, 0.07);
    border-radius: var(--radius-lg);
    padding: 0.8rem;
    margin-bottom: 0.7rem;
  }
  .crud-mobile .crud-filters.open { display: flex; }
  .crud-mobile .fleet-filter { max-width: none; width: 100%; }
  .crud-mobile .crud-filters > .d-flex {
    display: grid !important;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 0.5rem 0.6rem !important;
  }
  .crud-mobile .crud-filters .fleet-date { width: 100%; min-width: 0; }
  .crud-mobile .crud-filters .period-btn { grid-column: 1 / -1; }
  #crud-export2, #crud-mclear { display: inline-flex; justify-content: center; width: 100%; }

  .crud-mobile .table-card-custom > .table-responsive,
  .crud-mobile .table-card-custom > .table-footer-control { display: none; }

  .crud-cards { display: flex; flex-direction: column; gap: 0.55rem; }
  .m-card {
    background: #fff;
    border: 1px solid rgba(11, 19, 15, 0.07);
    border-radius: var(--radius-lg);
    padding: 0.7rem 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .m-card.open { border-color: var(--brand-forest-medium); }
  .mc-r1, .mc-r2, .mc-r3 { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
  .mc-title { font-weight: 800; font-size: 0.95rem; color: var(--text-main); min-width: 0; }
  .mc-title small { display: block; font-weight: 500; font-size: 0.72rem; color: var(--text-muted-green); }
  .mc-amt { font-weight: 800; font-size: 1rem; color: var(--text-main); white-space: nowrap; }
  .mc-who { display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; font-weight: 600; min-width: 0; }
  .mc-who > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mc-mut { font-size: 0.78rem; color: var(--text-muted-green); }
  .mc-r2 .mc-mut { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .mc-amt.sm { font-size: 0.82rem; font-weight: 700; flex-shrink: 0; }
  .mc-r3 { flex-wrap: wrap; justify-content: flex-start; }
  .mc-r3 > .chip:last-child, .mc-r3 > .mc-mut + .chip { margin-left: auto; }

  .m-actions {
    display: none;
    gap: 0.5rem;
    padding-top: 0.55rem;
    margin-top: 0.15rem;
    border-top: 1px solid rgba(11, 19, 15, 0.07);
  }
  .m-card.open .m-actions { display: flex; }
  .m-btn {
    flex: 1;
    height: 38px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(11, 19, 15, 0.12);
    background: #fff;
    color: var(--text-main);
    font-size: 0.85rem;
    font-weight: 700;
  }
  .m-btn.danger { color: #b91c1c; border-color: rgba(185, 28, 28, 0.25); }

  .crud-more {
    display: block;
    width: 100%;
    height: 42px;
    margin-top: 0.6rem;
    border: 1px dashed rgba(11, 19, 15, 0.2);
    border-radius: var(--radius-lg);
    background: transparent;
    color: var(--text-muted-green);
    font-size: 0.85rem;
    font-weight: 700;
  }
  .m-empty { text-align: center; padding: 2.5rem 1rem; color: var(--text-muted-green); }
  .m-empty i { display: block; font-size: 2rem; margin-bottom: 0.4rem; opacity: 0.6; }

  /* collapsed totals */
  #crud-extra { margin-top: 0.5rem !important; }
  .sum-fold > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    list-style: none;
    height: 44px;
    padding: 0 0.9rem;
    background: #fff;
    border: 1px solid rgba(11, 19, 15, 0.07);
    border-radius: var(--radius-lg);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-main);
  }
  .sum-fold > summary::-webkit-details-marker { display: none; }
  .sum-fold > summary::after { content: "\F282"; font-family: "bootstrap-icons"; font-size: 0.9rem; transition: transform 0.2s; }
  .sum-fold[open] > summary::after { transform: rotate(180deg); }
  .sum-fold[open] > summary { margin-bottom: 0.75rem; }
  .sum-fold .table-custom th, .sum-fold .table-custom td { padding: 0.6rem 0.55rem; white-space: normal; }
  .sum-fold .mini-bar { max-width: 80px; }
}

/* ======================================================================
   Record cutoff bar, cutoff preview, cash-advance deduct dialog
   ====================================================================== */
.cutbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #fff;
  border: 1px solid rgba(11, 19, 15, 0.08);
  border-radius: var(--radius-lg);
  padding: 0.4rem 0.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}
.page-header > #dash-cutbar { margin-bottom: 0; min-width: 330px; }
.cut-nav {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(11, 19, 15, 0.1);
  border-radius: var(--radius-md);
  background: #F8FAF9;
  color: var(--text-main);
}
.cut-nav:disabled { opacity: 0.35; }
.cut-label { flex: 1; min-width: 0; text-align: center; line-height: 1.2; }
.cut-label small { display: block; font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted-green); }
.cut-label b { display: block; font-size: 0.9rem; font-weight: 800; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cut-tools { display: flex; gap: 0.4rem; flex-shrink: 0; }
.cut-btn {
  height: 38px;
  padding: 0 0.8rem;
  border: 1px solid rgba(11, 19, 15, 0.1);
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--text-main);
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}
.cut-btn.icon { width: 38px; padding: 0; }
.cutoff-preview { background: var(--brand-lime-translucent); border-radius: var(--radius-md); padding: 0.6rem 0.9rem; }
.cutoff-preview small { display: block; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; color: var(--text-muted-green); }
.cutoff-preview b { font-size: 0.95rem; color: var(--text-main); }

.cut-gear-txt { display: none; }
.btn-custom:disabled { opacity: 0.45; cursor: not-allowed; }
@media (max-width: 767.98px) {
  .cutbar { padding: 0.4rem; gap: 0.4rem; flex-wrap: wrap; }
  .cut-label b { white-space: normal; font-size: 0.85rem; }
  .cut-tools { order: 3; width: 100%; }
  .cut-tools .cut-btn { flex: 1; height: 34px; font-size: 0.78rem; }
  .cut-btn.icon { width: auto; }
  .cut-gear-txt { display: inline; }
  .page-header > #dash-cutbar { min-width: 0; width: 100%; margin-top: 0.75rem; }
  .page-header { flex-wrap: wrap; }
}

/* cash advance cards + deduct dialog */
.mc-lbl { font-size: 0.7rem; font-weight: 600; color: var(--text-muted-green); }
.mc-prog { height: 6px; border-radius: 50rem; background: rgba(11, 19, 15, 0.08); overflow: hidden; }
.mc-prog > span { display: block; height: 100%; background: var(--brand-forest-medium); border-radius: 50rem; }
.m-btn.primary { background: var(--brand-forest-medium); color: #fff; border-color: var(--brand-forest-medium); }
.ded-sum { background: #F8FAF9; border-radius: var(--radius-lg); padding: 0.8rem; }
.ded-who { display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; margin-bottom: 0.6rem; }
.ded-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
.ded-grid small { display: block; font-size: 0.68rem; color: var(--text-muted-green); font-weight: 600; }
.ded-grid b { font-size: 0.95rem; white-space: nowrap; }
.ded-grid .bal b { color: #b91c1c; }
.ded-grid .ok b { color: #15803d; }
.ded-amt { display: flex; gap: 0.5rem; }
.ded-amt .form-control-custom { flex: 1; min-width: 0; }
.ded-amt .btn-custom { white-space: nowrap; }
.ded-hist { margin-top: 1rem; }
.ded-hist h6 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted-green); margin-bottom: 0.4rem; }
.ded-row { display: flex; align-items: center; gap: 0.6rem; padding: 0.45rem 0; border-top: 1px solid rgba(11, 19, 15, 0.07); font-size: 0.85rem; }
.ded-row > span { flex: 1; min-width: 0; }
.ded-row small { color: var(--text-muted-green); margin-left: 0.3rem; }
.ded-row a { color: #b91c1c; }
.ded-note-line { font-size: 0.85rem; color: var(--text-muted-green); }

/* ======================================================================
   Driver photos and profile
   ====================================================================== */
.avatar-initials.has-photo { background: #E9EFEF; padding: 0; overflow: hidden; border-radius: 50%; }
.avatar-initials img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: inherit; }
.avatar-initials.md { width: 44px; height: 44px; border-radius: 50%; font-size: 0.9rem; }
.avatar-initials.xl { width: 88px; height: 88px; border-radius: 50%; font-size: 1.6rem; border: 3px solid #fff; box-shadow: 0 2px 10px rgba(11, 19, 15, 0.15); }
.avatar-initials.sm { overflow: hidden; }
tr.row-click { cursor: pointer; }
tr.row-click:hover td { background: #F8FAF9; }
.m-card.view { cursor: pointer; }
.m-card.view:active { border-color: var(--brand-forest-medium); }
.mc-who .avatar-initials.md { margin-right: 0.1rem; }

.form-section {
  margin-top: 0.4rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid rgba(11, 19, 15, 0.08);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted-green);
}

/* photo picker */
.photo-row { display: flex; align-items: center; gap: 1rem; }
.photo-preview {
  width: 84px; height: 84px; flex-shrink: 0;
  border-radius: 50%;
  background: #E9EFEF;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  color: var(--text-muted-green);
  font-size: 2.4rem;
  border: 3px solid #fff;
  box-shadow: 0 0 0 1px rgba(11, 19, 15, 0.12);
}
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.photo-btns { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.photo-btns .field-help { flex-basis: 100%; margin: 0; }
.photo-editor {
  margin-top: 0.9rem;
  padding: 1rem;
  background: #F8FAF9;
  border: 1px dashed rgba(11, 19, 15, 0.2);
  border-radius: var(--radius-lg);
  text-align: center;
}
.photo-stage {
  position: relative;
  width: 220px; height: 220px;
  margin: 0 auto;
  border-radius: 50%;
  overflow: hidden;
  background: #0b130f;
  cursor: grab;
  touch-action: none;
  user-select: none;
  box-shadow: 0 0 0 4px #fff, 0 0 0 5px rgba(11, 19, 15, 0.2);
}
.photo-stage:active { cursor: grabbing; }
.photo-stage img { position: absolute; left: 0; top: 0; max-width: none; transform-origin: 0 0; pointer-events: none; }
.photo-zoom { display: flex; align-items: center; gap: 0.6rem; max-width: 260px; margin: 0.9rem auto 0.2rem; color: var(--text-muted-green); }
.photo-zoom input { flex: 1; accent-color: var(--brand-forest-medium); }
.photo-hint { font-size: 0.75rem; color: var(--text-muted-green); margin-bottom: 0.7rem; }
.photo-actions { display: flex; justify-content: center; gap: 0.6rem; }

/* profile dialog */
.pf-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.pf-id h4 { margin: 0 0 0.35rem; font-size: 1.25rem; font-weight: 800; color: var(--text-main); }
.pf-chips { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 0.35rem; }
.pf-phone { font-size: 0.85rem; font-weight: 600; color: var(--brand-forest-medium); text-decoration: none; }
.pf-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem; margin-bottom: 1rem; }
.pf-stats > div { background: #F8FAF9; border-radius: var(--radius-md); padding: 0.6rem 0.4rem; text-align: center; min-width: 0; }
.pf-stats b { display: block; font-size: 1rem; font-weight: 800; color: var(--text-main); white-space: nowrap; }
.pf-stats small { font-size: 0.68rem; color: var(--text-muted-green); }
.pf-stats .owe b { color: #b91c1c; }
.pf-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; }
.pf-sec { border: 1px solid rgba(11, 19, 15, 0.08); border-radius: var(--radius-lg); padding: 0.8rem 0.9rem; margin: 0; }
.pf-cols .pf-sec:first-child { grid-row: span 2; }
.pf-sec h3 { font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted-green); margin: 0 0 0.5rem; }
.pf-sec h3 i { margin-right: 0.3rem; }
.pf-sec dl { margin: 0; }
.pf-row { display: flex; flex-direction: column; padding: 0.4rem 0; border-top: 1px solid rgba(11, 19, 15, 0.06); }
.pf-row:first-child { border-top: 0; padding-top: 0; }
.pf-row dt { font-size: 0.7rem; font-weight: 600; color: var(--text-muted-green); }
.pf-row dd { margin: 0; font-size: 0.92rem; font-weight: 700; color: var(--text-main); word-break: break-word; }
.pf-row dd.none { font-weight: 500; color: #9aa8a1; font-style: italic; }
.pf-row dd small { display: block; font-size: 0.75rem; font-weight: 500; color: var(--text-muted-green); }
.pf-notes { margin: 0; font-size: 0.88rem; white-space: pre-wrap; }
.pf-sec + .pf-sec { margin-top: 0; }
.pf-cols + .pf-sec { margin-top: 0.9rem; }
.pf-foot { gap: 0.5rem; }
.pf-foot .pf-del { margin-right: auto; color: #b91c1c; }
@media (max-width: 767.98px) {
  .pf-cols { grid-template-columns: 1fr; }
  .pf-cols .pf-sec:first-child { grid-row: auto; }
  .pf-stats { grid-template-columns: repeat(2, 1fr); }
  .pf-foot { flex-wrap: wrap; }
  .pf-foot .btn-custom { flex: 1 1 40%; justify-content: center; }
  .pf-foot .pf-del { flex-basis: 100%; order: 5; margin-right: 0; }
  .photo-stage { width: 220px; height: 220px; }
}

/* ================= Sign-in, users, account, sync notices ================= */
.login-brand .brand-logo { width: 40px; height: 40px; border-radius: 10px; animation: none; }
.login-card .field-help { margin-top: 0.35rem; }
.login-card .btn-custom { height: 46px; }
.auth-error, .auth-ok {
  padding: 0.65rem 0.9rem; border-radius: var(--radius-md); font-size: 0.86rem; font-weight: 600; margin-bottom: 1rem;
}
.auth-error { background: rgba(185, 28, 28, 0.08); color: #b91c1c; border: 1px solid rgba(185, 28, 28, 0.2); }
.auth-ok { background: rgba(21, 128, 61, 0.1); color: #15803d; border: 1px solid rgba(21, 128, 61, 0.22); }
.acc-ident { padding: 0.7rem 0; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

.role-help { display: grid; gap: 0.5rem; font-size: 0.86rem; color: var(--text-muted-green); }
.role-help .chip { margin-right: 0.4rem; }

.nav-pills-custom { list-style: none; display: flex; gap: 0.4rem; padding: 0; margin: 0; }
.nav-pills-custom button {
  border: 1px solid rgba(11, 19, 15, 0.12); background: #fff; color: var(--text-main); border-radius: 999px;
  padding: 0.45rem 1rem; font-size: 0.86rem; font-weight: 700; display: inline-flex; gap: 0.4rem; align-items: center;
}
.nav-pills-custom button.active { background: var(--brand-forest-medium); color: #fff; border-color: var(--brand-forest-medium); }

.user-list { display: grid; gap: 0.7rem; }
.user-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.8rem 1.4rem; padding: 0.9rem 1.1rem;
  background: var(--card-background); border: 1px solid var(--border-light); border-radius: var(--radius-lg);
}
.user-row.off { opacity: 0.65; }
.user-row .u-who { display: flex; align-items: center; gap: 0.8rem; flex: 1 1 220px; min-width: 0; }
.user-row .u-name { font-weight: 800; color: var(--text-main); }
.user-row .u-sub { font-size: 0.8rem; color: var(--text-muted-green); }
.user-row .u-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.7rem; flex: 1 1 260px; }
.user-row .u-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.user-row .m-btn {
  flex: none; height: 34px; padding: 0 0.8rem; border-radius: var(--radius-md); border: 1px solid rgba(11, 19, 15, 0.12);
  background: #fff; color: var(--text-main); font-size: 0.8rem; font-weight: 700; display: inline-flex; align-items: center; gap: 0.35rem;
}
.user-row .m-btn:hover { background: #f1f5f3; }
.user-row .m-btn.danger { color: #b91c1c; border-color: rgba(185, 28, 28, 0.25); }
.cred-box {
  background: #f4f6f5; border: 1px dashed rgba(11, 19, 15, 0.25); border-radius: var(--radius-md); padding: 0.9rem 1rem;
  font-size: 0.88rem; white-space: pre-wrap; word-break: break-word; margin: 0; user-select: all;
}

.sync-banner {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 1rem; z-index: 2000; max-width: min(94vw, 560px);
  padding: 0.7rem 1rem; border-radius: var(--radius-lg); font-size: 0.86rem; font-weight: 600; box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap;
}
.sync-banner.warn { background: #fff7ed; color: #9a3412; border: 1px solid #fdba74; bottom: 5.9rem; }
.sync-banner.info { background: var(--brand-forest-medium); color: #fff; bottom: 5.9rem; }
.sync-banner .sync-btn { border: 0; border-radius: 999px; padding: 0.3rem 0.9rem; background: var(--brand-lime); color: #1a2e05; font-weight: 800; }
@media (min-width: 768px) { .sync-banner.warn, .sync-banner.info { bottom: 1rem; } }
/* ---------------------------------------------------------------------
   Desktop app (Electron): no title bar - the page fills the whole window and the
   Windows minimise / maximise / close buttons sit on top of the top bar.
--------------------------------------------------------------------- */
html.is-desktop #btn-fullscreen { display: none !important; }       /* full screen button is for the browser only */
html.is-desktop .navbar-custom { -webkit-app-region: drag; padding-right: calc(2.5rem + 138px); }
html.is-desktop .navbar-custom :is(button, a, input, select, .dropdown, .dropdown-menu, .navbar-search-wrapper) { -webkit-app-region: no-drag; }
/* pages without a top bar (sign-in) still need a strip to drag the window by */
html.is-desktop body:not(:has(.navbar-custom))::before {
  content: ''; position: fixed; top: 0; left: 0; right: 138px; height: 32px;
  -webkit-app-region: drag; z-index: 2000;
}
@media (max-width: 1200px) { html.is-desktop .navbar-custom { padding-right: calc(1rem + 138px); } }

/* ---------------------------------------------------------------------
   Moving between pages: the sidebar and top bar stay put, only the content fades quickly.
--------------------------------------------------------------------- */
@view-transition { navigation: auto; }
.sidebar-wrapper { view-transition-name: es-sidebar; }
.navbar-custom { view-transition-name: es-topbar; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .12s; }
::view-transition-group(es-sidebar), ::view-transition-group(es-topbar) { animation-duration: 0s; }
@media (prefers-reduced-motion: reduce) { ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; } }
