/* ===================================================
   PlexManager — Dark UI inspired by Plex/Netflix
   =================================================== */

:root {
  --color-bg:         #111318;
  --color-surface:    #1a1d24;
  --color-surface2:   #22262f;
  --color-border:     #2e3340;
  --color-plex:       #E5A00D;
  --color-plex-dark:  #cc8c00;
  --color-plex-light: #f0b429;
  --color-text:       #e8eaf0;
  --color-muted:      #8890a4;
  --color-success:    #22c55e;
  --color-danger:     #ef4444;
  --color-warning:    #f59e0b;
  --color-info:       #3b82f6;
  --color-lifetime:   #c0c0c0;
  --sidebar-w:        260px;
  --topbar-h:         64px;
  --radius:           12px;
  --radius-sm:        8px;
  --shadow:           0 4px 24px rgba(0,0,0,0.4);
  --shadow-card:      0 2px 12px rgba(0,0,0,0.3);
  --transition:       0.2s ease;
  --font:             'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; scroll-padding-top: var(--topbar-h); }
body { font-family: var(--font); background: var(--color-bg); color: var(--color-text); line-height: 1.6; min-height: 100vh; }
a { color: var(--color-plex); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--color-plex-light); }
img { max-width: 100%; display: block; }
button, input, select, textarea { font-family: inherit; }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--color-surface); }
::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-muted); }

/* ===== Layout ===== */
.app-layout { display: flex; min-height: 100vh; }

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}
.sidebar-logo {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--color-border);
}
.sidebar-logo svg { width: 32px; height: 32px; color: var(--color-plex); }
.sidebar-logo span { font-size: 1.2rem; font-weight: 700; color: var(--color-text); }
.sidebar-logo span em { color: var(--color-plex); font-style: normal; }

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.nav-section { margin-bottom: 24px; }
.nav-section-title {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-muted);
  padding: 0 8px;
  margin-bottom: 8px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--color-muted);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition);
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--color-surface2); color: var(--color-text); }
.nav-item.active { background: rgba(229,160,13,0.15); color: var(--color-plex); }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item .badge {
  margin-left: auto;
  background: var(--color-danger);
  color: white;
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 600;
}

.sidebar-user {
  padding: 16px 20px;
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar-user img {
  width: 36px; height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--color-border);
}
.sidebar-user .user-info { flex: 1; min-width: 0; }
.sidebar-user .user-name { font-size: 0.875rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .user-role { font-size: 0.7rem; color: var(--color-plex); }
.sidebar-user .logout-btn { color: var(--color-muted); transition: color var(--transition); }
.sidebar-user .logout-btn:hover { color: var(--color-danger); }

/* ===== Main Content ===== */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ===== Topbar ===== */
.topbar {
  height: var(--topbar-h);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--color-muted);
  cursor: pointer;
  padding: 4px;
}
.topbar-title { font-size: 1.1rem; font-weight: 600; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.notif-btn {
  position: relative;
  background: none;
  border: none;
  color: var(--color-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.notif-btn:hover { background: var(--color-surface2); color: var(--color-text); }
.notif-badge {
  position: absolute;
  top: 4px; right: 4px;
  width: 16px; height: 16px;
  background: var(--color-danger);
  border-radius: 50%;
  font-size: 0.6rem;
  font-weight: 700;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== Notification Dropdown ===== */
.notif-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 320px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 200;
  overflow: hidden;
}
.notif-dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-border);
}
.btn-link {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-muted);
  font-family: inherit;
  padding: 0;
  transition: color var(--transition);
}
.btn-link:hover { color: var(--color-plex); }
.notif-list { max-height: 360px; overflow-y: auto; }
.notif-item {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(46,51,64,0.5);
  cursor: default;
  transition: background var(--transition);
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--color-surface2); }
.notif-item-title { font-size: .875rem; font-weight: 600; margin-bottom: 3px; }
.notif-item-msg { font-size: .8rem; color: var(--color-muted); line-height: 1.4; }
.notif-item-time { font-size: .7rem; color: var(--color-muted); margin-top: 4px; }
.notif-empty { padding: 24px 16px; text-align: center; color: var(--color-muted); font-size:.875rem; }
@media (max-width: 480px) {
  .notif-dropdown { width: calc(100vw - 32px); right: -8px; }
}

/* ===== Page Content ===== */
.page-content { padding: 32px 24px; flex: 1; }
.page-header { margin-bottom: 28px; }
.page-title { font-size: 1.75rem; font-weight: 700; margin-bottom: 4px; }
.page-subtitle { color: var(--color-muted); font-size: 0.9rem; }

/* ===== Cards ===== */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-card);
  transition: border-color var(--transition);
}
.card:hover { border-color: var(--color-border); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.card-title { font-size: 1rem; font-weight: 600; }
.card-icon { width: 40px; height: 40px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; }
.card-icon svg { width: 20px; height: 20px; }
.card-icon.plex { background: rgba(229,160,13,0.15); color: var(--color-plex); }
.card-icon.success { background: rgba(34,197,94,0.15); color: var(--color-success); }
.card-icon.danger { background: rgba(239,68,68,0.15); color: var(--color-danger); }
.card-icon.info { background: rgba(59,130,246,0.15); color: var(--color-info); }
.card-icon.muted { background: var(--color-surface2); color: var(--color-muted); }

/* ===== Stat Cards ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform var(--transition), border-color var(--transition);
}
.stat-card:hover { transform: translateY(-2px); border-color: rgba(229,160,13,0.3); }
.stat-icon { width: 48px; height: 48px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-icon svg { width: 22px; height: 22px; }
.stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1; margin-bottom: 4px; }
.stat-label { font-size: 0.8rem; color: var(--color-muted); }

/* ===== Grid Layouts ===== */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }

/* ===== Subscription Card ===== */
.sub-card {
  background: linear-gradient(135deg, var(--color-surface) 0%, var(--color-surface2) 100%);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 28px;
  position: relative;
  overflow: hidden;
}
.sub-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--color-plex);
}
.sub-card.lifetime::before { background: linear-gradient(90deg, #C0C0C0, #e8e8e8, #C0C0C0); }
.sub-card.expired::before { background: var(--color-danger); }
.sub-card.pending::before { background: var(--color-warning); }

.sub-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 16px;
}
.sub-status-badge.active { background: rgba(34,197,94,0.15); color: var(--color-success); }
.sub-status-badge.expired { background: rgba(239,68,68,0.15); color: var(--color-danger); }
.sub-status-badge.pending { background: rgba(245,158,11,0.15); color: var(--color-warning); }
.sub-status-badge.suspended { background: rgba(107,114,128,0.15); color: var(--color-muted); }
.sub-status-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.days-remaining { font-size: 3rem; font-weight: 700; color: var(--color-plex); line-height: 1; }
.days-remaining.lifetime { color: var(--color-lifetime); }
.days-remaining.expired { color: var(--color-danger); }
.days-label { font-size: 0.875rem; color: var(--color-muted); margin-top: 4px; }

/* ===== Progress Bar ===== */
.progress { background: var(--color-surface2); border-radius: 4px; height: 6px; overflow: hidden; margin: 12px 0; }
.progress-bar { height: 100%; border-radius: 4px; background: var(--color-plex); transition: width 0.8s ease; }
.progress-bar.danger { background: var(--color-danger); }

/* ===== Forms ===== */
.form-group { margin-bottom: 20px; }
.form-label { display: block; font-size: 0.875rem; font-weight: 500; margin-bottom: 8px; color: var(--color-muted); }
.form-control {
  width: 100%;
  background: var(--color-surface2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--color-text);
  font-size: 0.875rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus {
  outline: none;
  border-color: var(--color-plex);
  box-shadow: 0 0 0 3px rgba(229,160,13,0.15);
}
.form-control::placeholder { color: var(--color-muted); }
.form-control:disabled { opacity: 0.5; cursor: not-allowed; }
select.form-control { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%238890a4' d='M6 8L0 0h12z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.input-group { display: flex; }
.input-group .form-control { border-radius: var(--radius-sm) 0 0 var(--radius-sm); border-right: none; }
.input-group-btn { padding: 0 16px; background: var(--color-plex); border: 1px solid var(--color-plex); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: #000; font-weight: 600; cursor: pointer; transition: background var(--transition); }
.input-group-btn:hover { background: var(--color-plex-light); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--color-plex); color: #000; }
.btn-primary:hover { background: var(--color-plex-light); color: #000; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(229,160,13,0.4); }
.btn-secondary { background: var(--color-surface2); color: var(--color-text); border: 1px solid var(--color-border); }
.btn-secondary:hover { background: var(--color-border); color: var(--color-text); }
.btn-danger { background: var(--color-danger); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-success { background: var(--color-success); color: white; }
.btn-success:hover { background: #16a34a; }
.btn-ghost { background: transparent; color: var(--color-muted); border: 1px solid var(--color-border); }
.btn-ghost:hover { background: var(--color-surface2); color: var(--color-text); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ===== Tables ===== */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead tr { border-bottom: 1px solid var(--color-border); }
th {
  padding: 12px 16px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-muted);
}
td { padding: 12px 16px; font-size: 0.875rem; border-bottom: 1px solid rgba(46,51,64,0.5); }
tbody tr { transition: background var(--transition); }
tbody tr:hover { background: rgba(255,255,255,0.02); }
tbody tr:last-child td { border-bottom: none; }

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
}
.badge-active    { background: rgba(34,197,94,0.15);  color: var(--color-success); }
.badge-expired   { background: rgba(239,68,68,0.15);  color: var(--color-danger); }
.badge-pending   { background: rgba(245,158,11,0.15); color: var(--color-warning); }
.badge-suspended { background: rgba(107,114,128,0.15);color: var(--color-muted); }
.badge-lifetime  { background: rgba(192,192,192,0.15);color: var(--color-lifetime); }
.badge-admin     { background: rgba(229,160,13,0.2);  color: var(--color-plex); }

/* ===== Alerts / Toasts ===== */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 0.875rem;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-success { background: rgba(34,197,94,0.1);  border: 1px solid rgba(34,197,94,0.3);  color: #4ade80; }
.alert-error   { background: rgba(239,68,68,0.1);  border: 1px solid rgba(239,68,68,0.3);  color: #f87171; }
.alert-warning { background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.3); color: #fbbf24; }
.alert-info    { background: rgba(59,130,246,0.1); border: 1px solid rgba(59,130,246,0.3); color: #60a5fa; }

/* Toast */
.toast-container {
  position: fixed;
  top: 80px; right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 360px;
}
.toast {
  background: var(--color-surface2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  box-shadow: var(--shadow);
  animation: slideIn 0.3s ease;
}
.toast.success { border-left: 3px solid var(--color-success); }
.toast.error   { border-left: 3px solid var(--color-danger); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOut { to { transform: translateX(120%); opacity: 0; } }
.toast.hiding { animation: slideOut 0.3s ease forwards; }

/* ===== User Avatar ===== */
.user-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--color-border);
  flex-shrink: 0;
}
.user-avatar-lg {
  width: 80px; height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--color-plex);
}
.avatar-placeholder {
  background: var(--color-surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--color-plex);
  text-transform: uppercase;
}

/* ===== Code Block ===== */
.code-block {
  background: var(--color-surface2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-family: 'Courier New', monospace;
  font-size: 0.875rem;
  color: var(--color-plex-light);
  letter-spacing: 0.1em;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  word-break: break-all;
}
.copy-btn {
  background: none;
  border: none;
  color: var(--color-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: color var(--transition);
  flex-shrink: 0;
}
.copy-btn:hover { color: var(--color-plex); }

/* ===== Plan Cards ===== */
.plan-card {
  background: var(--color-surface2);
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  position: relative;
  transition: all var(--transition);
  cursor: pointer;
}
.plan-card:hover, .plan-card.selected { border-color: var(--color-plex); }
.plan-card .plan-badge {
  position: absolute;
  top: -12px; left: 50%; transform: translateX(-50%);
  background: var(--color-plex);
  color: #000;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 12px;
  border-radius: 20px;
}
.plan-price { font-size: 2.5rem; font-weight: 700; color: var(--color-text); }
.plan-price span { font-size: 1rem; color: var(--color-muted); font-weight: 400; }
.plan-name { font-size: 0.9rem; color: var(--color-muted); margin-bottom: 8px; }

/* ===== Login Page ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 0%, rgba(229,160,13,0.08) 0%, transparent 60%),
              var(--color-bg);
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  padding: 48px 40px;
  box-shadow: var(--shadow);
  text-align: center;
}
.login-logo { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 32px; }
.login-logo svg { width: 48px; height: 48px; color: var(--color-plex); }
.login-logo-text { font-size: 1.75rem; font-weight: 800; }
.login-logo-text em { color: var(--color-plex); font-style: normal; }
.login-title { font-size: 1.4rem; font-weight: 700; margin-bottom: 8px; }
.login-subtitle { color: var(--color-muted); font-size: 0.9rem; margin-bottom: 36px; }
.btn-plex {
  background: var(--color-plex);
  color: #000;
  font-size: 1rem;
  padding: 14px 28px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  justify-content: center;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}
.btn-plex:hover { background: var(--color-plex-light); color: #000; transform: translateY(-2px); box-shadow: 0 8px 24px rgba(229,160,13,0.35); }
.btn-plex svg { width: 22px; height: 22px; }

/* ===== Invitation Page ===== */
.invite-page {
  min-height: 100vh;
  background: radial-gradient(ellipse at 50% 0%, rgba(229,160,13,0.06) 0%, transparent 60%),
              var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.invite-card {
  width: 100%;
  max-width: 540px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  padding: 40px;
  box-shadow: var(--shadow);
}
.invite-header { text-align: center; margin-bottom: 32px; }
.invite-code-badge {
  display: inline-block;
  background: rgba(229,160,13,0.1);
  border: 1px solid rgba(229,160,13,0.3);
  color: var(--color-plex);
  font-family: monospace;
  font-size: 1.1rem;
  font-weight: 700;
  padding: 8px 20px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.1em;
  margin-bottom: 16px;
}

/* ===== Sidebar Overlay (Mobile) ===== */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 90;
}

/* ===== Search ===== */
.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}
.search-bar .form-control { flex: 1; }

/* ===== Pagination ===== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 24px;
}
.page-btn {
  width: 36px; height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--color-surface2);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}
.page-btn:hover, .page-btn.active { background: var(--color-plex); border-color: var(--color-plex); color: #000; }

/* ===== Tabs ===== */
.tabs { display: flex; gap: 4px; margin-bottom: 24px; border-bottom: 1px solid var(--color-border); }
.tab-btn {
  padding: 10px 20px;
  background: none;
  border: none;
  color: var(--color-muted);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--transition);
}
.tab-btn:hover { color: var(--color-text); }
.tab-btn.active { color: var(--color-plex); border-bottom-color: var(--color-plex); }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition);
}
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow);
  transform: scale(0.95);
  transition: transform var(--transition);
}
.modal-overlay.open .modal { transform: scale(1); }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.modal-title { font-size: 1.1rem; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--color-muted); cursor: pointer; padding: 4px; border-radius: 4px; transition: color var(--transition); }
.modal-close:hover { color: var(--color-text); }
.modal-footer { display: flex; justify-content: flex-end; gap: 12px; margin-top: 28px; }

/* ===== API Status ===== */
.status-indicator { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.status-indicator.ok      { background: var(--color-success); box-shadow: 0 0 0 3px rgba(34,197,94,0.2); animation: pulse 2s infinite; }
.status-indicator.error   { background: var(--color-danger); }
.status-indicator.warning { background: var(--color-warning); }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 3px rgba(34,197,94,0.2); } 50% { box-shadow: 0 0 0 6px rgba(34,197,94,0.05); } }

/* ===== Utilities ===== */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-muted { color: var(--color-muted); }
.text-plex { color: var(--color-plex); }
.text-success { color: var(--color-success); }
.text-danger { color: var(--color-danger); }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }

/* ===== Quick Link Cards (dashboard) ===== */
.quick-link-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--color-surface2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-size: .85rem;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--transition);
}
.quick-link-card:hover {
  background: var(--color-surface);
  border-color: var(--color-plex);
  color: var(--color-plex);
  transform: translateY(-1px);
}
.quick-link-card svg { flex-shrink: 0; color: var(--color-muted); transition: color var(--transition); }
.quick-link-card:hover svg { color: var(--color-plex); }

/* ===== Plan display cards (subscription page) ===== */
.plan-display-card {
  transition: border-color var(--transition), transform var(--transition);
}
.plan-display-card:hover {
  border-color: var(--color-plex) !important;
  transform: translateY(-2px);
}
.plan-display-card.current {
  box-shadow: 0 0 0 1px var(--color-plex);
}
.w-full { width: 100%; }
.text-center { text-align: center; }
.divider { border: none; border-top: 1px solid var(--color-border); margin: 20px 0; }

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay {
    display: block;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
  }
  .sidebar-overlay.open { opacity: 1; pointer-events: all; }
  .main-content { margin-left: 0; }
  .topbar-menu-btn { display: flex; }
  .topbar-title { font-size: 0.95rem; }
  .page-content { padding: 20px 16px; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  .login-card { padding: 36px 24px; }
  .invite-card { padding: 28px 20px; }
  .page-title { font-size: 1.4rem; }
  .days-remaining { font-size: 2.2rem; }
  .card { padding: 16px; }
  .card-header { flex-wrap: wrap; gap: 8px; }
  /* Action button groups wrap on mobile */
  .flex.gap-2 { flex-wrap: wrap; }
  /* Page headers with buttons stack on mobile */
  .page-header.flex { flex-direction: column; align-items: flex-start; gap: 12px; }
  .page-header .flex.gap-2 { width: 100%; }
  /* Tabs scroll horizontally */
  .tabs { overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  /* Table minimum cell sizing */
  th, td { padding: 10px 12px; }
  /* Pagination wraps */
  .pagination { flex-wrap: wrap; gap: 4px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .btn-lg { padding: 12px 20px; }
  .page-title { font-size: 1.25rem; }
  .card { padding: 14px; }
  .modal { margin: 16px; width: calc(100vw - 32px); max-width: none; }
  /* Stat cards go single column */
  .stats-grid { grid-template-columns: 1fr; }
}
