:root{
  --primary:#4972F3;
  --accent:#D925D2;
  --bg:#0b0f1a;
  --panel:rgba(18,22,35,0.7);
  --panel-strong:rgba(18,22,35,0.9);
  --text:#e8ebf2;
  --muted:#a9b0c3;
  --success:#35c759;
  --warning:#ffcc00;
  --danger:#ff3b30;
  /* Base header height (desktop & default) */
  --header-base-h: 72px;
  /* Main container padding */
  --main-padding: 16px;
}
*{box-sizing:border-box}
html,body{height:100%}
html, body{
  overflow: hidden; /* lock page scroll; use .main as scroll container */
  overscroll-behavior: none; /* prevent rubber-band bounce */
}
html{ background-color: var(--bg); }
/* On iOS, use 100vh to cover entire viewport including safe areas */
@supports (padding: env(safe-area-inset-top)) {
  html, body{
    height: 100vh;
  }
}
body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Arial, "Apple Color Emoji","Segoe UI Emoji";
  color:var(--text);
  background-color: var(--bg);
  background:
    radial-gradient(1400px 800px at 10% -10%, rgba(73,114,243,0.28), rgba(0,0,0,0) 60%),
    radial-gradient(1200px 720px at 110% 0%, rgba(217,37,210,0.22), rgba(0,0,0,0) 60%),
    linear-gradient(180deg, #0b0f1a 0%, #0a0e18 100%);
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
}
/* iOS PWA translucent status bar blur overlay (content flows underneath) */
@supports (padding: env(safe-area-inset-top)) {
  .statusbar{
    position: fixed;
    left: 0; right: 0;
    /* Pull the overlay up to cover the system status bar area */
    top: calc(-1 * env(safe-area-inset-top));
    /* Make it tall enough so the blur bleeds below the notch */
    height: calc(env(safe-area-inset-top) + 32px);
    overflow: hidden;
    z-index: 1000; /* above header */
    pointer-events: none;
  }
  .statusbar::before{
    content: "";
    position: absolute;
    left: 0; right: 0; top: 0; bottom: -40%;
    /* Match our header glass look */
    /* backdrop-filter: blur(10px) saturate(140%);
    -webkit-backdrop-filter: blur(10px) saturate(140%); */
    /* background: linear-gradient(180deg, rgba(190, 21, 21, 0), rgba(255,255,255,0.06)); */
  }
}

.app{
  display:grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: var(--header-base-h) 1fr;
  grid-template-areas:
    "header header"
    "sidebar main";
  height:100%;
}
@supports (padding: env(safe-area-inset-top)) {
  .app{
    /* Grid rows adjusted for iOS safe area at top */
    grid-template-rows: calc(var(--header-base-h) + env(safe-area-inset-top)) 1fr;
  }
  .header{
    padding-top: calc(env(safe-area-inset-top)); /* keep visual header below notch */
  }
}
.header{
  grid-area:header;
  position:relative;
  display:flex;
  align-items:center;
  z-index: 100; /* ensure header stays above subpage media */

  justify-content:center;
  padding:0 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
  backdrop-filter: blur(10px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.35);
  border-bottom-right-radius: 18px;
  border-bottom-left-radius: 0;
  overflow:hidden;
}
.header::before{
  content:"";position:absolute;inset:0;pointer-events:none;
  background:
    radial-gradient(260px 180px at var(--mx, 50%) var(--my, 0%), rgba(255,255,255,0.20), rgba(255,255,255,0) 60%),
    linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0));
  border-bottom-right-radius: 18px;
  border-bottom-left-radius: 0;
}
.header .left, .header .right{position:absolute;top:0;height:100%;display:flex;align-items:center;padding:0 12px}
.header .left{left:0}
.header .right{right:0;gap:10px}
.header .brand{display:flex;align-items:center;gap:12px; min-width: 0}
.header .brand img{height:34px;width:34px;filter:drop-shadow(0 0 18px rgba(73,114,243,0.55))}
.header .brand .title{font-weight:800;letter-spacing:.3px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis}
/* Hide only the brand name when space is tight; keep subpage title visible */
.header.fit-hide-brandname #brand-title{display:none}
.header.fit-hide-logo .brand img{display:none}
.header .status{display:flex;align-items:center;gap:10px}
.badge{padding:6px 10px;border-radius:999px;font-size:12px;color:#fff}
.badge.online{background:linear-gradient(135deg,var(--primary),#6a8dfa)}
.badge.offline{background:linear-gradient(135deg,#5a6175,#3a3f51)}
.icon-btn{background:transparent;border:none;color:var(--text);cursor:pointer;font-size:20px;padding:10px;border-radius:10px}
.icon-btn:hover{background:rgba(255,255,255,0.06)}
.notif-bell-btn{position:relative;display:flex;align-items:center;justify-content:center}
.notif-bell-btn svg{width:22px;height:22px}
.notif-badge{position:absolute;top:4px;right:2px;min-width:18px;height:18px;padding:0 5px;border-radius:999px;background:var(--danger);color:#fff;font-size:11px;font-weight:700;display:flex;align-items:center;justify-content:center;line-height:1;pointer-events:none;box-shadow:0 2px 6px rgba(255,59,48,0.4)}
.push-prompt-overlay{position:fixed;inset:0;z-index:10000;display:flex;align-items:center;justify-content:center;background:rgba(0,0,0,0.5);backdrop-filter:blur(4px);opacity:0;transition:opacity .2s ease}
.push-prompt-overlay.visible{opacity:1}
.push-prompt-card{background:linear-gradient(180deg,rgba(18,22,35,0.97),rgba(14,17,28,0.99));border:1px solid rgba(255,255,255,0.10);border-radius:18px;padding:28px 24px;max-width:340px;width:90%;text-align:center;box-shadow:0 20px 60px rgba(0,0,0,0.5)}
.push-prompt-icon{margin-bottom:12px;color:var(--primary)}.push-prompt-icon svg{width:32px;height:32px}
.push-prompt-title{font-size:17px;font-weight:700;color:var(--text);margin-bottom:6px}
.push-prompt-text{font-size:13px;color:var(--muted);margin-bottom:20px;line-height:1.4}
.push-prompt-actions{display:flex;gap:10px;justify-content:center}

.sidebar{
  grid-area:sidebar;
  backdrop-filter: blur(14px);
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
  z-index: 60; /* ensure sidebar stays above subpage media on desktop */

  padding:10px;
  display:flex;
  flex-direction:column;
  gap:6px;
  border-top-right-radius: 0;
  border-bottom-left-radius: 18px;
  border-bottom-right-radius: 18px;
  position:relative;
  overflow:hidden;
}
.sidebar::before{
  content:"";position:absolute;inset:0;pointer-events:none;
  background:
    radial-gradient(240px 160px at var(--mx, 20%) var(--my, 0%), rgba(255,255,255,0.18), rgba(255,255,255,0) 60%);
}
.nav-btn{
  width:100%;
  display:flex;
  align-items:center;
  gap:10px;
  padding:12px 14px;
  background:transparent;
  border:none;
  border-radius:12px;
  color:var(--text);
  text-align:left;
  cursor:pointer;
  transition: all .2s ease;
}
.nav-btn:hover{background:linear-gradient(90deg, rgba(73,114,243,0.18), rgba(217,37,210,0.18))}
.nav-btn.active{background:linear-gradient(90deg, rgba(73,114,243,0.35), rgba(217,37,210,0.32))}
.nav-btn .icon{font-size:22px}
.nav-sep{height:8px}
.nav-bottom{margin-top:auto}

.main{
  grid-area:main;
  padding: var(--main-padding);
  overflow:auto; /* the only scrollable region */
  overscroll-behavior: contain; /* prevent viewport bounce */
  -webkit-overflow-scrolling: touch; /* smooth iOS scroll */
  position: relative; /* create a stacking context beneath header/sidebar */
  z-index: 0;
  /* iOS safe area handled via @supports rule above */
}
.card{
  padding:16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.03));
  border-radius:16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}

/* Reusable content card - subtle glass panel for sections/groups */
.content-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  transition: all 0.2s ease;
}
.content-card:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.12);
}
.content-card--gradient {
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
}
.content-card--primary {
  background: linear-gradient(180deg, rgba(73, 114, 243, 0.08), rgba(73, 114, 243, 0.04));
  border-color: rgba(73, 114, 243, 0.2);
}
.content-card--no-hover:hover {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.08);
}

.btn{
  padding:10px 14px;
  border-radius:10px;
  border:none;
  background: linear-gradient(135deg, rgba(73,114,243,0.40), rgba(217,37,210,0.36));
  color:var(--text);
  cursor:pointer;
}
.btn.primary{background: linear-gradient(135deg, var(--primary), #6a8dfa); }
.btn.danger{background: linear-gradient(135deg, var(--danger), #ff6b62);} 
.btn.ghost{background:rgba(255,255,255,0.06)}
.btn:disabled, .btn[disabled]{
  cursor: not-allowed;
  opacity: 0.75;
}
.btn.primary:disabled,
.btn.primary[disabled]{
  /* remove accent gradient when disabled */
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.12);
}
.input{
  padding:10px 12px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  outline:none;
  color:var(--text);
  max-width: 100%;
}
.input::placeholder{color:rgba(232,235,242,0.55)}
select.input{appearance:none;background-image:linear-gradient(45deg, transparent 50%, rgba(232,235,242,0.8) 50%), linear-gradient(135deg, rgba(232,235,242,0.8) 50%, transparent 50%);background-position:calc(100% - 18px) calc(50% - 4px), calc(100% - 12px) calc(50% - 4px);background-size:6px 6px, 6px 6px;background-repeat:no-repeat;padding-right: 32px;}
.select-dark{background: rgba(255,255,255,0.08) !important; color: var(--text) !important; border-color: rgba(255,255,255,0.14) !important;}
.select-dark option{background:#131a2a; color: var(--text);} /* Chromium/Firefox */
.select-dark optgroup{background:#131a2a; color: var(--text);}
.select-dark option:hover{background:#1a2336; color: var(--text);} /* best-effort */
@supports (color-scheme: dark){
  .select-dark{color-scheme: dark;}
}
.label{color:var(--muted);font-size:13px}
.form-row{display:flex;flex-direction:column;gap:8px;margin-bottom:12px}

.toast-stack{position:fixed; top:calc(var(--header-base-h) + 16px); right:16px; display:flex; flex-direction:column; gap:10px; z-index: 10001; pointer-events:none;}
.toast{
  position:relative; min-width:220px; max-width: min(92vw, 380px);
  color:var(--text); border-radius:14px; pointer-events:auto; cursor: default;
  background: linear-gradient(180deg, rgba(255,255,255,0.12), rgba(255,255,255,0.06));
  border:1px solid rgba(255,255,255,0.12);
  box-shadow: 0 8px 22px rgba(0,0,0,0.28);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  transform: perspective(800px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateZ(0);
  transform-origin: center;
  transition: transform .18s ease, filter .18s ease, opacity .18s ease;
  animation: toast-in .36s cubic-bezier(.2,.9,.2,1) both;
}
.toast.hide{animation: toast-out .42s cubic-bezier(.2,.8,.2,1) both;}
.toast::before{
  content:""; position:absolute; inset:0; border-radius:14px; pointer-events:none;
  background:
    radial-gradient(280px 180px at var(--mx, 60%) var(--my, 0%), rgba(255,255,255,0.20), rgba(255,255,255,0) 60%),
    linear-gradient(180deg, rgba(255,255,255,0.18), rgba(255,255,255,0.04));
  opacity:0.65;
  z-index: 0;
}
.toast::after{content:""; position:absolute; inset:0; border-radius:14px; pointer-events:none; opacity:0.0; transition:opacity .18s ease;}
.toast[data-color="success"]::after{background: linear-gradient(180deg, rgba(53,199,89,0.18), rgba(53,199,89,0.10)); opacity:1;}
.toast[data-color="warning"]::after{background: linear-gradient(180deg, rgba(255,204,0,0.20), rgba(255,204,0,0.12)); opacity:1;}
.toast[data-color="danger"]::after{background: linear-gradient(180deg, rgba(255,59,48,0.18), rgba(255,59,48,0.10)); opacity:1;}
.toast[data-color="info"]::after{background: linear-gradient(180deg, rgba(73,114,243,0.20), rgba(73,114,243,0.12)); opacity:1;}

/* Hover high-sensitivity reflection and border whitening (reusable) */
.toast-hoverfx, .glass-hoverfx{position:absolute; inset:0; border-radius:14px; pointer-events:none; opacity:0; transition: opacity .2s ease; z-index:2;
  /* main highlight spot (slightly stronger and narrower) */
  background: radial-gradient(120px 80px at var(--hx, 50%) var(--hy, 50%), rgba(255,255,255,0.30), rgba(255,255,255,0.12) 55%, rgba(255,255,255,0.0) 72%);
}
.toast-hoverfx::before, .glass-hoverfx::before{content:""; position:absolute; inset:0; border-radius:14px; pointer-events:none;
  /* edge-only whitening using mask to keep only a thin ring */
  padding:2px; 
  background: radial-gradient(140px 90px at var(--hx, 50%) var(--hy, 50%), rgba(255,255,255,0.65), rgba(255,255,255,0.0) 60%);
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
}
.toast.hovering .toast-hoverfx, .hovering.dynamic-reflection-hover .glass-hoverfx, .hovering.dynamic-reflection-borders-hover .glass-hoverfx, .hovering.dynamic-reflection-borders-only .glass-hoverfx{opacity:1;}

/* Only show the border whitening ring when borders-hover class is present */
.glass-hoverfx::before{opacity:0}
.dynamic-reflection-borders-hover.hovering .glass-hoverfx::before{opacity:1}
.dynamic-reflection-borders-only.hovering .glass-hoverfx::before{opacity:1}
.toast-inner{display:flex; align-items:flex-start; gap:10px; padding:12px 14px;}
.toast-content{flex:1; min-width:0;}
.toast-close{appearance:none; border:none; background:transparent; color:var(--text); height:28px; width:28px; border-radius:8px; cursor:pointer}
.toast-close:hover{background:rgba(255,255,255,0.16)}
.toast{ border-color: rgba(255,255,255,0.12); box-shadow: 0 8px 22px rgba(0,0,0,0.28); }
.toast-inner{position:relative; z-index:3}
@keyframes toast-in{
  0%{ opacity:0; transform: perspective(800px) translate3d(0,-10px,0) rotateY(-4deg); }
  100%{ opacity:1; transform: perspective(800px) translate3d(0,0,0) rotateY(var(--ry,0deg)); }
}
@keyframes toast-out{
  0%{ opacity:1; transform: perspective(800px) translate3d(0,0,0) rotateY(var(--ry,0deg)); }
  100%{ opacity:0; transform: perspective(800px) translate3d(0,-12px,-8px) rotateY(4deg); }
}

/* ===== Dynamic Liquid Glass – Generic Utilities ===== */
/* Soft 3D rotation driven by --ry (provided by ui.glassMotion or custom) */
.dynamic-rotation-soft{
  transform: perspective(800px) rotateY(var(--ry, 0deg));
  transform-origin: center;
  transition: transform .18s ease;
}

/* Soft global reflection driven by --mx/--my (viewport-based) */
.glass-dyn, .dynamic-reflection-soft{ position:relative; }
.glass-dyn::before, .dynamic-reflection-soft::before{
  content:""; position:absolute; inset:0; pointer-events:none; border-radius:inherit; z-index:0;
  background:
    radial-gradient(260px 160px at var(--mx, 60%) var(--my, 0%), rgba(255,255,255,0.18), rgba(255,255,255,0) 60%),
    linear-gradient(180deg, rgba(255,255,255,0.12), rgba(255,255,255,0.02));
  opacity:0.55;
}

/* Hover reflection uses .glass-hoverfx overlay created by ui.glassMotion.attach */
.dynamic-reflection-hover{ position:relative; }

/* Borders-only variant: whitening ring without the central spot */
.dynamic-reflection-borders-only{ position:relative; }
.dynamic-reflection-borders-only .glass-hoverfx{ background:none !important; }

.login-wrapper{height:100dvh;display:flex;align-items:center;justify-content:center;padding:16px}
.login{
  width:100%;max-width:420px;
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.04));
  border:1px solid rgba(255,255,255,0.08);
  border-radius:16px;
  padding:20px;
}
.login h1{margin-top:0}

/* Drawer and overlay for mobile */
.scrim{position:fixed;inset:0;background:rgba(0,0,0,0.45);backdrop-filter:blur(2px);opacity:0;pointer-events:none;transition:opacity .2s ease}
.scrim.show{opacity:1;pointer-events:auto}

/* Generic Modal (liquid glass, dark) */
.modal{position:fixed; z-index: 2100; left:50%; top:50%; transform: translate(-50%, -50%);
  width: min(92vw, 720px); max-height: 86vh; display:flex; flex-direction:column;
  background: linear-gradient(180deg, rgba(255,255,255,0.12), rgba(255,255,255,0.06));
  border:1px solid rgba(255,255,255,0.12); border-radius:16px; box-shadow: 0 12px 36px rgba(0,0,0,0.45);
  backdrop-filter: blur(12px) saturate(120%);
}
.modal .modal-head{display:flex; align-items:center; gap:10px; padding:12px 14px; border-bottom:1px solid rgba(255,255,255,0.10)}
.modal .modal-head h3{margin:0; flex:1}
.modal .modal-body{padding:12px 14px; overflow:auto}
.modal .modal-foot{display:flex; align-items:center; gap:10px; padding:12px 14px; border-top:1px solid rgba(255,255,255,0.10)}
.modal .modal-foot .spacer{flex:1}

/* Simple alert box for modal errors */
.alert{padding:10px 12px; border-radius:12px; border:1px solid rgba(255,255,255,0.12); background:rgba(255,59,48,0.10); color:var(--text); margin-bottom:10px}
.alert .title{font-weight:700; color:#ffd3d0; margin-bottom:6px}

/* Hide burger and scrim on desktop */
@media (min-width: 921px){
  #menu-btn{display:none}
  .scrim{display:none!important}
}

@media (max-width: 768px) {
  .app{
    grid-template-areas:
      "header header"
      "main main";
    grid-template-columns: 1fr;
    grid-template-rows: var(--header-base-h) 1fr;
  }
  .sidebar{display:none}
}

/* iOS mobile: increase header height and anchor its content to bottom */
@supports (padding: env(safe-area-inset-top)) {
  @media (max-width: 920px){
    :root{ --header-base-h: 104px; }
    .header{ align-items: flex-end; padding-bottom: 8px; }
    /* Anchor side controls at a consistent bottom baseline */
    .header .left, .header .right{
      align-items: center;
      padding-bottom: 0;
      top: auto;
      bottom: 8px;
      height: auto;
    }
    /* Ensure brand text aligns with brand image and baseline with side controls */
    .header .brand{ align-items: center; position: relative; bottom: 8px; }
    .header .brand img{ display:block; }
    .header .brand .title{ line-height: 1; }
  }
}

.muted{color:var(--muted);font-weight:400}

.progress{height:8px;background:rgba(255,255,255,0.06);border:1px solid rgba(255,255,255,0.08);border-radius:999px;overflow:hidden;margin-top:6px}
.progress .bar{height:100%;background:linear-gradient(90deg, var(--primary), var(--accent))}

/* Shared progress row utilities */
.progress-row{
  display:flex;
  align-items:center;
  gap:8px;
  width:100%;
}

.progress-row.progress-row--wide{
  gap:12px;
}

.progress-track{
  flex:1;
  height:var(--progress-height, 6px);
  background:rgba(255,255,255,0.10);
  border-radius:999px;
  overflow:hidden;
}

.progress-fill{
  height:100%;
  background:linear-gradient(90deg, var(--primary), var(--accent));
  border-radius:inherit;
  transition:width 0.3s ease;
}

.progress-label{
  font-size:11px;
  font-weight:600;
  color:var(--muted);
  font-family:'Courier New', monospace;
  white-space:nowrap;
  text-align:right;
}

.progress-label.progress-label--strong{
  font-size:12px;
  color:rgba(255,255,255,0.85);
}

.badge{padding:6px 10px;border-radius:999px;font-size:12px;color:#fff;background:linear-gradient(135deg, var(--primary), #6a8dfa)}
.badge.tiny{padding:4px 8px;font-size:11px}
.badge.warn{background:linear-gradient(135deg, var(--warning), #ffda4d);color:#000}

/* Payment state badges */
.badge.payment-state{font-weight:600;font-size:11px;padding:4px 10px;text-transform:uppercase;letter-spacing:0.3px}
.badge.payment-state-0{background:rgba(255,255,255,0.08);color:var(--muted);border:1px solid rgba(255,255,255,0.12)}
.badge.payment-state-1{background:#6ac3ff;color:#041016;border:1px solid rgba(106,195,255,0.55)}
.badge.payment-state-2{background:#ff3b30;color:#fff;border:1px solid rgba(255,59,48,0.55)}
.badge.payment-state-3{background:#ffa726;color:#1a0800;border:1px solid rgba(255,167,38,0.55)}
.badge.payment-state-4{background:#35c759;color:#041409;border:1px solid rgba(53,199,89,0.55)}
.badge.payment-state-5{background:#5a6175;color:#e8ebf2;border:1px solid rgba(90,97,117,0.55)}

/* Payments grid */
.payments-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:12px;padding:8px 0}
.payment-card{background:rgba(255,255,255,0.04);border:1px solid rgba(255,255,255,0.08);border-radius:12px;padding:14px;transition:all 0.2s ease}
.payment-card:hover{background:rgba(255,255,255,0.06);border-color:rgba(255,255,255,0.12);transform:translateY(-2px)}
.payment-card-header{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:10px}
.payment-card-price{font-size:18px;font-weight:700;color:var(--text);letter-spacing:-0.3px}
.payment-card-title{font-size:13px;color:var(--text);margin-bottom:8px;line-height:1.4;overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical}
.payment-card-date{font-size:12px;color:var(--muted);margin-top:auto}

.tags{display:flex;flex-wrap:wrap;gap:6px}
.tag{display:inline-flex;align-items:center;gap:6px;padding:6px 10px;background:rgba(255,255,255,0.06);border:1px solid rgba(255,255,255,0.10);border-radius:999px;font-size:13px;color:var(--text)}
.chip{display:inline-flex;align-items:center;gap:6px;padding:6px 10px;background:rgba(255,255,255,0.06);border:1px solid rgba(255,255,255,0.10);border-radius:999px;font-size:13px;color:var(--text)}
.chip .mini{width:18px;height:18px;border-radius:999px;border:1px solid rgba(255,255,255,0.15);background:rgba(255,255,255,0.08);color:var(--text);cursor:pointer;font-size:14px;display:grid;place-items:center;padding:0;line-height:1}
.chip .mini:hover{background:rgba(255,50,50,0.25);border-color:rgba(255,50,50,0.40)}

.hidden{display:none}

.actions{display:flex;gap:8px;}
.actions.split{display:flex;justify-content:space-between;align-items:center}
.actions.split .left{display:flex;gap:8px}
.actions.split .right{display:flex;gap:8px}

.kv-list{display:flex;flex-direction:column;gap:16px}
.kv-row{display:grid;grid-template-columns:1fr 2fr;gap:12px;align-items:center}
.kv-row.full{grid-template-columns:1fr}
.kv-name{font-size:14px;color:var(--muted);font-weight:500}
.kv-value{display:flex;flex-direction:column;gap:8px}

/* Subpages (full replacement inside main) */
.subpage-root{height:100%; display:flex; flex-direction:column}
/* .subpage-root > .gv-root moved to the GalleryViewer stylesheet */

/* Subtle scrollbars (targeted) */
:where(
  .strategy-view-main,
  .strategy-view-panel,
  .strategy-view-panel .panel-content,
  .rule-editor-content,
  .achievement-editor-content,
  .custom-enum-editor-content
){
  scrollbar-width: thin;
  scrollbar-color: rgba(232, 235, 242, 0.14) transparent;
}

:where(
  .strategy-view-main,
  .strategy-view-panel,
  .strategy-view-panel .panel-content,
  .rule-editor-content,
  .achievement-editor-content,
  .custom-enum-editor-content
)::-webkit-scrollbar{
  width: 6px;
  height: 6px;
}

:where(
  .strategy-view-main,
  .strategy-view-panel,
  .strategy-view-panel .panel-content,
  .rule-editor-content,
  .achievement-editor-content,
  .custom-enum-editor-content
)::-webkit-scrollbar-track{
  background: transparent;
}

:where(
  .strategy-view-main,
  .strategy-view-panel,
  .strategy-view-panel .panel-content,
  .rule-editor-content,
  .achievement-editor-content,
  .custom-enum-editor-content
)::-webkit-scrollbar-thumb{
  background: rgba(232, 235, 242, 0.14);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
}

:where(
  .strategy-view-main,
  .strategy-view-panel,
  .strategy-view-panel .panel-content,
  .rule-editor-content,
  .achievement-editor-content,
  .custom-enum-editor-content
)::-webkit-scrollbar-thumb:hover{
  background: rgba(232, 235, 242, 0.22);
  background-clip: content-box;
}

/* Scroll and highlight utility */
.hl-target{position:relative}
.hl-flash{position:absolute;inset:-2px;border-radius:16px;pointer-events:none;}
.hl-flash::before{content:"";position:absolute;inset:0;border-radius:16px;padding:2px;background:linear-gradient(120deg, rgba(73,114,243,0.7), rgba(217,37,210,0.7), rgba(73,114,243,0.7)); -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; animation: hl-move 1.2s linear infinite; opacity:0.85}
@keyframes hl-move{0%{background-position:0% 50%}100%{background-position:200% 50%}}

/* Dataset state tag (mini lists in Content Factory) */
.mini-row .mini-name{display:flex; align-items:center; gap:6px; min-width:0}
.ds-state{display:inline-block; padding:2px 8px; border-radius:999px; font-size:11px; line-height:1.6; border:1px solid rgba(255,255,255,0.10); white-space:nowrap}
/* Color variants per state */
.ds-state.ds-empty{background:rgba(255,255,255,0.06); color:var(--muted)}
.ds-state.ds-creating{background:linear-gradient(135deg, #8a6df3, #a58ef8); color:#0a0e18; border-color: rgba(165,142,248,0.55)}
.ds-state.ds-ready{background:linear-gradient(135deg, #6ac3ff, #69f3e0); color:#041016; border-color: rgba(106,195,255,0.55)}
.ds-state.ds-processing{background:linear-gradient(135deg, var(--primary), #6a8dfa); color:#fff; border-color: rgba(73,114,243,0.55)}
.ds-state.ds-processed{background:linear-gradient(135deg, #ffd37a, #ffcc00); color:#2a2200; border-color: rgba(255,204,0,0.55)}
.ds-state.ds-filtering{background:linear-gradient(135deg, #ff9db0, #ff6b81); color:#2a0008; border-color: rgba(255,107,129,0.55)}
.ds-state.ds-filtered{background:linear-gradient(135deg, var(--success), #57d179); color:#041409; border-color: rgba(53,199,89,0.55)}
.ds-state.ds-unknown{background:rgba(255,255,255,0.06); color:#fff}

/* Make textareas resizable */
textarea.input{resize: both; min-height: 42px;}


/* Tooltips are now handled by Tippy.js - see js/utils/tooltip.js */

/* Reusable round button (neutral/glassy) with Content Factory-like hover */
.rbtn{height:36px;width:36px;border-radius:999px;border:1px solid rgba(255,255,255,0.10);background:rgba(255,255,255,0.06);color:var(--text);display:grid;place-items:center;cursor:pointer}
.rbtn:hover{background:linear-gradient(135deg, rgba(73,114,243,0.20), rgba(217,37,210,0.18)); filter:none}
.rbtn:disabled{opacity:0.6; cursor:not-allowed}
.rbtn:disabled:hover{background:rgba(255,255,255,0.06); filter:none}

/* Round button with text support */
.rbtn-text{display:inline-flex;align-items:center;gap:8px;padding:8px 14px;height:36px;border-radius:999px;border:1px solid rgba(255,255,255,0.10);background:rgba(255,255,255,0.06);color:var(--text);cursor:pointer;font-size:14px;font-weight:500;white-space:nowrap}
.rbtn-text:hover{background:linear-gradient(135deg, rgba(73,114,243,0.20), rgba(217,37,210,0.18)); filter:none}
.rbtn-text.primary{background:linear-gradient(135deg, var(--primary), #6a8dfa); color:#fff; border-color:transparent}
.rbtn-text.primary:hover{filter: brightness(1.1); box-shadow: 0 4px 12px rgba(73,114,243,0.4)}
.rbtn-text:disabled{opacity:0.6; cursor:not-allowed}
.rbtn-text:disabled:hover{background:rgba(255,255,255,0.06); filter:none}
.rbtn-text .icon{font-size:18px;display:flex;align-items:center}

/* Spinner animation */
@keyframes icon-spin{ from{ transform: rotate(0deg); } to{ transform: rotate(360deg); } }
.icon-spin{animation: icon-spin 0.8s linear infinite; transform-origin: center}

/* Liquid Glass Switch (two-segment) */
.glass-switch{
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0;
  padding: 4px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255,255,255,0.12), rgba(255,255,255,0.06));
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 8px 22px rgba(0,0,0,0.30);
  backdrop-filter: blur(10px) saturate(120%);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
}
.glass-switch .seg{
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text);
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 10px;
  position: relative;
  z-index: 2;
  cursor: pointer;
  transition: color .15s ease, filter .15s ease;
}
.glass-switch .seg.active{
  color: #fff;
  /* Optional subtle gradient text glow when active */
  text-shadow: 0 0 0 transparent, 0 0 16px rgba(73,114,243,0.55);
}
.glass-switch .seg:not(.active){
  color: rgba(232,235,242,0.75);
}
.glass-switch .thumb{
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: var(--thumb-left, 4px);
  width: var(--thumb-width, 50%);
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border: 1px solid rgba(255,255,255,0.20);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.14), 0 8px 18px rgba(0,0,0,0.35);
  transition: left .22s cubic-bezier(.2,.8,.2,1), width .22s cubic-bezier(.2,.8,.2,1), transform .12s ease;
  z-index: 1;
}
.glass-switch .seg:active ~ .thumb{ transform: scale(0.985); }

/* ===== Modal (Liquid Glass) ===== */
.modal-scrim{position:fixed;inset:0;background:rgba(0,0,0,0.45);backdrop-filter: blur(2px); display:flex;align-items:center;justify-content:center; z-index:1000}
.modal-scrim.show{opacity:1}
.modal-glass{
  width: min(840px, 94vw);
  max-height: 86vh;
  display:flex; flex-direction:column;
  background: linear-gradient(180deg, rgba(255,255,255,0.10), rgba(255,255,255,0.06));
  border:1px solid rgba(255,255,255,0.12);
  border-radius:16px;
  box-shadow: 0 18px 48px rgba(0,0,0,0.45);
  backdrop-filter: blur(12px) saturate(120%);
  -webkit-backdrop-filter: blur(12px) saturate(120%);
  overflow:hidden;
}
.modal-head{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:12px 14px;border-bottom:1px solid rgba(255,255,255,0.10);background:linear-gradient(180deg, rgba(255,255,255,0.12), rgba(255,255,255,0.06))}
.modal-head .title{font-weight:800}
.modal-body{padding:14px;overflow:auto}
.modal-foot{display:flex;align-items:center;gap:10px;padding:12px 14px;border-top:1px solid rgba(255,255,255,0.10);background:linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.03))}
.modal-foot .spacer{flex:1}

/* Searchable combobox pattern */
.combo-search{position:relative}
.combo-search .input{padding-right:36px}
.combo-list{
  position:relative;
  margin-top:8px;
  display:grid;
  grid-template-columns: 1fr;
  gap:6px;
  max-height: 36vh;
  overflow:auto;
  padding:6px;
  background: rgba(255,255,255,0.06);
  border:1px solid rgba(255,255,255,0.10);
  border-radius:10px;
}
.combo-item{
  display:flex;align-items:center;justify-content:space-between;
  gap:10px;
  padding:8px 10px;
  background: rgba(255,255,255,0.04);
  border:1px solid rgba(255,255,255,0.08);
  border-radius:10px;
  color:var(--text);
  cursor:pointer;
}
.combo-item:hover{background: linear-gradient(135deg, rgba(73,114,243,0.20), rgba(217,37,210,0.18))}
.combo-item.active{outline:2px solid rgba(73,114,243,0.55)}
.combo-list .empty{color:var(--muted); padding:10px}

@media (max-width: 600px){
  .modal-glass{width: 96vw; max-height: 88vh}
  .modal-body{padding:10px}
  .combo-list{max-height: 42vh}
}

/* ===== Collapsible Section Component (Reusable) ===== */
/* Generic collapsible card with smooth animations */
/* Used in: paymentEditor, and other forms requiring collapsible sections */

.collapsible-section {
  margin-bottom: 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  overflow: hidden;
  transition: all 0.2s ease;
}

.collapsible-section:hover {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
}

.collapsible-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.15s ease;
}

.collapsible-section-header:hover {
  background: rgba(255, 255, 255, 0.04);
}

.collapsible-section-header:active {
  background: rgba(255, 255, 255, 0.06);
}

.collapsible-section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.collapsible-section-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  opacity: 0.7;
}

.collapsible-section-icon svg {
  width: 20px;
  height: 20px;
}

.collapsible-section-chevron {
  transition: transform 0.25s ease;
  opacity: 0.5;
  flex-shrink: 0;
}

.collapsible-section.expanded .collapsible-section-chevron {
  transform: rotate(180deg);
}

.collapsible-section-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease, padding 0.35s ease;
}

.collapsible-section.expanded .collapsible-section-content {
  max-height: 2000px; /* Large enough for most content */
  padding: 0 16px 16px;
}

/* Badge for active filters/items count */
.collapsible-section-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 11px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 2px 6px rgba(73, 114, 243, 0.35);
  transition: all 0.2s ease;
  margin-left: 8px;
}

.collapsible-section:hover .collapsible-section-badge {
  box-shadow: 0 3px 8px rgba(73, 114, 243, 0.45);
  transform: scale(1.05);
}

/* Fix for Mobile Navigation (Restoring missing styles from PaymentEditor update) */
@media (max-width: 920px) {
  .sidebar.open {
    display: flex;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    width: 280px;
    z-index: 1200; /* Above header (100) and scrim (1100) */
    animation: drawer-enter 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    border-radius: 0 20px 20px 0;
    box-shadow: 0 0 50px rgba(0,0,0,0.6);
    /* Darker glass for better contrast on mobile */
    background: linear-gradient(180deg, rgba(18,22,35,0.95), rgba(18,22,35,0.90));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }
  /* Ensure scrim is below sidebar but above content */
  .scrim { z-index: 1100; }
}

@keyframes drawer-enter {
  from { transform: translateX(-100%); opacity: 0.5; }
  to { transform: translateX(0); opacity: 1; }
}

/* ===== Settings List (iOS/Samsung style - shared between Settings and Admin Settings) ===== */
.settings-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: rgba(255,255,255,0.04);
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.08);
}

.settings-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.03));
  cursor: pointer;
  transition: background 0.2s ease;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  min-height: 56px;
}

.settings-item:last-child {
  border-bottom: none;
}

.settings-item:hover {
  background: linear-gradient(90deg, rgba(73,114,243,0.12), rgba(217,37,210,0.12));
}

.settings-item:active {
  background: linear-gradient(90deg, rgba(73,114,243,0.18), rgba(217,37,210,0.18));
}

.settings-item .icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  flex-shrink: 0;
}

.settings-item .content {
  flex: 1;
  min-width: 0;
}

.settings-item .title {
  font-weight: 500;
  font-size: 15px;
  color: var(--text);
  margin-bottom: 2px;
}

.settings-item .desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.3;
}

.settings-item .value {
  font-size: 14px;
  color: var(--muted);
  margin-right: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.settings-item .chevron {
  width: 20px;
  height: 20px;
  color: rgba(255,255,255,0.35);
  flex-shrink: 0;
}

/* Settings section headers */
.settings-section-header {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  padding: 0 16px;
  margin-top: 20px;
  margin-bottom: 8px;
}

.settings-section-header:first-child {
  margin-top: 0;
}

/* Settings input groups */
.settings-input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.settings-input-group label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.settings-input-group .hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: -4px;
}

/* ===== Reusable Switch Toggle (.switch-container) ===== */
/* Usage: <label class="switch-container [small|tiny]"><input type="checkbox" /><span class="switch-slider"><span class="switch-icon">SVG</span></span></label> */
/* .switch-icon is optional. Override checked color via --switch-active, defaults to var(--primary). */
.switch-container { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.switch-container input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-container .switch-slider { width: 42px; height: 24px; background: rgba(255,255,255,0.18); border: 1px solid rgba(255,255,255,0.15); border-radius: 12px; position: relative; transition: background 0.2s ease, border-color 0.2s ease; flex-shrink: 0; }
.switch-container .switch-slider::before { content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%; background: rgba(255,255,255,0.8); top: 2px; left: 2px; transition: all 0.2s ease; }
.switch-container input:checked + .switch-slider { background: var(--switch-active, var(--primary)); border-color: transparent; }
.switch-container input:checked + .switch-slider::before { background: white; transform: translateX(18px); }
/* Small variant (36x20) */
.switch-container.small .switch-slider { width: 36px; height: 20px; }
.switch-container.small .switch-slider::before { width: 14px; height: 14px; }
.switch-container.small input:checked + .switch-slider::before { transform: translateX(16px); }
/* Tiny variant (32x18) */
.switch-container.tiny .switch-slider { width: 32px; height: 18px; }
.switch-container.tiny .switch-slider::before { width: 14px; height: 14px; top: 1px; left: 1px; }
.switch-container.tiny input:checked + .switch-slider::before { transform: translateX(14px); }
/* Optional icon inside knob */
.switch-container .switch-icon { position: absolute; top: 50%; left: 3px; transform: translateY(-50%); width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; color: #000; pointer-events: none; transition: all 0.2s ease; z-index: 1; }
.switch-container .switch-icon svg { width: 12px; height: 12px; }
.switch-container input:checked + .switch-slider .switch-icon { left: 21px; }
.switch-container.small .switch-icon { width: 14px; height: 14px; }
.switch-container.small .switch-icon svg { width: 10px; height: 10px; }
.switch-container.small input:checked + .switch-slider .switch-icon { left: 19px; }

/* Settings responsive */
@media (max-width: 920px) {
  .settings-item .value {
    max-width: 120px;
  }
}

@media (max-width: 600px) {
  .settings-item {
    padding: 12px 14px;
  }

  .settings-item .icon {
    width: 24px;
    height: 24px;
  }

  .settings-item .title {
    font-size: 14px;
  }

  .settings-item .desc {
    font-size: 12px;
  }

  .settings-item .value {
    font-size: 13px;
    max-width: 80px;
  }
}

