/* Reset */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0f172a;
  color: #e2e8f0;
  line-height: 1.6;
}

a { color: #38bdf8; text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
.app { min-height: 100vh; }

.navbar {
  background: #1e293b;
  border-bottom: 1px solid #334155;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 2rem;
}

.brand {
  font-size: 1.125rem;
  font-weight: 700;
  color: #38bdf8;
  text-decoration: none;
}

.nav-links { display: flex; gap: 1rem; }

.nav-links a {
  color: #94a3b8;
  text-decoration: none;
  font-size: 0.875rem;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  transition: color 0.15s, background 0.15s;
}
.nav-links a:hover { color: #e2e8f0; background: #334155; }

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* Buttons */
.btn {
  background: #334155;
  color: #e2e8f0;
  border: 1px solid #475569;
  border-radius: 0.375rem;
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: background 0.15s;
}
.btn:hover { background: #475569; text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 0.25rem 0.75rem; }
.btn-primary { background: #2563eb; border-color: #3b82f6; }
.btn-primary:hover { background: #1d4ed8; }
.btn-danger { background: #991b1b; border-color: #dc2626; }
.btn-danger:hover { background: #b91c1c; }
.btn-secondary { background: #475569; }

/* Dashboard */
.dashboard { display: flex; flex-direction: column; gap: 1rem; }

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

.toolbar select {
  background: #1e293b;
  color: #e2e8f0;
  border: 1px solid #475569;
  border-radius: 0.375rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
}

.status {
  color: #94a3b8;
  font-size: 0.8rem;
  margin-left: auto;
}

.error { color: #f87171; }

.empty {
  text-align: center;
  padding: 3rem;
  color: #94a3b8;
}

/* Table */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

th, td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid #1e293b;
}

th {
  background: #1e293b;
  color: #94a3b8;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  position: sticky;
  top: 0;
}

th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: #e2e8f0; }

tr:hover td { background: #1e293b; }

td a { color: #38bdf8; text-decoration: none; }
td a:hover { text-decoration: underline; }

.num { text-align: right; font-variant-numeric: tabular-nums; }
.date { font-size: 0.75rem; color: #94a3b8; white-space: nowrap; }

.old-price {
  text-decoration: line-through;
  color: #64748b;
  font-size: 0.75rem;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  font-size: 0.875rem;
  color: #94a3b8;
}

/* Profile Form */
.form-page { max-width: 700px; }
.form-page h2 { margin-bottom: 1rem; }

.alert {
  background: #7f1d1d;
  color: #fca5a5;
  padding: 0.75rem 1rem;
  border-radius: 0.375rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

fieldset {
  border: 1px solid #334155;
  border-radius: 0.5rem;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

legend {
  color: #94a3b8;
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0 0.5rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.8125rem;
  color: #cbd5e1;
  margin-bottom: 0.75rem;
}

label.checkbox {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.design-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.25rem 1rem;
  margin-bottom: 1rem;
}

.hint { color: #64748b; font-size: 0.75rem; }
.muted { color: #64748b; font-size: 0.75rem; }

/* Active-filter chips on the profiles list */
.filters-cell { max-width: 380px; }
.chip {
  display: inline-block;
  background: #334155;
  border: 1px solid #475569;
  color: #cbd5e1;
  font-size: 0.6875rem;
  line-height: 1.4;
  padding: 0.0625rem 0.5rem;
  border-radius: 999px;
  margin: 0.125rem 0.125rem 0 0;
  white-space: nowrap;
}

/* Listing staleness */
.listings-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 1rem;
  min-height: 1.75rem;
  margin-bottom: 0.5rem;
}
.listings-toolbar .toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: #94a3b8;
  cursor: pointer;
  user-select: none;
}
.listings-toolbar .toggle input {
  cursor: pointer;
}
.badge {
  display: inline-block;
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  margin-left: 0.4rem;
  vertical-align: middle;
}
.badge-warn  { background: #78350f; color: #fcd34d; border: 1px solid #b45309; }
.badge-stale { background: #334155; color: #94a3b8; border: 1px solid #475569; }
.badge-error { background: #7f1d1d; color: #fca5a5; border: 1px solid #b91c1c; cursor: help; }
.badge-ok    { background: #14532d; color: #86efac; border: 1px solid #16a34a; cursor: help; }
.notify-result { margin-left: 0.25rem; vertical-align: middle; }
/* Listing state — signalled by a subtle row tint only (no badges, no dimming);
   text stays at full opacity so it remains legible. */
tr.state-new            { background: rgba(34, 197, 94, 0.15); }   /* green */
tr.state-recently_stale { background: rgba(180, 83, 9, 0.18); }   /* amber */
tr.state-stale          { background: rgba(100, 116, 139, 0.22); } /* slate grey */
tr.state-deleted        { background: rgba(220, 38, 38, 0.18); }   /* red — confirmed removed */
tr.state-deleted td:first-child { text-decoration: line-through; } /* struck title */

/* Admin area */
.subnav {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid #334155;
  margin-bottom: 1.25rem;
}
.subnav a {
  padding: 0.5rem 0.9rem;
  color: #94a3b8;
  font-size: 0.875rem;
  border-bottom: 2px solid transparent;
}
.subnav a:hover { color: #e2e8f0; text-decoration: none; }
.subnav a.active { color: #e2e8f0; border-bottom-color: #38bdf8; }
.badge-admin { background: #78350f; color: #fcd34d; border: 1px solid #b45309; }
.badge-user  { background: #334155; color: #94a3b8; border: 1px solid #475569; }

input[type="text"],
input[type="number"],
select {
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid #475569;
  border-radius: 0.375rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
  outline: none;
  border-color: #3b82f6;
}

.row {
  display: flex;
  gap: 1rem;
}
.row label { flex: 1; }

.actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

/* Settings */
.settings { max-width: 600px; }
.settings h2 { margin-bottom: 0.5rem; }
.settings .hint {
  color: #94a3b8;
  font-size: 0.8125rem;
  margin-bottom: 1.5rem;
}
.settings .hint code {
  background: #1e293b;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-size: 0.8rem;
}

.field {
  display: flex;
  justify-content: space-between;
  padding: 0.375rem 0;
  font-size: 0.8125rem;
  border-bottom: 1px solid #1e293b;
}
.field:last-child { border-bottom: none; }

.field .label { color: #94a3b8; }
.field .value { color: #e2e8f0; font-family: monospace; }

/* Profiles page */
.profiles-page { max-width: 900px; }
.profiles-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.profiles-header h2 { margin: 0; }
.actions-cell { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }

/* Auth pages */
.auth-container {
  max-width: 400px;
  margin: 3rem auto;
}
.auth-container h2 { margin-bottom: 0.5rem; }
.auth-container p { color: #94a3b8; font-size: 0.875rem; margin-bottom: 1rem; }

.auth-form { display: flex; flex-direction: column; gap: 0.75rem; }
.auth-form small { color: #64748b; font-size: 0.75rem; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.form-group label {
  margin-bottom: 0;
}

input[type="password"] {
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid #475569;
  border-radius: 0.375rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
}
input[type="password"]:focus {
  outline: none;
  border-color: #3b82f6;
}

.flash {
  padding: 0.75rem 1rem;
  border-radius: 0.375rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
}
.flash.error {
  background: #7f1d1d;
  color: #fca5a5;
}
.flash.success {
  background: #14532d;
  color: #86efac;
}

/* Navbar user */
.nav-user {
  color: #94a3b8;
  font-size: 0.8125rem;
  margin-left: auto;
}
.nav-logout {
  display: inline;
}
.nav-logout .btn {
  background: transparent;
  border: 1px solid #475569;
  color: #94a3b8;
  font-size: 0.75rem;
}
.nav-logout .btn:hover {
  background: #334155;
  color: #e2e8f0;
}

/* HTMX indicator */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline; }
.htmx-request.htmx-indicator { display: inline; }

/* Logs */
.logs { display: flex; flex-direction: column; gap: 1rem; }

.log-filters {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.8125rem;
  color: #94a3b8;
}
.log-filters select {
  background: #1e293b;
  color: #e2e8f0;
  border: 1px solid #475569;
  border-radius: 0.375rem;
  padding: 0.375rem 0.5rem;
  font-size: 0.8125rem;
  margin-left: 0.375rem;
}
.log-pause { display: flex; align-items: center; gap: 0.375rem; cursor: pointer; }

.log-table {
  font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.75rem;
}
.log-table td {
  vertical-align: top;
  border-bottom: 1px solid #1e293b;
  padding: 0.25rem 0.625rem;
}
.log-time { color: #64748b; white-space: nowrap; }
.log-msg { color: #e2e8f0; width: 100%; }

.log-badge {
  display: inline-block;
  min-width: 3.25rem;
  text-align: center;
  padding: 0 0.375rem;
  border-radius: 0.25rem;
  font-size: 0.6875rem;
  font-weight: 600;
}
.log-INFO  .log-badge { background: #1e3a5f; color: #7dd3fc; }
.log-DEBUG .log-badge { background: #334155; color: #94a3b8; }
.log-WARN  .log-badge { background: #78350f; color: #fcd34d; }
.log-ERROR .log-badge { background: #7f1d1d; color: #fca5a5; }
.log-ERROR .log-msg { color: #fca5a5; }

.log-pid {
  color: #38bdf8;
  margin-left: 0.5rem;
}
.log-attrs { color: #94a3b8; margin-left: 0.5rem; }
