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

body {
  font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  background: #0d1117;
  color: #c9d1d9;
  min-height: 100vh;
}

a { color: #58a6ff; text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, 'Cascadia Code', monospace; font-size: 13px; }

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: #161b22;
  border-right: 1px solid #30363d;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 16px 20px;
  border-bottom: 1px solid #30363d;
}

.sidebar-header h1 {
  font-size: 14px;
  font-weight: 600;
  color: #e6edf3;
}

.sidebar-header p {
  font-size: 12px;
  color: #7d8590;
  margin-top: 2px;
}

.sidebar-nav { flex: 1; padding: 8px 0; overflow-y: auto; }

.nav-section {
  padding: 8px 20px 4px;
  font-size: 11px;
  font-weight: 500;
  color: #7d8590;
}

.nav-link {
  display: block;
  padding: 6px 20px;
  color: #8b949e;
  font-size: 13px;
  border-left: 2px solid transparent;
}

.nav-link:hover { color: #c9d1d9; background: #1f2937; text-decoration: none; }
.nav-link.active { color: #e6edf3; border-left-color: #58a6ff; background: #1f2937; }

.sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid #30363d;
}

.sidebar-footer a { font-size: 12px; color: #7d8590; }
.sidebar-footer a:hover { color: #c9d1d9; }

.main { flex: 1; overflow-x: auto; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: 48px;
  border-bottom: 1px solid #30363d;
  display: flex;
  align-items: center;
  padding: 0 24px;
  background: #0d1117;
  flex-shrink: 0;
  gap: 8px;
  overflow: visible;
}

.topbar-title { font-size: 14px; font-weight: 500; color: #e6edf3; }
.topbar-sep { color: #30363d; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.context-pills {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.context-pills::-webkit-scrollbar { display: none; }

.pill-link {
  display: inline-block;
  padding: 4px 12px;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 100px;
  color: #8b949e;
  font-size: 12px;
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.2s ease;
}
.pill-link:hover { border-color: #8b949e; color: #e6edf3; }
.pill-link.active { background: #30363d; border-color: #58a6ff; color: #e6edf3; font-weight: 500; }

.content { flex: 1; padding: 24px; }

.table-wrap { border: 1px solid #30363d; border-radius: 6px; overflow: hidden; }

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

th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: #7d8590;
  padding: 10px 16px;
  background: #161b22;
  border-bottom: 1px solid #30363d;
}

td { padding: 10px 16px; border-bottom: 1px solid #21262d; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #161b22; }

.type-badge {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid #30363d;
  color: #8b949e;
  font-family: ui-monospace, monospace;
}

.key-name { font-family: ui-monospace, monospace; font-size: 13px; }
.ttl { font-size: 12px; font-family: ui-monospace, monospace; color: #7d8590; }
.ttl-persistent { color: #3fb950; }
.ttl-expiring { color: #d29922; }
.ttl-expired { color: #f78166; }

.empty-state { padding: 48px 24px; text-align: center; color: #7d8590; font-size: 13px; }

.filter-bar { margin-bottom: 16px; display: flex; gap: 8px; }

.filter-bar input {
  flex: 1;
  padding: 7px 12px;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #c9d1d9;
  font-size: 13px;
  font-family: ui-monospace, monospace;
  outline: none;
}

.filter-bar input:focus { border-color: #58a6ff; }

.count-line { margin-bottom: 12px; font-size: 12px; color: #7d8590; }

.btn {
  padding: 7px 14px;
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #c9d1d9;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.btn:hover { background: #30363d; text-decoration: none; }

.btn-danger { padding: 4px 8px; background: transparent; border: 1px solid #6e2020; border-radius: 6px; color: #f78166; font-size: 12px; cursor: pointer; line-height: 1; }
.btn-danger:hover { background: #6e2020; color: #fff; }

.back-link { font-size: 12px; color: #7d8590; display: inline-block; margin-bottom: 16px; }
.back-link:hover { color: #c9d1d9; }

.meta-row { display: flex; gap: 32px; margin-bottom: 20px; flex-wrap: wrap; }

.meta-item { display: flex; flex-direction: column; gap: 2px; }
.meta-label { font-size: 11px; color: #7d8590; font-weight: 500; }
.meta-value { font-size: 13px; color: #c9d1d9; font-family: ui-monospace, monospace; }

.section-title { font-size: 12px; font-weight: 600; color: #7d8590; margin-bottom: 8px; }

.value-box {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 12px 16px;
  font-family: ui-monospace, monospace;
  font-size: 13px;
  color: #c9d1d9;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 480px;
  overflow-y: auto;
  line-height: 1.6;
}

.hash-field { color: #79c0ff; width: 40%; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0d1117;
}

.login-box {
  width: 320px;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 32px;
}

.login-box h2 { font-size: 15px; font-weight: 600; color: #e6edf3; margin-bottom: 24px; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: #8b949e; margin-bottom: 6px; }

.form-group input {
  width: 100%;
  padding: 8px 12px;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #c9d1d9;
  font-size: 14px;
  outline: none;
}

.form-group input:focus { border-color: #58a6ff; }

.form-error { font-size: 12px; color: #f78166; margin-bottom: 14px; }

.btn-submit {
  width: 100%;
  padding: 9px 14px;
  background: #1f6feb;
  border: 1px solid #388bfd;
  border-radius: 6px;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.btn-submit:hover { background: #388bfd; }

.error-banner {
  background: #160b0b;
  border: 1px solid #6e2020;
  border-radius: 6px;
  padding: 12px 16px;
  color: #f78166;
  font-size: 13px;
  margin-bottom: 16px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
  flex-shrink: 0;
}
.status-ok   { background: #3fb950; }
.status-err  { background: #f78166; }

.status-line {
  display: flex;
  align-items: center;
  font-size: 13px;
  color: #8b949e;
  margin-bottom: 24px;
  gap: 16px;
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.info-block { border: 1px solid #30363d; border-radius: 6px; overflow: hidden; }

.info-block-title {
  font-size: 11px;
  font-weight: 500;
  color: #7d8590;
  padding: 8px 16px;
  background: #161b22;
  border-bottom: 1px solid #30363d;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  border-bottom: 1px solid #21262d;
  font-size: 13px;
}

.info-row:last-child { border-bottom: none; }

.info-label { color: #7d8590; }
.info-value { color: #c9d1d9; font-family: ui-monospace, monospace; font-size: 12px; }
.info-value.ok { color: #3fb950; }
.info-value.warn { color: #d29922; }

/* Collapsable Details Block */
.collapsable-block {
  border: 1px solid #30363d;
  border-radius: 6px;
  margin-bottom: 24px;
  background: #0d1117;
}

.collapsable-block summary {
  padding: 8px 16px;
  background: #161b22;
  font-size: 11px;
  font-weight: 500;
  color: #7d8590;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  user-select: none;
}

.collapsable-block summary::-webkit-details-marker { display: none; }

.collapsable-block summary:hover {
  background: #1f2937;
  color: #c9d1d9;
}

.collapsable-block summary::after {
  content: '▼';
  font-size: 8px;
  transition: transform 0.2s ease;
  color: #484f58;
}

.collapsable-block[open] summary::after {
  transform: rotate(180deg);
}

.collapsable-block .details-content {
  border-top: 1px solid #30363d;
  padding: 0;
}

/* ── Transitions ───────────────────────────────────────────────────────────── */

.btn          { transition: background 150ms ease, border-color 150ms ease; }
.btn-danger   { transition: background 150ms ease, color 150ms ease, border-color 150ms ease; }
.btn-submit   { transition: background 150ms ease; }
.nav-link     { transition: color 150ms ease, background 150ms ease, border-color 150ms ease; }
td            { transition: background 150ms ease; }
.type-badge   { transition: border-color 150ms ease; }
/* checkbox transitions handled in the component block below */

/* ── Confirm dialog ────────────────────────────────────────────────────────── */

.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease;
}

.confirm-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.confirm-dialog {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 24px;
  width: 340px;
  max-width: calc(100vw - 48px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transition: opacity 150ms ease;
}

.confirm-overlay.visible .confirm-dialog {
  opacity: 1;
}

.confirm-title {
  font-size: 14px;
  font-weight: 500;
  color: #e6edf3;
  margin-bottom: 8px;
}

.confirm-key {
  display: block;
  font-family: ui-monospace, 'Cascadia Code', monospace;
  font-size: 12px;
  color: #7d8590;
  word-break: break-all;
  margin-bottom: 20px;
  line-height: 1.5;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.confirm-ok-btn { padding: 7px 14px; font-size: 13px; }

/* ── Keys table ────────────────────────────────────────────────────────────── */

.col-cb { width: 40px; padding-left: 14px; padding-right: 8px; }
.col-del { width: 48px; text-align: right; }

input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  width: 15px;
  height: 15px;
  border: 1px solid #3d444d;
  border-radius: 3px;
  background: transparent;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  vertical-align: middle;
  transition: background 150ms ease, border-color 150ms ease;
}

input[type="checkbox"]:hover {
  border-color: #58a6ff;
}

input[type="checkbox"]:checked {
  background: #58a6ff;
  border-color: #58a6ff;
}

input[type="checkbox"]:indeterminate {
  background: transparent;
  border-color: #58a6ff;
}

/* checkmark — fades in on check */
input[type="checkbox"]::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 5px;
  height: 8px;
  border-right: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(45deg);
  opacity: 0;
  transition: opacity 120ms ease;
}

input[type="checkbox"]:checked::after {
  opacity: 1;
}

/* indeterminate dash */
input[type="checkbox"]:indeterminate::after {
  left: 3px;
  top: 6px;
  width: 7px;
  height: 1.5px;
  border: none;
  background: #58a6ff;
  transform: none;
  opacity: 1;
}

tr.row-selected td { background: #111d2e; }
tr.row-selected:hover td { background: #152235; }

.selection-toolbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: #161b22;
  border-top: 1px solid #30363d;
  display: flex;
  align-items: center;
  padding: 0 24px 0 264px;
  gap: 16px;
  z-index: 100;
  opacity: 1;
  transition: opacity 150ms ease;
}

.selection-toolbar.hidden { display: none; }

.sel-count { font-size: 13px; color: #8b949e; flex: 1; }

.toolbar-actions { display: flex; gap: 8px; align-items: center; }
