:root {
  --bg: #eef2f6;
  --bg-accent: #e4ebf3;
  --surface: #ffffff;
  --ink: #1a2332;
  --muted: #5c6b7a;
  --line: #d5dee8;
  --accent: #1f5f8b;
  --accent-hover: #174a6c;
  --danger: #a33b3b;
  --ok: #1f6b4a;
  --shadow: 0 10px 30px rgba(26, 35, 50, 0.08);
  --radius: 10px;
  --font: "Trebuchet MS", "Lucida Sans Unicode", "Lucida Grande", sans-serif;
  --mono: "Consolas", "Courier New", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, #d7e6f2 0%, transparent 55%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-accent) 100%);
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 20px 48px;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand-name {
  font-weight: 700;
  font-size: 1.15rem;
  line-height: 1.2;
}

.brand-sub,
.muted,
.lede {
  color: var(--muted);
}

.lede {
  margin: 0 0 18px;
  line-height: 1.45;
}

.session-bar {
  display: flex;
  align-items: center;
  gap: 12px;
}

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

.auth-panel {
  max-width: 420px;
  margin: 40px auto 0;
}

h1,
h2 {
  margin: 0 0 8px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

h1 {
  font-size: 1.6rem;
}

h2 {
  font-size: 1.25rem;
}

form label {
  display: block;
  margin-bottom: 14px;
  font-size: 0.92rem;
  color: var(--muted);
}

input,
select,
button {
  font: inherit;
}

input,
select {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  color: var(--ink);
}

input:focus,
select:focus {
  outline: 2px solid rgba(31, 95, 139, 0.25);
  border-color: var(--accent);
}

.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: #e8f1f7;
  color: var(--accent);
  border-color: #c5d8e6;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--ink);
  border-color: #b8c5d3;
}

.btn-danger {
  background: #f7ecec;
  color: var(--danger);
  border-color: #e5c7c7;
}

.error {
  color: var(--danger);
  margin: 0 0 12px;
}

.hidden {
  display: none !important;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.tab {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 14px;
  color: var(--muted);
  cursor: pointer;
}

.tab.active {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0 8px;
  align-items: end;
}

.filters > label {
  margin-bottom: 0;
}

.filters-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

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

th {
  background: #f5f8fb;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

tr:last-child td {
  border-bottom: none;
}

td.message {
  max-width: 360px;
  white-space: pre-wrap;
  word-break: break-word;
}

.empty {
  text-align: center;
  color: var(--muted);
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

.key-form {
  display: grid;
  grid-template-columns: 1.4fr 1fr auto;
  gap: 12px;
  align-items: end;
  margin: 16px 0 18px;
}

.new-key {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
  padding: 14px;
  border-radius: 8px;
  border: 1px solid #c9e0d4;
  background: #eef8f2;
  color: var(--ok);
}

.new-key code {
  font-family: var(--mono);
  font-size: 0.92rem;
  word-break: break-all;
  color: var(--ink);
  background: #fff;
  border: 1px solid #d5e8dc;
  border-radius: 6px;
  padding: 10px;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
}

.badge-ok {
  background: #e8f6ee;
  color: var(--ok);
}

.badge-off {
  background: #f3f3f3;
  color: var(--muted);
}

code.prefix {
  font-family: var(--mono);
  font-size: 0.85rem;
}

@media (max-width: 860px) {
  .filters,
  .key-form {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }
}
