:root {
  --bg: #0f1419;
  --bg-card: #1a2332;
  --bg-elevated: #243044;
  --border: #2d3a4f;
  --text: #e8edf4;
  --muted: #8b9cb3;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 10px;
  --font-mono: "JetBrains Mono", "Fira Code", "Consolas", monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.muted { color: var(--muted); font-size: 0.875rem; }
.hidden { display: none !important; }

/* Login */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(ellipse at top, #1e293b 0%, var(--bg) 60%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 2.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.login-brand { text-align: center; margin-bottom: 2rem; }
.login-brand h1 { font-size: 1.5rem; margin: 0.75rem 0 0.25rem; }
.login-form label { display: block; font-size: 0.875rem; color: var(--muted); margin-bottom: 0.5rem; }
.login-form input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 1.25rem;
}
.login-form input:focus { outline: none; border-color: var(--accent); }

.logo-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.1rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-elevated); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--muted); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-block { width: 100%; }

.alert { padding: 0.75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: 0.875rem; }
.alert-error { background: rgba(239,68,68,0.15); border: 1px solid rgba(239,68,68,0.4); color: #fca5a5; }

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15,20,25,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand { display: flex; align-items: center; gap: 0.75rem; }
.brand h1 { font-size: 1.125rem; font-weight: 600; }

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.search-input {
  min-width: 220px;
  padding: 0.55rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.875rem;
}
.search-input:focus { outline: none; border-color: var(--accent); }

.sync-banner {
  padding: 0.6rem 1.5rem;
  font-size: 0.875rem;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--muted);
}
.sync-banner.error { color: #fca5a5; background: rgba(239,68,68,0.1); }
.sync-banner.success { color: #86efac; }

.nav-tabs {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem 0.75rem;
  display: flex;
  gap: 0.5rem;
}

.nav-tab {
  padding: 0.45rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid transparent;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.nav-tab:hover {
  color: var(--text);
  background: var(--bg-card);
}

.nav-tab.active {
  color: var(--text);
  background: var(--bg-elevated);
  border-color: var(--border);
}

.table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}

.cred-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.cred-table thead {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

.cred-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-weight: 600;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.cred-table td {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.cred-table tbody tr:last-child td {
  border-bottom: none;
}

.cred-table tbody tr:hover {
  background: rgba(59, 130, 246, 0.06);
}

.cred-table tbody tr.filtered-out {
  display: none;
}

.col-date {
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.8125rem;
  min-width: 100px;
}

.col-email code,
.col-password code {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  word-break: break-all;
}

.col-password code {
  color: #93c5fd;
}

.col-action {
  width: 80px;
  text-align: right;
  white-space: nowrap;
}

.col-status {
  min-width: 120px;
}

.status-cell {
  display: flex;
  align-items: center;
}

.status-options,
.status-selected {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.status-selected-icon {
  font-size: 1rem;
  line-height: 1;
  min-width: 1.75rem;
}

.status-btn {
  padding: 0.25rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  background: var(--bg);
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
}

.status-btn:hover {
  border-color: var(--muted);
  color: var(--text);
}

.status-btn.active {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.15);
  color: var(--text);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.25);
}

.status-reset-btn {
  padding: 0.25rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.status-reset-btn:hover {
  border-color: var(--danger);
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.08);
}

.cred-row.status-sold {
  background: rgba(34, 197, 94, 0.06);
}

.cred-row.status-sold-duel {
  background: rgba(34, 197, 94, 0.12);
}

.cred-row.status-expired {
  background: rgba(239, 68, 68, 0.08);
  opacity: 0.82;
}

.cred-row.status-expired .col-password code {
  color: #fca5a5;
}

.empty-cell {
  text-align: center;
  color: var(--muted);
  padding: 2rem 1rem !important;
}

/* Orders */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}

.orders-list { display: flex; flex-direction: column; gap: 1rem; }

.order-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: border-color 0.15s;
}
.order-card:hover { border-color: #3d4f6a; }
.order-card.filtered-out { display: none; }

.order-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.order-date { font-size: 0.875rem; color: var(--muted); margin-right: 0.75rem; }
.order-id { font-weight: 600; font-family: var(--font-mono); font-size: 0.9rem; }

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  margin-left: 0.5rem;
}
.badge-paid { background: rgba(34,197,94,0.15); color: #86efac; }
.badge-other { background: rgba(245,158,11,0.15); color: #fcd34d; }

.order-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.35rem 1.5rem;
  font-size: 0.875rem;
  margin-bottom: 0.75rem;
}
.order-meta .label { color: var(--muted); margin-right: 0.35rem; }

.credentials {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.6;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  padding: 0.875rem 1rem;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 200px;
  overflow-y: auto;
}

.range-note {
  margin-bottom: 1rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.empty-state, .no-results {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}

@media (max-width: 640px) {
  .topbar-inner { flex-direction: column; align-items: stretch; }
  .topbar-actions { flex-direction: column; }
  .search-input { width: 100%; min-width: unset; }
}
