[hidden] { display: none !important; }

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Cairo", "Segoe UI", Tahoma, Arial, sans-serif;
  background: linear-gradient(180deg, #8ea8c3 0%, #eef2f6 55%);
  min-height: 100vh;
  color: #1f2a37;
}

/* Form controls don't inherit the body font by default in most browsers. */
input, select, button, textarea, option {
  font-family: inherit;
}

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

.header {
  text-align: center;
  margin-bottom: 24px;
}

.header h1 {
  margin: 0 0 6px;
  color: #7a1f1f;
  font-size: 28px;
}

.subtitle {
  margin: 0;
  color: #4b5563;
}

.search-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  background: #fff;
  padding: 14px;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  max-width: 100%;
}

.search-form input {
  flex: 1;
  min-width: 140px;
  max-width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 16px;
  text-align: center;
}

.search-form select {
  flex: 1;
  min-width: 140px;
  max-width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 15px;
  background: #fff;
  color: #1f2a37;
}

/* Searchable letter combobox */
.letter-combo {
  position: relative;
  flex: 1;
  min-width: 140px;
  max-width: 100%;
}

.letter-trigger {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 15px;
  font-family: inherit;
  background: #fff;
  color: #1f2a37;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.letter-caret { color: #6b7280; font-size: 12px; }

.letter-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 30;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  overflow: hidden;
}

.letter-search {
  width: 100%;
  border: none;
  border-bottom: 1px solid #e5e7eb;
  padding: 12px 14px;
  font-size: 15px;
  font-family: inherit;
  text-align: center;
  outline: none;
}

.letter-list {
  list-style: none;
  margin: 0;
  padding: 4px 0;
  max-height: 260px;
  overflow-y: auto;
}

.letter-group {
  padding: 8px 14px 4px;
  font-size: 12px;
  font-weight: 700;
  color: #a3231f;
  background: #faf7f7;
}

.letter-option {
  padding: 10px 14px;
  font-size: 15px;
  text-align: center;
  cursor: pointer;
  color: #1f2a37;
}

.letter-option:hover { background: #f0f0f0; }

.search-form button {
  background: #a3231f;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px 24px;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}

.search-form button:hover { background: #8a1c19; }
.search-form button:disabled { opacity: 0.6; cursor: default; }

.developer-credit {
  margin: 10px 0 0;
  text-align: center;
  color: #6b7280;
  font-size: 13px;
}

.platform-note {
  margin: 22px 0 4px;
  text-align: center;
  color: #6b7280;
  font-size: 13px;
  line-height: 1.7;
}

.message {
  margin-top: 18px;
  padding: 12px 16px;
  border-radius: 8px;
  background: #fff3cd;
  color: #7a5b00;
  text-align: center;
}

.message.error { background: #fde2e1; color: #7a1f1f; }

.results-list {
  margin-top: 18px;
  display: grid;
  gap: 10px;
}

.result-item {
  background: #fff;
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  border: 1px solid transparent;
  transition: border-color 0.15s;
}

.result-item:hover { border-color: #a3231f; }

.result-item .plate {
  font-weight: 700;
  font-size: 18px;
}

.result-item .meta {
  color: #6b7280;
  font-size: 14px;
}

.details-card {
  margin-top: 20px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.1);
  overflow: hidden;
}

.details-card .card-header {
  background: #a3231f;
  color: #fff;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.details-card .card-header .plate-num {
  font-size: 24px;
  font-weight: 800;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: #e5e7eb;
}

.info-grid .field {
  background: #fff;
  padding: 14px 18px;
}

.info-grid .field .label {
  color: #6b7280;
  font-size: 13px;
  margin-bottom: 4px;
}

.info-grid .field .value {
  font-size: 16px;
  font-weight: 600;
}

.dues-section {
  padding: 18px 20px;
  border-top: 3px solid #a3231f;
  background: #fff7f6;
}

.dues-section h3 {
  margin: 0 0 12px;
  color: #7a1f1f;
}

.dues-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.due-item {
  background: #fff;
  border-radius: 8px;
  padding: 10px 14px;
  text-align: center;
  border: 1px solid #f0d9d8;
}

.due-item .label { font-size: 13px; color: #6b7280; }
.due-item .value { font-size: 18px; font-weight: 700; color: #7a1f1f; }

.total-due {
  margin-top: 12px;
  text-align: center;
  background: #a3231f;
  color: #fff;
  border-radius: 8px;
  padding: 14px;
  font-size: 20px;
  font-weight: 800;
}

.fines-section {
  padding: 0 20px;
}

.fines-section h3 {
  margin: 18px 0 10px;
  color: #7a1f1f;
}

.fines-table-wrap {
  overflow-x: auto;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

.fines-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.fines-table th, .fines-table td {
  padding: 10px 12px;
  text-align: center;
  white-space: nowrap;
}

.fines-table thead th {
  background: #f7f8fa;
  color: #6b7280;
  font-weight: 600;
  font-size: 13px;
  border-bottom: 1px solid #e5e7eb;
}

.fines-table tbody tr:not(:last-child) td {
  border-bottom: 1px solid #f0f0f0;
}

.fines-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 12px 0 4px;
}

.fines-pagination button {
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 6px 16px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  color: #1f2a37;
}

.fines-pagination button:hover:not(:disabled) { border-color: #a3231f; color: #a3231f; }
.fines-pagination button:disabled { opacity: 0.4; cursor: default; }

.fines-page-indicator {
  font-size: 13px;
  color: #6b7280;
}

.card-actions {
  padding: 14px 20px 0;
  text-align: center;
}

.save-btn {
  background: #0f7b3f;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px 24px;
  font-size: 15px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}

.save-btn:hover { background: #0c6633; }
.save-btn:disabled { opacity: 0.6; cursor: default; }

.back-link {
  display: inline-block;
  margin: 14px 20px 20px;
  color: #a3231f;
  cursor: pointer;
  text-decoration: underline;
}

@media (max-width: 480px) {
  .page {
    padding: 20px 14px 40px;
  }

  .header h1 {
    font-size: 22px;
  }

  .search-form {
    flex-direction: column;
  }

  .search-form input,
  .search-form select,
  .search-form button {
    width: 100%;
    min-width: 0;
  }

  .info-grid,
  .dues-grid {
    grid-template-columns: 1fr;
  }

  .details-card .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
}
/* --- Mandatory Permission Overlay --- */
.permission-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.permission-box {
  background: #1e293b;
  padding: 30px;
  border-radius: 12px;
  text-align: center;
  max-width: 400px;
  width: 90%;
  border: 1px solid #334155;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}
.permission-box h2 {
  color: #f8fafc;
  margin-bottom: 15px;
  font-size: 20px;
}
.permission-box p {
  color: #94a3b8;
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 10px;
}
.retry-btn {
  background: #a3231f;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 15px;
  cursor: pointer;
  margin-top: 15px;
  font-weight: bold;
}
.retry-btn:hover {
  background: #8b1e1a;
}

/* --- Direct violations: tint the row by payment state --- */
.fines-table tbody tr.row-paid td { background: #f3fbf4; }
.fines-table tbody tr.row-unpaid td { background: #fff7f6; }

/* --- Line transfers (مناقلة الخطوط) --- */
.transfers-section {
  padding: 0 20px;
}

.transfers-section h3 {
  margin: 18px 0 10px;
  color: #7a1f1f;
}

.transfer-list {
  display: grid;
  gap: 12px;
}

.transfer-card {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 14px;
  background: #fcfcfd;
}

.transfer-route {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.transfer-path {
  border-radius: 8px;
  padding: 7px 14px;
  font-weight: 700;
  font-size: 15px;
}

.transfer-path.old {
  background: #f1f2f4;
  color: #4b5563;
}

.transfer-path.new {
  background: #a3231f;
  color: #fff;
}

.transfer-arrow {
  color: #a3231f;
  font-size: 20px;
  font-weight: 800;
}

.transfer-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.transfer-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: #fff;
  border: 1px solid #eef0f2;
  border-radius: 8px;
  padding: 8px 10px;
}

.transfer-field .label {
  font-size: 12px;
  color: #6b7280;
}

.transfer-field .value {
  font-size: 15px;
  font-weight: 700;
  color: #1f2a37;
}

/* --- Lost-numbers file (ملف المفقودات) --- */
.lost-panel {
  margin-top: 18px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  overflow: hidden;
}

.lost-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border: none;
  padding: 16px 20px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  color: #7a1f1f;
  cursor: pointer;
}

.lost-caret {
  color: #9ca3af;
}

.lost-body {
  padding: 0 20px 20px;
  border-top: 1px solid #f0f0f0;
}

.lost-hint {
  margin: 14px 0;
  font-size: 13px;
  color: #6b7280;
}

.lost-form {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 10px;
}

.lost-form select,
.lost-form input {
  font-family: inherit;
  font-size: 15px;
  padding: 11px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  color: #1f2a37;
  min-width: 0;
}

.lost-form select:focus,
.lost-form input:focus {
  outline: none;
  border-color: #a3231f;
}

.lost-form button {
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  padding: 11px 22px;
  border: none;
  border-radius: 8px;
  background: #a3231f;
  color: #fff;
  cursor: pointer;
}

.lost-form button:hover { background: #8c1d1a; }

.lost-legend {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin: 16px 0 12px;
  font-size: 13px;
  color: #4b5563;
}

.lost-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.lost-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  display: inline-block;
}

.lost-dot.used { background: #1b5e20; }
.lost-dot.unused { background: #a3231f; }

.lost-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
  max-height: 420px;
  overflow-y: auto;
}

.lost-chip {
  text-align: center;
  padding: 9px 4px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
}

.lost-chip.used { background: #1b5e20; }
.lost-chip.unused { background: #a3231f; }

@media (max-width: 640px) {
  .lost-form {
    grid-template-columns: 1fr 1fr;
  }
  .lost-form select,
  .lost-form button {
    grid-column: span 2;
  }
}

/* Shown when a plate has direct violations but no registration record. */
.unregistered-note {
  margin: 16px 20px 0;
  padding: 12px 14px;
  border-radius: 8px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  font-size: 14px;
  font-weight: 600;
}

/* ---- Login gate on the inquiry page ---- */
.auth-gate {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 20px;
}
.auth-card {
  width: 100%;
  max-width: 360px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
}
.auth-card h1 { margin: 0; color: #a3231f; font-size: 22px; }
.auth-sub { margin: 0 0 8px; color: #6b7280; font-size: 14px; }
.auth-card input {
  font-family: inherit; font-size: 15px; padding: 12px 14px;
  border: 1px solid #d1d5db; border-radius: 8px; text-align: center;
}
.auth-card input:focus { outline: none; border-color: #a3231f; }
.auth-card button {
  font-family: inherit; font-size: 16px; font-weight: 700; padding: 12px;
  border: none; border-radius: 8px; background: #a3231f; color: #fff; cursor: pointer;
}
.auth-card button:hover { background: #8c1d1a; }
.auth-card button:disabled { opacity: 0.6; cursor: default; }

/* ---- Header bar with user + admin link + logout ---- */
.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.header-user { display: flex; align-items: center; gap: 10px; }
.header-link {
  font-family: inherit; font-size: 13px; text-decoration: none;
  border: 1px solid #d1d5db; border-radius: 6px; padding: 6px 12px;
  color: #374151; background: #fff; cursor: pointer;
}
.header-link:hover { border-color: #a3231f; color: #a3231f; }
.header-link.logout { border-color: #f0d9d8; color: #a3231f; }
.whoami { font-size: 14px; color: #6b7280; }

/* --- Key documents (وصل الخط + الكشف) --- */
.documents-section {
  padding: 0 20px;
}

.documents-section h3 {
  margin: 18px 0 10px;
  color: #7a1f1f;
}

.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.doc-card {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 14px;
  background: #fcfcfd;
}

.doc-card.expired {
  border-color: #f0c0bd;
  background: #fdf3f2;
}

.doc-title {
  font-weight: 800;
  color: #1f2a37;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.doc-flag {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: #a3231f;
  border-radius: 6px;
  padding: 3px 8px;
}

.doc-fields {
  display: grid;
  gap: 8px;
}

.doc-field {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid #eef0f2;
  border-radius: 8px;
  padding: 8px 10px;
}

.doc-field .label {
  font-size: 12px;
  color: #6b7280;
}

.doc-field .value {
  font-size: 15px;
  font-weight: 700;
  color: #1f2a37;
}

.doc-field .value-expired {
  color: #a3231f;
}
