:root {
  --bg: #0d1015;
  --panel: #151921;
  --panel-2: #1a1f28;
  --border: #242c38;
  --border-soft: #1c232d;
  --text: #e6e9ef;
  --muted: #8a93a3;
  --muted-2: #5c6573;
  --accent: #5b8def;
  --accent-soft: rgba(91, 141, 239, 0.14);
  --green: #3ecf8e;
  --red: #ef5a5a;
  --orange: #e8a23b;
  --radius: 10px;
  --radius-sm: 7px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 14px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

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

/* --- Topbar --- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 22px;
  background: rgba(13, 16, 21, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-soft);
}
.topbar nav { display: flex; gap: 4px; align-items: center; height: 54px; }
.topbar nav a {
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 7px;
  font-size: 14px;
}
.topbar nav a:hover { color: var(--text); text-decoration: none; background: var(--panel); }
.topbar nav a.active { color: var(--text); background: var(--panel); }
.topbar .brand { font-weight: 600; color: var(--text); margin-right: 8px; }
.topbar .brand:hover { text-decoration: none; }
.logout button {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 7px 14px;
}
.logout button:hover { color: var(--text); }

/* --- Layout --- */
main { padding: 36px clamp(16px, 4vw, 48px) 80px; }

h1 { font-size: 20px; font-weight: 600; margin: 4px 0 24px; }
h2 { font-size: 13px; font-weight: 600; color: var(--muted); margin: 32px 0 14px; letter-spacing: 0.03em; }

.muted { color: var(--muted); }
.error { color: var(--red); }

/* --- Cards --- */
.cards { display: flex; gap: 14px; margin-bottom: 28px; }
.card {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 18px 22px;
}
.card .num { display: block; font-size: 26px; font-weight: 600; letter-spacing: -0.01em; }

/* --- Tables --- */
table { width: 100%; border-collapse: collapse; margin-top: 14px; }
th, td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}
th { color: var(--muted); font-weight: 500; font-size: 12px; letter-spacing: 0.02em; }
tbody tr:hover { background: rgba(255, 255, 255, 0.018); }

code.key {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  background: #11151c;
  padding: 3px 7px;
  border-radius: 5px;
  color: #aeb8cc;
}
.key-cell { white-space: nowrap; }
.key-cell .key {
  display: inline-block;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}
button.copy {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 4px 8px;
  margin-left: 6px;
  font-size: 13px;
  line-height: 1;
  border-radius: 6px;
}
button.copy:hover { color: var(--text); background: var(--panel); }

/* --- Badges --- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}
.badge-active { background: rgba(62, 207, 142, 0.14); color: var(--green); }
.badge-expired { background: rgba(239, 90, 90, 0.14); color: var(--red); }
.badge-revoked { background: rgba(232, 162, 59, 0.14); color: var(--orange); }
.badge-not_found { background: rgba(138, 147, 163, 0.14); color: var(--muted); }

/* --- Row form --- */
.row-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 16px;
}
.row-form .inline { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; }

/* --- Inputs --- */
input, select {
  background: #11151c;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder { color: var(--muted-2); }

/* --- Buttons --- */
button {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: filter 0.15s, background 0.15s;
}
button:hover { filter: brightness(1.08); }
button:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
button.danger {
  background: transparent;
  color: var(--red);
  border: 1px solid rgba(239, 90, 90, 0.3);
}
button.danger:hover { background: rgba(239, 90, 90, 0.1); filter: none; }
button.warn {
  background: transparent;
  color: var(--orange);
  border: 1px solid rgba(232, 162, 59, 0.3);
}
button.warn:hover { background: rgba(232, 162, 59, 0.1); filter: none; }

td.actions { white-space: nowrap; }
td.actions form { display: inline-block; vertical-align: middle; }
td.actions form + form { margin-left: 6px; }
table input[type="date"] { padding: 6px 8px; font-size: 13px; width: 140px; }
table input[type="text"] { padding: 6px 8px; font-size: 13px; width: 170px; }
.hint { font-size: 12px; color: var(--muted); margin: 8px 2px 0; }

/* --- Login --- */
.login-box {
  max-width: 320px;
  margin: 16vh auto 0;
  padding: 30px;
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
}
.login-box h1 { text-align: center; font-size: 18px; }
.login-box label { display: block; margin-bottom: 18px; color: var(--muted); font-size: 13px; }
.login-box input { width: 100%; margin-top: 8px; }
.login-box button { width: 100%; }

/* --- Notice --- */
.notice {
  background: var(--accent-soft);
  border: 1px solid rgba(91, 141, 239, 0.3);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 20px;
}
.notice p { margin: 0 0 4px; }
.notice-error {
  background: rgba(239, 90, 90, 0.12);
  border-color: rgba(239, 90, 90, 0.35);
}
.key-row { display: flex; gap: 10px; align-items: center; margin-top: 10px; }
.key-row code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
  background: #11151c;
  padding: 7px 11px;
  border-radius: 7px;
}

/* --- Responsive --- */
@media (max-width: 640px) {
  .topbar { padding: 0 14px; }
  .topbar nav { gap: 2px; height: 50px; }
  .topbar nav a { padding: 8px 9px; font-size: 13px; }
  main { padding: 24px 14px 60px; }
  .cards { flex-direction: column; }
  table { font-size: 13px; }
  th, td { padding: 10px 8px; }
}
