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

:root {
  --bg:      #f4f5f7;
  --surface: #ffffff;
  --border:  #dde1e7;
  --text:    #1a1d23;
  --muted:   #6b7280;
  --accent:  #2563eb;
  --green:   #16a34a;
  --yellow:  #ca8a04;
  --red:     #dc2626;
  --radius:  6px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ── Login ───────────────────────────────────────────────────────────────── */

body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.login-box h1 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1.75rem;
  text-align: center;
  letter-spacing: -.01em;
}

.field { margin-bottom: 1rem; }

.field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 0.3rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.field input {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  outline: none;
  transition: border-color .15s;
}

.field input:focus { border-color: var(--accent); }

.login-box .btn-primary {
  width: 100%;
  padding: 0.6rem;
  margin-top: 0.25rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity .15s;
}

.login-box .btn-primary:hover { opacity: .88; }

.error-msg {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  color: var(--red);
  font-size: 0.8rem;
  padding: 0.5rem 0.75rem;
  margin-bottom: 1rem;
}

/* ── Dashboard shell ─────────────────────────────────────────────────────── */

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: 52px;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

header h1 { font-size: 0.95rem; font-weight: 600; }

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.btn-link {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.8rem;
}

.btn-link:hover { color: var(--text); }

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

footer {
  text-align: center;
  padding: 1.5rem;
  font-size: 0.75rem;
  color: var(--muted);
}

/* ── Stat cards ──────────────────────────────────────────────────────────── */

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

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 0.3rem;
  letter-spacing: -.02em;
}

.stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
}

/* ── Stores table ────────────────────────────────────────────────────────── */

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

th, td {
  padding: 0.6rem 1.5rem;
  text-align: left;
}

th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td { border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafafa; }

/* ── Panel (replaces stores-section) ────────────────────────────────────── */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.panel-header h2 {
  font-size: 0.875rem;
  font-weight: 600;
  flex: 1;
}

.panel-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.panel-footer {
  padding: 0.6rem 1.5rem;
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
  min-height: 2rem;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.btn-primary {
  padding: 0.45rem 0.9rem;
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity .15s;
}
.btn-primary:hover { opacity: .88; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.btn-outline {
  padding: 0.45rem 0.9rem;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
}
.btn-outline:hover { background: #eff6ff; }

.btn-danger-outline {
  padding: 0.45rem 0.9rem;
  background: transparent;
  color: var(--red);
  border: 1px solid var(--red);
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
}
.btn-danger-outline:hover:not(:disabled) { background: #fef2f2; }
.btn-danger-outline:disabled { opacity: .4; cursor: not-allowed; }

.btn-row-delete {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0.2rem 0.4rem;
  border-radius: var(--radius);
}
.btn-row-delete:hover { color: var(--red); background: #fef2f2; }

/* ── Key table specific ──────────────────────────────────────────────────── */

.col-check  { width: 2.5rem; text-align: center; }
.col-action { width: 5rem;   text-align: right; }

.text-red { color: var(--red); }

/* ── Modal ───────────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
/* display:flex above overrides the UA [hidden]{display:none} rule — re-assert it */
.modal-overlay[hidden] { display: none; }

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  width: 100%;
  max-width: 440px;
  margin: 1rem;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 0.95rem; font-weight: 600; }

.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0.2rem;
}
.modal-close:hover { color: var(--text); }

.modal-body { padding: 1.25rem 1.5rem; }

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
}

.key-warning {
  background: #fefce8;
  border: 1px solid #fde047;
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem;
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 1rem;
  color: #854d0e;
}

.key-display {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
}

.key-display code {
  flex: 1;
  font-family: 'Courier New', monospace;
  font-size: 0.78rem;
  word-break: break-all;
  color: var(--text);
}

.btn-copy {
  flex-shrink: 0;
  padding: 0.3rem 0.6rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 0.75rem;
  cursor: pointer;
}
.btn-copy:hover { opacity: .88; }

/* ── Status indicators ───────────────────────────────────────────────────── */

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 5px;
  flex-shrink: 0;
}

.dot-green  { background: var(--green); }
.dot-yellow { background: var(--yellow); }
.dot-red    { background: var(--red); }
.dot-grey   { background: var(--muted); }

.health-badge {
  font-size: 1.1rem;
  line-height: 1;
}

.health-badge.ok    { color: var(--green); }
.health-badge.error { color: var(--red); }

.muted { color: var(--muted); }

/* ── Select ──────────────────────────────────────────────────────────────── */

.field select {
  width: 100%;
  padding: 0.55rem 2rem 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-family: inherit;
  background: var(--surface)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%236b7280' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E")
    no-repeat right 0.75rem center;
  color: var(--text);
  outline: none;
  cursor: pointer;
  transition: border-color .15s;
  -webkit-appearance: none;
  appearance: none;
}
.field select:focus { border-color: var(--accent); }

/* Wizard labels are questions/descriptions — don't inherit the uppercase form-field style */
.modal--wide .field > label {
  text-transform: none;
  letter-spacing: normal;
  font-size: 0.875rem;
  color: var(--text);
  font-weight: 500;
}

/* ── Bulk import wizard ───────────────────────────────────────────────────── */

.modal--wide { max-width: 560px; }

.wizard-steps {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.wizard-step {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: .02em;
}
.wizard-step.is-active { color: var(--accent); }
.wizard-step.is-done   { color: var(--green);  }

.wizard-sep {
  color: var(--border);
  font-size: 0.85rem;
}

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.25rem;
  text-align: center;
  transition: border-color .15s, background .15s;
  cursor: default;
}
.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: #eff6ff;
}
.drop-zone p { font-size: 0.875rem; }

.import-summary {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}

.import-count {
  flex: 1;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.82rem;
}
.import-count strong { font-size: 1.4rem; display: block; line-height: 1.2; }

.import-count--new  { background: #f0fdf4; border: 1px solid #bbf7d0; color: var(--green); }
.import-count--skip { background: var(--bg); border: 1px solid var(--border); color: var(--muted); }

.hostname-preview {
  max-height: 130px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.4rem 0.75rem;
  background: var(--bg);
}

.hostname-item {
  font-size: 0.8rem;
  font-family: 'Courier New', monospace;
  padding: 0.2rem 0;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.hostname-item:last-child { border-bottom: none; }

.radio-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.4rem;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.875rem;
  cursor: pointer;
  font-weight: normal;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
}

.import-keys-scroll {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.import-table th,
.import-table td {
  padding: 0.4rem 0.75rem;
}

.key-cell {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.key-short {
  font-family: 'Courier New', monospace;
  font-size: 0.78rem;
  color: var(--muted);
}

.btn-copy-sm {
  flex-shrink: 0;
  padding: 0.2rem 0.5rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 0.72rem;
  cursor: pointer;
  white-space: nowrap;
}
.btn-copy-sm:hover { opacity: .88; }
