:root{
  --bg:#03080d;--panel:#071522;--panel2:#0b1d2d;--line:#2c5268;
  --text:#f5f8fb;--muted:#91a7b6;--gold:#e9aa3b;--green:#49e99a;
  --blue:#62c3ff;--cyan:#79efff;
}
*{box-sizing:border-box}
html,body{margin:0;width:100%;height:100%;overflow:hidden;background:#02060a;color:var(--text);font-family:system-ui,-apple-system,"Thonburi",Tahoma,sans-serif}
body{position:fixed;inset:0}
a{text-decoration:none;color:inherit}
button{font:inherit;color:inherit}
.app-shell{
  height:100dvh;display:grid;grid-template-rows:74px minmax(0,1fr) 54px;overflow:hidden;
  background:
    radial-gradient(circle at 50% 0%,rgba(0,180,255,.12),transparent 34%),
    linear-gradient(180deg,#04101a,#02070c);
  position:relative
}
.app-shell:before{
  content:"";position:absolute;inset:0;pointer-events:none;opacity:.28;
  background:linear-gradient(rgba(101,231,255,.045) 1px,transparent 1px),linear-gradient(90deg,rgba(101,231,255,.03) 1px,transparent 1px);
  background-size:100% 26px,26px 100%
}
.topbar{position:relative;z-index:3;display:flex;align-items:center;gap:13px;padding:9px 16px;border-bottom:1px solid rgba(116,226,255,.18);background:linear-gradient(180deg,rgba(6,18,29,.96),rgba(3,11,18,.94));box-shadow:0 8px 22px rgba(0,0,0,.5)}
.back-lever{height:44px;min-width:126px;border-radius:13px;border:1px solid rgba(117,210,255,.3);background:linear-gradient(#142a38,#08131c);display:flex;align-items:center;gap:9px;padding:0 11px;cursor:pointer}
.lever-rail{position:relative;width:59px;height:16px;border-radius:999px;background:#071018;border:1px solid rgba(126,202,239,.3);box-shadow:inset 0 0 8px #000}
.lever-knob{position:absolute;left:34px;top:50%;width:20px;height:20px;transform:translateY(-50%);border-radius:50%;background:radial-gradient(circle at 35% 30%,#ffd879,#df962b);box-shadow:0 0 10px rgba(255,185,75,.42);transition:left .18s ease}
.back-lever.armed .lever-knob{left:4px}.lever-label{font-size:11px;font-weight:900;letter-spacing:.8px;color:#d8edf4}
.brand{height:44px;min-width:92px;padding:0 14px;border-radius:12px;display:flex;align-items:center;justify-content:center;background:linear-gradient(#ffd46d,#c88a20);border:1px solid #71501c;color:#15100a;font-size:21px;font-weight:950}
.title-block{min-width:0}.title-block small{display:block;color:#d7a44a;font-size:9px;font-weight:900;letter-spacing:3px}.title-block strong{display:block;font-size:18px;line-height:1.1;margin-top:2px}
.feedback-toggle{margin-left:auto;min-height:38px;padding:0 11px;border-radius:10px;border:1px solid #405767;background:#091722;color:#a7b6bf;font-size:10px;font-weight:800}
.feedback-toggle.on{color:#10170f;background:linear-gradient(#5aec99,#29b96b);border-color:#2aca75}
.online{display:flex;align-items:center;gap:8px;font-size:11px;font-weight:900;letter-spacing:1px;color:#b7c5cd}
.online i,.statusbar i{width:11px;height:11px;border-radius:50%;background:#58ef95;box-shadow:0 0 7px #58ef95,0 0 16px #2fdc79}

.workspace{position:relative;z-index:2;min-height:0;display:grid;grid-template-rows:auto minmax(0,1fr);gap:12px;padding:14px 16px;overflow:hidden}
.mode-selector-panel,.content-panel{border:1px solid rgba(111,231,255,.18);border-radius:22px;background:linear-gradient(160deg,rgba(5,20,34,.95),rgba(3,11,19,.96));box-shadow:inset 0 0 0 2px rgba(4,13,22,.98),0 12px 24px rgba(0,0,0,.32)}
.mode-selector-panel{padding:14px 18px 12px}
.selector-head{display:flex;align-items:flex-end;justify-content:space-between;gap:14px;margin-bottom:10px}
.selector-head small{font-size:9px;letter-spacing:3px;color:#e9ad50;font-weight:900}.selector-head h1{font-size:23px;margin:3px 0 0}.selector-head p{margin:0;color:#8fa6b5;font-size:11px}

.horizontal-switch{position:relative;padding-top:4px}
.switch-track{position:relative;height:34px;margin:0 7.5%;border-radius:999px;background:linear-gradient(#06111a,#0a1b28);border:1px solid rgba(116,222,255,.24);box-shadow:inset 0 0 12px #000}
.switch-track:before,.switch-track:after{content:"";position:absolute;top:50%;width:8px;height:8px;border-radius:50%;background:#26404f;transform:translateY(-50%)}
.switch-track:before{left:33.333%}.switch-track:after{left:66.666%}
.switch-fill{position:absolute;left:5px;top:5px;bottom:5px;border-radius:999px;background:linear-gradient(90deg,rgba(73,233,154,.18),rgba(98,195,255,.18),rgba(237,174,68,.18));width:calc(100% - 10px)}
.switch-handle{position:absolute;top:50%;left:0;width:58px;height:58px;border-radius:50%;border:2px solid rgba(255,205,104,.72);background:radial-gradient(circle at 35% 30%,#5b6871,#18232b 45%,#080e13 72%);box-shadow:0 0 0 5px rgba(4,12,18,.86),0 0 18px rgba(255,186,70,.28);transform:translate(-50%,-50%);transition:left .28s cubic-bezier(.2,.85,.25,1.1);cursor:grab;touch-action:none}
.switch-handle:after{content:"";position:absolute;inset:15px;border-radius:50%;background:radial-gradient(circle at 38% 30%,#f2c260,#bb7d1c);box-shadow:inset 0 1px rgba(255,255,255,.55)}
body[data-mode="database"] .switch-handle{left:0%}
body[data-mode="event"] .switch-handle{left:50%}
body[data-mode="reseller"] .switch-handle{left:100%}

.switch-options{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin-top:12px}
.switch-options button{border:1px solid rgba(112,195,235,.15);border-radius:14px;background:linear-gradient(180deg,rgba(13,33,49,.88),rgba(6,17,27,.86));padding:9px 8px;cursor:pointer;min-width:0}
.switch-options b{display:inline-block;font-size:18px;color:#edb14c;margin-right:7px}.switch-options span{font-size:10px;font-weight:900;letter-spacing:1.4px}.switch-options small{display:block;font-size:9px;color:#809aa9;margin-top:2px}
.switch-options button.active{border-color:rgba(81,239,158,.62);box-shadow:0 0 18px rgba(75,235,157,.12);background:linear-gradient(180deg,rgba(14,43,52,.96),rgba(7,23,31,.94))}

.content-panel{min-height:0;overflow:hidden;padding:14px}
.mode-view{display:none;height:100%;overflow:auto;padding:4px 5px 10px;scrollbar-width:thin;scrollbar-color:#345368 transparent}
.mode-view.active{display:flex;flex-direction:column;animation:panelIn .2s ease}
@keyframes panelIn{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
.mode-header{display:flex;align-items:center;gap:14px}
.mode-number{width:66px;height:52px;border-radius:13px;display:flex;align-items:center;justify-content:center;background:linear-gradient(180deg,#f3bf5b,#b87a18);border:1px solid #80591d;color:#16100a;font-size:28px;font-weight:950}
.mode-title{min-width:0}.mode-title small{display:block;font-size:9px;letter-spacing:2.5px;color:#8fb0c1;font-weight:900}.mode-title h2{font-size:28px;line-height:1;margin:2px 0 3px}.mode-title p{margin:0;color:#879eac;font-size:11px}
.active-chip{margin-left:auto;padding:7px 10px;border-radius:999px;border:1px solid rgba(105,216,255,.18);background:rgba(7,25,38,.7);color:#76e7fb;font-size:9px;letter-spacing:2px;font-weight:900}
.mode-detail{margin:12px 0;color:#b8c8d2;font-size:13px;line-height:1.45}
.main-action{height:66px;border-radius:17px;display:flex;align-items:center;justify-content:space-between;padding:0 20px;color:#061018;border:2px solid rgba(255,255,255,.1);box-shadow:inset 0 1px rgba(255,255,255,.55),0 9px 18px rgba(0,0,0,.28)}
.main-action span{font-size:22px;font-weight:900}.main-action b{font-size:31px}
.green .main-action{background:linear-gradient(180deg,#57e99d,#24b76c)}.blue .main-action{background:linear-gradient(180deg,#74c6ff,#3a89d6)}.gold .main-action{background:linear-gradient(180deg,#f4c45f,#bc7f1b)}

.menu-list{display:grid;gap:9px;margin-top:12px}
.menu-row{display:grid;grid-template-columns:48px minmax(0,1fr) 26px;align-items:center;gap:12px;min-height:64px;padding:9px 12px;border-radius:15px;border:1px solid rgba(110,204,248,.14);background:linear-gradient(180deg,rgba(9,27,41,.88),rgba(5,16,25,.9));transition:border-color .16s ease,transform .16s ease}
.menu-row:hover{transform:translateX(2px);border-color:rgba(110,222,255,.38)}
.menu-index{width:42px;height:36px;border-radius:10px;display:flex;align-items:center;justify-content:center;background:#091721;border:1px solid rgba(118,214,255,.16);color:#e8af4a;font-size:14px;font-weight:900}
.menu-copy{min-width:0}.menu-copy strong{display:block;font-size:14px}.menu-copy small{display:block;margin-top:3px;color:#849cab;font-size:11px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.menu-arrow{font-size:26px;color:#7feafa;text-align:right}

.statusbar{display:flex;align-items:center;gap:22px;padding:7px 18px;border-top:1px solid rgba(111,231,255,.15);background:linear-gradient(#0b1923,#061018);z-index:3}
.statusbar>div{display:flex;align-items:center;gap:8px}.statusbar span b,.statusbar span small{display:block}.statusbar b{font-size:10px}.statusbar small{font-size:8px;color:#7f909a}.statusbar .position{margin-left:auto;display:block;text-align:right}.statusbar .position b{display:block;font-size:11px}

@media(max-width:700px){
  .app-shell{grid-template-rows:62px minmax(0,1fr) 46px}
  .topbar{gap:6px;padding:6px 8px}.back-lever{min-width:91px;height:38px;padding:0 7px;gap:6px}.lever-rail{width:42px;height:13px}.lever-knob{left:24px;width:16px;height:16px}.back-lever.armed .lever-knob{left:3px}.lever-label{font-size:8px}
  .brand{height:38px;min-width:72px;font-size:17px;padding:0 9px}.title-block small{font-size:6px;letter-spacing:1.5px}.title-block strong{font-size:12px}.online{display:none}.feedback-toggle{min-height:34px;padding:0 7px;font-size:8px}
  .workspace{padding:8px;gap:8px}.mode-selector-panel{padding:10px 11px 9px}.selector-head h1{font-size:18px}.selector-head p{font-size:9px}.selector-head small{font-size:7px}
  .switch-track{height:26px;margin:0 9%}.switch-handle{width:44px;height:44px}.switch-options{gap:5px;margin-top:9px}.switch-options button{padding:6px 4px;border-radius:10px}.switch-options b{font-size:14px;margin-right:3px}.switch-options span{font-size:7px;letter-spacing:.8px}.switch-options small{font-size:7px}
  .content-panel{padding:9px}.mode-header{gap:9px}.mode-number{width:51px;height:42px;font-size:21px}.mode-title h2{font-size:21px}.mode-title p{font-size:9px}.mode-title small{font-size:7px}.active-chip{font-size:7px;padding:5px 7px}
  .mode-detail{margin:8px 0;font-size:11px}.main-action{height:52px;padding:0 15px}.main-action span{font-size:17px}.main-action b{font-size:25px}
  .menu-list{gap:6px;margin-top:8px}.menu-row{grid-template-columns:38px minmax(0,1fr) 20px;gap:8px;min-height:52px;padding:7px 9px}.menu-index{width:34px;height:30px;font-size:11px}.menu-copy strong{font-size:12px}.menu-copy small{font-size:9px}.menu-arrow{font-size:21px}
  .statusbar{padding:5px 8px}.statusbar>div:nth-child(2){display:none}
}


/* === V7 MOBILE CONSOLE COMPACT === */
@media(max-width:700px){
  .workspace{
    grid-template-rows:auto minmax(0,1fr);
    padding:7px;
    gap:7px;
  }

  .mode-selector-panel{
    padding:8px 10px 8px;
    border-radius:18px;
  }

  .selector-head{
    margin-bottom:6px;
    align-items:center;
  }

  .selector-head h1{
    font-size:17px;
    line-height:1.05;
  }

  .selector-head p{
    font-size:8px;
    max-width:47%;
    text-align:right;
    line-height:1.25;
  }

  .horizontal-switch{
    padding-top:1px;
  }

  .switch-track{
    height:22px;
    margin:0 10%;
  }

  .switch-track:before,
  .switch-track:after{
    width:6px;
    height:6px;
  }

  .switch-handle{
    width:40px;
    height:40px;
    box-shadow:
      0 0 0 4px rgba(4,12,18,.86),
      0 0 14px rgba(255,186,70,.24);
  }

  .switch-handle:after{
    inset:11px;
  }

  .switch-options{
    gap:4px;
    margin-top:7px;
  }

  .switch-options button{
    min-height:46px;
    padding:5px 3px;
    border-radius:9px;
  }

  .switch-options b{
    font-size:13px;
    margin-right:2px;
  }

  .switch-options span{
    font-size:7px;
    letter-spacing:.7px;
  }

  .switch-options small{
    font-size:6.5px;
    margin-top:1px;
  }

  .content-panel{
    padding:8px;
    border-radius:18px;
  }

  .mode-header{
    gap:8px;
  }

  .mode-number{
    width:48px;
    height:40px;
    font-size:20px;
    border-radius:10px;
  }

  .mode-title h2{
    font-size:20px;
  }

  .mode-title p{
    font-size:8.5px;
  }

  .mode-title small{
    font-size:6.5px;
    letter-spacing:1.5px;
  }

  .active-chip{
    font-size:6.5px;
    padding:4px 6px;
    letter-spacing:1.2px;
  }

  .mode-detail{
    margin:7px 0;
    font-size:10.5px;
    line-height:1.3;
  }

  .main-action{
    height:48px;
    padding:0 14px;
    border-radius:14px;
  }

  .main-action span{
    font-size:16px;
  }

  .main-action b{
    font-size:23px;
  }

  .menu-list{
    gap:5px;
    margin-top:7px;
  }

  .menu-row{
    grid-template-columns:34px minmax(0,1fr) 18px;
    gap:7px;
    min-height:48px;
    padding:6px 8px;
    border-radius:12px;
  }

  .menu-index{
    width:31px;
    height:28px;
    font-size:10px;
    border-radius:8px;
  }

  .menu-copy strong{
    font-size:11.5px;
    line-height:1.15;
  }

  .menu-copy small{
    font-size:8.5px;
    margin-top:2px;
  }

  .menu-arrow{
    font-size:19px;
  }

  .statusbar{
    min-height:44px;
  }
}

/* iPhone portrait: lock the app layout to viewport and scroll only menu content */
@media(max-width:430px){
  html,body{
    height:100%;
    overscroll-behavior:none;
    touch-action:manipulation;
  }

  body{
    width:100%;
    overflow:hidden;
  }

  .app-shell{
    height:100dvh;
    min-height:100dvh;
    max-height:100dvh;
    grid-template-rows:60px minmax(0,1fr) 44px;
  }

  .topbar{
    min-height:60px;
    height:60px;
  }

  .workspace{
    min-height:0;
    overflow:hidden;
  }

  .content-panel{
    min-height:0;
    overflow:hidden;
  }

  .mode-view{
    min-height:0;
    overflow-y:auto;
    -webkit-overflow-scrolling:touch;
    overscroll-behavior:contain;
    padding-bottom:8px;
  }
}


/* === V8 HEADER COMPACT REFINEMENT === */
@media(max-width:700px){
  .app-shell{
    grid-template-rows:56px minmax(0,1fr) 44px;
  }

  .topbar{
    height:56px;
    min-height:56px;
    padding:5px 7px;
    gap:5px;
  }

  .back-lever{
    min-width:84px;
    height:34px;
    padding:0 6px;
    gap:5px;
    border-radius:11px;
  }

  .lever-rail{
    width:38px;
    height:12px;
  }

  .lever-knob{
    left:22px;
    width:15px;
    height:15px;
  }

  .back-lever.armed .lever-knob{
    left:2px;
  }

  .lever-label{
    font-size:7.5px;
    letter-spacing:.5px;
  }

  .brand{
    height:34px;
    min-width:66px;
    padding:0 8px;
    border-radius:10px;
    font-size:15px;
    line-height:1;
  }

  .title-block{
    min-width:0;
    flex:1;
  }

  .title-block small{
    font-size:5.8px;
    letter-spacing:1.25px;
    line-height:1;
  }

  .title-block strong{
    font-size:11px;
    line-height:1.05;
    margin-top:2px;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
  }

  .feedback-toggle{
    min-height:31px;
    height:31px;
    min-width:70px;
    padding:0 6px;
    font-size:7.2px;
    border-radius:9px;
  }

  .online{
    display:none;
  }
}

@media(max-width:390px){
  .topbar{
    gap:4px;
    padding-left:6px;
    padding-right:6px;
  }

  .back-lever{
    min-width:78px;
  }

  .brand{
    min-width:60px;
    font-size:14px;
  }

  .title-block strong{
    font-size:10px;
  }

  .feedback-toggle{
    min-width:64px;
    font-size:6.8px;
  }
}
