/* ── Reset & Variables ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #0d0f14;
  --surface:     #13161e;
  --surface2:    #1a1e28;
  --surface3:    #222736;
  --border:      #2a2f3f;
  --border2:     #353b50;
  --text:        #e2e6f0;
  --text-muted:  #6b7491;
  --text-dim:    #9299b0;
  --accent:      #4f8ef7;
  --accent-glow: rgba(79,142,247,0.15);
  --green:       #2ecc71;
  --green-dim:   rgba(46,204,113,0.12);
  --orange:      #f39c12;
  --orange-dim:  rgba(243,156,18,0.12);
  --red:         #e74c3c;
  --red-dim:     rgba(231,76,60,0.12);
  --purple:      #9b59b6;
  --purple-dim:  rgba(155,89,182,0.15);
  --blue-dim:    rgba(79,142,247,0.12);
  --radius:      8px;
  --radius-lg:   12px;
  --font-mono:   'JetBrains Mono', monospace;
  --font-ui:     'Syne', sans-serif;
  --sidebar-w:   260px;
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--font-ui); font-size: 14px; }

/* ── Shell ─────────────────────────────────────────────────────────────── */
.shell { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ───────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
}
.brand-icon { font-size: 24px; color: var(--accent); line-height: 1; }
.brand-name { font-size: 13px; line-height: 1.4; color: var(--text-muted); }
.brand-name strong { display: block; font-size: 15px; color: var(--text); font-weight: 800; }

.nav { padding: 16px 12px; flex: 1; display: flex; flex-direction: column; gap: 4px; }

.nav-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: none;
  border: none;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
}
.nav-btn:hover { background: var(--surface2); color: var(--text); }
.nav-btn.active { background: var(--accent-glow); color: var(--accent); }
.nav-icon { font-size: 12px; opacity: 0.8; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.token-section label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}
.token-section textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 8px;
  resize: none;
  outline: none;
  transition: border-color 0.15s;
}
.token-section textarea:focus { border-color: var(--accent); }
.token-section textarea::placeholder { color: var(--text-muted); }

.conn-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--border2);
  transition: background 0.3s;
}
.conn-status.connected .status-dot { background: var(--green); box-shadow: 0 0 6px var(--green); }
.conn-status.connected .status-text { color: var(--green); }

/* ── Main ──────────────────────────────────────────────────────────────── */
.main {
  flex: 1;
  overflow-y: auto;
  background: var(--bg);
  padding: 32px;
}

/* ── Tabs ──────────────────────────────────────────────────────────────── */
.tab { display: none; animation: fadeIn 0.2s ease; }
.tab.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.tab-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
}
.tab-header h1 { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.tab-header p { color: var(--text-muted); font-size: 13px; }

/* ── Legend ────────────────────────────────────────────────────────────── */
.legend { display: flex; gap: 16px; margin-bottom: 14px; }
.badge { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 20px; }
.badge-blocked  { background: rgba(231,76,60,0.12);  color: #e74c3c; }
.badge-released { background: rgba(46,204,113,0.12); color: #2ecc71; }
.badge-user     { background: var(--blue-dim);   color: var(--accent); }
.badge-sp       { background: var(--purple-dim); color: var(--purple); }

/* ── Table ─────────────────────────────────────────────────────────────── */
.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 16px;
}

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

thead { background: var(--surface2); }
thead th {
  padding: 11px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
}
.col-check { width: 44px; text-align: center !important; }

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }
tbody tr.row-selected { background: var(--accent-glow); }

tbody td {
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text);
  font-family: var(--font-mono);
}
tbody td:first-child { text-align: center; }

/* Row colors */
tbody tr.row-blocked  { background: rgba(231,76,60,0.06); }
tbody tr.row-released { background: rgba(46,204,113,0.05); }
tbody tr.row-user     { background: var(--blue-dim); }
tbody tr.row-sp       { background: var(--purple-dim); }

.empty-row td { text-align: center; color: var(--text-muted); padding: 32px; font-family: var(--font-ui); }

/* Status badges in table */
.status-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}
.status-blocked  { background: rgba(231,76,60,0.15);  color: #e74c3c; }
.status-released { background: rgba(46,204,113,0.15); color: #2ecc71; }
.type-user { color: var(--accent); }
.type-sp   { color: var(--purple); }

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-connect   { width: 100%; justify-content: center; background: var(--accent); color: #fff; margin-top: 8px; }
.btn-connect:hover   { background: #6b9ff8; }
.btn-secondary { background: var(--surface3); color: var(--text-dim); border: 1px solid var(--border2); }
.btn-secondary:hover { background: var(--surface2); color: var(--text); }
.btn-success   { background: var(--green); color: #fff; }
.btn-success:hover   { background: #27ae60; }
.btn-warning   { background: var(--orange); color: #fff; }
.btn-warning:hover   { background: #d68910; }
.btn-danger    { background: var(--red); color: #fff; }
.btn-danger:hover    { background: #c0392b; }

/* ── Actions bar ───────────────────────────────────────────────────────── */
.actions-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.action-hint { font-size: 12px; color: var(--text-muted); font-family: var(--font-mono); }

/* ── Create User Form ──────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 24px;
  margin-bottom: 24px;
  max-width: 700px;
}
.form-group-full { grid-column: 1 / -1; }

.form-group label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 7px;
}
.req { color: var(--red); }

.form-group input,
.form-group select {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.15s;
}
.form-group input:focus,
.form-group select:focus { border-color: var(--accent); }
.form-group select option { background: var(--surface2); }

.input-eye { position: relative; }
.input-eye input { padding-right: 40px; }
.eye-btn {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; font-size: 14px; opacity: 0.5;
}
.eye-btn:hover { opacity: 1; }

.upn-preview {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent);
  min-height: 37px;
}

.checkboxes { display: flex; flex-direction: column; gap: 10px; }
.chk-label {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; cursor: pointer; color: var(--text-dim);
}
.chk-label input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--accent); }

.result-box {
  margin-top: 20px;
  background: var(--green-dim);
  border: 1px solid rgba(46,204,113,0.3);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--green);
  line-height: 1.8;
}
.result-box.error {
  background: var(--red-dim);
  border-color: rgba(231,76,60,0.3);
  color: var(--red);
}

/* ── Toast ─────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px; right: 24px;
  background: var(--surface3);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  padding: 12px 20px;
  font-size: 13px;
  font-family: var(--font-mono);
  color: var(--text);
  opacity: 0;
  transform: translateY(8px);
  transition: all 0.25s;
  pointer-events: none;
  z-index: 9999;
  max-width: 360px;
}
.toast.show { opacity: 1; transform: none; }
.toast.success { border-color: rgba(46,204,113,0.4); color: var(--green); }
.toast.error   { border-color: rgba(231,76,60,0.4);  color: var(--red); }
.toast.warning { border-color: rgba(243,156,18,0.4); color: var(--orange); }

/* ── Modal ─────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  padding: 28px;
  min-width: 400px;
  max-width: 520px;
}
.modal-title { font-size: 17px; font-weight: 800; margin-bottom: 12px; }
.modal-body  { font-size: 13px; color: var(--text-dim); margin-bottom: 24px; line-height: 1.7; font-family: var(--font-mono); white-space: pre-wrap; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ── Scrollbar ─────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ── Device Code Panel ─────────────────────────────────────────────────── */
.device-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.device-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.device-url {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  word-break: break-all;
}
.device-code {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.2em;
  background: var(--surface3);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 8px 12px;
  text-align: center;
}
.device-msg {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
}
.device-spinner {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-top: 4px;
}
.spinner {
  display: inline-block;
  width: 12px; height: 12px;
  border: 2px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btn-sm { padding: 6px 12px; font-size: 12px; margin-top: 4px; }
