:root {
  --bg: #0e1116;
  --bg-soft: #161b22;
  --bg-card: #1b222d;
  --border: #2a313c;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #58a6ff;
  --warn: #f0b429;
  --warn-bg: #2d2406;
  --ok: #3fb950;
  --danger: #f85149;
}

* { box-sizing: border-box; }

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

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

body.auth {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 32px rgba(0,0,0,.3);
}
.card h1 { margin: 0 0 12px; font-size: 22px; }
.card label { display: block; margin: 16px 0 6px; color: var(--muted); font-size: 13px; }
.card input {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 15px;
  font-family: inherit;
}
.card input:focus { outline: none; border-color: var(--accent); }
.card button {
  width: 100%;
  margin-top: 20px;
  padding: 11px;
  background: var(--accent);
  color: #0d1117;
  border: 0;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
.card button:hover { filter: brightness(1.1); }

.muted { color: var(--muted); }
.small { font-size: 12px; }

.error {
  background: rgba(248,81,73,.12);
  border: 1px solid rgba(248,81,73,.4);
  color: #ffb4af;
  padding: 10px 12px;
  border-radius: 8px;
  margin-top: 12px;
  font-size: 13px;
}
.hidden { display: none !important; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
  gap: 8px;
}
.brand { font-weight: 700; }
.actions { display: flex; align-items: center; gap: 12px; }
.actions button.primary {
  background: var(--accent);
  color: #0d1117;
  border: 0;
  border-radius: 6px;
  padding: 7px 14px;
  font-weight: 600;
  cursor: pointer;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px;
}

.section { margin-bottom: 28px; }
.section h2 {
  font-size: 16px;
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.count {
  background: var(--border);
  color: var(--muted);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
}

.section.pending {
  background: rgba(240,180,41,.06);
  border: 1px solid rgba(240,180,41,.3);
  border-radius: 10px;
  padding: 16px;
}

.pending-row {
  display: grid;
  grid-template-columns: 160px 180px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.pending-row:last-child { border-bottom: 0; }
.pending-row .desc { color: var(--muted); font-size: 13px; font-style: italic; }
.pending-row input {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 7px 10px;
  font-family: ui-monospace, monospace;
  font-size: 13px;
  min-width: 240px;
}
.pending-row button {
  background: var(--ok);
  color: #0d1117;
  border: 0;
  border-radius: 6px;
  padding: 7px 12px;
  cursor: pointer;
  font-weight: 600;
}

.service-group {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 10px;
}
.service-group summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 16px;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.service-group summary::-webkit-details-marker { display: none; }
.service-group summary::before { content: "▸"; margin-right: 8px; transition: transform .15s; }
.service-group[open] summary::before { transform: rotate(90deg); display: inline-block; }

.key-row {
  display: grid;
  grid-template-columns: 220px 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 9px 16px;
  border-top: 1px solid var(--border);
  font-size: 13px;
}
.key-row .name { font-family: ui-monospace, monospace; }
.key-row .value {
  font-family: ui-monospace, monospace;
  color: var(--muted);
  letter-spacing: 1px;
  user-select: none;
  word-break: break-all;
}
.key-row .value.revealed {
  color: var(--accent);
  user-select: all;
  letter-spacing: 0;
}
.key-row .date { font-size: 11px; color: var(--muted); white-space: nowrap; }
.key-row .ops { display: flex; gap: 4px; }
.key-row .ops button {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 7px;
  border-radius: 5px;
  font-size: 14px;
}
.key-row .ops button:hover { background: var(--bg); border-color: var(--border); color: var(--text); }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  max-width: 400px;
}
.modal-card h3 { margin: 0 0 16px; }
.modal-card label { display: block; margin: 12px 0 6px; color: var(--muted); font-size: 13px; }
.modal-card input {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: inherit;
}
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.modal-actions button {
  background: var(--border);
  color: var(--text);
  border: 0;
  border-radius: 6px;
  padding: 8px 14px;
  cursor: pointer;
}
.modal-actions button.primary { background: var(--accent); color: #0d1117; font-weight: 600; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
  z-index: 200;
  font-size: 13px;
}

@media (max-width: 700px) {
  .key-row { grid-template-columns: 1fr auto; gap: 8px; }
  .key-row .value, .key-row .date { grid-column: 1 / -1; }
  .pending-row { grid-template-columns: 1fr; }
  .pending-row input { min-width: 0; width: 100%; }
}
