/* ===========================================================
   Fleet / HR Ops Demo — shared styles
   Sidebar app shell + panel/table system, derived from the
   legend (required *, dropdown v, selected = green pill,
   +/x add-remove, back/next <>, alternating row shading)
   =========================================================== */

:root {
  --bg: #eef1f0;
  --surface: #ffffff;
  --border: #d7ddd9;
  --border-strong: #b7c0ba;
  --text: #202826;
  --text-muted: #6d7772;
  --accent: #2f5fd9;
  --accent-dark: #244bb0;
  --success: #4caf6e;
  --success-light: #e4f5e9;
  --success-dark: #2f8a52;
  --danger: #e0464c;
  --danger-light: #fbe7e7;
  --warning: #c9821a;
  --warning-light: #fbedd9;
  --info: #2f6fd9;
  --stripe: #eef7ef;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 30, 25, 0.05), 0 6px 18px rgba(20, 30, 25, 0.05);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

/* ---------- app shell ---------- */

.app-shell {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  max-width: 1180px;
  margin: 28px auto;
  padding: 0 20px 40px;
}

.demo-banner {
  max-width: 1180px;
  margin: 16px auto 0;
  padding: 0 20px;
  display: flex;
  justify-content: flex-end;
}
.demo-tag {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: #e7edfd;
  border: 1px solid #c9d6f9;
  padding: 3px 8px;
  border-radius: 999px;
}

/* sidebar */

.sidebar {
  width: 210px;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 16px;
  position: sticky;
  top: 20px;
}

.user-greet {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 18px;
  padding-left: 4px;
  text-decoration: none;
  cursor: pointer;
  line-height: 1.5;
}
.user-greet:hover {
  color: var(--accent);
}
.user-greet .switch-icon {
  display: block;
  font-size: 10.5px;
  font-weight: 600;
  opacity: 0.7;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.nav-item {
  display: block;
  text-align: center;
  font-size: 13.5px;
  font-weight: 600;
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  color: var(--text);
  text-decoration: none;
  background: #fff;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.nav-item:hover {
  background: #f4f6f5;
}
.nav-item.active {
  background: var(--success-light);
  border-color: var(--success);
  color: var(--success-dark);
}

/* main content */

.main-content {
  flex: 1;
  min-width: 0;
}

.page-title {
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  margin: 6px 0 22px;
}

/* ---------- panel ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px 22px;
  margin-bottom: 20px;
  overflow-x: auto;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.panel-header h2 {
  font-size: 14.5px;
  font-weight: 700;
  margin: 0;
}

.panel-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.date-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
}
.date-nav .arrow-btn {
  background: none;
  border: none;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
}
.date-nav .arrow-btn:hover { color: var(--text); }

.sort-by {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-muted);
}
.sort-by .select-wrap {
  position: relative;
}
.sort-by select {
  appearance: none;
  -webkit-appearance: none;
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 4px 22px 4px 10px;
  background: #fff;
  color: var(--text);
}
.sort-by .select-wrap::after {
  content: "v";
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 9px;
  font-weight: 700;
  color: var(--text-muted);
  pointer-events: none;
}

/* ---------- table ---------- */

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  font-weight: 600;
  padding: 0 12px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  white-space: nowrap;
}
table.data-table tbody tr:nth-child(even) {
  background: var(--stripe);
}
table.data-table tbody tr:hover {
  background: #e8f5eb;
}

/* status pills */
.status-pill {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--text);
  text-align: center;
  line-height: 1.3;
}
.status-pending { color: var(--text-muted); }
.status-approved { background: var(--success-light); border-color: var(--success); color: var(--success-dark); }
.status-refused { background: var(--danger-light); border-color: var(--danger); color: var(--danger); }
.status-appealed-note {
  display: block;
  font-size: 9.5px;
  font-weight: 600;
  opacity: 0.75;
}

/* criteria text variants */
.criteria-out-of-service { color: var(--danger); font-weight: 600; }
.criteria-major-defect { color: var(--warning); font-weight: 600; }
.criteria-minor-defect { color: var(--info); font-weight: 600; }

/* view / action button */
.btn-view {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 700;
  padding: 6px 16px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}
.btn-view:hover {
  background: #f4f6f5;
  border-color: var(--text-muted);
}

/* generic buttons (reused on other screens) */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: #f4f6f5; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-selected { background: var(--success-light); border-color: var(--success); color: var(--success-dark); }

/* ---------- detail / record form card (e.g. Cry Sheet Request) ---------- */

.form-page {
  display: flex;
  justify-content: center;
  padding: 0 20px;
}

.form-card {
  width: 100%;
  max-width: 560px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 30px 34px 34px;
}

.form-card h1 {
  text-align: center;
  font-size: 20px;
  margin: 0 0 26px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 20px;
  margin-bottom: 18px;
}

.field-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-box.span-2 { grid-column: 1 / -1; }

.field-box label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.value-box {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 9px 12px;
  background: #fff;
  min-height: 20px;
}

.value-box .unit {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 12px;
}

.value-box.empty {
  color: var(--text-muted);
}

.link-pill {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 3px 10px;
  text-decoration: none;
  white-space: nowrap;
}
.link-pill:hover { background: #f4f6f5; }

.textarea-box {
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 12px;
  font-size: 13.5px;
  min-height: 90px;
  background: #fff;
  margin-bottom: 22px;
}

.criteria-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.criteria-row {
  display: flex;
  gap: 26px;
  flex-wrap: wrap;
  margin-bottom: 26px;
}

.criteria-option {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  cursor: pointer;
  user-select: none;
}
.criteria-option input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 17px;
  height: 17px;
  border: 1.5px solid var(--border-strong);
  border-radius: 4px;
  margin: 0;
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  background: #fff;
}
.criteria-option input[type="radio"]:checked {
  border-color: var(--danger);
  background: var(--danger);
}
.criteria-option input[type="radio"]:checked::after {
  content: "";
  position: absolute;
  inset: 4px;
  background: #fff;
  border-radius: 50%;
  opacity: 0;
}
.criteria-option input[type="radio"]:checked {
  box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 999px var(--danger);
}

.decision-row {
  display: flex;
  gap: 14px;
  justify-content: center;
  border-top: 1px solid var(--border);
  padding-top: 22px;
}

.decision-row .btn {
  flex: 1;
  justify-content: center;
  max-width: 150px;
}

.btn-approve { background: var(--success-light); border-color: var(--success); color: var(--success-dark); }
.btn-approve:hover { background: #d3f0dc; }
.btn-refuse { background: var(--danger-light); border-color: var(--danger); color: var(--danger); }
.btn-refuse:hover { background: #f8d9d9; }
.btn-review { background: #fff; }

/* ---------- filter bar (employee / date-range filters + generate) ---------- */

.filter-bar {
  display: flex;
  align-items: flex-end;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.filter-field label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
}
.filter-field .select-wrap,
.filter-field .box-input {
  min-width: 130px;
}
.filter-field select {
  appearance: none;
  -webkit-appearance: none;
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 7px 26px 7px 10px;
  background: #fff;
  color: var(--text);
  width: 100%;
}
.filter-field .select-wrap {
  position: relative;
}
.filter-field .select-wrap::after {
  content: "v";
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  pointer-events: none;
}
.filter-field .box-input {
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 7px 10px;
  background: #fff;
  color: var(--text);
}
.filter-bar .btn-generate {
  margin-left: auto;
}

/* ---------- add link (e.g. + Add Asset) ---------- */

.add-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--text);
  font-weight: 700;
  font-size: 12.5px;
  letter-spacing: 0.02em;
  text-decoration: none;
  cursor: pointer;
  margin-top: 12px;
}
.add-link:hover { color: var(--accent); }

/* ---------- availability text ---------- */

.avail-available { color: var(--success-dark); font-weight: 700; }
.avail-out { color: var(--danger); font-weight: 700; }
.row-link { color: var(--text); text-decoration: none; font-weight: 600; }
.row-link:hover { color: var(--accent); text-decoration: underline; }

/* full clickable row (wraps each cell's content) */
.data-table tbody tr.clickable-row { cursor: pointer; }
.row-cell-link {
  display: block;
  color: inherit;
  text-decoration: none;
  margin: -12px;
  padding: 12px;
}
.row-cell-link:hover { color: var(--accent); }

/* ---------- summary block (plain text lines) ---------- */

.summary-text {
  font-size: 13px;
  margin: 18px 0 16px;
  line-height: 1.9;
}
.summary-text .summary-title { font-weight: 700; margin-bottom: 4px; }

/* ---------- asset detail page ---------- */

.asset-page {
  display: flex;
  justify-content: center;
  padding: 0 20px;
}
.asset-card {
  width: 100%;
  max-width: 460px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 28px 30px;
}
.asset-card h1 {
  text-align: center;
  font-size: 16px;
  letter-spacing: 0.06em;
  margin: 0 0 18px;
}
.asset-photo {
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  margin-bottom: 20px;
  background: #dfe4e1;
}
.asset-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.asset-field {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
  font-size: 13.5px;
}
.asset-field label {
  width: 128px;
  flex-shrink: 0;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12.5px;
}
.asset-field .value-box { flex: 1; }
.asset-field .unit-suffix { font-size: 12px; color: var(--text-muted); margin-left: 6px; white-space: nowrap; }

.maintenance-title {
  font-size: 12.5px;
  font-weight: 700;
  margin: 22px 0 10px;
}
.history-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.history-row:nth-child(odd) { background: var(--stripe); }
.history-row .icon-delete { flex-shrink: 0; }
.history-row a {
  flex: 1;
  color: var(--text);
  text-decoration: none;
}
.history-row a.btn-view { flex: none; }
.history-row a:hover { color: var(--accent); text-decoration: underline; }
.history-row .history-date { color: var(--text-muted); font-size: 12px; white-space: nowrap; }

.icon-delete {
  color: var(--danger);
  font-weight: 700;
  cursor: pointer;
  background: none;
  border: none;
  font-size: 13px;
  padding: 2px 4px;
  line-height: 1;
}
.icon-delete:hover { background: #fbe4e5; border-radius: 4px; }

/* ---------- dispatch form page ---------- */

.dispatch-page {
  display: flex;
  justify-content: center;
  padding: 0 20px;
}
.dispatch-card {
  width: 100%;
  max-width: 820px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 32px 34px;
  overflow-x: auto;
}
.dispatch-card .data-table:not(.equip-table):not(.materials-table) th,
.dispatch-card .data-table:not(.equip-table):not(.materials-table) td {
  padding: 12px 10px;
  font-size: 12.5px;
}
.dispatch-card h1 {
  text-align: center;
  font-size: 20px;
  margin: 0 0 22px;
}

.driver-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
  font-size: 13.5px;
}
.driver-row label { font-weight: 600; color: var(--text-muted); }
.driver-row .select-wrap { width: 200px; }
.driver-row select {
  appearance: none; -webkit-appearance: none;
  width: 100%; font-size: 13.5px; font-weight: 600;
  border: 1px solid var(--border-strong); border-radius: 6px;
  padding: 8px 26px 8px 10px; background: #fff; color: var(--text);
}
.contact-line {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.section-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 22px 0 12px;
}

.equip-table th { font-size: 10.5px; }
.equip-table td { vertical-align: middle; }
.equip-table .select-wrap { min-width: 130px; }
.equip-table select {
  appearance: none; -webkit-appearance: none;
  width: 100%; font-size: 12.5px; font-weight: 600;
  border: 1px solid var(--border-strong); border-radius: 6px;
  padding: 7px 24px 7px 10px; background: #fff; color: var(--text);
}
.equip-table .box-input { width: 100%; font-size: 12.5px; }

.materials-table th, .materials-table td {
  text-align: center;
}
.materials-table td { height: 26px; }

.gas-receipt-row {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  font-weight: 600;
  margin-top: 6px;
}

.dispatch-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.dispatch-actions .btn { flex: 1; min-width: 90px; max-width: 130px; justify-content: center; }

/* ---------- SMS preview screen ---------- */

.sms-page {
  display: flex;
  justify-content: center;
  padding: 0 20px;
}
.sms-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px 26px;
}
.sms-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.sms-header .sms-to { font-size: 14px; font-weight: 700; }
.sms-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--danger);
  margin-bottom: 14px;
}
.sms-body {
  font-size: 13px;
  line-height: 1.85;
  color: var(--text);
  white-space: pre-line;
  margin-bottom: 22px;
}
.sms-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.sms-actions .btn { flex: 1; justify-content: center; max-width: 120px; }

/* ---------- confirm dialog / success message ---------- */

.confirm-page, .success-page {
  display: flex;
  justify-content: center;
  padding: 0 20px;
}
.confirm-card {
  width: 100%;
  max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 26px 22px;
  text-align: center;
}
.confirm-card p {
  font-size: 13.5px;
  line-height: 1.6;
  margin: 0 0 20px;
}
.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.confirm-actions .btn { flex: 1; justify-content: center; max-width: 100px; }

.success-card {
  width: 100%;
  max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 30px 26px;
  text-align: center;
}
.success-card .success-icon { margin: 0 auto 14px; }
.success-card p { font-size: 14px; font-weight: 600; margin: 0 0 20px; }

/* ---------- upload box / certificate rows ---------- */

.upload-box {
  width: 100%;
  aspect-ratio: 16 / 11;
  border: 1.5px dashed var(--border-strong);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  background: #f7f8f7;
  margin-bottom: 20px;
  cursor: pointer;
  text-decoration: none;
}
.upload-box:hover { background: #eef1ef; }

.cert-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 13px;
}
.cert-row label {
  width: 120px;
  flex-shrink: 0;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12px;
}
.cert-row .icon-delete { flex-shrink: 0; }

/* ---------- profile detail card (employee / view-only records) ---------- */

.profile-page {
  display: flex;
  justify-content: center;
  padding: 0 20px;
}
.profile-card {
  width: 100%;
  max-width: 460px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 30px 30px;
  overflow-x: auto;
}
.profile-card h1 {
  text-align: center;
  font-size: 18px;
  margin: 0 0 20px;
}
.profile-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  font-size: 13.5px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.profile-row .label { color: var(--text-muted); }
.profile-row .value { font-weight: 600; text-align: right; }

/* ---------- certificate detail edit ---------- */

.cert-detail-card {
  width: 100%;
  max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px 24px;
}
.cert-detail-card .cert-name-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 16px;
}
.cert-file-row {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.expiration-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 20px;
}
.expiration-row .box-input { width: 62px; text-align: center; }
.expiration-row .box-input.year { width: 74px; }

/* ---------- responsive ---------- */

@media (max-width: 760px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; position: static; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .nav-item { flex: 1 1 auto; }
}