/* ═══════════════════════════════════════════════════════════════
   ETunnel Admin Panel — Light Professional Theme
   Clean white surfaces, slate text, indigo accent.
   ═══════════════════════════════════════════════════════════════ */

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

:root {
  --bg:          #f4f6fa;
  --bg-card:     #ffffff;
  --bg-card2:    #f1f3f8;
  --bg-input:    #ffffff;
  --border:      #e4e8ef;
  --border-focus:#4f46e5;
  --primary:     #4f46e5;
  --primary-hover:#6366f1;
  --danger:      #dc2626;
  --danger-hover:#b91c1c;
  --success:     #059669;
  --warning:     #d97706;
  --text:        #111827;
  --text-muted:  #64748b;
  --text-dim:    #94a3b8;
  --sidebar-w:   248px;
  --radius:      10px;
  --radius-sm:   7px;
  --shadow:      0 8px 24px rgba(15, 23, 42, 0.08);
  --transition:  0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

html { font-size: 15px; }
body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ─── Screens ─────────────────────────────────────────────────── */
.screen { display: none; }
.screen.active { display: flex; }

/* ─── Login ───────────────────────────────────────────────────── */
#login-screen {
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 60% 45% at 50% -10%, rgba(79, 70, 229, 0.08) 0%, transparent 70%),
    var(--bg);
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
}

.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}
.logo-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 0.85rem;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
  box-shadow: 0 4px 16px rgba(79, 70, 229, 0.25);
}
.login-logo h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}
.login-logo p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 0.3rem;
  font-weight: 400;
}

/* ─── Dashboard Layout ────────────────────────────────────────── */
#dashboard-screen {
  min-height: 100vh;
  flex-direction: row;
}

/* ─── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  flex-shrink: 0;
  transition: transform var(--transition);
  z-index: 100;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 1.4rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
  flex-shrink: 0;
}
.sidebar-title {
  font-weight: 700;
  font-size: 1.02rem;
  color: var(--text);
  letter-spacing: -0.01em;
}
.sidebar-subtitle {
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 500;
}

.sidebar-nav {
  flex: 1;
  padding: 0.85rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.62rem 0.85rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
  position: relative;
}
.nav-item:hover { background: var(--bg-card2); color: var(--text); }
.nav-item.active {
  background: rgba(79, 70, 229, 0.08);
  color: var(--primary);
}
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -0.65rem;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 1.3rem;
  border-radius: 0 3px 3px 0;
  background: var(--primary);
}
.nav-icon {
  width: 1.15rem;
  height: 1.15rem;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  opacity: 0.95;
}
.nav-icon svg { display: block; }

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

.feed-url-box {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.9rem;
}
.feed-label {
  font-size: 0.68rem;
  color: var(--text-dim);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.feed-url {
  font-size: 0.72rem;
  color: var(--primary);
  word-break: break-all;
  margin-bottom: 0.5rem;
  font-family: 'Consolas', 'Monaco', monospace;
  line-height: 1.5;
}

/* ─── Main Content ────────────────────────────────────────────── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ─── Topbar ──────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.8rem 1.5rem;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: none;
  padding: 0.25rem;
  line-height: 1;
}
.topbar-title {
  font-weight: 600;
  font-size: 1rem;
  flex: 1;
  color: var(--text);
  /* Shrink + ellipsis instead of pushing the "Add Server" button off-screen */
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.badge {
  font-size: 0.75rem;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 0.2rem 0.75rem;
  color: var(--text-muted);
}

/* ─── Views ───────────────────────────────────────────────────── */
.view { display: none; padding: 1.5rem; flex-direction: column; gap: 1rem; }
.view.active { display: flex; }

/* ─── Toolbar ─────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}
.search-input {
  flex: 1;
  min-width: 200px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0.55rem 0.9rem;
  font-size: 0.875rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.search-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}
.toolbar-right { display: flex; gap: 0.5rem; }
.select-sm {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.7rem;
  font-size: 0.8rem;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.select-sm:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

/* ─── Servers Grid ────────────────────────────────────────────── */
.servers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 0.75rem;
}

.server-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  position: relative;
  /* Allow the card to shrink below its content's intrinsic width on phones —
     without this, long monospace hosts (e.g. maxcdn.bootstrapcdn.com) blow the
     grid track wider than the viewport and the right edge gets clipped. */
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}
.server-card:hover {
  border-color: #c7cdd9;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
}
.server-card.offline { opacity: 0.6; }

.server-card-header {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
}
.server-flag {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  line-height: 1;
  flex-shrink: 0;
}
.server-flag svg { display: block; width: 12px; height: 12px; color: var(--text-dim); }
.server-meta { flex: 1; min-width: 0; }
.server-name {
  font-weight: 600;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.server-location { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.05rem; }

.server-status {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.62rem;
  font-weight: 600;
  padding: 0.18rem 0.55rem;
  border-radius: 99px;
  flex-shrink: 0;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.server-status.online {
  color: var(--success);
  background: rgba(5, 150, 105, 0.08);
  border: 1px solid rgba(5, 150, 105, 0.22);
}
.server-status.offline {
  color: var(--danger);
  background: rgba(220, 38, 38, 0.07);
  border: 1px solid rgba(220, 38, 38, 0.22);
}
.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.server-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.3rem 0.45rem;
  font-size: 0.73rem;
  padding: 0.55rem 0.7rem;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.detail-row {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  /* Grid items default to min-width:auto, which blocks the ellipsis in
     .detail-value from kicking in on narrow screens. */
  min-width: 0;
}
.detail-label { color: var(--text-dim); font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.06em; }
.detail-value {
  color: var(--text);
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.73rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.server-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.tag {
  font-size: 0.62rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  background: rgba(79, 70, 229, 0.07);
  color: var(--primary);
  border: 1px solid rgba(79, 70, 229, 0.2);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.server-actions {
  display: flex;
  gap: 0.4rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* ─── Empty State ─────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}
.empty-icon {
  color: var(--text-dim);
  margin-bottom: 1rem;
}
.empty-icon svg { display: inline-block; }
.empty-state h3 {
  font-size: 1.15rem;
  color: var(--text);
  margin-bottom: 0.5rem;
  font-weight: 600;
}
.empty-state p {
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
  line-height: 1.7;
  color: var(--text-muted);
}

/* ─── Stats ───────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
}
.stat-card.online { border-color: rgba(5,150,105,0.3); }
.stat-card.offline { border-color: rgba(220,38,38,0.3); }
.stat-icon {
  color: var(--text-dim);
  margin-bottom: 0.6rem;
}
.stat-card.online .stat-icon { color: var(--success); }
.stat-card.offline .stat-icon { color: var(--danger); }
.stat-icon svg { display: block; margin: 0 auto; }
.stat-value { font-size: 1.9rem; font-weight: 700; color: var(--text); margin-bottom: 0.25rem; letter-spacing: -0.02em; }
.stat-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }

.rev-period-select { min-width: 140px; width: auto; padding: 0.35rem 0.6rem; font-size: 0.8rem; }
.rev-single {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  max-width: 340px;
  margin: 0 auto;
}
.rev-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.4rem; }
.rev-value { font-size: 2rem; font-weight: 700; color: var(--text); letter-spacing: -0.02em; }
.rev-count { font-size: 0.75rem; color: var(--text-dim); margin-top: 0.4rem; }

.protocol-breakdown {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.5rem 0;
}
.proto-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.proto-name { width: 120px; font-size: 0.85rem; color: var(--text-muted); }
.proto-bar-wrap { flex: 1; background: var(--bg-card2); border-radius: 99px; height: 8px; overflow: hidden; }
.proto-bar { height: 100%; background: var(--primary); border-radius: 99px; transition: width 0.4s ease; }
.proto-count { width: 2rem; text-align: right; font-size: 0.85rem; font-weight: 600; color: var(--text); }

/* ─── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-header {
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
}
.card-body { padding: 1.25rem; }
.card-body p { font-size: 0.875rem; color: var(--text-muted); margin-bottom: 0.75rem; }

/* ─── Import / Export ─────────────────────────────────────────── */
.ie-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.ie-grid .full-width { grid-column: 1 / -1; }

.drop-zone {
  border: 1.5px dashed #cbd5e1;
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  margin: 0.75rem 0;
}
.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--primary);
  background: rgba(79, 70, 229, 0.04);
}
.drop-icon {
  color: var(--text-dim);
  margin-bottom: 0.5rem;
}
.drop-icon svg { display: inline-block; }
.drop-zone p { font-size: 0.83rem; color: var(--text-muted); line-height: 1.6; }
.drop-zone code { color: var(--primary); font-size: 0.85rem; }

.divider { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }
.feed-info { padding: 0; }
.feed-info p { font-size: 0.875rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.code-block {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.85rem;
  color: var(--primary);
  word-break: break-all;
}
.form-row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}
.input-full {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.9rem;
  font-size: 0.875rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.input-full:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

/* ─── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--transition), border-color var(--transition), color var(--transition), opacity var(--transition);
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn svg { display: block; }
.btn-primary   { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger    { background: transparent; color: var(--danger); border-color: rgba(220,38,38,0.35); }
.btn-danger:hover:not(:disabled) { background: rgba(220,38,38,0.06); border-color: var(--danger); }
.btn-secondary { background: rgba(79,70,229,0.08); color: var(--primary); border-color: rgba(79,70,229,0.25); }
.btn-secondary:hover:not(:disabled) { background: rgba(79,70,229,0.14); }
.btn-ghost     { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-card2); color: var(--text); }
.btn-warning   { background: rgba(217,119,6,0.08); color: var(--warning); border-color: rgba(217,119,6,0.25); }
.btn-warning:hover:not(:disabled) { background: rgba(217,119,6,0.14); }
.btn-sm  { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-full { width: 100%; }
.btn-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Forms ───────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.form-group label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.form-group input,
.form-group select,
.form-group textarea {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0.55rem 0.9rem;
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}
.form-group select { cursor: pointer; }
.textarea-mono { font-family: 'Consolas', 'Monaco', monospace; resize: vertical; }
.font-mono { font-family: 'Consolas', 'Monaco', monospace; }
.required { color: var(--danger); }

/* Divider between the username/password block and the legacy PIN fallback */
.form-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.9rem 0;
  color: var(--text-dim);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.form-divider::before,
.form-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}
#login-form .form-group { margin-bottom: 0.85rem; }
#login-form .form-divider { margin: 0 0 0.85rem; }

.form-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  cursor: pointer;
}
.form-check input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--primary);
  cursor: pointer;
}

.input-with-btn {
  display: flex;
  gap: 0.5rem;
}
.input-with-btn input { flex: 1; }

/* flex helpers */
.flex-1 { flex: 1; }
.flex-2 { flex: 2; }
.w-24 { width: 90px; flex-shrink: 0; }
.w-28 { width: 110px; flex-shrink: 0; }

/* ─── Alerts ──────────────────────────────────────────────────── */
.alert {
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.83rem;
  border: 1px solid transparent;
}
.alert-success { background: rgba(5,150,105,0.07); border-color: rgba(5,150,105,0.25); color: var(--success); }
.alert-error   { background: rgba(220,38,38,0.06); border-color: rgba(220,38,38,0.25); color: var(--danger); }
.alert-info    { background: rgba(79,70,229,0.06); border-color: rgba(79,70,229,0.25); color: var(--primary); }
.error-msg { font-size: 0.83rem; color: var(--danger); text-align: center; margin-top: 0.5rem; }

/* ─── Modal ───────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.2);
  display: flex;
  flex-direction: column;
}
.modal-sm { max-width: 400px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-header h2 { font-size: 1rem; font-weight: 600; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.3rem 0.45rem;
  border-radius: 5px;
  transition: color var(--transition), background var(--transition);
}
.modal-close:hover { color: var(--text); background: var(--bg-card2); }
.modal-body { padding: 1.25rem 1.5rem; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* ─── Tabs ────────────────────────────────────────────────────── */
.modal-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.tab-btn {
  flex: 1;
  padding: 0.75rem 1rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-btn:hover:not(.active) { color: var(--text); }

.tab-panel { display: none; padding: 1.25rem 1.5rem; flex-direction: column; gap: 0.9rem; }
.tab-panel.active { display: flex; }

/* ─── Parse Preview ───────────────────────────────────────────── */
.parse-preview {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.3rem 0.75rem;
}
.parse-preview .preview-row { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.parse-preview .preview-label { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); }
.parse-preview .preview-value { color: var(--text); font-family: 'Consolas', 'Monaco', monospace; font-size: 0.78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ─── Toast ───────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  color: var(--text);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.15);
  max-width: 320px;
  pointer-events: auto;
  animation: slideIn 0.2s ease;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--primary); }
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
@keyframes fadeOut {
  to { opacity: 0; transform: translateX(100%); }
}
.toast.removing { animation: fadeOut 0.2s ease forwards; }

/* ─── Utilities ───────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ─── Subscriptions view ─────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.codes-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.codes-table th, .codes-table td { text-align: left; padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.codes-table th { color: var(--text-muted); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; }
.codes-table td code, .codes-table td .mono { font-family: 'Consolas', 'Monaco', monospace; font-size: 0.78rem; }
.pill { display: inline-block; font-size: 0.66rem; font-weight: 700; padding: 0.15rem 0.55rem; border-radius: 99px; letter-spacing: 0.04em; text-transform: uppercase; }
.pill.AVAILABLE { color: var(--success); background: rgba(5,150,105,.08); border: 1px solid rgba(5,150,105,.22); }
.pill.REDEEMED { color: var(--primary); background: rgba(79,70,229,.08); border: 1px solid rgba(79,70,229,.22); }
.pill.REVOKED { color: var(--danger); background: rgba(220,38,38,.07); border: 1px solid rgba(220,38,38,.22); }
.pill.EXPIRED { color: var(--warning); background: rgba(217,119,6,.08); border: 1px solid rgba(217,119,6,.22); }
.plans-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.75rem; }
.plan-chip { background: var(--bg-card2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.75rem 0.85rem; }
.plan-row {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.9rem;
  flex-wrap: wrap;
}
.plan-row.disabled { opacity: 0.55; }
.plan-row-info { flex: 1; min-width: 220px; }
.plan-row-info small { display: block; color: var(--text-muted); font-size: 0.75rem; margin-top: 0.15rem; }
.plan-row-actions { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.pill-on  { color: var(--success); background: rgba(5,150,105,.08); border: 1px solid rgba(5,150,105,.22); }
.pill-off { color: var(--danger);  background: rgba(220,38,38,.07); border: 1px solid rgba(220,38,38,.22); }
.check-line { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; user-select: none; color: var(--text-muted); font-size: 0.82rem; margin-top: 0.25rem; }
.check-line input { width: 16px; height: 16px; accent-color: var(--primary); }
.plan-chip b { display: block; }
.plan-chip small { color: var(--text-muted); }

/* ─── Responsive ──────────────────────────────────────────────── */
@media (max-width: 900px) {
  .ie-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-toggle { display: block; }
  .servers-grid { grid-template-columns: 1fr; }
  .modal { max-height: 95vh; }
  .modal-tabs .tab-btn { font-size: 0.8rem; padding: 0.65rem 0.5rem; }
  .form-row { flex-direction: column; }
  .w-24, .w-28 { width: 100%; }
  .topbar-actions .badge { display: none; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .view { padding: 1rem; }
  .topbar { padding: 0.75rem 1rem; }
  /* Phone polish for server cards: tighter padding and action buttons that
     share the row width evenly instead of overflowing the card edge. */
  .server-card { padding: 0.7rem 0.75rem; }
  .server-actions .btn { flex: 1; }
  /* Search + filter dropdowns stack neatly instead of overflowing */
  .toolbar-right { width: 100%; }
  .toolbar-right .select-sm { flex: 1; min-width: 0; }
}

/* ─── Free-tier server styles ─────────────────────────────────────────────── */
.server-card.is-free {
  border-color: rgba(16, 185, 129, 0.5);
  box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.18);
}
.free-badge {
  font-size: 0.72rem;
  font-weight: 600;
  color: #10b981;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 6px;
  padding: 4px 8px;
  margin: 0 0 0.6rem;
  word-break: break-word;
}
.btn-free {
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.4);
}
.btn-free:hover {
  background: rgba(16, 185, 129, 0.22);
}
.btn-warning {
  background: rgba(245, 158, 11, 0.12);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.4);
}
.btn-warning:hover {
  background: rgba(245, 158, 11, 0.22);
}
/* rev-period select inside card header */
.rev-period-select {
  font-size: 0.8rem;
  padding: 4px 8px;
  margin-left: 0.5rem;
}
