@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600;700&display=swap');

:root{
  --bg:#050a12;
  --surface:#0b1018;
  --surface-2:#0d141e;
  --surface-3:#101822;
  --border:#1f3348;
  --border-soft:#182635;
  --text:#eef7ff;
  --text-dim:#9db5cb;
  --text-faint:#66809a;
  --blue:#3d9cff;
  --blue-soft:#173a5c;
  --cyan:#35d9c8;
  --amber:#ffb020;
  --amber-soft:#3a2c10;
  --red:#ff4d5e;
  --red-soft:#3a1319;
  --purple:#b48eff;
  --purple-soft:#241a3d;
  --radius-lg:18px;
  --radius-md:12px;
  --radius-sm:8px;
  --ease:cubic-bezier(.22,1,.36,1);
  --font-display:'Space Grotesk', 'Inter', system-ui, sans-serif;
  --font-body:'Inter', system-ui, -apple-system, sans-serif;
}

*{box-sizing:border-box;}
html,body{height:100%;}
body{
  margin:0;
  min-height:100vh;
  background:var(--bg);
  color:var(--text);
  font-family:var(--font-body);
  -webkit-font-smoothing:antialiased;
  position:relative;
  overflow-x:hidden;
}
h1,h2,h3{
  font-family:var(--font-display);
  margin:0;
  letter-spacing:-0.01em;
}
p{margin:0;}
button,input{font-family:inherit;}
button{cursor:pointer;}
::selection{background:#1c4870;color:#fff;}

@media (prefers-reduced-motion:reduce){
  *{animation-duration:0.001ms !important; animation-iteration-count:1 !important; transition-duration:0.001ms !important;}
}

/* ---------- background décor ---------- */
.bg-grid{
  position:fixed; inset:0;
  background-image:
    linear-gradient(to right, rgba(255,255,255,.035) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size:42px 42px;
  mask-image:radial-gradient(ellipse 80% 60% at 50% 0%, #000 40%, transparent 90%);
  pointer-events:none;
  z-index:0;
}
.orb{
  position:fixed; border-radius:50%; filter:blur(90px); pointer-events:none; z-index:0; opacity:.35;
}
.orb-a{ width:520px; height:520px; top:-180px; left:-140px; background:radial-gradient(circle, #2f6fe0, transparent 70%); }
.orb-b{ width:480px; height:480px; bottom:-200px; right:-160px; background:radial-gradient(circle, #21b8a8, transparent 70%); }

/* ---------- shared bits ---------- */
.eyebrow{
  display:inline-flex; align-items:center; gap:8px;
  font-size:11.5px; font-weight:700; letter-spacing:.06em;
  color:var(--blue);
}
.eyebrow i{
  width:6px; height:6px; border-radius:50%; background:var(--blue);
  box-shadow:0 0 0 4px var(--blue-soft);
}
.login-dot{
  width:9px; height:9px; border-radius:50%;
  background:var(--cyan);
  box-shadow:0 0 12px 2px rgba(53,217,200,.7);
  display:inline-block;
}
.brand{
  display:flex; align-items:center; gap:10px;
  font-family:var(--font-display); font-weight:700; font-size:16px;
  color:var(--text);
}
.brand b{color:var(--blue); font-weight:700;}
.brand em{
  font-style:normal; font-weight:500; font-size:11px; color:var(--text-dim);
  border:1px solid var(--border); border-radius:999px; padding:2px 8px; margin-left:2px;
}

.btn{
  position:relative;
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  border-radius:var(--radius-sm);
  border:1px solid var(--border);
  background:var(--surface-2);
  color:var(--text);
  font-weight:600; font-size:14px;
  padding:11px 18px;
  transition:transform .18s var(--ease), background .18s, border-color .18s, box-shadow .18s;
}
.btn:hover{transform:translateY(-1px); border-color:#2c4a68;}
.btn:active{transform:translateY(0);}
.btn-primary{
  background:linear-gradient(180deg, #2f7de8, #1f63c9);
  border-color:#4c92ee;
  color:#fff;
  box-shadow:0 8px 24px -10px rgba(61,156,255,.65);
}
.btn-primary:hover{box-shadow:0 10px 28px -8px rgba(61,156,255,.8);}
.btn-ghost{background:transparent;}
.btn-danger{
  background:linear-gradient(180deg,#e5495b,#c8303f);
  border-color:#ff7280; color:#fff;
  box-shadow:0 8px 24px -10px rgba(255,77,94,.55);
}
.btn-block{width:100%;}
.btn:disabled{opacity:.6; pointer-events:none;}
.btn-spinner{
  width:15px; height:15px; border-radius:50%;
  border:2px solid rgba(255,255,255,.35); border-top-color:#fff;
  animation:spin .7s linear infinite;
}
.spinner{
  width:16px; height:16px; border-radius:50%;
  border:2px solid rgba(255,255,255,.15); border-top-color:var(--blue);
  animation:spin .7s linear infinite; display:inline-block;
}
@keyframes spin{to{transform:rotate(360deg);}}

.field{display:flex; flex-direction:column; gap:7px; margin-bottom:16px;}
.field span{font-size:12.5px; font-weight:600; color:var(--text-dim);}
.field input{
  background:var(--surface); border:1px solid var(--border);
  border-radius:var(--radius-sm); color:var(--text);
  padding:12px 13px; font-size:14.5px; outline:none;
  transition:border-color .15s, box-shadow .15s, background .15s;
}
.field input::placeholder{color:#54687e;}
.field input:focus{
  border-color:var(--blue);
  box-shadow:0 0 0 3px rgba(61,156,255,.18);
  background:#0d141f;
}
.field small{color:var(--text-faint); font-size:11.5px;}
.pw-wrap{position:relative; display:flex;}
.pw-wrap input{flex:1; padding-right:42px;}
.pw-toggle{
  position:absolute; right:6px; top:50%; transform:translateY(-50%);
  width:30px; height:30px; border-radius:7px; border:none; background:transparent;
  color:var(--text-faint); font-size:14px;
  display:flex; align-items:center; justify-content:center;
  transition:color .15s, background .15s;
}
.pw-toggle:hover{color:var(--text); background:var(--surface-3);}

.icon-btn{
  width:38px; height:38px; border-radius:10px;
  border:1px solid var(--border); background:var(--surface-2);
  color:var(--text-dim); font-size:15px;
  display:flex; align-items:center; justify-content:center;
  transition:transform .15s var(--ease), border-color .15s, color .15s, background .15s;
}
.icon-btn:hover{transform:translateY(-1px) rotate(6deg); color:var(--text); border-color:#2c4a68;}
.icon-btn-danger:hover{color:var(--red); border-color:#5c2c33; background:var(--red-soft);}

.form-error{
  background:var(--red-soft); border:1px solid #5c2c33; color:#ffb3ba;
  border-radius:var(--radius-sm); padding:10px 12px; font-size:13px;
  animation:shake .32s var(--ease);
}
.form-success{
  background:#0f2b20; border:1px solid #285d48; color:#7fe8b8;
  border-radius:var(--radius-sm); padding:10px 12px; font-size:13px;
}
@keyframes shake{
  10%,90%{transform:translateX(-1px);}
  20%,80%{transform:translateX(2px);}
  30%,50%,70%{transform:translateX(-4px);}
  40%,60%{transform:translateX(4px);}
}

/* ============================================================ */
/*  LOGIN                                                        */
/* ============================================================ */
.login-screen{
  position:relative; z-index:1;
  min-height:100vh; display:none;
  align-items:center; justify-content:center;
  padding:24px;
}
body.is-guest .login-screen{display:flex;}
body.is-guest .app-shell{display:none;}

.login-card{
  width:100%; max-width:380px;
  background:linear-gradient(180deg, rgba(13,20,30,.92), rgba(10,16,24,.92));
  border:1px solid var(--border);
  border-radius:var(--radius-lg);
  padding:32px 28px 28px;
  backdrop-filter:blur(14px);
  box-shadow:0 30px 80px -30px rgba(0,0,0,.7);
  animation:cardIn .5s var(--ease);
}
@keyframes cardIn{
  from{opacity:0; transform:translateY(18px) scale(.98);}
  to{opacity:1; transform:translateY(0) scale(1);}
}
.login-card h1{font-size:22px; margin-top:18px;}
.login-sub{color:var(--text-dim); font-size:13.5px; margin-top:6px; margin-bottom:22px;}

/* ============================================================ */
/*  APP SHELL                                                    */
/* ============================================================ */
.app-shell{position:relative; z-index:1; display:none; min-height:100vh; flex-direction:column;}
body.is-authed .app-shell{display:flex;}

.app-nav{
  position:sticky; top:0; z-index:20;
  display:flex; align-items:center; justify-content:space-between;
  padding:14px 22px;
  background:rgba(5,10,18,.75);
  backdrop-filter:blur(10px);
  border-bottom:1px solid var(--border-soft);
}
.app-nav-right{display:flex; align-items:center; gap:10px;}
.whoami{font-size:13px; color:var(--text-dim); margin-right:4px;}

.app-main{
  flex:1; width:100%; max-width:960px; margin:0 auto;
  padding:28px 22px 60px;
}
.panel-head{
  display:flex; align-items:flex-end; justify-content:space-between; gap:14px;
  margin-bottom:20px; flex-wrap:wrap;
}
.panel-head h2{font-size:24px; margin-top:6px;}

.stats-row{
  display:grid; grid-template-columns:repeat(4,1fr); gap:10px; margin-bottom:18px;
}
.stat-card{
  background:var(--surface-2); border:1px solid var(--border-soft);
  border-radius:var(--radius-md); padding:14px 14px;
  animation:cardIn .4s var(--ease) both;
}
.stat-card b{display:block; font-family:var(--font-display); font-size:22px;}
.stat-card span{font-size:11.5px; color:var(--text-dim); font-weight:600;}
.stat-card.stat-active b{color:var(--cyan);}
.stat-card.stat-last_day b{color:var(--amber);}
.stat-card.stat-expired b{color:var(--red);}
.stat-card.stat-unlimited b{color:var(--purple);}

.search-row{
  display:flex; gap:10px; margin-bottom:18px; flex-wrap:wrap;
}
.search-row input[type="search"]{
  flex:1; min-width:200px;
  background:var(--surface); border:1px solid var(--border);
  border-radius:var(--radius-sm); color:var(--text);
  padding:11px 14px; font-size:14px; outline:none;
  transition:border-color .15s, box-shadow .15s;
}
.search-row input[type="search"]:focus{border-color:var(--blue); box-shadow:0 0 0 3px rgba(61,156,255,.18);}
.filter-chips{display:flex; gap:8px; flex-wrap:wrap;}
.chip{
  border:1px solid var(--border); background:var(--surface-2); color:var(--text-dim);
  border-radius:999px; padding:9px 14px; font-size:12.5px; font-weight:600;
  transition:all .15s var(--ease); white-space:nowrap;
}
.chip:hover{color:var(--text); border-color:#2c4a68;}
.chip.is-active{background:var(--blue-soft); border-color:var(--blue); color:#cfe6ff;}

.sub-list{display:flex; flex-direction:column; gap:10px;}
.sub-card{
  display:flex; align-items:center; gap:14px;
  background:var(--surface-2); border:1px solid var(--border-soft);
  border-radius:var(--radius-md); padding:14px 16px;
  animation:rowIn .35s var(--ease) both;
  transition:border-color .18s, transform .18s;
}
.sub-card:hover{border-color:#2c4a68; transform:translateY(-1px);}
@keyframes rowIn{
  from{opacity:0; transform:translateY(8px);}
  to{opacity:1; transform:translateY(0);}
}
.sub-dot{width:9px; height:9px; border-radius:50%; flex:0 0 auto;}
.sub-dot.st-active{background:var(--cyan); box-shadow:0 0 10px 1px rgba(53,217,200,.6);}
.sub-dot.st-last_day{background:var(--amber); box-shadow:0 0 10px 1px rgba(255,176,32,.6); animation:pulse 1.4s ease-in-out infinite;}
.sub-dot.st-expired{background:var(--red);}
.sub-dot.st-unlimited{background:var(--purple); box-shadow:0 0 10px 1px rgba(180,142,255,.6);}
.sub-dot.st-invalid{background:#4d5c6d;}
@keyframes pulse{
  0%,100%{transform:scale(1); opacity:1;}
  50%{transform:scale(1.35); opacity:.6;}
}
.sub-main{flex:1; min-width:0;}
.sub-name{font-weight:600; font-size:14.5px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.sub-meta{font-size:12.5px; color:var(--text-dim); margin-top:2px;}
.sub-badge{
  font-size:11px; font-weight:700; letter-spacing:.02em;
  border-radius:999px; padding:5px 11px; white-space:nowrap;
}
.sub-badge.st-active{background:#0e2b28; color:var(--cyan); border:1px solid #1c5a52;}
.sub-badge.st-last_day{background:var(--amber-soft); color:var(--amber); border:1px solid #6a4c14;}
.sub-badge.st-expired{background:var(--red-soft); color:#ff8b96; border:1px solid #6a2530;}
.sub-badge.st-unlimited{background:var(--purple-soft); color:var(--purple); border:1px solid #4a3878;}
.sub-badge.st-invalid{background:#161f29; color:#7b8fa3; border:1px solid #2a3644;}
.sub-actions{display:flex; gap:6px;}

/* promo codes */
.promo-badge{
  font-size:11px; font-weight:700; letter-spacing:.02em;
  border-radius:999px; padding:5px 11px; white-space:nowrap;
  background:var(--purple-soft); color:var(--purple); border:1px solid #4a3878;
}
.promo-card.is-exhausted{opacity:.55;}

.loading-state{
  display:flex; align-items:center; gap:10px; justify-content:center;
  padding:50px 0; color:var(--text-dim); font-size:13.5px;
}
.loading-state[hidden]{display:none;}
.empty-state{text-align:center; padding:50px 20px; color:var(--text-dim);}
.empty-icon{font-size:30px; color:var(--blue); margin-bottom:8px;}
.empty-state p{font-weight:600; color:var(--text); font-size:15px;}
.empty-state span{font-size:13px;}

/* ============================================================ */
/*  MODALS / OVERLAY                                             */
/* ============================================================ */
.overlay{
  position:fixed; inset:0; z-index:50;
  background:rgba(3,6,10,.6);
  backdrop-filter:blur(3px);
  display:flex; align-items:center; justify-content:center;
  padding:20px;
  animation:fadeIn .18s ease;
}
.overlay[hidden]{display:none;}
@keyframes fadeIn{from{opacity:0;} to{opacity:1;}}
.modal{
  width:100%; max-width:440px;
  background:linear-gradient(180deg, rgba(14,21,31,.98), rgba(9,14,21,.98));
  border:1px solid var(--border);
  border-radius:var(--radius-lg);
  padding:22px 22px 24px;
  box-shadow:0 30px 80px -20px rgba(0,0,0,.8);
  animation:modalIn .28s var(--ease);
  max-height:88vh; overflow-y:auto;
}
.modal-sm{max-width:380px;}
@keyframes modalIn{
  from{opacity:0; transform:translateY(14px) scale(.97);}
  to{opacity:1; transform:translateY(0) scale(1);}
}
.modal-head{
  display:flex; align-items:center; justify-content:space-between;
  margin-bottom:16px;
}
.modal-head h3{font-size:17px;}
.modal-actions{display:flex; justify-content:flex-end; gap:10px; margin-top:6px;}
.confirm-text{color:var(--text-dim); font-size:14px; line-height:1.5; margin-bottom:20px;}
.confirm-text b{color:var(--text);}

.quick-dates{display:flex; gap:8px; flex-wrap:wrap; margin:-6px 0 18px;}
.quick-dates button{
  border:1px solid var(--border); background:var(--surface); color:var(--text-dim);
  border-radius:999px; padding:7px 12px; font-size:12px; font-weight:600;
  transition:all .15s var(--ease);
}
.quick-dates button:hover{border-color:var(--blue); color:#cfe6ff; background:var(--blue-soft);}

/* settings side panel */
#settingsOverlay{justify-content:flex-end; padding:0;}
.side-panel{
  width:100%; max-width:400px; height:100%;
  background:linear-gradient(180deg, rgba(14,21,31,.98), rgba(9,14,21,.98));
  border-left:1px solid var(--border);
  padding:22px 22px 30px;
  overflow-y:auto;
  animation:panelIn .3s var(--ease);
  box-shadow:-30px 0 80px -30px rgba(0,0,0,.8);
}
@keyframes panelIn{
  from{opacity:0; transform:translateX(24px);}
  to{opacity:1; transform:translateX(0);}
}
.settings-section{margin-bottom:26px; padding-bottom:22px; border-bottom:1px solid var(--border-soft);}
.settings-section:last-child{border-bottom:none;}
.settings-label{font-size:12px; font-weight:700; letter-spacing:.04em; color:var(--text-dim); margin-bottom:12px;}
.settings-hint{font-size:12.5px; color:var(--text-dim); margin:-4px 0 14px; line-height:1.5;}
.account-row{display:flex; align-items:center; gap:12px;}
.account-avatar{
  width:38px; height:38px; border-radius:10px;
  background:linear-gradient(135deg, var(--blue), var(--cyan));
  display:flex; align-items:center; justify-content:center;
  font-weight:700; color:#04121c; font-family:var(--font-display); font-size:15px;
}

/* ============================================================ */
/*  TOASTS                                                       */
/* ============================================================ */
.toast-stack{
  position:fixed; bottom:20px; right:20px; z-index:80;
  display:flex; flex-direction:column; gap:10px; max-width:340px;
}
.toast{
  background:var(--surface-2); border:1px solid var(--border);
  border-left:3px solid var(--blue);
  border-radius:var(--radius-sm); padding:12px 14px;
  font-size:13.5px; color:var(--text);
  box-shadow:0 14px 40px -14px rgba(0,0,0,.7);
  animation:toastIn .25s var(--ease);
}
.toast.toast-ok{border-left-color:var(--cyan);}
.toast.toast-error{border-left-color:var(--red);}
.toast.toast-out{animation:toastOut .2s var(--ease) forwards;}
@keyframes toastIn{from{opacity:0; transform:translateX(20px);} to{opacity:1; transform:translateX(0);}}
@keyframes toastOut{to{opacity:0; transform:translateX(20px);}}

/* ============================================================ */
/*  RESPONSIVE                                                   */
/* ============================================================ */
@media (max-width:640px){
  .app-nav{padding:12px 14px;}
  .brand{font-size:14px;}
  .brand em{display:none;}
  .whoami{display:none;}
  .app-main{padding:20px 14px 50px;}
  .panel-head h2{font-size:20px;}
  .stats-row{grid-template-columns:repeat(2,1fr);}
  .sub-card{flex-wrap:wrap; padding:13px 14px;}
  .sub-main{width:100%; order:1;}
  .sub-dot{order:0;}
  .sub-badge{order:2;}
  .sub-actions{order:3; margin-left:auto;}
  .side-panel{max-width:100%;}
  .modal{padding:18px 16px 20px; border-radius:16px;}
  .login-card{padding:26px 20px 22px;}
}

@media (max-width:400px){
  .stats-row{grid-template-columns:1fr 1fr;}
  .filter-chips{width:100%; overflow-x:auto; padding-bottom:2px;}
}
