:root {
  --sidebar-w: 220px;
  --accent: #2f6fed;
  --accent-dark: #1f4fc4;
  --bg: #eef0f3;
  --card-bg: #ffffff;
  --border: #e2e5ea;
  --text: #333d4b;
  --text-muted: #8a94a3;
  --danger: #e5484d;
  --success: #2f9e44;
  --warning: #f0a80b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-shell { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: #fff;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 13px;
}
.sidebar-brand img { width: 34px; height: 34px; border-radius: 50%; }
.sidebar-nav { list-style: none; margin: 0; padding: 10px 0; flex: 1; overflow-y: auto; }
.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: #4b5563;
  font-size: 13px;
}
.sidebar-nav li a:hover { background: #f5f7fa; text-decoration: none; }
.sidebar-nav li a.active { background: var(--accent); color: #fff; }
.sidebar-nav .nav-icon { width: 16px; text-align: center; opacity: .8; }
.sidebar-nav .nav-group-label {
  padding: 14px 16px 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
}
.sidebar-nav .sub { padding-left: 30px; font-size: 12.5px; }
.sidebar-nav .nav-parent { justify-content: flex-start; }
.sidebar-nav .nav-caret { margin-left: auto; opacity: .5; font-size: 14px; }
.sidebar-nav-bottom {
  flex: 0 0 auto;
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding-top: 6px;
  overflow: visible;
}

/* Main column */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
}
.topbar-left { display: flex; align-items: center; gap: 10px; font-size: 13px; white-space: nowrap; }
.topbar-role { color: var(--text); }
.badge-id {
  background: #1f2430;
  color: #fff;
  border-radius: 3px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 600;
}
.topbar-center {
  flex: 1;
  text-align: center;
  color: var(--text-muted);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}
.topbar-right { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 12.5px; }
.topbar-right form.topbar-search { display: flex; }
.topbar-right form:not(.topbar-search) { display: inline; }

.topbar-search {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 10px;
}
.topbar-search-icon {
  font-size: 11px;
  opacity: .6;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  color: inherit;
  display: inline-flex;
  align-items: center;
}
.topbar-search-icon:hover { opacity: 1; }
.topbar-search input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 12px;
  width: 110px;
  color: var(--text);
}

.icon-btn {
  width: 28px; height: 28px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: #f5f7fa; }
a.icon-btn, a.icon-btn:hover { text-decoration: none; }

.logout-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 10px;
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
}
.logout-btn:hover { background: #f5f7fa; }

/* Shrink the search boxes on narrower screens instead of hiding them
   outright — a maximized window on a laptop is easily under 1150px wide,
   and losing top search there made it look "broken". Only truly cramped
   widths (phones/small tablets) drop the inline boxes, and even then the
   magnifying-glass icon-btn still gets you to /person as a fallback. */
@media (max-width: 1150px) {
  .topbar-search input { width: 80px; }
}
@media (max-width: 860px) {
  .topbar-search input { width: 60px; }
  .topbar-center { display: none; }
}
@media (max-width: 640px) {
  .topbar-search { display: none !important; }
}

.content { padding: 20px; flex: 1; }

/* Stat tiles (dashboard) */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat-tile {
  background: var(--card-bg);
  border-radius: 6px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.stat-tile .icon {
  width: 46px; height: 46px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 18px; flex-shrink: 0;
}
.stat-tile .value { font-size: 20px; font-weight: 700; line-height: 1.2; }
.stat-tile .label { color: var(--text-muted); font-size: 12px; }
.icon-orange { background: #f0a80b; }
.icon-green { background: #2f9e44; }
.icon-blue { background: #2f6fed; }
.icon-teal { background: #17a2b8; }
.icon-red { background: #e5484d; }

/* Cards / panels */
.panel {
  background: var(--card-bg);
  border-radius: 6px;
  margin-bottom: 18px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
  overflow: hidden;
}
.panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 13px;
}
.panel-header .collapse-dot {
  width: 16px; height: 16px;
  background: var(--accent);
  color: #fff;
  border-radius: 3px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; line-height: 1;
}
.panel-body { padding: 16px; }
.panel-body.empty { color: var(--text-muted); font-size: 12.5px; }

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

/* Three stacked columns on a person profile, each column holding a
   different mix of panels (mirrors the reference MDC's masonry layout). */
.profile-columns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; align-items: start; }
.profile-col { display: flex; flex-direction: column; }
.mini-row { padding: 6px 0; font-size: 12.5px; border-bottom: 1px solid #f0f1f4; }
.mini-row:last-child { border-bottom: none; }
.sample-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 0; font-size: 12.5px; border-bottom: 1px solid #f0f1f4;
}
.sample-row:last-child { border-bottom: none; }
.sample-status {
  font-size: 10.5px; font-weight: 600; text-transform: uppercase;
  color: var(--success);
}
.sample-status.not-set { color: var(--text-muted); }

@media (max-width: 1150px) {
  .profile-columns { grid-template-columns: 1fr; }
}

table.data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.data-table th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  padding: 8px 10px;
  white-space: nowrap;
}
table.data-table td { padding: 9px 10px; border-bottom: 1px solid #f0f1f4; vertical-align: middle; }
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tr:hover td { background: #fafbfc; }

.status-pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  background: #1f2430;
}
.status-pill.paid, .status-pill.closed, .status-pill.valid { background: #1f2430; }
.status-pill.unpaid, .status-pill.open, .status-pill.active { background: var(--danger); }

.action-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px;
  border-radius: 4px;
  background: #17a2b8;
  color: #fff;
  margin-right: 4px;
  font-size: 11px;
}
.action-icon.link { background: #6f42c1; }
.action-icon.danger { background: var(--danger); }
a.action-icon, a.action-icon:hover { text-decoration: none; }

/* Infraction report / citation forms */
.infraction-codes-block { margin: 4px 0 14px; }
.infraction-codes-header { display: flex; align-items: center; justify-content: space-between; }
.infraction-codes-header label { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.infraction-code-row { display: flex; gap: 8px; margin-bottom: 6px; }
.infraction-code-row .code-input { flex: 1; }
.infraction-meta-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 16px;
  font-size: 13px;
}
.section-subhead { margin: 18px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.narrative-box {
  white-space: pre-wrap;
  background: #fafbfc;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 8px;
}
.evidence-gallery { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
.evidence-gallery img { width: 140px; height: 100px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }

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

/* Profile header */
.profile-header {
  background: var(--card-bg);
  border-radius: 6px;
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 18px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.profile-photo {
  width: 78px; height: 78px;
  border-radius: 6px;
  background: #eceff3;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  font-size: 28px;
  overflow: hidden;
  flex-shrink: 0;
}
.profile-photo img { width: 100%; height: 100%; object-fit: cover; }
.profile-photo-wrap { position: relative; flex-shrink: 0; }
.photo-upload-badge {
  position: absolute; bottom: -4px; right: -4px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: 2px solid #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
}
.profile-name { font-size: 18px; font-weight: 700; margin: 0 0 4px; }
.profile-meta { color: var(--text-muted); font-size: 12.5px; display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.dept-mini-icon { font-size: 13px; }
.profile-age { margin-left: auto; text-align: right; color: var(--text-muted); font-size: 12.5px; }

.actions-dropdown { position: relative; display: inline-block; }
.actions-dropdown summary { list-style: none; cursor: pointer; }
.actions-dropdown summary::-webkit-details-marker { display: none; }
.actions-dropdown .dropdown-menu {
  position: absolute; top: calc(100% + 4px); left: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,.08);
  min-width: 160px;
  z-index: 10;
  overflow: hidden;
}
.actions-dropdown .dropdown-menu a {
  display: block;
  padding: 8px 12px;
  font-size: 12.5px;
  color: var(--text);
}
.actions-dropdown .dropdown-menu a:hover { background: #f5f7fa; text-decoration: none; }

.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 7px 14px;
  font-size: 12.5px;
  cursor: pointer;
}
.btn:hover { background: var(--accent-dark); text-decoration: none; color: #fff; }
.btn.btn-sm { padding: 4px 9px; font-size: 11.5px; }
.btn.btn-danger { background: var(--danger); }
.btn.btn-outline { background: #fff; color: var(--text); border: 1px solid var(--border); }

.search-bar { display: flex; gap: 8px; margin-bottom: 16px; }
.search-bar input[type="text"] {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
}

.search-page { max-width: 640px; margin: 40px auto 0; }
.search-error {
  background: #fdecea;
  color: var(--danger);
  border: 1px solid #f4c2c1;
  border-radius: 4px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 14px;
}
.search-hint { font-size: 12.5px; text-align: center; }

/* Vehicle detail page */
.vehicle-panel-body { display: flex; gap: 28px; padding: 24px; }
.vehicle-photo-placeholder {
  flex-shrink: 0;
  width: 220px; height: 130px;
  background: #1f2430;
  border-radius: 6px;
  color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  gap: 4px;
}
.vehicle-photo-placeholder .vp-title { font-size: 13px; font-weight: 600; }
.vehicle-photo-placeholder .vp-sub { font-size: 11px; font-weight: 700; color: var(--danger); text-transform: uppercase; letter-spacing: .05em; }

.vehicle-main { flex: 1; }
.vehicle-title { text-align: center; font-size: 20px; margin: 4px 0 12px; }

.plate-graphic {
  width: 150px;
  margin: 0 auto 24px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px 10px;
  text-align: center;
  position: relative;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.plate-tab {
  position: absolute; top: -3px;
  width: 20px; height: 6px;
  background: var(--danger);
  border-radius: 2px;
}
.plate-tab.left { left: 14px; }
.plate-tab.right { right: 14px; }
.plate-state { font-family: Georgia, 'Times New Roman', serif; font-style: italic; font-size: 10.5px; color: var(--danger); margin-bottom: 2px; }
.plate-number { font-family: 'Courier New', monospace; font-weight: 700; font-size: 17px; color: #1f4fc4; letter-spacing: .04em; }

.vehicle-info-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-top: 8px; }
.vehicle-info-col { font-size: 13px; }
.vehicle-info-col .info-label { color: var(--text-muted); font-size: 11.5px; margin-bottom: 6px; }
.vehicle-info-sub { font-size: 11px; margin-top: 3px; }
.paint-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.paint-swatch { width: 16px; height: 16px; border-radius: 3px; border: 1px solid rgba(0,0,0,.1); flex-shrink: 0; }

.vehicle-incidents { border-top: 1px solid var(--border); padding: 18px 24px 22px; }
.vehicle-incidents h3 { font-size: 13px; text-align: center; margin: 0 0 14px; }
.text-center { text-align: center; }

@media (max-width: 900px) {
  .vehicle-panel-body { flex-direction: column; align-items: center; text-align: center; }
  .vehicle-info-row { grid-template-columns: 1fr 1fr; }
}

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 16px; }
.form-group { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.form-group label { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.form-group input, .form-group select, .form-group textarea {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
}
.form-group.checkbox { flex-direction: row; align-items: center; gap: 8px; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 14px; }
.inline-form .form-group { margin-bottom: 0; min-width: 120px; }

.footer-note {
  text-align: center;
  color: var(--text-muted);
  font-size: 11.5px;
  padding: 30px 0 10px;
  line-height: 1.7;
}

.text-muted { color: var(--text-muted); }
.mb-0 { margin-bottom: 0; }

/* Login page */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1f2430, #2f3648);
}
.login-card {
  background: #fff;
  border-radius: 8px;
  padding: 34px 32px;
  width: 320px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  text-align: center;
}
.login-card img { width: 56px; height: 56px; margin-bottom: 10px; }
.login-card h1 { font-size: 16px; margin: 0 0 4px; }
.login-card p.subtitle { color: var(--text-muted); font-size: 12px; margin: 0 0 20px; }
.login-card .form-group { text-align: left; }
.login-error {
  background: #fdecea;
  color: var(--danger);
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 12px;
  margin-bottom: 14px;
}
.training-banner {
  background: #fff7e0;
  border: 1px solid #f0d98c;
  color: #7a5c00;
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 11.5px;
  margin-bottom: 16px;
}

@media (max-width: 900px) {
  .stat-row, .grid-3 { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
