:root {
  color-scheme: light;
  --ink: #17211f;
  --muted: #65726e;
  --line: #d5dfdc;
  --strong-line: #b9c8c4;
  --panel: #ffffff;
  --page: #f3f7f5;
  --soft: #edf4f1;
  --accent: #08745d;
  --accent-strong: #075747;
  --accent-ink: #ffffff;
  --danger: #b64b2d;
  --shadow: 0 8px 24px rgba(22, 40, 35, 0.07);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #edf4f2;
  --muted: #a1b0ab;
  --line: #34433e;
  --strong-line: #53645f;
  --panel: #171e1b;
  --page: #101613;
  --soft: #202a26;
  --accent: #49cda8;
  --accent-strong: #7ce6c7;
  --accent-ink: #07120e;
  --danger: #ff8a6c;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.24);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--page);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
a { font: inherit; }

:where(button, input, a):focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 2px;
}

.app-shell {
  width: min(1320px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 42px;
}

.topbar,
.entry-panel,
.records-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 22px;
  border-top: 4px solid var(--accent);
}

h1,
h2,
p { margin: 0; }

h1 { font-size: clamp(25px, 3vw, 34px); }
h2 { font-size: 21px; }

.eyebrow {
  margin-bottom: 4px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.subtitle {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.top-actions,
.segmented,
.dialog-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.segmented {
  gap: 3px;
  padding: 3px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.segmented button,
.text-button,
.primary-button,
.secondary-button {
  min-height: 40px;
  padding: 0 13px;
  border-radius: 7px;
  font-weight: 850;
  cursor: pointer;
}

.segmented button {
  min-height: 34px;
  padding: 0 10px;
  color: var(--ink);
  background: transparent;
  border: 0;
}

.segmented button.active {
  color: var(--accent-ink);
  background: var(--accent);
}

.text-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--strong-line);
  text-decoration: none;
}

.primary-button {
  color: var(--accent-ink);
  background: var(--accent);
  border: 1px solid var(--accent);
}

button:disabled { cursor: wait; opacity: .62; }

main { padding-top: 16px; }

.message {
  margin-bottom: 12px;
  padding: 11px 14px;
  color: var(--accent-strong);
  background: color-mix(in srgb, var(--accent) 10%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line));
  border-radius: 8px;
  font-size: 14px;
  font-weight: 800;
}

.message.error {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 9%, var(--panel));
  border-color: color-mix(in srgb, var(--danger) 30%, var(--line));
}

.entry-panel,
.records-panel { padding: 20px; }
.records-panel { margin-top: 16px; }

.section-heading,
.records-head,
.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.access-pill,
.count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  color: var(--accent-strong);
  background: var(--soft);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--line));
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.record-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  align-items: end;
  gap: 12px;
  margin-top: 18px;
}

label { display: grid; gap: 6px; }

label > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

input {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--strong-line);
  border-radius: 7px;
  outline: 0;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
}

.plate-input { letter-spacing: .04em; text-transform: uppercase; }

.records-head { align-items: end; }

.records-head h2 {
  display: flex;
  align-items: center;
  gap: 9px;
}

.search-form {
  display: grid;
  grid-template-columns: minmax(240px, 360px) auto auto;
  gap: 8px;
}

.table-wrap {
  margin-top: 18px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

th {
  color: var(--muted);
  background: var(--soft);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .035em;
  text-transform: uppercase;
}

td { font-size: 14px; }
tbody tr:last-child td { border-bottom: 0; }

.record-name { font-weight: 850; }
.record-plate { font-family: ui-monospace, Consolas, monospace; font-weight: 900; letter-spacing: .04em; }

.row-actions { display: flex; gap: 6px; }
.row-actions button { min-height: 34px; padding: 0 10px; }
.delete-button { color: var(--danger); }

.delete-action {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}

.empty-state {
  padding: 38px 18px;
  color: var(--muted);
  text-align: center;
  font-weight: 750;
}

.admin-dialog {
  width: min(620px, calc(100% - 24px));
  padding: 0;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .28);
}

.admin-dialog::backdrop { background: rgba(8, 17, 14, .56); }
.admin-dialog form { padding: 22px; }

.close-button {
  width: 38px;
  height: 38px;
  color: var(--ink);
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 50%;
  font-size: 25px;
  cursor: pointer;
}

.admin-edit-grid,
.admin-credentials {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.admin-edit-grid { grid-template-columns: 1fr 1fr; }
.admin-edit-grid label:last-child { grid-column: 1 / -1; }
.admin-credentials { grid-template-columns: 1fr 1fr; padding-top: 16px; border-top: 1px solid var(--line); }

.delete-summary {
  margin-top: 18px;
  padding: 13px;
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 9%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--danger) 28%, var(--line));
  border-radius: 8px;
  font-weight: 800;
}

.dialog-message { min-height: 20px; margin-top: 10px; color: var(--danger); font-size: 13px; font-weight: 800; }
.dialog-actions { justify-content: flex-end; margin-top: 12px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

[hidden] { display: none !important; }

@media (max-width: 900px) {
  .record-form { grid-template-columns: 1fr 1fr; }
  .record-form label:nth-child(3),
  .record-form .primary-button { grid-column: 1 / -1; }
}

@media (max-width: 700px) {
  .app-shell { width: 100%; padding: 0 0 24px; }
  .topbar { align-items: stretch; flex-direction: column; border-left: 0; border-right: 0; border-radius: 0; }
  .top-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .top-actions .text-button { grid-column: 1 / -1; }
  main { padding: 12px 10px 0; }
  .entry-panel,
  .records-panel { padding: 16px; }
  .record-form,
  .search-form,
  .admin-edit-grid,
  .admin-credentials { grid-template-columns: 1fr; }
  .record-form label:nth-child(3),
  .record-form .primary-button,
  .admin-edit-grid label:last-child { grid-column: auto; }
  .records-head { align-items: stretch; flex-direction: column; }
  .search-form { width: 100%; }
  .table-wrap { overflow: visible; border: 0; }
  table,
  tbody,
  tr,
  td { display: block; width: 100%; }
  table { min-width: 0; }
  thead { display: none; }
  tbody { display: grid; gap: 10px; }
  tbody tr { padding: 8px 13px; background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 8px; }
  td { display: grid; grid-template-columns: 105px minmax(0, 1fr); gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
  td::before { content: attr(data-label); color: var(--muted); font-size: 11px; font-weight: 900; text-transform: uppercase; }
  td:last-child { border-bottom: 0; }
  .row-actions { justify-content: flex-start; }
  .dialog-actions { align-items: stretch; flex-direction: column-reverse; }
  .dialog-actions button { width: 100%; }
}
