/* =========================================================
   BASE
   ========================================================= */

* {
  box-sizing: border-box;
}

html {
  font-family: Arial, Helvetica, sans-serif;
}

body {
  margin: 0;

  background: #f5f6f8;
  color: #222;

  font-size: 15px;
  line-height: 1.5;
}

a {
  color: #1769aa;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1,
h2,
h3 {
  color: #222;
}

h1 {
  margin-top: 0;
  margin-bottom: 8px;
}

h2 {
  margin-top: 0;
  margin-bottom: 18px;

  font-size: 20px;
}

p {
  margin-top: 0;
  margin-bottom: 12px;
}

small {
  color: #666;
}

.muted {
  color: #666;
}

/* =========================================================
     NAVIGATION
     ========================================================= */

nav {
  display: flex;
  align-items: center;
  gap: 22px;

  min-height: 58px;

  padding: 14px 24px;

  background: #17202a;
}

nav a {
  color: #fff;
  text-decoration: none;
}

nav a:hover {
  text-decoration: underline;
}

nav .brand {
  margin-right: 20px;

  font-size: 17px;
  font-weight: 700;

  white-space: nowrap;
}

.nav-spacer {
  flex: 1;
}

.tenant-name {
  color: #cfd8dc;

  font-size: 14px;

  white-space: nowrap;
}

.logout-form {
  margin: 0;
  padding: 0;
}

.nav-button {
  margin: 0;
  padding: 0;

  border: 0;

  background: transparent;
  color: #fff;

  font: inherit;

  cursor: pointer;
}

.nav-button:hover {
  text-decoration: underline;
}

/* =========================================================
     MAIN LAYOUT
     ========================================================= */

main {
  width: 100%;
  max-width: 1200px;

  margin: 30px auto;
  padding: 0 20px;
}

.page-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;

  margin-bottom: 22px;
}

.page-title h1 {
  margin-bottom: 4px;
}

.page-title p {
  margin: 0;
}

/* =========================================================
     PANELS
     ========================================================= */

.panel {
  margin-bottom: 20px;
  padding: 20px;

  border: 1px solid #ddd;
  border-radius: 8px;

  background: #fff;
}

.panel-heading,
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;

  margin-bottom: 18px;
}

.panel-heading h2,
.section-heading h2 {
  margin: 0;
}

.panel-actions {
  margin-top: auto;
  padding-top: 18px;
}

/* =========================================================
     TWO COLUMN LAYOUT
     ========================================================= */

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;

  margin-bottom: 20px;

  align-items: stretch;
}

.grid-2 > .panel {
  display: flex;
  flex-direction: column;

  margin-bottom: 0;
}

/* =========================================================
     DASHBOARD
     ========================================================= */

/* Main summary cards */

.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 15px;

  margin-bottom: 20px;
}

.card {
  display: block;

  padding: 18px 20px;

  border: 1px solid #ddd;
  border-radius: 8px;

  background: #fff;
  color: #222;

  text-decoration: none;
}

a.card:hover {
  border-color: #bbb;

  text-decoration: none;
}

.card span {
  display: block;

  color: #666;

  font-size: 13px;
}

.card strong {
  display: block;

  margin-top: 3px;

  font-size: 27px;
  line-height: 1.2;
}

.card small {
  display: block;

  margin-top: 2px;

  color: #666;
}

/* Needs attention */

.dashboard-attention {
  padding-top: 16px;
  padding-bottom: 16px;
}

.dashboard-attention-header h2 {
  margin-bottom: 12px;

  font-size: 17px;
}

.dashboard-attention-items {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.dashboard-attention-item {
  display: block;

  padding: 4px 18px;

  border-right: 1px solid #e5e5e5;

  color: #222;
  text-decoration: none;
}

.dashboard-attention-item:first-child {
  padding-left: 0;
}

.dashboard-attention-item:last-child {
  border-right: 0;
}

.dashboard-attention-item:hover {
  text-decoration: none;
}

.dashboard-attention-item span {
  display: block;

  color: #666;

  font-size: 13px;
}

.dashboard-attention-item strong {
  display: inline-block;

  margin-top: 2px;

  font-size: 20px;
}

.dashboard-attention-item small {
  margin-left: 5px;

  color: #666;
}

/* Contracts requiring attention */

.dashboard-section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;

  margin-bottom: 14px;
}

.dashboard-section-header h2 {
  margin-bottom: 2px;

  font-size: 18px;
}

.dashboard-section-header p {
  margin: 0;
}

.dashboard-section-header > a {
  flex-shrink: 0;

  font-size: 14px;
}

/* Small dashboard status badges */

.badge {
  display: inline-block;

  padding: 3px 8px;

  border-radius: 12px;

  background: #eef2f5;
  color: #555;

  font-size: 12px;
  font-weight: 600;

  white-space: nowrap;
}

.badge.warning {
  background: #fff3cd;
  color: #664d03;
}

/* =========================================================
     BUTTONS
     ========================================================= */

.button {
  display: inline-block;

  width: auto;

  padding: 10px 14px;

  border: 0;
  border-radius: 6px;

  background: #1769aa;
  color: #fff;

  font: inherit;
  font-weight: 600;

  text-decoration: none;

  cursor: pointer;
}

.button:hover {
  opacity: 0.92;

  color: #fff;
  text-decoration: none;
}

.button.secondary {
  background: #666;
}

.button.danger {
  background: #b3261e;
}

.button:disabled {
  opacity: 0.5;

  cursor: not-allowed;
}

/* =========================================================
     FORMS
     ========================================================= */

form {
  max-width: 650px;
}

form label {
  display: block;

  margin-bottom: 15px;

  font-weight: 600;
}

input,
select,
textarea {
  display: block;

  width: 100%;

  margin-top: 6px;
  padding: 10px 11px;

  border: 1px solid #ccc;
  border-radius: 5px;

  background: #fff;
  color: #222;

  font: inherit;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #1769aa;
  outline: none;

  box-shadow: 0 0 0 2px rgba(23, 105, 170, 0.12);
}

textarea {
  min-height: 110px;

  resize: vertical;
}

input[type="checkbox"] {
  display: inline-block;

  width: auto;

  margin-right: 8px;
}

form .button {
  width: auto;
}

.inline-form {
  display: inline-flex;
  align-items: center;
  gap: 8px;

  max-width: none;

  margin: 0;
}

.inline-form select {
  width: auto;

  margin: 0;
}

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

/* =========================================================
     AUTH
     ========================================================= */

.auth-card {
  max-width: 480px;

  margin: 50px auto;
  padding: 30px;

  border: 1px solid #ddd;
  border-radius: 8px;

  background: #fff;
}

.auth-card h1 {
  margin-bottom: 24px;
}

.alert {
  margin-bottom: 16px;
  padding: 12px 14px;

  border: 1px solid #ffe69c;
  border-radius: 6px;

  background: #fff3cd;
  color: #664d03;
}

/* =========================================================
     TABLES
     ========================================================= */

table {
  width: 100%;

  margin-bottom: 30px;

  border-collapse: collapse;

  background: #fff;
}

th,
td {
  padding: 12px;

  border-bottom: 1px solid #e5e5e5;

  text-align: left;
  vertical-align: middle;
}

th {
  background: #fafafa;

  color: #444;

  font-size: 14px;
  font-weight: 600;
}

tbody tr:hover {
  background: #fafafa;
}

.panel table {
  margin-bottom: 0;
}

/* =========================================================
     STATUS
     ========================================================= */

.status {
  display: inline-block;

  font-weight: 700;
}

.status.in {
  color: #188038;
}

.status.out {
  color: #b3261e;
}

/* =========================================================
     VEHICLE / OWNER SUMMARY
     ========================================================= */

.vehicle-summary,
.owner-summary {
  min-height: 100%;
}

.vehicle-summary p,
.owner-summary p {
  margin-bottom: 10px;
}

/* =========================================================
     CONTRACT SUMMARY
     ========================================================= */

.detail-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 20px;
}

.detail-grid > div {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.detail-label {
  color: #666;

  font-size: 13px;
}

.detail-grid strong {
  font-size: 15px;
}

/* =========================================================
     VEHICLE CONDITION
     ========================================================= */

.condition-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 15px;

  margin-bottom: 20px;
}

.condition-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;

  margin: 20px 0;
}

.condition-summary > div {
  display: flex;
  flex-direction: column;
  gap: 5px;

  padding: 14px;

  border: 1px solid #ddd;
  border-radius: 8px;

  background: #fafafa;
}

.condition-summary span {
  color: #666;

  font-size: 13px;
}

.condition-summary strong {
  font-size: 16px;
}

.condition-notes {
  margin: 20px 0;
  padding: 14px;

  border-left: 3px solid #ccc;

  background: #fafafa;
}

.condition-notes p {
  margin: 5px 0 0;
}

/* =========================================================
     VEHICLE MOVEMENTS
     ========================================================= */

.movement {
  padding: 18px 0;

  border-top: 1px solid #ddd;
}

.movement:first-of-type {
  border-top: 0;
}

.movement-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;

  margin-bottom: 12px;
}

.movement-header strong {
  font-size: 16px;
}

.movement-condition {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;

  margin: 10px 0;

  font-size: 14px;
}

.movement-notes {
  margin-top: 12px;
  margin-bottom: 10px;
}

/* =========================================================
     VEHICLE PHOTOS
     ========================================================= */

.vehicle-photos {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;

  margin-top: 12px;
}

.vehicle-photos a {
  display: block;

  line-height: 0;
}

.vehicle-photos img {
  width: 150px;
  height: 110px;

  object-fit: cover;

  border: 1px solid #ddd;
  border-radius: 6px;

  background: #eee;
}

.vehicle-photos img:hover {
  opacity: 0.9;
}

.vehicle-photos.large img {
  width: 190px;
  height: 140px;
}

/* =========================================================
     PHOTO UPLOAD / PREVIEW
     ========================================================= */

#photoPreview {
  margin-bottom: 20px;
}

#photoPreview:empty {
  display: none;
}

/* =========================================================
     CHECK-IN / CHECK-OUT
     ========================================================= */

.vehicle-check-form {
  max-width: none;
}

.vehicle-check-form .panel-actions {
  display: flex;
  gap: 10px;

  margin-top: 20px;
}

/* =========================================================
     INVOICE DISPLAY
     ========================================================= */

.invoice-status {
  font-weight: 600;
}

.invoice-status.paid {
  color: #188038;
}

.invoice-status.overdue {
  color: #b3261e;
}

.invoice-status.sent {
  color: #1769aa;
}

.invoice-status.draft {
  color: #666;
}

/* =========================================================
     SMALL HELPERS
     ========================================================= */

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

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

.no-margin {
  margin: 0;
}

.mb-0 {
  margin-bottom: 0;
}

.mt-20 {
  margin-top: 20px;
}
/* =========================================================
   LIST FILTERS
   ========================================================= */

.filter-panel {
  padding: 16px 18px;
}

.filter-form {
  display: grid;
  grid-template-columns:
    minmax(240px, 2fr)
    minmax(120px, 0.8fr)
    minmax(140px, 1fr)
    minmax(160px, 1fr)
    auto;

  align-items: end;
  gap: 12px;

  max-width: none;
}

.filter-form label {
  margin: 0;

  color: #555;

  font-size: 13px;
  font-weight: 600;
}

.filter-form input,
.filter-form select {
  margin-top: 5px;
}

.filter-actions {
  display: flex;
  gap: 7px;
}

.filter-actions .button {
  white-space: nowrap;
}
.owner-filter-form {
  grid-template-columns: minmax(280px, 500px) auto;
  justify-content: start;
}
.contract-filter-form {
  grid-template-columns:
    minmax(240px, 2fr)
    minmax(130px, 0.8fr)
    minmax(150px, 1fr)
    minmax(190px, 1.2fr)
    auto;
}
.invoice-filter-form {
  grid-template-columns:
    minmax(280px, 500px)
    minmax(150px, 180px)
    auto;

  justify-content: start;
}

.text-warning {
  color: #b26a00;
  font-weight: 600;
}
.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
/* =========================================================
     RESPONSIVE
     ========================================================= */

@media (max-width: 900px) {
  .detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .condition-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .filter-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-search {
    grid-column: 1 / -1;
  }

  .filter-actions {
    grid-column: 1 / -1;
  }
}

@media (max-width: 700px) {
  body {
    font-size: 15px;
  }

  nav {
    flex-wrap: wrap;
    gap: 14px;

    padding: 14px 18px;
  }

  nav .brand {
    width: 100%;

    margin-right: 0;
  }

  .nav-spacer {
    display: none;
  }

  .tenant-name {
    margin-left: auto;
  }

  main {
    margin-top: 20px;
    padding: 0 14px;
  }

  .page-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  /* Dashboard */

  .cards {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .dashboard-attention-items {
    grid-template-columns: 1fr;
  }

  .dashboard-attention-item,
  .dashboard-attention-item:first-child {
    padding: 10px 0;

    border-right: 0;
    border-bottom: 1px solid #e5e5e5;
  }

  .dashboard-attention-item:last-child {
    border-bottom: 0;
  }

  .dashboard-section-header {
    flex-direction: column;
    gap: 6px;
  }

  /* Details */

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .condition-grid {
    grid-template-columns: 1fr;
  }

  .condition-summary {
    grid-template-columns: 1fr;
  }

  .movement-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .movement-condition {
    flex-direction: column;
    gap: 6px;
  }

  .vehicle-photos img,
  .vehicle-photos.large img {
    width: 120px;
    height: 90px;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  table {
    display: block;

    max-width: 100%;

    overflow-x: auto;

    white-space: nowrap;
  }

  th,
  td {
    padding: 10px;
  }

  form {
    max-width: 100%;
  }

  .auth-card {
    margin: 25px auto;
    padding: 20px;
  }
  .filter-form {
    grid-template-columns: 1fr;
  }

  .filter-search,
  .filter-actions {
    grid-column: auto;
  }
  .owner-filter-form {
    grid-template-columns: 1fr;
  }
  .invoice-filter-form {
    grid-template-columns: 1fr;
  }
  .page-actions {
    flex-wrap: wrap;
  }
}

@media (max-width: 450px) {
  .vehicle-photos {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }

  .vehicle-photos a {
    width: 100%;
  }

  .vehicle-photos img,
  .vehicle-photos.large img {
    width: 100%;
    height: 110px;
  }

  .button {
    min-height: 42px;
  }

  .panel {
    padding: 16px;
  }
}

/* =========================================================
     TABLE EMPTY STATES
     ========================================================= */

.table-empty {
  text-align: center;
  padding: 48px 24px !important;
}

.table-empty strong {
  display: block;
  font-size: 17px;
  margin-bottom: 6px;
}

.table-empty span {
  display: block;
  margin-bottom: 18px;
  color: #6b7280;
}

.table-empty .button {
  display: inline-block;
}

/* Standalone empty state used inside forms */

.empty-state {
  text-align: center;
  padding: 40px 24px;
}

.empty-state h2 {
  margin-top: 0;
  margin-bottom: 8px;
}

.empty-state p {
  max-width: 520px;
  margin: 0 auto 20px;
  color: #6b7280;
}

.empty-state .panel-actions {
  justify-content: center;
}
