:root {
  --bg: #0d1117;
  --bg-deep: #090c10;
  --card: #161c26;
  --border: rgba(255, 255, 255, 0.12);
  --border-soft: rgba(255, 255, 255, 0.07);
  --text: #e6edf3;
  --text-dim: #9aa7b4;
  --accent: #e05a47;
  --accent-2: #c43825;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #facc15;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 500px at 50% -220px, rgba(224, 90, 71, 0.10), transparent 65%),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, Arial, sans-serif;
  font-size: 14px;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(9, 12, 16, 0.75);
}

.brand {
  font-weight: 800;
  letter-spacing: 0.08em;
  font-size: 12.5px;
  color: var(--text);
  text-decoration: none;
}

.brand span { color: var(--accent); }

.topnav { display: flex; gap: 18px; }
.topnav a { color: var(--text-dim); text-decoration: none; font-size: 13px; }
.topnav a:hover { color: #fff; }

.shell {
  flex: 1;
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  padding: 48px 20px 32px;
}

.shell.medium { max-width: 780px; }
.shell.wide { max-width: 1240px; }

.foot {
  text-align: center;
  padding: 18px;
  color: var(--text-dim);
  font-size: 11px;
  border-top: 1px solid var(--border-soft);
}

.card {
  background: linear-gradient(180deg, rgba(22, 28, 38, 0.94) 0%, rgba(13, 17, 24, 0.96) 100%);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px 30px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
}

.card.wide { width: 100%; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  background: rgba(224, 90, 71, 0.15);
  border: 1px solid rgba(224, 90, 71, 0.35);
  border-radius: 100px;
  color: #ff9cb1;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.12em;
  margin-bottom: 12px;
}

h1 { margin: 0 0 6px; font-size: 22px; font-weight: 800; }
h2 { margin: 0 0 8px; font-size: 15.5px; font-weight: 700; }
.sub { margin: 0 0 20px; color: var(--text-dim); font-size: 12.5px; line-height: 1.5; }
.hint { color: var(--text-dim); font-size: 12.5px; line-height: 1.5; }
.dim { color: var(--text-dim); font-size: 12px; }
.sub a { color: #ff9cb1; text-decoration: none; }
.sub a:hover { color: #fff; text-decoration: underline; }

.alert {
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 12.5px;
  line-height: 1.45;
  margin-bottom: 16px;
  background: rgba(224, 90, 71, 0.15);
  border: 1px solid rgba(224, 90, 71, 0.4);
  color: #ffb8c7;
}

.alert.is-success {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.4);
  color: #86efac;
}

.form { display: flex; flex-direction: column; gap: 14px; }
.form.narrow { max-width: 420px; }

.f { display: flex; flex-direction: column; gap: 6px; }
.f label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  text-transform: uppercase;
}

input[type="text"], input[type="email"], input[type="password"] {
  width: 100%;
  background: rgba(8, 10, 14, 0.7);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 10px 12px;
  color: #fff;
  font-size: 13.5px;
  outline: none;
  transition: all 0.15s ease;
}

input:focus {
  border-color: var(--accent);
  background: rgba(8, 10, 14, 0.95);
  box-shadow: 0 0 0 3px rgba(224, 90, 71, 0.22);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 16px;
  background: linear-gradient(135deg, #e05a47 0%, #c43825 100%);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 7px;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(224, 90, 71, 0.35);
  text-decoration: none;
  font-family: inherit;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.btn:hover { background: linear-gradient(135deg, #f06a57 0%, #d44835 100%); }

.btn.secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  box-shadow: none;
}

.btn.secondary:hover { background: rgba(255, 255, 255, 0.14); }

.btn.danger {
  background: rgba(239, 68, 68, 0.16);
  border: 1px solid rgba(239, 68, 68, 0.45);
  box-shadow: none;
  color: #fca5a5;
}

.btn.danger:hover { background: rgba(239, 68, 68, 0.26); }

.btn.small { padding: 7px 12px; font-size: 12px; }
.btn.tiny { padding: 4px 9px; font-size: 11px; box-shadow: none; }

.btn.warn {
  background: rgba(250, 204, 21, 0.12);
  border: 1px solid rgba(250, 204, 21, 0.45);
  box-shadow: none;
  color: #fde68a;
}
.btn.warn:hover { background: rgba(250, 204, 21, 0.22); }

.pill.keystate-active { color: #86efac; border-color: rgba(34, 197, 94, 0.35); background: rgba(34, 197, 94, 0.08); }
.pill.keystate-frozen { color: #fde68a; border-color: rgba(250, 204, 21, 0.35); background: rgba(250, 204, 21, 0.08); }
.pill.keystate-cancelled { color: #fca5a5; border-color: rgba(239, 68, 68, 0.35); background: rgba(239, 68, 68, 0.08); }

.reason {
  width: 170px;
  padding: 4px 8px;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 11px;
  font-family: inherit;
}
.reason:focus { outline: none; border-color: rgba(224, 90, 71, 0.6); }

.linkbtn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 12.5px;
  text-decoration: underline;
  padding: 0;
  font-family: inherit;
}

.links {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  gap: 18px;
  align-items: center;
  flex-wrap: wrap;
}

.links a { color: var(--text-dim); font-size: 12.5px; text-decoration: underline; }
.links a:hover { color: #fff; }

.inline { display: inline; }

.head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 6px;
}

.head > div { min-width: 0; }
.head .sub { overflow-wrap: anywhere; }

.panel {
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: rgba(9, 12, 16, 0.5);
  padding: 18px 20px;
  margin-top: 18px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.panel-head h2 { margin: 0; }

.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border-soft);
  color: var(--text-dim);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.pill.status-pending, .pill.status-unverified { color: #fde68a; border-color: rgba(250, 204, 21, 0.35); background: rgba(250, 204, 21, 0.08); }
.pill.status-approved { color: #86efac; border-color: rgba(34, 197, 94, 0.35); background: rgba(34, 197, 94, 0.08); }
.pill.status-rejected, .pill.status-revoked { color: #fca5a5; border-color: rgba(239, 68, 68, 0.35); background: rgba(239, 68, 68, 0.08); }

.status {
  padding: 12px 14px;
  border-radius: 7px;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-soft);
  color: var(--text-dim);
}

.status-pending, .status-unverified { color: #fde68a; border-color: rgba(250, 204, 21, 0.3); }
.status-rejected, .status-revoked { color: #fca5a5; border-color: rgba(239, 68, 68, 0.3); }

.keyrow {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin: 12px 0 16px;
}

.key {
  flex: 1;
  min-width: 260px;
  display: block;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 10px 12px;
  font-family: Consolas, monospace;
  font-size: 12.5px;
  letter-spacing: 0.06em;
  word-break: break-all;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 12px;
}

.table-wrap .grid { margin-top: 0; }

.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  margin-top: 12px;
}

.grid th, .grid td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}

.grid th {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  font-weight: 800;
}

.grid th, .grid .nowrap { white-space: nowrap; }
.grid tbody tr:hover { background: rgba(255, 255, 255, 0.03); }
.selfrow { background: rgba(224, 90, 71, 0.06); }
.you {
  font-size: 9.5px;
  padding: 1px 6px;
  border-radius: 100px;
  background: rgba(224, 90, 71, 0.2);
  border: 1px solid rgba(224, 90, 71, 0.4);
  color: #ff9cb1;
  font-weight: 800;
  letter-spacing: 0.06em;
}


code.mono {
  background: var(--bg-deep);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11.5px;
}

@media (max-width: 720px) {
  .grid:not(.users):not(.audit) th:nth-child(3), .grid:not(.users):not(.audit) td:nth-child(3) { display: none; }
}

[hidden] { display: none !important; }

/* ---------- Admin console ---------- */

.topbar { gap: 28px; }

.adminnav { display: flex; gap: 4px; flex: 1; }
.adminnav a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 7px;
  white-space: nowrap;
}
.adminnav a:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }
.adminnav a.is-active { color: #fff; background: rgba(224, 90, 71, 0.16); box-shadow: inset 0 -2px 0 var(--accent); }

.topuser { display: flex; align-items: center; gap: 10px; }
.topuser-email { color: var(--text-dim); font-size: 12.5px; }

.avatar {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(224, 90, 71, 0.35), rgba(196, 56, 37, 0.15));
  border: 1px solid rgba(224, 90, 71, 0.4);
  color: #ffd2c9;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.avatar.sm { width: 28px; height: 28px; font-size: 10.5px; }

.shell.wide { padding-top: 32px; }

.pagehead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.pagehead h1 { font-size: 24px; }
.pagehead .sub { margin: 0; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.stat {
  display: block;
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  background: linear-gradient(180deg, rgba(22, 28, 38, 0.9), rgba(13, 17, 24, 0.9));
  color: var(--text);
  text-decoration: none;
}
a.stat:hover { border-color: var(--border); background: rgba(255, 255, 255, 0.05); }
.stat-label { font-size: 10.5px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-dim); }
.stat-value { margin-top: 6px; font-size: 26px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.stat.is-attention { border-color: rgba(224, 90, 71, 0.5); box-shadow: inset 3px 0 0 var(--accent); }
.stat.is-attention .stat-value { color: #ff9cb1; }
.stat.is-warn .stat-value { color: #fde68a; }

.tablepanel { padding: 0; margin-top: 0; background: rgba(13, 17, 24, 0.85); }
.tablepanel > .grid { margin-top: 0; }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft);
}

.tabs { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border-radius: 7px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 600;
}
.tab:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }
.tab.is-active { color: #fff; background: rgba(255, 255, 255, 0.09); }
.tab .count {
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 10.5px;
  text-align: center;
}
.tab.is-active .count { background: rgba(224, 90, 71, 0.3); color: #ffd2c9; }
.tabsep { width: 1px; height: 18px; margin: 0 6px; background: var(--border); }

input.search {
  width: 260px;
  padding: 7px 12px;
  font-size: 12.5px;
  background: rgba(8, 10, 14, 0.7);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: #fff;
  font-family: inherit;
  outline: none;
}
input.search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(224, 90, 71, 0.22); }

.empty { margin: 0; padding: 26px 16px; text-align: center; color: var(--text-dim); font-size: 12.5px; }

.grid.users th, .grid.users td, .grid.audit th, .grid.audit td { padding: 11px 16px; }
.tablepanel .grid thead th { background: rgba(255, 255, 255, 0.02); }
.grid .num { text-align: right; font-variant-numeric: tabular-nums; }
.grid tr.is-pending td:first-child { box-shadow: inset 3px 0 0 var(--yellow); }
.tablepanel .grid tbody tr:last-child td { border-bottom: none; }

.usercell { display: flex; align-items: center; gap: 11px; min-width: 0; }
.usertext { min-width: 0; }
.uname { font-weight: 700; font-size: 13px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.uemail { color: var(--text-dim); font-size: 12px; overflow-wrap: anywhere; }
.role {
  font-size: 9.5px;
  padding: 1px 6px;
  border-radius: 100px;
  background: rgba(125, 160, 255, 0.14);
  border: 1px solid rgba(125, 160, 255, 0.35);
  color: #b9c9ff;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.cellnote { margin-top: 4px; max-width: 180px; color: var(--text-dim); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.grid td.actions { width: 1%; white-space: nowrap; }
.rowactions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.rowactions .inline { display: inline-flex; gap: 6px; }

.iconbtn { padding: 4px 9px; font-size: 14px; line-height: 1; letter-spacing: 0; }

.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu[open] > summary { background: rgba(255, 255, 255, 0.16); }
.menu-pop {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 30;
  width: 250px;
  padding: 6px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #121821;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.6);
  white-space: normal;
}
.menu-label {
  padding: 8px 10px 4px;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.menu-sep { height: 1px; margin: 6px 4px; background: var(--border-soft); }
.menu-item {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.menu-item:hover { background: rgba(255, 255, 255, 0.07); }
.menu-item.warn { color: #fde68a; }
.menu-item.danger { color: #fca5a5; }
.menu-item.danger:hover { background: rgba(239, 68, 68, 0.14); }
.menu-reason { padding: 4px 6px 6px; }
.menu-reason .reason { width: 100%; padding: 7px 9px; font-size: 12px; }

.pill.action-ok { color: #86efac; border-color: rgba(34, 197, 94, 0.35); background: rgba(34, 197, 94, 0.08); }
.pill.action-warn { color: #fde68a; border-color: rgba(250, 204, 21, 0.35); background: rgba(250, 204, 21, 0.08); }
.pill.action-danger { color: #fca5a5; border-color: rgba(239, 68, 68, 0.35); background: rgba(239, 68, 68, 0.08); }
.mono-sm { font-family: Consolas, monospace; font-size: 11.5px; }

.settings { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 18px; align-items: start; }
.settings .panel { margin-top: 0; padding: 22px 24px; }
.settings .form { max-width: 440px; margin-top: 8px; }
.kv { display: grid; grid-template-columns: 90px 1fr; gap: 10px 14px; margin: 12px 0 0; font-size: 13px; }
.kv dt { color: var(--text-dim); font-size: 12px; }
.kv dd { margin: 0; overflow-wrap: anywhere; }

@media (max-width: 980px) {
  .topbar { flex-wrap: wrap; gap: 10px 18px; padding: 12px 16px; }
  .adminnav { order: 3; flex-basis: 100%; overflow-x: auto; }
  .topuser-email { display: none; }
  .settings { grid-template-columns: 1fr; }
  .toolbar .tabs { width: 100%; }
  input.search { width: 100%; }

  /* Tables turn into stacked cards */
  .grid.users thead, .grid.audit thead { display: none; }
  .grid.users tr, .grid.audit tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 14px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-soft);
  }
  .grid.users tbody tr:last-child, .grid.audit tbody tr:last-child { border-bottom: none; }
  .grid.users td, .grid.audit td { display: block; padding: 0; border: none; text-align: left; }
  .grid.users td[data-label]::before, .grid.audit td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 3px;
    font-size: 9.5px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-dim);
  }
  .grid.users td:first-child { grid-column: 1 / -1; }
  .grid.users td:first-child::before { display: none; }
  .grid.users td.actions { grid-column: 1 / -1; width: auto; }
  .rowactions { justify-content: flex-start; flex-wrap: wrap; }
  .menu-pop { left: 0; right: auto; }
  .grid tr.is-pending td:first-child { box-shadow: none; }
  .grid tr.is-pending { box-shadow: inset 3px 0 0 var(--yellow); }
}
