/* ── Variables ────────────────────────────────────── */
:root {
  --bg:           #07090d;
  --surface:      #0d1420;
  --surface2:     #111b2e;
  --border:       #192840;
  --border2:      #243d5a;
  --text:         #b8cfe8;
  --muted:        #3d5a78;
  --accent:       #4fc3f7;
  --accent-dim:   rgba(79,195,247,.1);
  --danger:       #f46464;
  --danger-dim:   rgba(244,100,100,.1);
  --warn:         #e8a030;
  --warn-dim:     rgba(232,160,48,.1);
  --ok:           #48c880;
  --ok-dim:       rgba(72,200,128,.1);
  --radius:       2px;
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 13px;
  line-height: 1.4;
  min-height: 100vh;
}

/* Subtle grid overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(79,195,247,.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(79,195,247,.018) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

.container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 1rem 1.25rem;
  position: relative;
  z-index: 1;
}

/* ── Nav ──────────────────────────────────────────── */
nav {
  background: rgba(7,9,13,.96);
  border-bottom: 1px solid var(--border2);
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 44px;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
  box-shadow: 0 1px 0 rgba(79,195,247,.15);
}

.brand {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--accent);
  white-space: nowrap;
}

.nav-link {
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  padding: 0 .25rem;
  transition: color .15s;
  border-bottom: 1px solid transparent;
  line-height: 44px;
}
.nav-link:hover       { color: var(--text); text-decoration: none; }
.nav-link.active      { color: var(--accent); border-bottom-color: var(--accent); }

.spacer { flex: 1; }

.nav-user {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: 11px;
  color: var(--muted);
}
.nav-user img { width: 22px; height: 22px; border-radius: 50%; opacity: .85; }

/* ── Card ─────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
}
.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 5%, var(--accent) 50%, transparent 95%);
  opacity: .25;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  flex-wrap: wrap;
  padding: .55rem .9rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}

.card-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: .5rem;
}

.card-body { padding: 0; }

/* ── Server grid ──────────────────────────────────── */
.server-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: .6rem;
  margin-bottom: .9rem;
}

.server-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .6rem .85rem;
  position: relative;
  overflow: hidden;
  transition: border-color .15s;
}
.server-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: var(--accent);
  opacity: .2;
}
.server-card:hover { border-color: var(--border2); }

.server-card-name {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: .25rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.server-card-meta { font-size: 10px; color: var(--muted); margin-bottom: .3rem; }
.server-card-count { display: flex; align-items: baseline; gap: .3rem; }
.server-card-count .big { font-size: 1.4rem; font-weight: 700; color: var(--text); line-height: 1; }
.server-card-count .of  { font-size: 10px; color: var(--muted); }

/* ── Table — ultra compact ────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 5px 8px;
  border-bottom: 1px solid var(--border2);
  white-space: nowrap;
  background: var(--surface2);
  text-align: left;
}

tbody td {
  font-size: 11px;
  padding: 3px 8px;
  border-bottom: 1px solid rgba(25,40,64,.6);
  vertical-align: middle;
  line-height: 1.3;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .08s; }
tbody tr:hover td { background: rgba(79,195,247,.03); }

/* ── Status dots ──────────────────────────────────── */
.dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  vertical-align: middle;
}
.dot-ok     { background: var(--ok);     box-shadow: 0 0 5px var(--ok); }
.dot-warn   { background: var(--warn); }
.dot-danger { background: var(--danger); box-shadow: 0 0 5px var(--danger); }
.dot-muted  { background: var(--muted); }

/* ── Inline badges ────────────────────────────────── */
.badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .06em;
  padding: 1px 5px;
  border-radius: var(--radius);
  white-space: nowrap;
  vertical-align: middle;
  text-transform: uppercase;
}
.badge-ok     { background: var(--ok-dim);     color: var(--ok);     border: 1px solid rgba(72,200,128,.25); }
.badge-warn   { background: var(--warn-dim);   color: var(--warn);   border: 1px solid rgba(232,160,48,.25); }
.badge-danger { background: var(--danger-dim); color: var(--danger); border: 1px solid rgba(244,100,100,.25); }
.badge-muted  { background: transparent;       color: var(--muted);  border: 1px solid var(--border2); }

/* ── Buttons ──────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .2rem;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .04em;
  border-radius: var(--radius);
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: all .12s;
}
.btn:hover { background: var(--accent-dim); color: var(--text); border-color: var(--accent); text-decoration: none; }

.btn-warn   { border-color: rgba(232,160,48,.4); color: var(--warn); }
.btn-warn:hover   { background: var(--warn-dim); border-color: var(--warn); color: var(--warn); }

.btn-danger { border-color: rgba(244,100,100,.4); color: var(--danger); }
.btn-danger:hover { background: var(--danger-dim); border-color: var(--danger); color: var(--danger); }

.btn-primary { border-color: rgba(79,195,247,.4); color: var(--accent); }
.btn-primary:hover { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }

.btn-discord {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1.25rem;
  background: #5865f2;
  border: 1px solid #4752c4;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius);
  text-decoration: none;
  transition: background .15s;
}
.btn-discord:hover { background: #4752c4; color: #fff; text-decoration: none; }

/* ── Action cell ──────────────────────────────────── */
.action-cell { display: flex; gap: .3rem; align-items: center; flex-wrap: nowrap; }

/* ── Links ────────────────────────────────────────── */
a { color: var(--accent); text-decoration: none; transition: color .12s; }
a:hover { color: var(--text); text-decoration: none; }
.link-muted { color: var(--muted); font-size: 10px; }
.link-muted:hover { color: var(--accent); }

/* ── Mono ─────────────────────────────────────────── */
.mono {
  font-family: 'SFMono-Regular', 'Consolas', monospace;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: .02em;
}

/* ── Inputs ───────────────────────────────────────── */
input[type="text"], input[type="number"] {
  background: var(--surface2);
  border: 1px solid var(--border2);
  color: var(--text);
  padding: 4px 10px;
  border-radius: var(--radius);
  font-size: 12px;
  font-family: inherit;
  outline: none;
  transition: border-color .12s;
}
input[type="text"]:focus, input[type="number"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(79,195,247,.12);
}

select {
  background: var(--surface2);
  border: 1px solid var(--border2);
  color: var(--text);
  padding: 4px 8px;
  border-radius: var(--radius);
  font-size: 11px;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  transition: border-color .12s;
}
select:focus { border-color: var(--accent); }
select:hover { border-color: var(--border); }

textarea {
  background: var(--surface2);
  border: 1px solid var(--border2);
  color: var(--text);
  padding: 4px 8px;
  border-radius: var(--radius);
  font-size: 11px;
  font-family: inherit;
  outline: none;
  resize: vertical;
  transition: border-color .12s;
}
textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(79,195,247,.12); }

/* ── Note cell ────────────────────────────────────── */
.note-form-inline { display: flex; flex-direction: column; gap: .25rem; width: 100%; max-width: 180px; }
.note-form-inline textarea { width: 100%; min-width: 0; rows: 2; }
.note-form-actions { display: flex; gap: .25rem; }
.note-btn { font-size: 9px; padding: 1px 6px; }
.note-preview { font-size: 10px; color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px; }

/* ── Alert ────────────────────────────────────────── */
.alert {
  padding: .45rem .75rem;
  font-size: 11px;
  border: 1px solid;
  border-radius: var(--radius);
  margin-bottom: .75rem;
}
.alert-warn  { border-color: rgba(232,160,48,.3); color: var(--warn);   background: var(--warn-dim); }
.alert-error { border-color: rgba(244,100,100,.3); color: var(--danger); background: var(--danger-dim); }
.alert-ok    { border-color: rgba(72,200,128,.3); color: var(--ok);     background: var(--ok-dim); }

/* ── Server tabs ──────────────────────────────────── */
.server-tabs { display: flex; gap: .25rem; flex-wrap: wrap; }

.tab-btn {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
  border-radius: var(--radius);
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all .12s;
}
.tab-btn:hover { background: var(--accent-dim); color: var(--text); border-color: var(--accent); }
.tab-btn.active { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }

/* ── Live indicator ───────────────────────────────── */
.live-indicator {
  display: flex;
  align-items: center;
  gap: .35rem;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ok);
  white-space: nowrap;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 4px var(--ok); opacity: 1; }
  50%       { box-shadow: 0 0 8px var(--ok); opacity: .6; }
}
.dot-pulse { animation: pulse 2s ease-in-out infinite; }

/* ── Login ────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  text-align: center;
  width: 100%;
  max-width: 360px;
  position: relative;
  overflow: hidden;
}
.login-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: .4;
}
.login-card h1 { font-size: 14px; font-weight: 700; letter-spacing: .2em; text-transform: uppercase; color: var(--accent); margin-bottom: .4rem; }
.login-card p  { font-size: 11px; color: var(--muted); margin-bottom: 1.75rem; letter-spacing: .06em; }

/* ── HTMX animations ──────────────────────────────── */
@keyframes fadein {
  from { opacity: 0; transform: translateY(-2px); }
  to   { opacity: 1; transform: translateY(0); }
}
#player-table-wrap { transition: opacity .2s; }
#player-table-wrap.htmx-request { opacity: .35; }
#player-table-wrap tbody tr { animation: fadein .12s ease both; }
#player-table-wrap tbody tr:nth-child(1)  { animation-delay: .00s }
#player-table-wrap tbody tr:nth-child(2)  { animation-delay: .02s }
#player-table-wrap tbody tr:nth-child(3)  { animation-delay: .04s }
#player-table-wrap tbody tr:nth-child(4)  { animation-delay: .06s }
#player-table-wrap tbody tr:nth-child(5)  { animation-delay: .08s }
#player-table-wrap tbody tr:nth-child(n+6) { animation-delay: .10s }

/* ── Player link ──────────────────────────────────── */
.player-link {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  transition: color .12s;
}
.player-link:hover { color: var(--accent); }

/* ── Detail page ──────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0;
  border-top: 1px solid var(--border);
}
.detail-item {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  padding: .55rem .9rem;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.detail-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}
.detail-value {
  font-size: 12px;
  color: var(--text);
  word-break: break-all;
}
.link-accent { color: var(--accent); font-size: 12px; }
.link-accent:hover { color: var(--text); }

/* ── Responsive ───────────────────────────────────── */
@media (max-width: 768px) {
  .container { padding: .75rem; }
  nav { padding: 0 .75rem; gap: .75rem; }
  .server-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) { .server-grid { grid-template-columns: 1fr; } }
