:root {
  color-scheme: light;
  --bg: #f6f7f8;
  --surface: #ffffff;
  --ink: #17201d;
  --muted: #63706a;
  --line: #d9dfdc;
  --teal: #0f766e;
  --amber: #b7791f;
  --rose: #be3455;
  --shadow: 0 14px 34px rgba(23, 32, 29, 0.07);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
  letter-spacing: 0;
}

button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  background: var(--ink);
  color: #ffffff;
  font-weight: 750;
  cursor: pointer;
}

button:hover {
  background: #26322e;
}

.secondary-button {
  background: #e9eeeb;
  color: #33413b;
  border: 1px solid #d6dfdb;
}

.secondary-button:hover {
  background: #dde5e1;
}

.small-button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
  background: #eef7f4;
  color: #075e58;
  border: 1px solid #c7e8df;
}

.small-button:hover {
  background: #dff1ec;
}

.danger-button {
  background: #fff1f2;
  color: #9f1239;
  border-color: #fecdd3;
}

.danger-button:hover {
  background: #ffe4e6;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

label {
  display: block;
  margin: 0 0 7px;
  color: #34413b;
  font-size: 13px;
  font-weight: 750;
}

a {
  color: var(--teal);
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-wrap: anywhere;
}

.admin-shell {
  min-height: 100vh;
  padding: 28px clamp(16px, 4vw, 44px) 48px;
}

.admin-topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.admin-topbar h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.panel,
.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.auth-panel {
  margin-bottom: 18px;
}

.auth-form {
  max-width: 720px;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
}

.admin-create-form {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(130px, 180px) auto;
  gap: 10px;
  margin-bottom: 14px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.metric {
  min-height: 108px;
  padding: 15px;
  display: grid;
  align-content: start;
  gap: 9px;
}

.metric span,
.muted {
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  font-size: 28px;
  line-height: 1;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0;
}

.tabs button {
  background: #e9eeeb;
  color: #33413b;
  border: 1px solid #d6dfdb;
}

.tabs button:hover,
.tabs button.active,
.tabs button[aria-selected="true"] {
  background: var(--ink);
  color: #ffffff;
}

.views {
  min-width: 0;
}

.admin-view {
  display: block;
}

.admin-view[hidden] {
  display: none !important;
}

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

.panel-head h2 {
  margin: 0;
  font-size: 20px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 1040px;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid #e4e9e6;
  text-align: left;
  vertical-align: middle;
}

th {
  color: #53615b;
  font-size: 12px;
  text-transform: uppercase;
}

.status {
  display: inline-grid;
  place-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
}

.status.active {
  background: #e8f7f1;
  color: #047857;
}

.status.revoked {
  background: #fff1f2;
  color: #9f1239;
}

.status.expired {
  background: #fff7ed;
  color: #9a3412;
}

.status.public {
  background: #e8f7f1;
  color: #047857;
}

.status.protected {
  background: #fff7ed;
  color: #9a3412;
}

.events-list {
  display: grid;
  gap: 8px;
}

.event-row {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) minmax(170px, 0.7fr) minmax(160px, 0.7fr) minmax(180px, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid #e4e9e6;
  border-radius: 6px;
  background: #fcfdfc;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(420px, calc(100vw - 44px));
  background: #17201d;
  color: #ffffff;
  padding: 12px 14px;
  border-radius: 8px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.24);
}

.hidden {
  display: none !important;
}

@media (max-width: 1040px) {
  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .event-row {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 700px) {
  .admin-shell {
    padding: 20px 14px 42px;
  }

  .admin-topbar,
  .inline-form,
  .admin-create-form,
  .panel-head {
    display: grid;
    grid-template-columns: 1fr;
  }

  .metrics-grid {
    grid-template-columns: 1fr;
  }
}
