:root {
  --bg: #eef2f6;
  --ink: #0f172a;
  --mute: #5b6778;
  --line: #d8dee8;
  --fill: #ffffff;
  --wash: #f4f7fa;
  --accent: #0f8a7a;
  --accent-soft: #e7f6f3;
  --warn: #b42318;
  --warn-soft: #fef3f2;
  --ok: #067647;
  --ok-soft: #ecfdf3;
  --header: #0b1220;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

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

body:has(.login-box) {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.frame {
  width: min(1180px, calc(100% - 32px));
  margin: 20px auto;
  border: 1px solid var(--line);
  background: var(--fill);
  min-height: calc(100vh - 40px);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--header);
  color: #dce3ea;
  min-width: 0;
}

.brand-lockup {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  max-width: calc(100% - 12rem);
  height: 32px;
  overflow: hidden;
  text-decoration: none;
}

.brand-lockup img {
  display: block;
  height: 32px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  object-position: left center;
}

.who {
  color: #9aa6b2;
  font-size: 12px;
  flex: 0 1 auto;
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layout {
  display: grid;
  grid-template-columns: 188px minmax(0, 1fr);
  flex: 1;
  width: 100%;
  min-width: 0;
}

.nav {
  border-right: 1px solid var(--line);
  padding: 16px 12px;
  background: var(--wash);
  min-width: 0;
}

.nav a, .nav button {
  display: block;
  width: 100%;
  margin: 0 0 4px;
  padding: 8px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-decoration: none;
  text-align: left;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
}

.nav a.active {
  background: var(--accent-soft);
  color: #0b5f54;
  font-weight: 600;
}

.nav a:hover, .nav button:hover {
  background: #e7edf4;
  text-decoration: none;
}

.main {
  padding: 24px 24px 32px;
  min-width: 0;
  max-width: 100%;
  overflow: auto;
}

h1, h2 { margin: 0 0 8px; font-size: 20px; font-weight: 650; letter-spacing: -0.02em; }
p { margin: 0 0 12px; }

.muted { color: var(--mute); }

.banner {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 16px;
  background: var(--accent-soft);
}

.banner.warn {
  background: var(--warn-soft);
  border-color: #f5c2c0;
  color: var(--warn);
}

.counts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0 24px;
}

.count {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--wash);
}

.count b { display: block; font-size: 22px; line-height: 1; margin-bottom: 6px; }
.count span { color: var(--mute); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }

form.stack, .row, .toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: end;
  margin-bottom: 18px;
}

.toolbar > label,
.row > label {
  flex: 1 1 160px;
}

.toolbar > .primary,
.row > .primary {
  flex: 0 0 auto;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--mute);
  min-width: 0;
}

label select, label input {
  width: 100%;
  min-width: 0;
}

input, select, button, textarea {
  font: inherit;
  color: var(--ink);
  background: var(--fill);
  border: 1px solid #c9d2de;
  padding: 8px 10px;
  border-radius: 8px;
}

input:focus, select:focus, button:focus, textarea:focus {
  outline: 2px solid #b7e4dc;
  border-color: var(--accent);
}

button, .btn {
  cursor: pointer;
  background: var(--fill);
  font-size: 13px;
}

button.primary {
  background: var(--header);
  color: var(--fill);
  border-color: var(--header);
  font-weight: 600;
  padding: 9px 16px;
}

button.primary:hover { filter: brightness(1.15); }

button.ghost { background: var(--paper, var(--wash)); }

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--fill);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: auto;
}

th, td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: middle;
}

th {
  background: var(--wash);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--mute);
  font-weight: 650;
  white-space: nowrap;
}

tbody tr:last-child > * { border-bottom: 0; }
tbody tr:hover td { background: #fafbfc; }

th.actions, td.actions {
  width: 9.5rem;
  white-space: nowrap;
  text-align: right;
}

.actions {
  display: inline-flex;
  gap: 6px;
  flex-wrap: nowrap;
  justify-content: flex-end;
  align-items: center;
  vertical-align: middle;
}

.actions form {
  display: inline-flex;
  margin: 0;
}

.actions button {
  padding: 5px 10px;
  font-size: 12px;
  white-space: nowrap;
  line-height: 1.2;
}

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.02em;
}

.pill-active { background: var(--ok-soft); color: var(--ok); }
.pill-revoked { background: var(--warn-soft); color: var(--warn); }
.pill-unused, .pill-enabled { background: var(--accent-soft); color: #0b5f54; }
.pill-expired, .pill-disabled { background: #f1f5f9; color: #475569; }
.pill-bound { background: #eef2ff; color: #3730a3; }

.login-box {
  width: min(400px, calc(100% - 32px));
  margin: 24px auto;
  border: 1px solid var(--line);
  background: var(--fill);
  padding: 0 0 8px;
  overflow: hidden;
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.login-brand {
  background: var(--header);
  padding: 18px 24px 14px;
  overflow: hidden;
}

.login-brand img {
  display: block;
  height: 40px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  object-position: left center;
}

.login-box h1,
.login-box > .muted,
.login-box > form,
.login-box > .banner,
.login-box > .keybox {
  margin-left: 24px;
  margin-right: 24px;
}

.login-box h1 {
  margin-top: 22px;
  font-size: 16px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.legal {
  border-top: 1px solid var(--line);
  padding: 12px 20px;
  font-size: 11px;
  color: var(--mute);
  line-height: 1.4;
}

.legal p { margin: 0; }

.login-box .legal {
  margin-top: 16px;
  padding: 14px 24px;
}

.login-box form.stack {
  flex-direction: column;
  align-items: stretch;
  margin-left: 24px;
  margin-right: 24px;
}

.login-box button.primary {
  width: 100%;
  margin-top: 8px;
}

.hp {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.keybox {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
  padding: 12px;
  border: 1px dashed #b7c2d0;
  border-radius: 8px;
  background: var(--wash);
  margin-bottom: 16px;
  word-break: break-all;
}

@media (max-width: 860px) {
  .frame { width: calc(100% - 16px); margin: 8px auto; }
  .layout { grid-template-columns: 1fr; }
  .nav { border-right: 0; border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 4px; }
  .nav a, .nav button { width: auto; }
  .counts { grid-template-columns: 1fr 1fr; }
  th.actions, td.actions { width: auto; }
  .actions { flex-wrap: wrap; }
}
