* { box-sizing: border-box; }
body { font: 14px/1.5 system-ui, sans-serif; margin: 0; color: #1a1a1a; background: #f6f7f9; }
header { display: flex; align-items: center; gap: 24px; padding: 12px 24px; background: #1f2937; color: #fff; }
header nav { display: flex; align-items: center; flex: 1; }
header nav a { color: #cbd5e1; text-decoration: none; margin-right: 16px; }
header nav a:hover { color: #fff; }
header nav a.logout-link { margin-right: 0; }
header nav .user-info { display: flex; flex-direction: column; line-height: 1.3; text-align: right; margin-left: auto; margin-right: 16px; }
header nav .user-info strong { color: #fff; font-weight: 600; font-size: 12px; }
header nav .user-info small { color: #9ca3af; font-size: 11px; }
main { max-width: 1000px; margin: 24px auto; padding: 0 24px; }
h1 { font-size: 22px; } h2 { font-size: 16px; margin-top: 28px; }
.flash { background: #dcfce7; border: 1px solid #86efac; padding: 8px 12px; border-radius: 6px; margin-bottom: 16px; }
.cards { display: flex; flex-wrap: wrap; gap: 12px; }
.card { background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; padding: 14px 16px; min-width: 150px; }
.card.ok { border-left: 4px solid #22c55e; } .card.bad { border-left: 4px solid #ef4444; }
.card-title { text-transform: capitalize; color: #6b7280; font-size: 12px; }
.card .big { font-size: 20px; font-weight: 600; } .card .sub { color: #6b7280; font-size: 12px; }
table { width: 100%; border-collapse: collapse; background: #fff; margin-top: 8px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid #eee; font-size: 13px; }
table.kv th { width: 140px; color: #6b7280; }
.badge { padding: 2px 8px; border-radius: 999px; font-size: 12px; background: #e5e7eb; }
.badge.success { background: #dcfce7; } .badge.error { background: #fee2e2; }
.badge.in_progress { background: #fef9c3; } .badge.skipped { background: #e0e7ff; }
pre { background: #0f172a; color: #e2e8f0; padding: 12px; border-radius: 6px; overflow-x: auto; white-space: pre-wrap; }
pre.err { background: #450a0a; }
.btn, button { display: inline-block; margin-top: 8px; padding: 6px 12px; border: 1px solid #2563eb; background: #2563eb; color: #fff; border-radius: 6px; text-decoration: none; cursor: pointer; font-size: 13px; }
button.danger { background: #ef4444; border-color: #ef4444; }
button.btn-sm { margin-top: 0; padding: 3px 10px; font-size: 12px; }
.filters input { padding: 6px 8px; border: 1px solid #d1d5db; border-radius: 6px; margin-right: 8px; }
.pager { margin-top: 12px; display: flex; gap: 12px; align-items: center; }
.status-list { list-style: none; padding: 0; display: flex; gap: 16px; }

/* ── Dealers UI enhancements ───────────────────────────────────────── */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 4px; }
.page-head h1 { margin: 0; }
.page-head .count { color: #6b7280; font-size: 13px; }

/* generic button variants */
.btn-secondary { background: #fff; color: #374151; border-color: #d1d5db; }
.btn-secondary:hover { background: #f9fafb; }
.btn-ghost { background: transparent; border-color: transparent; color: #2563eb; padding: 6px 8px; }
.btn-ghost:hover { background: #eff6ff; }
.btn:hover, button:hover { filter: brightness(0.96); }

/* a toolbar / panel that groups controls into a white card */
.panel { background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; padding: 12px 16px; margin: 16px 0; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.panel-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.panel-row + .panel-row { margin-top: 10px; padding-top: 10px; border-top: 1px solid #f1f5f9; }
.panel-row .spacer { flex: 1; }
.panel-label { font-size: 12px; font-weight: 600; color: #6b7280; text-transform: uppercase; letter-spacing: .04em; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 11px; color: #6b7280; }
.panel select, .panel input[type=text], .panel input[type=file] { padding: 6px 9px; border: 1px solid #d1d5db; border-radius: 6px; background: #fff; font-size: 13px; }
.panel select:focus, .panel input:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.inline-form { display: inline; margin: 0; }

/* card-wrapped data table */
.table-card { background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; overflow: hidden; box-shadow: 0 1px 2px rgba(0,0,0,.04); margin-top: 8px; }
.table-card table { margin: 0; }
.table-card thead th { background: #f9fafb; color: #6b7280; text-transform: uppercase; font-size: 11px; letter-spacing: .04em; border-bottom: 1px solid #e5e7eb; position: sticky; top: 0; }
.table-card tbody tr:hover { background: #f9fafb; }
.table-card tbody tr:last-child td { border-bottom: none; }
.table-card td.id { color: #9ca3af; font-variant-numeric: tabular-nums; }
.table-card td.name { font-weight: 600; }
.table-card td.muted { color: #9ca3af; }
.actions { display: flex; gap: 6px; align-items: center; white-space: nowrap; }

/* pills */
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; line-height: 1.6; }
.pill-state { background: #eef2ff; color: #4338ca; font-variant-numeric: tabular-nums; }
.pill-lock { background: #fef3c7; color: #92400e; }
.pill-open { background: #ecfdf5; color: #047857; }
.pill-status.done { background: #dcfce7; color: #166534; }
.pill-status.failed { background: #fee2e2; color: #991b1b; }
.pill-status.processing { background: #dbeafe; color: #1e40af; }
.pill-status.pending { background: #f3f4f6; color: #4b5563; }

/* empty state */
.empty { text-align: center; color: #9ca3af; padding: 40px 16px; }

/* collapsible help text */
.help { font-size: 13px; color: #4b5563; width: 100%; }
.help summary { cursor: pointer; color: #2563eb; font-weight: 600; list-style: none; display: inline-flex; align-items: center; gap: 6px; }
.help summary::before { content: "ⓘ"; font-weight: 400; }
.help summary::-webkit-details-marker { display: none; }
.help[open] summary { margin-bottom: 6px; }
.help ul { margin: 6px 0 0; padding-left: 20px; line-height: 1.7; }
.help code { background: #f1f5f9; padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* pagination as pills */
nav.pagination { display: flex; gap: 6px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
nav.pagination a, nav.pagination strong, nav.pagination span { display: inline-block; min-width: 32px; text-align: center; padding: 5px 9px; border-radius: 6px; font-size: 13px; text-decoration: none; }
nav.pagination a { color: #374151; border: 1px solid #e5e7eb; background: #fff; }
nav.pagination a:hover { background: #f3f4f6; }
nav.pagination strong { background: #2563eb; color: #fff; }
nav.pagination span { color: #9ca3af; }

/* dealer create/edit form */
.dealer-form { background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; padding: 20px 24px; max-width: 640px; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.dealer-form .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.dealer-form label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: #374151; }
.dealer-form .full { grid-column: 1 / -1; }
.dealer-form input[type=text] { padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; font-weight: 400; }
.dealer-form input[type=text]:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.dealer-form label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; color: #374151; }
.dealer-form .form-actions { display: flex; gap: 10px; align-items: center; margin-top: 20px; padding-top: 16px; border-top: 1px solid #f1f5f9; }

/* login page */
.login-body { background: #f6f7f9; }
.login-wrap { max-width: none; margin: 0; padding: 0; min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; padding: 32px 28px; width: 320px; box-shadow: 0 1px 2px rgba(0,0,0,.04); display: flex; flex-direction: column; gap: 14px; }
.login-card h1 { font-size: 17px; margin: 0; }
.login-card label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: #374151; }
.login-card input[type=text], .login-card input[type=password] { padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; font-weight: 400; }
.login-card input[type=text]:focus, .login-card input[type=password]:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.login-card button { margin-top: 4px; }
.flash-error { background: #fee2e2; border-color: #fca5a5; }

/* config page — duplicate-handling mode help */
.muted { color: #6b7280; font-size: 13px; }
.mode-help { background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 10px; padding: 14px 20px; max-width: 640px; margin: 12px 0 20px; }
.mode-help dt { margin-top: 10px; font-size: 14px; }
.mode-help dt:first-child { margin-top: 0; }
.mode-help dd { margin: 4px 0 0; font-size: 13px; color: #374151; line-height: 1.5; }
.mode-help dt .muted { font-weight: 400; }
