:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #d1d5db;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --success: #166534;
  --error: #b91c1c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.container {
  width: min(1100px, calc(100% - 2rem));
  margin: 0 auto;
}

.topbar {
  background: #111827;
  color: #fff;
  padding: 1rem 0;
  margin-bottom: 1.5rem;
}

.brand {
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.1rem;
}

.topbar-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topnav a {
  color: #dbeafe;
  text-decoration: none;
  font-size: 0.95rem;
}

.topnav a:hover {
  color: #fff;
}

.topnav-user {
  color: #cbd5e1;
  font-size: 0.9rem;
}

.logout-form {
  margin: 0;
}

.logout-form button {
  padding: 0.45rem 0.75rem;
  font-size: 0.9rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.customer-heading h1 {
  margin-bottom: 0.25rem;
}

.customer-subtitle {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 1rem;
}

.customer-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.customer-actions .button {
  display: block;
  width: 100%;
  text-align: center;
  padding: 0.75rem 0.5rem;
}

.customer-actions .button.is-active {
  background: var(--accent-dark);
  font-weight: 700;
}

h1, h2 {
  margin: 0 0 0.75rem;
}

.hint {
  color: var(--muted);
  margin-top: -0.25rem;
}

.search-form {
  display: flex;
  gap: 0.75rem;
}

.search-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.search-header h1 {
  margin: 0 0 0.35rem;
}

.protected-field input:disabled {
  background: #f3f4f6;
  color: var(--muted);
  cursor: not-allowed;
}

.search-wrap {
  position: relative;
  flex: 1;
}

.search-suggestions {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  right: 0;
  z-index: 20;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
  max-height: 360px;
  overflow-y: auto;
}

.suggestion-item,
.suggestion-more {
  display: block;
  width: 100%;
  padding: 0.75rem 0.9rem;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  text-align: left;
  font: inherit;
  cursor: pointer;
}

a.suggestion-item {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  line-height: 1.35;
  -webkit-tap-highlight-color: rgba(37, 99, 235, 0.15);
}

.suggestion-item:last-of-type {
  border-bottom: none;
}

.suggestion-item:hover,
.suggestion-item.active {
  background: #eff6ff;
}

.suggestion-more {
  color: var(--accent);
  font-weight: 600;
  border-top: 1px solid var(--border);
}

.suggestion-more:hover {
  background: #eff6ff;
}

.photo-section {
  margin-top: 1.25rem;
}

.photo-section h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}

.photo-card,
.photo-upload {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f9fafb;
  overflow: hidden;
}

.photo-card img {
  display: block;
  width: 100%;
  height: 180px;
  object-fit: cover;
  background: #e5e7eb;
}

.photo-card figcaption,
.photo-upload {
  padding: 0.75rem;
}

.photo-upload {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  justify-content: center;
}

.photo-upload label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.photo-upload label span,
.photo-upload input[type="file"] {
  font-size: 0.9rem;
}

.photo-remove {
  width: 100%;
  text-align: center;
}

.auth-panel {
  max-width: 480px;
  margin: 0 auto;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.auth-form label span {
  font-size: 0.9rem;
  color: var(--muted);
}

.field-hint {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.35;
}

.auth-or {
  text-align: center;
  margin: -0.35rem 0;
}

.forgot-link {
  margin: -0.35rem 0 0;
}

.auth-links {
  margin: 1rem 0 0;
  color: var(--muted);
}

.auth-links a {
  color: var(--accent);
}

.audit-panel h2 {
  margin-top: 0;
}

.audit-entry {
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 1rem;
  overflow: hidden;
}

.audit-entry-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: #f9fafb;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}

.audit-entry-header span {
  color: var(--muted);
}

.audit-table {
  width: 100%;
}

.audit-table th,
.audit-table td {
  padding: 0.65rem 0.75rem;
  font-size: 0.92rem;
}

input[type="search"],
input[type="text"],
input[type="number"],
input[type="date"] {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
}

button,
.button {
  display: inline-block;
  padding: 0.65rem 1rem;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font: inherit;
  cursor: pointer;
}

button:hover,
.button:hover {
  background: var(--accent-dark);
}

.button.secondary {
  background: #e5e7eb;
  color: var(--text);
}

.button.secondary:hover {
  background: #d1d5db;
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.actions {
  display: flex;
  gap: 0.75rem;
}

.actions a {
  color: var(--accent);
  text-decoration: none;
}

.result-row {
  cursor: pointer;
}

.result-row:hover,
.result-row:focus {
  background: #eff6ff;
  outline: none;
}

.detail-grid {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 0.75rem 1rem;
}

.detail-grid dt {
  font-weight: 600;
  color: var(--muted);
}

.detail-grid dd {
  margin: 0;
}

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

.edit-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.edit-form label span {
  font-size: 0.9rem;
  color: var(--muted);
}

.form-actions {
  grid-column: 1 / -1;
}

.flash {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.flash-success {
  background: #dcfce7;
  color: var(--success);
}

.flash-error {
  background: #fee2e2;
  color: var(--error);
}

@media (max-width: 700px) {
  .panel-header,
  .search-form {
    flex-direction: column;
    align-items: stretch;
  }

  .customer-actions {
    grid-template-columns: 1fr;
  }

  .topbar-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }
}

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

.stat-card h2 {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
}

.stat-list {
  margin: 0;
}

.stat-list div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
}

.stat-list div:last-child {
  border-bottom: none;
}

.stat-list dt {
  margin: 0;
  color: var(--muted);
}

.stat-list dd {
  margin: 0;
  font-weight: 600;
}

.filter-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  align-items: end;
}

.filter-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.filter-form label span {
  font-size: 0.9rem;
  color: var(--muted);
}

.filter-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.table-wrap {
  overflow-x: auto;
}

.logs-table code {
  font-size: 0.85rem;
}

.status-ok {
  color: var(--success);
  font-weight: 600;
}

.status-fail {
  color: var(--error);
  font-weight: 600;
}
