:root {
  color-scheme: light dark;
  --bg: #0b0d12;
  --bg-gradient: radial-gradient(circle at 20% -10%, #1a2036 0%, #0b0d12 45%);
  --card: #161a22;
  --card-border: #262c38;
  --border: #2a2f3a;
  --text: #e8eaed;
  --muted: #93a1b3;
  --accent: #6c8dfa;
  --accent-2: #8b6cfa;
  --accent-soft: rgba(108, 141, 250, 0.12);
  --danger: #ef5a6f;
  --success: #4ade80;
  --warning: #f5b942;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg-gradient), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  padding: 2rem;
  min-height: 100vh;
}

.view[hidden] { display: none; }

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.4rem;
}

.brand-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: cover;
}

.login-card .brand-logo { width: 56px; height: 56px; border-radius: 12px; }

.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent), var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 1.4rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.login-card {
  max-width: 340px;
  margin: 5rem auto;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.login-card .brand { justify-content: center; margin-bottom: 0.5rem; }

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  max-width: 1100px;
  margin-left: auto;
  margin-right: auto;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

#app-view { max-width: 1100px; margin: 0 auto; }

h1 { font-size: 1.3rem; margin: 0; font-weight: 600; }
h2 { font-size: 1rem; margin: 0 0 0.85rem; color: var(--muted); font-weight: 600; letter-spacing: 0.01em; }

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
}
.section-heading h2 { margin: 0; }

label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.85rem;
}

input, select {
  background: #0c0e14;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  font-size: 0.9rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

code {
  font-family: ui-monospace, Consolas, monospace;
  background: rgba(255, 255, 255, 0.05);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.82rem;
}

button {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  border: none;
  padding: 0.55rem 1.1rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: transform 0.1s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

button:hover { box-shadow: 0 4px 14px rgba(108, 141, 250, 0.35); transform: translateY(-1px); }
button:active { transform: translateY(0); }

button.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: none;
}
button.secondary:hover { box-shadow: none; background: rgba(255, 255, 255, 0.04); }

a.secondary {
  display: inline-block;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.55rem 1.1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s ease;
}
a.secondary:hover { background: rgba(255, 255, 255, 0.04); }

button.danger { background: linear-gradient(135deg, var(--danger), #c23a4d); }

button.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.3rem 0.6rem;
  font-size: 1rem;
  line-height: 1;
  box-shadow: none;
}
button.icon-btn:hover {
  color: var(--text);
  border-color: var(--accent);
  box-shadow: none;
  transform: rotate(90deg);
}

.error { color: var(--danger); min-height: 1.2em; font-size: 0.85rem; }

.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.tab-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  color: var(--muted);
  box-shadow: none;
}
.tab-btn:hover { color: var(--text); box-shadow: none; transform: none; }

.tab-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  border-color: transparent;
}

.tab-panel[hidden] { display: none; }

.key-output {
  background: #0c0e14;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem;
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 0.85rem;
  font-family: ui-monospace, Consolas, monospace;
}

.filters {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.filters button { height: 2.4rem; }

.table-wrap {
  border: 1px solid var(--card-border);
  border-radius: 10px;
}

table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 0.85rem;
}

th, td {
  text-align: left;
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.key-cell {
  cursor: pointer;
  display: inline-block;
  max-width: 100%;
  vertical-align: bottom;
  font-size: 0.68rem;
  white-space: nowrap;
}

#stock-table { table-layout: auto; }
#stock-table th:nth-child(1), #stock-table td:nth-child(1) { width: 1%; white-space: nowrap; }
#stock-table th:nth-child(3), #stock-table td:nth-child(3) { width: 6.5rem; }

#stock-table th:last-child,
#stock-table td:last-child {
  width: 2.75rem;
  text-align: center;
  overflow: visible;
}

.icon-btn-sm {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--danger);
  padding: 0.25rem 0.45rem;
  font-size: 0.85rem;
  line-height: 1;
  box-shadow: none;
}
.icon-btn-sm:hover {
  background: rgba(239, 90, 111, 0.12);
  border-color: var(--danger);
  box-shadow: none;
  transform: none;
}

th {
  color: var(--muted);
  font-weight: 600;
  background: rgba(255, 255, 255, 0.03);
  position: sticky;
  top: 0;
}

tbody tr { transition: background 0.1s ease; }
tbody tr:hover { background: rgba(108, 141, 250, 0.06); }
tbody tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}
.badge-unclaimed { background: rgba(108, 141, 250, 0.15); color: #8fa8ff; }
.badge-claiming { background: rgba(245, 185, 66, 0.15); color: var(--warning); }
.badge-claimed { background: rgba(74, 222, 128, 0.15); color: var(--success); }
.badge-failed { background: rgba(239, 90, 111, 0.15); color: var(--danger); }

.download-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
.download-link:hover { text-decoration: underline; }

.pagination {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.85rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.hint { color: var(--muted); font-size: 0.85rem; }

#status-content {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
  font-size: 0.95rem;
}

#status-content .stat { display: flex; flex-direction: column; gap: 0.15rem; }
#status-content .stat span:first-child { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; }
#status-content .stat span:last-child { font-size: 1.1rem; font-weight: 600; }
