:root {
  font-family:
    Inter,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  color: #172b4d;
  background: #eef3f9;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  line-height: 1.5;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px;
  min-height: 100vh;
}

/* MODERN HEADER */

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  background: linear-gradient(135deg, #102a43, #174c86);
  border-radius: 20px;
  box-shadow: 0 8px 24px rgba(16, 42, 67, 0.16);
}

header h1 {
  color: #ffffff;
  margin: 0;
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

h1 {
  font-size: 1.55rem;
}

h2 {
  color: #102a43;
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.3px;
  margin-top: 0;
}

/* DASHBOARD CARDS */

section {
  background: #ffffff;
  border: 1px solid #e3eaf3;
  border-radius: 20px;
  padding: 28px;
  margin: 24px 0;
  box-shadow: 0 8px 30px rgba(23, 43, 77, 0.06);
}

/* FORM ELEMENTS */

label {
  display: block;
  margin: 12px 0;
  font-weight: 600;
  color: #334155;
}

input {
  display: block;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  margin-top: 6px;
  font-size: 1rem;
  background: #ffffff;
  color: #172b4d;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* GENERAL BUTTONS */

button {
  border: 0;
  background: #174c86;
  color: #ffffff;
  border-radius: 12px;
  padding: 14px 20px;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition:
    transform 0.2s,
    box-shadow 0.2s,
    opacity 0.2s;
}

button:hover:not(:disabled) {
  box-shadow: 0 6px 16px rgba(16, 42, 67, 0.14);
}

button:active:not(:disabled) {
  transform: scale(0.97);
}

button:focus-visible {
  outline: 3px solid #f59e0b;
  outline-offset: 3px;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* TRUCK BUTTONS */

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

.truckButtons button {
  min-height: 125px;
  padding: 20px;
  font-size: 1.4rem;
  font-weight: 800;
  border-radius: 18px;
  box-shadow: 0 6px 16px rgba(16, 42, 67, 0.12);
}

#big {
  background: linear-gradient(135deg, #059669, #047857);
}

#small {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
}

/* ATTENDANCE BUTTONS */

#in {
  background: linear-gradient(135deg, #0891b2, #0e7490);
}

#out {
  background: linear-gradient(135deg, #8b5cf6, #6d28d9);
}

/* ACTIONS */

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
}

/* PHOTO PREVIEW */

#preview {
  display: block;
  max-width: 100%;
  max-height: 420px;
  object-fit: contain;
  margin: 16px 0;
  border-radius: 14px;
}

/* DAILY TRUCK COUNTERS */

#counts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin: 20px 0;
}

#counts strong {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 85px;
  padding: 16px;
  background: #eff6ff;
  color: #174c86;
  border: 1px solid #dbeafe;
  border-radius: 16px;
  font-size: 1.1rem;
  font-weight: 800;
  text-align: center;
  overflow-wrap: anywhere;
}

/* TRUCK AND ATTENDANCE RECORDS */

.entry {
  padding: 18px 0;
  border-top: 1px solid #e2e8f0;
  color: #334155;
}

.entry img {
  display: block;
  width: 280px;
  max-width: 100%;
  height: auto;
  margin-top: 14px;
  border-radius: 14px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 12px rgba(16, 42, 67, 0.08);
}

/* STATUS MESSAGES */

#message {
  font-weight: 600;
  white-space: pre-wrap;
  line-height: 1.6;
}

/* LOGOUT BUTTON */

#logout {
  background: #334e68;
  color: #ffffff;
  white-space: nowrap;
}

/* MOBILE RESPONSIVE DESIGN */

@media (max-width: 600px) {
  main {
    padding: 14px;
  }

  header {
    padding: 16px;
    border-radius: 16px;
  }

  header h1 {
    font-size: 1.15rem;
  }

  section {
    padding: 18px;
    margin: 16px 0;
    border-radius: 16px;
  }

  h2 {
    font-size: 1.1rem;
  }

  .truckButtons {
    gap: 10px;
  }

  .truckButtons button {
    min-height: 105px;
    padding: 12px;
    font-size: 1.1rem;
  }

  #counts {
    gap: 8px;
  }

  #counts strong {
    min-height: 75px;
    padding: 10px 6px;
    font-size: 0.85rem;
  }

  .actions {
    flex-direction: column;
  }

  .actions button {
    width: 100%;
  }

  #logout {
    padding: 10px 12px;
    font-size: 0.85rem;
  }

  .entry img {
    width: 100%;
    max-width: 340px;
  }
}

@media (prefers-reduced-motion: reduce) {
  button,
  input {
    transition: none;
  }
}

#preview[hidden] {
  display: none;
}

#offlinePanel[hidden] { display: none; }
#offlinePanel { background: #f8fbff; }
#pendingCount { font-weight: 800; }
