:root {
  --bg: #08090e;
  --surface: #11131d;
  --surface-2: #191c2b;
  --surface-3: #22263a;
  --border: rgba(255, 255, 255, 0.08);
  --text: #f5f7fb;
  --muted: #98a2b3;
  --purple: #9d4edd;
  --cyan: #00e5ff;
  --green: #10d876;
  --amber: #ffb020;
  --red: #ff4d6d;
  --grad: linear-gradient(135deg, #9d4edd 0%, #00e5ff 100%);
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

/* ---------- Login Screen ---------- */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(circle at 18% 18%, rgba(157, 78, 221, 0.22), transparent 42%),
    radial-gradient(circle at 82% 82%, rgba(0, 229, 255, 0.14), transparent 42%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.brand-badge {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--grad);
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 18px;
  color: #fff;
  box-shadow: 0 8px 24px rgba(157, 78, 221, 0.35);
}

.brand-title {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
}

.brand-sub {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

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

.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
  flex: 1;
}

.nav-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 11px 14px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 12px;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: all 0.16s ease;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.nav-btn.active {
  background: linear-gradient(135deg, rgba(157, 78, 221, 0.22), rgba(0, 229, 255, 0.14));
  border-color: rgba(157, 78, 221, 0.4);
  color: #fff;
}

.nav-count {
  background: rgba(255, 176, 32, 0.2);
  color: var(--amber);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}

.user-footer {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: 10px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface-3);
  border: 1px solid rgba(0, 229, 255, 0.35);
  display: grid;
  place-items: center;
  font-weight: 800;
  color: var(--cyan);
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(8, 9, 14, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 12px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.hamburger {
  display: none;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  width: 38px;
  height: 38px;
  font-size: 18px;
  cursor: pointer;
}

.page-title {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.content {
  padding: 20px 22px 48px;
  max-width: 1420px;
  width: 100%;
  margin: 0 auto;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 35;
}

/* ---------- Cards & KPIs ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(195px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.kpi-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.kpi-value {
  font-size: 24px;
  font-weight: 800;
  margin: 6px 0 4px;
  letter-spacing: -0.02em;
}

.kpi-sub {
  font-size: 12px;
  color: var(--muted);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.card-title {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

/* ---------- Buttons, Forms & Badges ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 15px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { opacity: 0.92; }
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--grad);
  border-color: transparent;
  color: #fff;
  font-weight: 700;
}

.btn-success {
  background: rgba(16, 216, 118, 0.16);
  border-color: rgba(16, 216, 118, 0.4);
  color: var(--green);
}

.btn-amber {
  background: rgba(255, 176, 32, 0.15);
  border-color: rgba(255, 176, 32, 0.4);
  color: var(--amber);
}

.btn-danger {
  background: rgba(255, 77, 109, 0.14);
  border-color: rgba(255, 77, 109, 0.35);
  color: var(--red);
}

.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 8px;
}

.btn-block { width: 100%; }

.field {
  margin-bottom: 13px;
}

.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 5px;
}

.input, .select, .textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  outline: none;
}

.input:focus, .select:focus, .textarea:focus {
  border-color: var(--cyan);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}

.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.filters-bar .input, .filters-bar .select {
  width: auto;
  min-width: 160px;
  flex: 1;
}

/* App & Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.b-active { background: rgba(16, 216, 118, 0.16); color: var(--green); border: 1px solid rgba(16, 216, 118, 0.35); }
.b-soon { background: rgba(255, 176, 32, 0.16); color: var(--amber); border: 1px solid rgba(255, 176, 32, 0.4); }
.b-expired { background: rgba(255, 77, 109, 0.16); color: var(--red); border: 1px solid rgba(255, 77, 109, 0.4); }
.b-inactive { background: rgba(152, 162, 179, 0.16); color: var(--muted); border: 1px solid rgba(152, 162, 179, 0.3); }

.app-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  margin: 2px 3px 2px 0;
}
.app-music { background: rgba(157, 78, 221, 0.24); color: #e0b3ff; }
.app-video { background: rgba(255, 77, 109, 0.22); color: #ff99ab; }
.app-movies { background: rgba(0, 229, 255, 0.18); color: #8ff3ff; }

/* App Selector Cards in Create/Edit Modal */
.app-selector-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.app-check-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 2px solid var(--border);
  cursor: pointer;
  user-select: none;
  text-align: center;
  transition: all 0.15s;
}

.app-check-card.checked {
  border-color: var(--cyan);
  background: rgba(0, 229, 255, 0.09);
}

.app-check-card input {
  accent-color: var(--cyan);
  transform: scale(1.15);
}

.live-quote-box {
  background: linear-gradient(135deg, rgba(157, 78, 221, 0.14), rgba(0, 229, 255, 0.08));
  border: 1px solid rgba(0, 229, 255, 0.25);
  border-radius: 12px;
  padding: 12px 14px;
  margin: 10px 0 14px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(115px, 1fr));
  gap: 10px;
}

/* ---------- Tables ---------- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border-radius: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th, td {
  padding: 11px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ---------- Modals & Toasts ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal {
  width: 100%;
  max-width: 600px;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.65);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.toast-root {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
}

.toast {
  background: var(--surface-3);
  border: 1px solid rgba(0, 229, 255, 0.35);
  color: #fff;
  padding: 11px 16px;
  border-radius: 12px;
  font-weight: 600;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
}

.toast.err {
  border-color: var(--red);
  color: #ffd6de;
}

.muted { color: var(--muted); }
.text-green { color: var(--green); }
.text-amber { color: var(--amber); }
.text-red { color: var(--red); }
.text-cyan { color: var(--cyan); }
.empty-state { text-align: center; color: var(--muted); padding: 30px 12px; }

/* ---------- Mobile Responsive ---------- */
@media (max-width: 960px) {
  .hamburger { display: grid; place-items: center; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.open { display: block; }
  .topbar { padding: 11px 14px; }
  .content { padding: 14px 12px 44px; }
  .app-selector-grid { grid-template-columns: 1fr; }
}

@media print {
  .sidebar, .topbar, .filters-bar, .no-print, .actions-row {
    display: none !important;
  }
  body, .card {
    background: #fff !important;
    color: #000 !important;
    border-color: #ccc !important;
  }
  th, td { color: #111 !important; border-color: #ddd !important; }
}

