*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ===== DESIGN TOKENS ===== */
:root {
  /* dark mode defaults */
  --bg:       #0c0c0c;
  --surface:  #151515;
  --surface2: #1d1d1d;
  --surface3: #252525;
  --gold1:    #f0c234;
  --gold2:    #c99a18;
  --gold3:    #8a6a0a;
  --night:    #162238;
  --night2:   #1e3254;
  --night3:   #2e4d7a;
  --text:     #edecea;
  --text2:    #b8b4b0;
  --muted:    #787572;
  --border:   rgba(240,194,52,0.12);
  --border2:  rgba(240,194,52,0.28);
  --bubble-in-bg:     #1d1d1d;
  --bubble-in-border: rgba(240,194,52,0.12);
  --bubble-out-bg:    #162238;
  --bubble-out-border:rgba(46,77,122,0.5);
  --input-bg: #1d1d1d;
  --r-sm: 8px; --r-md: 14px; --r-lg: 20px;
  --font: 'Helvetica Neue', Arial, sans-serif;
  --nav-h: 56px; --bottom-nav-h: 62px; --side-nav-w: 200px;
  /* fmt bar colors */
  --fmt-white: #ffffff;
  --fmt-black: #111111;
}

/* ===== LIGHT MODE ===== */
html.light {
  --bg:       #f2efe9;
  --surface:  #ebe7e0;
  --surface2: #e2ddd5;
  --surface3: #d8d2c8;
  --gold1:    #e8b800;
  --gold2:    #b88c10;
  --gold3:    #8a6a0a;
  --night:    #1e3254;
  --night2:   #2e4d7a;
  --night3:   #3a5a8a;
  --text:     #1a1714;
  --text2:    #4a4744;
  --muted:    #7a7572;
  --border:   rgba(138,106,10,0.18);
  --border2:  rgba(138,106,10,0.36);
  --bubble-in-bg:     #ddd9d0;
  --bubble-in-border: rgba(138,106,10,0.15);
  --bubble-out-bg:    #1e3254;
  --bubble-out-border:rgba(46,77,122,0.6);
  --input-bg: #ebe7e0;
  --fmt-white: #f5f2ec;
  --fmt-black: #1a1714;
}

html, body { height: 100%; background: var(--bg); font-family: var(--font); color: var(--text); transition: background .3s, color .3s; }

/* ===== TOP BAR ===== */
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--border);
  height: var(--nav-h); padding: 0 20px;
  display: flex; align-items: center; justify-content: space-between;
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  transition: background .3s, border-color .3s;
}
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--gold1); flex-shrink: 0; transition: background .4s; }
.status-dot.offline { background: #5a5a5a; }
.logo-name { font-size: 14px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; color: var(--text); }
.logo-name span { color: var(--gold1); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.avatar-sm { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border2); cursor: pointer; background: var(--surface2); flex-shrink: 0; }
.avatar-sm-placeholder { width: 30px; height: 30px; border-radius: 50%; background: var(--gold2); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: #fff; cursor: pointer; flex-shrink: 0; }

/* icon button */
.btn-icon { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 18px; padding: 4px; line-height: 1; display: flex; align-items: center; justify-content: center; border-radius: var(--r-sm); }
.btn-icon:hover { color: var(--gold2); }

/* theme toggle */
.theme-toggle { width: 34px; height: 20px; background: var(--surface3); border: 1px solid var(--border); border-radius: 99px; cursor: pointer; position: relative; flex-shrink: 0; transition: background .3s; }
.theme-toggle::after { content: ''; position: absolute; width: 14px; height: 14px; border-radius: 50%; background: var(--muted); top: 2px; left: 2px; transition: transform .25s, background .25s; }
html.light .theme-toggle::after { transform: translateX(14px); background: var(--gold2); }

/* ===== SIDE NAV ===== */
.side-nav {
  position: fixed; top: var(--nav-h); left: 0; bottom: 0;
  width: var(--side-nav-w); background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; z-index: 90; padding: 12px 8px;
  transition: background .3s, border-color .3s;
}
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px;
  border-radius: var(--r-md); color: var(--muted); font-size: 12px; font-weight: 500;
  cursor: pointer; text-decoration: none; letter-spacing: .02em; transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: rgba(184,140,16,.12); color: var(--gold2); }
.nav-item .nav-icon { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.nav-badge { margin-left: auto; background: var(--gold1); color: #111; font-size: 9px; font-weight: 700; padding: 2px 7px; border-radius: 99px; }
.side-nav-footer { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }

/* ===== PAGE CONTENT ===== */
.page-content {
  position: fixed; top: var(--nav-h); left: var(--side-nav-w); right: 0; bottom: 0;
  overflow: hidden; display: flex; flex-direction: column;
}

/* ===== BOTTOM NAV ===== */
.bottom-nav {
  display: none; position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-h); background: var(--surface); border-top: 1px solid var(--border);
  z-index: 100; justify-content: space-around; align-items: center;
  padding-bottom: env(safe-area-inset-bottom); transition: background .3s;
}
.bn-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  cursor: pointer; text-decoration: none; color: var(--muted);
  font-size: 9px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase;
  padding: 4px 8px; border-radius: var(--r-sm); flex: 1; max-width: 80px; position: relative;
}
.bn-item.active { color: var(--gold2); }
.bn-item .bn-icon { width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; }
.bn-badge { position: absolute; top: 0; right: 8px; background: var(--gold1); color: #111; font-size: 8px; font-weight: 700; padding: 1px 5px; border-radius: 99px; }

/* ===== BUTTONS ===== */
.btn-prim {
  background: var(--gold2); border: none; border-radius: var(--r-md);
  color: #fff; font-family: var(--font); font-size: 11px; font-weight: 700;
  letter-spacing: .13em; text-transform: uppercase; padding: 12px 24px; cursor: pointer;
}
.btn-prim:hover { background: var(--gold1); color: #111; }
.btn-ghost {
  background: none; border: 1px solid var(--border2); border-radius: var(--r-md);
  color: var(--muted); font-family: var(--font); font-size: 11px; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase; padding: 11px 20px; cursor: pointer;
}
.btn-ghost:hover { color: var(--text); border-color: var(--gold2); }
.btn-ok { font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; background: var(--gold2); color: #111; border: none; border-radius: var(--r-sm); padding: 6px 16px; cursor: pointer; }
.btn-ok:hover { background: var(--gold1); }
.btn-no { font-size: 10px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; background: none; color: var(--muted); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 6px 16px; cursor: pointer; }
.btn-no:hover { color: var(--text); }
.ibtn { width: 34px; height: 34px; background: var(--surface2); border: 1px solid var(--border); border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 16px; flex-shrink: 0; color: var(--muted); }
.ibtn:hover { border-color: var(--gold2); color: var(--gold2); }
.sbtn { width: 34px; height: 34px; background: var(--gold2); border: none; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; color: #fff; font-size: 15px; flex-shrink: 0; }
.sbtn:hover { background: var(--gold1); color: #111; }
.sbtn:active { transform: scale(.95); }
.act-btn { font-size: 9px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); background: var(--surface3); border: 1px solid var(--border); border-radius: 99px; padding: 3px 10px; cursor: pointer; margin-right: 3px; margin-bottom: 3px; }
.act-btn:hover { color: var(--gold2); border-color: var(--gold3); }
.act-btn.danger:hover { color: #cc6655; border-color: rgba(204,102,85,.4); }
.chat-btn { font-size: 9px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: #111; background: var(--gold2); border: none; border-radius: 99px; padding: 4px 13px; cursor: pointer; }
.chat-btn:hover { background: var(--gold1); }

/* ===== FORMS ===== */
.flabel { display: block; font-size: 10px; font-weight: 600; letter-spacing: .13em; text-transform: uppercase; color: var(--muted); margin-bottom: 5px; margin-top: 14px; }
.flabel:first-child { margin-top: 0; }
.finput { width: 100%; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--r-md); color: var(--text); font-family: var(--font); font-size: 14px; font-weight: 300; padding: 11px 14px; outline: none; transition: border-color .2s; }
.finput:focus { border-color: var(--gold2); }
textarea.finput { resize: vertical; min-height: 80px; line-height: 1.5; }
.err-msg { color: #cc6655; font-size: 12px; margin-top: 8px; min-height: 16px; }
.ok-msg  { color: var(--gold2); font-size: 12px; margin-top: 8px; min-height: 16px; }

/* ===== CARDS ===== */
.card { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 20px 22px; margin-bottom: 16px; transition: background .3s; }
.card-title { font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--text); margin-bottom: 16px; }

/* ===== BADGES ===== */
.badge { font-size: 9px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; padding: 3px 10px; border-radius: 99px; }
.b-act  { background: rgba(46,77,122,.25);  color: #7aaee0; border: 1px solid var(--night3); }
.b-pend { background: rgba(201,154,24,.15); color: var(--gold2); border: 1px solid var(--gold3); }
.b-sus  { background: rgba(140,40,30,.15);  color: #cc6655; border: 1px solid rgba(140,70,60,.3); }

/* ===== TOGGLE SWITCH ===== */
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); }
.toggle-row:last-child { border-bottom: none; }
.toggle-label { font-size: 13px; color: var(--text); font-weight: 300; }
.toggle-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.toggle-switch { position: relative; width: 40px; height: 22px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: var(--surface3); border: 1px solid var(--border); border-radius: 99px; cursor: pointer; transition: background .25s; }
.toggle-slider:before { content: ''; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; background: var(--muted); border-radius: 50%; transition: transform .25s, background .25s; }
.toggle-switch input:checked + .toggle-slider { background: rgba(184,140,16,.2); border-color: var(--gold3); }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(18px); background: var(--gold1); }

/* ===== STATUS DOTS ===== */
.online-dot  { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--gold1); flex-shrink: 0; }
.offline-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #5a5a5a; flex-shrink: 0; }

/* ===== LIGHTBOX ===== */
.lightbox { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.88); z-index: 700; align-items: center; justify-content: center; }
.lightbox.open { display: flex; }
.lightbox img { max-width: 90vw; max-height: 90vh; border-radius: var(--r-lg); object-fit: contain; }
.lightbox-close { position: absolute; top: 20px; right: 24px; background: none; border: none; color: #fff; font-size: 28px; cursor: pointer; }

/* ===== MODAL ===== */
.overlay-bg { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.65); z-index: 600; align-items: center; justify-content: center; }
.overlay-bg.open { display: flex; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 28px; width: min(400px, 90vw); }
.modal-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.modal-sub   { font-size: 12px; color: var(--muted); margin-bottom: 18px; font-weight: 300; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 99px; }

/* ===== MOBILE ===== */
@media (max-width: 700px) {
  .side-nav { display: none; }
  .bottom-nav { display: flex; }
  .page-content { left: 0; bottom: var(--bottom-nav-h); }
  .hide-mobile { display: none !important; }
}
@media (min-width: 701px) {
  .hide-desktop { display: none !important; }
}
