/* eids-data-tool — clean, utilitarian stylesheet */

/* ─── Reset & base ────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html {
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  color: #1e2a35;
  background: #f4f6f8;
}

/* ─── Layout container ─────────────────────────────────────────────────── */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
}

/* ─── Top navigation bar ───────────────────────────────────────────────── */
.topbar {
  background: #1a2430;
  color: #e8ecf0;
  border-bottom: 3px solid #0d7fc0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  gap: 2rem;
  height: 50px;
}

.topbar-brand {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #e8ecf0;
  text-decoration: none;
  white-space: nowrap;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex: 1;
}

.topbar-nav a {
  color: #b0bec5;
  text-decoration: none;
  font-size: 0.875rem;
  padding: 0.35rem 0.75rem;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}

.topbar-nav a:hover,
.topbar-nav a.active {
  background: rgba(255,255,255,0.08);
  color: #e8ecf0;
}

.topbar-end {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.db-source-select {
  font-size: 0.78rem;
  padding: 3px 6px;
  border-radius: 4px;
  border: 1.5px solid #2c4a5e;
  background: #0f2531;
  color: #cfe7f2;
}
.db-source-select[data-mode="local"] {
  border-color: #d99a2b;
  color: #ffd98a;
}
.db-source-select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ─── Typography & headings ────────────────────────────────────────────── */
h1 { font-size: 1.6rem; margin: 0 0 1rem; font-weight: 600; color: #0f1d27; }
h2 { font-size: 1.25rem; margin: 1.25rem 0 0.75rem; font-weight: 600; }
h3 { font-size: 1.05rem; margin: 1rem 0 0.5rem; font-weight: 600; }

p { margin: 0 0 0.75rem; }

a { color: #0d7fc0; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Card ─────────────────────────────────────────────────────────────── */
.card {
  background: #fff;
  border: 1px solid #d5dde5;
  border-radius: 6px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}

/* ─── Forms ─────────────────────────────────────────────────────────────── */
form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
}

/* ─── Reports filter grid (overrides generic form flex for this form) ────── */
.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px 16px;
  align-items: end;
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.filter-field > label {
  font-size: .8rem;
  font-weight: 600;
  color: #475569;
}

.filter-field > input,
.filter-field > select {
  width: 100%;
  box-sizing: border-box;
}

.filter-field select[multiple] {
  min-height: 90px;
}

.filter-field > small {
  font-size: 0.72rem;
  color: #6b7f8e;
  line-height: 1.3;
}

input[type="text"],
input[type="date"],
input[type="email"],
input[type="password"],
input[type="search"],
input:not([type]),
select,
textarea {
  font-family: inherit;
  font-size: 0.875rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid #c0cdd8;
  border-radius: 4px;
  background: #fff;
  color: #1e2a35;
  line-height: 1.4;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #0d7fc0;
  box-shadow: 0 0 0 3px rgba(13,127,192,0.15);
}

label {
  font-size: 0.8rem;
  font-weight: 500;
  color: #4a5e6d;
  display: block;
  margin-bottom: 0.2rem;
}

/* ─── Buttons ───────────────────────────────────────────────────────────── */
button,
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.4rem 0.85rem;
  border-radius: 4px;
  border: 1px solid transparent;
  cursor: pointer;
  line-height: 1.4;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}

button[type="submit"],
.btn-primary {
  background: #0d7fc0;
  color: #fff;
  border-color: #0a6aa3;
}
button[type="submit"]:hover,
.btn-primary:hover {
  background: #0a6aa3;
}

button[type="button"],
button:not([type]),
.btn-default {
  background: #fff;
  color: #2e4050;
  border-color: #c0cdd8;
}
button:not([type="submit"]):hover,
.btn-default:hover {
  background: #f0f4f7;
}

/* logout button in nav — keep it minimal */
.topbar-end button,
.topbar-end .btn {
  background: transparent;
  border-color: #546070;
  color: #b0bec5;
  font-size: 0.8rem;
  padding: 0.3rem 0.65rem;
}
.topbar-end button:hover {
  background: rgba(255,255,255,0.08);
  color: #e8ecf0;
}

/* ─── Tables ────────────────────────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  background: #fff;
}

thead tr {
  background: #2b3e50;
  color: #e8ecf0;
}

thead th {
  padding: 0.5rem 0.65rem;
  text-align: left;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

tbody tr:nth-child(odd)  { background: #fff; }
tbody tr:nth-child(even) { background: #f6f9fb; }
tbody tr:hover           { background: #eaf3f9; }

td {
  padding: 0.4rem 0.65rem;
  border-bottom: 1px solid #e4eaf0;
  vertical-align: top;
}

/* ─── Summary chips ─────────────────────────────────────────────────────── */
.summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.82rem;
  color: #3a5060;
  margin-bottom: 0.75rem;
}

.summary strong {
  font-weight: 600;
  color: #1a2a38;
}

.chip {
  display: inline-block;
  background: #e4edf5;
  border: 1px solid #c5d5e4;
  border-radius: 12px;
  padding: 0.15rem 0.6rem;
  font-size: 0.78rem;
  color: #2e4050;
}

/* ─── Pager & export links ──────────────────────────────────────────────── */
.pager {
  font-size: 0.82rem;
  color: #5a7080;
  margin: 0.5rem 0;
}

.export {
  font-size: 0.82rem;
  margin: 0.4rem 0 0.75rem;
  color: #5a7080;
}

.export a {
  margin-right: 0.4rem;
}

/* ─── Notices & alerts ──────────────────────────────────────────────────── */
.notice {
  background: #e8f3fa;
  border-left: 4px solid #0d7fc0;
  padding: 0.5rem 0.85rem;
  border-radius: 0 4px 4px 0;
  font-size: 0.85rem;
  color: #1a3d54;
  margin-bottom: 0.75rem;
}

.error {
  background: #fdecea;
  border-left: 4px solid #c0392b;
  padding: 0.5rem 0.85rem;
  border-radius: 0 4px 4px 0;
  font-size: 0.85rem;
  color: #7b1e18;
  margin-bottom: 0.75rem;
}

/* ─── Loading / HTMX indicators ─────────────────────────────────────────── */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator,
.htmx-indicator.htmx-request { display: inline-block; }

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid #c5d5e4;
  border-top-color: #0d7fc0;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 0.4rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-msg {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1.5rem 0;
  color: #5a7080;
  font-size: 0.9rem;
}

/* ─── Misc ───────────────────────────────────────────────────────────────── */
hr {
  border: none;
  border-top: 1px solid #d5dde5;
  margin: 1.25rem 0;
}

/* ─── Badges ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #e4edf5;
  color: #2e4050;
  border: 1px solid #c5d5e4;
}
.badge-ok  { background: #d4edda; color: #155724; border-color: #c3e6cb; }
.badge-err { background: #fdecea; color: #7b1e18; border-color: #f5c6cb; }
.badge-warn { background: #fff3cd; color: #7a5c00; border-color: #ffe69c; }

/* ─── Small action buttons ───────────────────────────────────────────────── */
.btn-sm {
  font-size: 0.75rem;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  border: 1px solid #c0cdd8;
  background: #fff;
  color: #2e4050;
  cursor: pointer;
  white-space: nowrap;
}
.btn-sm:hover { background: #f0f4f7; }
.btn-danger { border-color: #e8a09a; color: #c0392b; background: #fff; }
.btn-danger:hover { background: #fdecea; }

/* ─── Inline edit form (DFI hosts, etc.) ────────────────────────────────── */
.edit-form {
  background: #f6f9fb;
  border: 1px solid #d0dce8;
  border-radius: 6px;
  padding: 1rem 1.25rem;
  margin-top: 0.5rem;
}
.edit-form-grid {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 0.5rem 1rem;
  align-items: center;
  margin-bottom: 0.75rem;
}
.edit-form-grid label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #3a5060;
}
.edit-form-grid input,
.edit-form-grid select {
  width: 100%;
  box-sizing: border-box;
}
.edit-form-actions {
  display: flex;
  gap: 0.5rem;
}
.action-cell {
  white-space: nowrap;
  display: flex;
  gap: 0.3rem;
  align-items: center;
  flex-wrap: wrap;
}
