:root {
  --sidebar-bg: #3d1766;
  --sidebar-bg-2: #2a0f49;
  --sidebar-active: rgba(255, 255, 255, 0.14);
  --accent: #6c3fc5;
  --accent-dark: #5a2fb0;
  --bg: #f1f2f6;
  --card-bg: #ffffff;
  --border: #e3e3ee;
  --text: #1f1b2e;
  --text-dim: #6b6478;
  --success: #16a374;
  --danger: #dc2626;
  --warning: #d97706;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: "Sora", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-family: var(--font-body);
}

h1, h2, h3, .login-logo, .page-title, .tile .v {
  font-family: var(--font-display);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); min-height: 100%; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

.app-shell { display: flex; min-height: 100vh; }

/* ---------- sidebar ---------- */
.sidebar {
  width: 230px;
  flex: none;
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  transition: transform 0.2s ease;
  z-index: 50;
}
.sidebar-brand {
  padding: 22px 20px;
  font-weight: 800;
  font-size: 19px;
  letter-spacing: 0.01em;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.sidebar-nav { list-style: none; margin: 14px 0; padding: 0 10px; flex: 1; }
.sidebar-nav li { margin-bottom: 4px; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.82);
}
.sidebar-nav a:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.sidebar-nav a.active { background: var(--sidebar-active); color: #fff; }
.sidebar-nav .ic { width: 18px; height: 18px; flex: none; }

.nav-group-toggle { cursor: pointer; justify-content: space-between; }
.nav-group-toggle .chev { width: 13px; height: 13px; flex: none; transition: transform 0.15s ease; opacity: 0.7; }
.nav-group-toggle .toggle-left { display: flex; align-items: center; gap: 10px; }
.nav-group.open .nav-group-toggle .chev { transform: rotate(180deg); }
.nav-group-items { list-style: none; margin: 2px 0 0; padding: 0 0 0 14px; max-height: 0; overflow: hidden; transition: max-height 0.2s ease; }
.nav-group.open .nav-group-items { max-height: 220px; }
.nav-group-items a { font-size: 13px; padding: 9px 14px; }
.nav-group-items .ic { width: 16px; height: 16px; }
.sidebar-foot { padding: 16px 20px; font-size: 12px; color: rgba(255, 255, 255, 0.5); border-top: 1px solid rgba(255, 255, 255, 0.1); }

/* ---------- main area ---------- */
.main { margin-left: 230px; flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; background: var(--card-bg); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 40; gap: 12px;
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.hamburger { display: none; background: none; border: 1px solid var(--border); border-radius: 8px; width: 34px; height: 34px; cursor: pointer; }
.balance-chip {
  font-weight: 700; font-size: 13.5px; padding: 7px 14px; border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), #9a4fd0); color: #fff;
}
.user-chip { font-size: 13.5px; font-weight: 600; color: var(--text-dim); }
.btn-logout { font-size: 13px; font-weight: 600; color: var(--text-dim); background: none; border: 1px solid var(--border); border-radius: 8px; padding: 7px 13px; cursor: pointer; }
.btn-logout:hover { background: var(--bg); }

.account-menu { position: relative; }
.account-menu-trigger {
  display: flex; align-items: center; gap: 6px; background: none; border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px; cursor: pointer; color: var(--text-dim);
}
.account-menu-trigger:hover { background: var(--bg); }
.account-menu-trigger .ic { width: 17px; height: 17px; }
.account-menu-trigger .chev { width: 12px; height: 12px; transition: transform 0.15s ease; }
.account-menu.open .account-menu-trigger .chev { transform: rotate(180deg); }
.account-menu-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0; background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: 0 16px 40px -14px rgba(30, 10, 60, 0.3); min-width: 190px; padding: 6px;
  display: none; z-index: 60;
}
.account-menu.open .account-menu-dropdown { display: block; }
.account-menu-dropdown button, .account-menu-dropdown a {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px;
  border: none; background: none; cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--text); text-align: left;
}
.account-menu-dropdown button:hover, .account-menu-dropdown a:hover { background: var(--bg); }
.account-menu-dropdown button .ic, .account-menu-dropdown a .ic { width: 17px; height: 17px; flex: none; color: var(--text-dim); }
.account-menu-dropdown button.danger { color: var(--danger); }
.account-menu-dropdown button.danger .ic { color: var(--danger); }

.content { padding: 24px; flex: 1; max-width: 1100px; width: 100%; margin: 0 auto; }
.page-title { font-size: 21px; font-weight: 800; margin: 0 0 4px; }
.page-sub { color: var(--text-dim); font-size: 13.5px; margin: 0 0 22px; }

/* ---------- cards / tiles ---------- */
.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 14px; padding: 20px; box-shadow: 0 2px 4px rgba(20, 10, 40, 0.04); margin-bottom: 18px; }
.card h3 { margin: 0 0 14px; font-size: 15px; font-weight: 700; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 20px; }
.tile { background: var(--card-bg); border: 1px solid var(--border); border-radius: 14px; padding: 18px; }
.tile .k { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; }
.tile .v { font-size: 23px; font-weight: 800; margin-top: 6px; font-variant-numeric: tabular-nums; }

/* ---------- forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-dim); margin-bottom: 6px; }
.field input, .field select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px;
  font-size: 14px; background: var(--bg);
}
.field input:focus, .field select:focus { outline: 2px solid var(--accent); outline-offset: 1px; background: #fff; }
.row-inline { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row-inline .field { flex: 1; min-width: 180px; margin-bottom: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 9px; font-weight: 700; font-size: 13.5px;
  border: 1px solid transparent; cursor: pointer;
}
.btn-primary { background: linear-gradient(135deg, var(--accent), #9a4fd0); color: #fff; }
.btn-primary:hover { filter: brightness(1.07); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }
.btn-light { background: var(--bg); color: var(--text); border-color: var(--border); }
.btn-light:hover { background: #e9eaf0; }
.btn-danger { background: #fde8e8; color: var(--danger); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-dim); padding: 10px 12px; border-bottom: 1px solid var(--border); }
td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }

.pill { display: inline-flex; font-size: 11px; font-weight: 800; text-transform: uppercase; padding: 3px 10px; border-radius: 999px; }
.pill.success { background: rgba(22, 163, 116, 0.12); color: var(--success); }
.pill.failed { background: rgba(220, 38, 38, 0.12); color: var(--danger); }
.pill.pending { background: rgba(217, 119, 6, 0.12); color: var(--warning); }

/* ---------- login ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: #e9eaf2;
}
.login-shell {
  display: grid; grid-template-columns: 1.05fr 1fr; width: 100%; max-width: 920px;
  background: var(--card-bg); border-radius: 22px; overflow: hidden;
  box-shadow: 0 40px 80px -30px rgba(30, 10, 60, 0.35);
}

/* -- left: brand panel -- */
.login-brand-panel {
  position: relative; overflow: hidden; padding: 48px 44px;
  background: linear-gradient(155deg, var(--sidebar-bg-2) 0%, var(--sidebar-bg) 55%, var(--accent) 130%);
  color: #fff; display: flex; align-items: center;
}
.login-brand-pattern { position: absolute; inset: 0; opacity: 0.5; pointer-events: none; }
.login-brand-pattern::before, .login-brand-pattern::after {
  content: ""; position: absolute; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.18), transparent 70%);
}
.login-brand-pattern::before { width: 460px; height: 460px; top: -200px; right: -180px; }
.login-brand-pattern::after { width: 340px; height: 340px; bottom: -160px; left: -120px; background: radial-gradient(circle, rgba(255, 255, 255, 0.12), transparent 70%); }
.login-brand-content { position: relative; z-index: 1; }
.login-logo { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 19px; margin-bottom: 34px; }
.login-logo svg { width: 22px; height: 22px; }
.login-headline { font-size: 28px; font-weight: 800; line-height: 1.25; margin: 0 0 14px; }
.login-lead { font-size: 14px; color: rgba(255, 255, 255, 0.78); line-height: 1.6; margin: 0 0 28px; max-width: 34ch; }
.login-features { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.login-features li { display: flex; align-items: center; gap: 10px; font-size: 13.5px; font-weight: 600; color: rgba(255, 255, 255, 0.92); }
.login-features svg { width: 17px; height: 17px; flex: none; background: rgba(255, 255, 255, 0.18); border-radius: 50%; padding: 3px; box-sizing: content-box; }

/* -- right: form panel -- */
.login-form-panel { padding: 48px 44px; display: flex; align-items: center; }
.login-form-inner { width: 100%; }
.login-form-eyebrow { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); margin-bottom: 10px; }
.login-form-head h2 { font-size: 25px; font-weight: 800; margin: 0 0 6px; }
.login-form-head p { font-size: 13.5px; color: var(--text-dim); margin: 0 0 26px; }
.login-error { background: #fde8e8; color: var(--danger); padding: 10px 12px; border-radius: 9px; font-size: 13px; margin-bottom: 14px; display: none; }

@media (max-width: 820px) {
  .login-shell { grid-template-columns: 1fr; max-width: 420px; }
  .login-brand-panel { display: none; }
  .login-form-panel { padding: 38px 28px; }
}

/* ---------- toast ---------- */
.toast { position: fixed; bottom: 22px; right: 22px; background: var(--text); color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 13.5px; box-shadow: 0 10px 30px rgba(0,0,0,.25); z-index: 100; opacity: 0; transform: translateY(8px); transition: all 0.2s ease; pointer-events: none; max-width: 320px; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

/* ---------- modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(20, 10, 40, 0.45); display: none; align-items: center; justify-content: center; z-index: 80; padding: 16px; }
.modal-backdrop.open { display: flex; }
.modal { background: #fff; border-radius: 14px; padding: 22px; width: 100%; max-width: 380px; }
.modal h3 { margin: 0 0 16px; font-size: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.empty-state { text-align: center; color: var(--text-dim); padding: 36px 0; font-size: 13.5px; }
.result-row { display: flex; justify-content: space-between; padding: 7px 0; font-size: 13.5px; border-bottom: 1px solid var(--border); gap: 12px; }
.result-row:last-child { border-bottom: none; }
.result-row .k { color: var(--text-dim); }
.result-row .v { font-weight: 600; text-align: right; }

.packages-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.package-card { border: 1px solid var(--border); border-radius: 12px; padding: 14px; background: var(--bg); }
.package-card .name { font-weight: 700; font-size: 13.5px; margin-bottom: 8px; }
.package-card .price { font-weight: 800; font-size: 16px; color: var(--accent-dark); margin-bottom: 10px; }

.promo-banner { background: linear-gradient(135deg, var(--sidebar-bg), var(--accent)); color: #fff; padding: 20px 22px; }
.promo-banner-title { font-size: 19px; font-weight: 800; }
.promo-banner-title::after { content: " OFFERS"; font-weight: 500; opacity: 0.6; font-size: 14px; }
.promo-banner-sub { font-size: 13px; opacity: 0.85; margin-top: 4px; }

@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .hamburger { display: inline-flex; align-items: center; justify-content: center; }
  .content { padding: 16px; }
}
