:root {
  --bg: #0c0d10;
  --surface: #14161c;
  --border: #252830;
  --text: #e8eaef;
  --muted: #8b919d;
  --accent: #5b8cff;
  --accent-dim: #3d5fb3;
  --danger: #e85d5d;
  --radius: 10px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--surface);
  padding: 0.15em 0.4em;
  border-radius: 4px;
}

.app {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.04em;
  font-size: 1.1rem;
}

.brand-link {
  color: inherit;
  text-decoration: none;
}

.brand-link:hover {
  color: var(--accent);
  text-decoration: none;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
}

.panel h1 {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
}

.muted {
  color: var(--muted);
  margin: 0 0 1.25rem;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.hidden {
  display: none !important;
}

.label {
  font-size: 0.85rem;
  color: var(--muted);
}

.input {
  width: 100%;
  max-width: 420px;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}

.input-mono {
  font-family: var(--mono);
  font-size: 0.95rem;
}

.input:focus {
  outline: 2px solid var(--accent-dim);
  outline-offset: 1px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
  cursor: pointer;
  font-family: inherit;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.08);
}

.btn-ghost:hover:not(:disabled) {
  border-color: var(--muted);
}

.btn-icon {
  padding: 0.45rem;
  min-width: 2.25rem;
  min-height: 2.25rem;
}

.btn-icon svg {
  display: block;
  width: 1.1rem;
  height: 1.1rem;
  fill: currentColor;
}

.btn-danger:hover:not(:disabled) {
  border-color: var(--danger);
  color: var(--danger);
}

.alert {
  margin-top: 1rem;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  background: rgba(232, 93, 93, 0.12);
  border: 1px solid rgba(232, 93, 93, 0.35);
  color: #f0a8a8;
  font-size: 0.9rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.stat {
  padding: 0.85rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.stat-label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.stat-value {
  font-size: 1.15rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.stats--compact {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

.stats--compact .stat {
  padding: 0.55rem 0.75rem;
}

.stats--compact .stat-value {
  font-size: 1rem;
}

.toolbar {
  margin-bottom: 1rem;
}

.table-wrap {
  overflow-x: auto;
  margin-bottom: 1.75rem;
}

.keys-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.keys-table th,
.keys-table td {
  text-align: left;
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

.keys-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.keys-table td {
  font-variant-numeric: tabular-nums;
}

.col-actions {
  width: 1%;
  white-space: nowrap;
}

.key-cell {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.key-prefix {
  font-family: var(--mono);
  letter-spacing: 0.02em;
}

.empty {
  padding: 1rem 0;
  margin: 0;
}

.info-blocks {
  display: grid;
  gap: 1rem;
}

@media (min-width: 640px) {
  .info-blocks {
    grid-template-columns: 1fr 1fr;
  }
}

.info-card {
  padding: 1rem 1.1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.info-card h2 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.info-card p {
  margin: 0.35rem 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.info-card p:first-of-type {
  margin-top: 0;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 40;
}

.modal {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 50;
  width: min(440px, calc(100% - 2rem));
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.modal-wide {
  width: min(720px, calc(100% - 2rem));
}

.modal h2 {
  margin: 0 0 0.35rem;
  font-size: 1.2rem;
}

.modal-close {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  width: 2rem;
  height: 2rem;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 6px;
}

.modal-close:hover {
  color: var(--text);
  background: var(--bg);
}

.stat-table-wrap {
  max-height: 50vh;
  overflow: auto;
  margin-top: 0.75rem;
}
