:root {
  --brand: #f5821f;
  --brand-dark: #d96c0c;
  --ink: #1f2933;
  --muted: #5f6b7a;
  --line: #e3e7ec;
  --bg: #f6f7f9;
  --card: #fff;
  --danger: #b42318;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

h1, h2 { margin: 0 0 16px; font-size: 1.15rem; }

/* Layout */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  background: var(--card);
  border-bottom: 3px solid var(--brand);
}
.topbar img { height: 40px; width: auto; display: block; }

/* minmax(0, ...) lets the wide table scroll inside its card instead of stretching the page */
main { max-width: 1100px; margin: 0 auto; padding: 16px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px;
}

/* Forms */
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }

label { display: grid; gap: 4px; font-size: 0.875rem; font-weight: 600; color: var(--muted); }

input, select {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 10px 12px;
  /* 1rem, not the label's smaller size: iPhones zoom the page when a focused field is under 16px */
  font: inherit;
  font-size: 1rem;
  font-weight: 400;
  color: var(--ink);
  background: #fff;
  border: 1px solid #c5ccd6;
  border-radius: 8px;
}
input:focus-visible, select:focus-visible, button:focus-visible {
  outline: 3px solid rgb(245 130 31 / 0.45);
  outline-offset: 1px;
  border-color: var(--brand);
}
#vehicleNo { text-transform: uppercase; }

button {
  padding: 10px 18px;
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  background: var(--brand);
  border: 1px solid var(--brand-dark);
  border-radius: 8px;
  cursor: pointer;
}
button:hover { background: var(--brand-dark); }
button:disabled { opacity: 0.6; cursor: wait; }
button.ghost { background: #fff; border-color: #c5ccd6; }
button.ghost:hover { background: var(--bg); }
button.danger { padding: 4px 10px; font-size: 0.875rem; color: var(--danger); background: #fff; border-color: #f0c4bf; }
button.danger:hover { background: #fdf0ee; }

.actions { display: flex; align-items: center; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.status { margin: 0; font-size: 0.9rem; color: var(--muted); }
.status.error { color: var(--danger); }

/* Records */
.filters { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.filters label { flex: 1 1 150px; max-width: 200px; }
.filters .push { margin-left: auto; }

.summary { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; padding: 0; list-style: none; }
.summary li { padding: 6px 12px; font-size: 0.9rem; background: #fff4ea; border: 1px solid #fbd3ad; border-radius: 999px; }
.summary strong { font-variant-numeric: tabular-nums; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.925rem; white-space: nowrap; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); }
th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); background: var(--bg); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: #fffaf5; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: 100%; max-width: 380px; padding: 32px 28px; border-top: 4px solid var(--brand); }
.login img { display: block; width: 100%; max-width: 260px; height: auto; margin: 0 auto 24px; }
.login h1 { text-align: center; color: var(--muted); font-size: 1rem; font-weight: 600; }
.login form { display: grid; gap: 14px; }
.login button { margin-top: 4px; }

/* Phone: two-column form, and each record becomes a card instead of a wide table row
   (the data-label on every cell supplies the column name) */
@media (max-width: 640px) {
  main { padding: 12px; gap: 12px; }
  .card { padding: 16px; }
  .topbar img { height: 34px; }

  .fields { grid-template-columns: 1fr 1fr; gap: 12px; }
  .actions button { width: 100%; }

  .filters { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
  .filters label { grid-column: span 3; max-width: none; }
  .filters button { grid-column: span 2; padding-inline: 6px; }
  .filters .push { grid-column: 1 / -1; margin: 0; }

  .table-wrap { overflow: visible; }
  table { white-space: normal; }
  thead { display: none; }
  table, tbody, td { display: block; }
  tbody tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 16px;
    margin-bottom: 10px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
  }
  tbody tr:hover { background: none; }
  td, td.num { padding: 0; text-align: left; overflow-wrap: anywhere; border: 0; }
  td::before {
    content: attr(data-label);
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
  }
  td:last-child, td.empty { grid-column: 1 / -1; }
  td:last-child { text-align: right; }
  td.empty { padding: 12px 0; text-align: center; }
  button.danger { min-height: 44px; padding: 8px 18px; }
}
