:root {
  color: #0f172a;
  background: #eef2ff;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: linear-gradient(135deg, #eef2ff 0%, #f8fafc 45%, #ecfeff 100%); }
button { font-family: inherit; }
.page { min-height: 100vh; padding: 14px; padding-bottom: 82px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; margin-bottom: 12px; border: 1px solid rgba(148,163,184,.28); border-radius: 18px; background: rgba(255,255,255,.86); box-shadow: 0 18px 40px rgba(15,23,42,.08); backdrop-filter: blur(12px); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { width: 42px; height: 42px; border-radius: 12px; box-shadow: 0 10px 24px rgba(15,23,42,.16); }
.topbar h1 { margin: 0; font-size: 22px; line-height: 1.1; }
.topbar p { margin: 4px 0 0; color: #64748b; font-size: 12px; }
.top-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.conn { position: relative; padding-left: 14px; font-size: 12px; color: #64748b; white-space: nowrap; }
.conn::before { content: ''; position: absolute; left: 0; top: 50%; width: 8px; height: 8px; border-radius: 999px; transform: translateY(-50%); background: #ef4444; }
.conn.on::before { background: #22c55e; box-shadow: 0 0 0 4px rgba(34,197,94,.14); }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 10px; }
.stat-card .s-card__content, .stat-card { min-height: 58px; }
.stat-card { display: flex; flex-direction: column; justify-content: center; gap: 4px; border-left: 4px solid #3b82f6; }
.stat-card span { color: #64748b; font-size: 12px; }
.stat-card strong { font-size: 24px; line-height: 1; }
.stat-card.red { border-left-color: #ef4444; }
.stat-card.orange { border-left-color: #f59e0b; }
.stat-card.green { border-left-color: #10b981; }
.main-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; height: calc(100vh - 286px); min-height: 460px; }
.panel { min-height: 0; overflow: hidden; }
.panel .s-card__content { height: 100%; min-height: 0; }
.scroll-area { height: 100%; overflow-y: auto; padding-right: 4px; }
.empty { padding: 32px 0; text-align: center; color: #94a3b8; }
.empty.dark { color: #64748b; }
.chat-item { position: relative; margin-bottom: 7px; padding: 6px 8px 6px 12px; border: 1px solid #eef2f7; border-radius: 12px; background: rgba(255,255,255,.96); overflow: hidden; transition: background .15s, box-shadow .15s, border-color .15s; }
.chat-item::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: #3b82f6; }
.chat-item:hover { box-shadow: 0 6px 16px rgba(15,23,42,.07); }
.chat-item.spam { border-color: #fecaca; background: #fff7f7; }
.chat-item.spam::before { background: #ef4444; }
.chat-item.deleted { opacity: .78; background: #f8fafc; }
.chat-item.deleted::before { background: #94a3b8; }
.chat-item.web::before { background: #8b5cf6; }
.chat-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.chat-user-line { display: flex; align-items: center; gap: 6px; min-width: 0; }
.chat-user { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #2563eb; font-weight: 800; font-size: 13px; }
.chat-uid { color: #94a3b8; font-size: 11px; }
.chat-meta-line { display: flex; align-items: center; justify-content: flex-end; gap: 5px; white-space: nowrap; }
.chat-id { color: #64748b; font-size: 11px; background: #f1f5f9; border-radius: 999px; padding: 1px 6px; }
.chat-time { color: #94a3b8; font-size: 11px; }
.chat-text { margin-top: 4px; color: #334155; font-size: 13px; line-height: 1.38; white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; }
.deleted .chat-text { color: #94a3b8; text-decoration: line-through; }
.chat-foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 4px; min-height: 20px; }
.chat-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-left: auto; }
.reason-tag { max-width: min(70%, 520px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel-extra { display: flex; gap: 6px; align-items: center; }
.log-window { height: 100%; overflow: auto; padding: 6px; border-radius: 12px; border: 1px solid #1e293b; background: #0b1020; color: #cbd5e1; font-family: Consolas, Monaco, 'Courier New', monospace; font-size: 11px; line-height: 1.28; }
.log-line { display: grid; grid-template-columns: 68px 48px minmax(0, 1fr); gap: 6px; padding: 2px 3px; border-bottom: 1px solid rgba(148,163,184,.08); white-space: nowrap; }
.log-msg { overflow: hidden; text-overflow: ellipsis; }
.log-time { color: #64748b; }
.log-level { text-align: center; border-radius: 4px; font-weight: 800; }
.log-line.INFO .log-level { color: #93c5fd; background: rgba(59,130,246,.12); }
.log-line.WARNING .log-level { color: #fbbf24; background: rgba(245,158,11,.12); }
.log-line.ERROR .log-level { color: #f87171; background: rgba(239,68,68,.14); }
.ban-panel { margin-top: 10px; height: 206px; overflow: hidden; }
.ban-panel .s-card__content { height: 100%; min-height: 0; }
.ban-list { height: 100%; overflow: auto; display: grid; gap: 6px; }
.ban-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 9px; border-radius: 10px; background: #fff7ed; border-left: 4px solid #f97316; }
.ban-main { min-width: 0; display: grid; gap: 2px; }
.ban-main b { color: #9a3412; font-size: 13px; }
.ban-main span { color: #64748b; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ban-meta { display: flex; align-items: center; gap: 8px; color: #94a3b8; font-size: 11px; white-space: nowrap; }
.send-box { position: fixed; left: 50%; bottom: 12px; width: min(960px, calc(100vw - 24px)); transform: translateX(-50%); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; padding: 10px; border: 1px solid rgba(148,163,184,.32); border-radius: 16px; background: rgba(255,255,255,.94); box-shadow: 0 18px 40px rgba(15,23,42,.14); backdrop-filter: blur(12px); z-index: 50; }
@media (max-width: 900px) { .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .main-grid { grid-template-columns: 1fr; height: auto; min-height: 0; } .chat-panel, .log-panel { height: 42vh; min-height: 330px; } .ban-panel { height: 240px; } }
@media (max-width: 520px) { .page { padding: 8px; padding-bottom: 78px; } .topbar { align-items: flex-start; flex-direction: column; border-radius: 14px; padding: 11px; } .topbar h1 { font-size: 19px; } .top-actions { width: 100%; justify-content: space-between; } .stats-grid { gap: 7px; } .stat-card strong { font-size: 20px; } .chat-panel, .log-panel { height: 39vh; min-height: 300px; } .chat-item { margin-bottom: 8px; padding: 6px 7px 6px 12px; } .chat-head { gap: 6px; } .chat-user { max-width: 42vw; } .chat-uid { display: none; } .chat-text { padding: 5px 7px; border-radius: 8px; background: #f8fafc; line-height: 1.35; } .reason-tag { max-width: 58%; } .log-window { font-size: 10px; } .log-line { grid-template-columns: 55px 42px minmax(0, 1fr); gap: 4px; } .ban-panel { height: 220px; } .send-box { bottom: 8px; width: calc(100vw - 12px); padding: 8px; border-radius: 13px; } }

.form-select { height: 30px; border: 1px solid #cbd5e1; border-radius: 10px; padding: 0 10px; background: #fff; color: #0f172a; }
.manage-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; margin-top: 10px; }
.manage-panel .s-card__content { max-height: 260px; overflow: auto; }
.shop-form { display: grid; grid-template-columns: 90px 1fr 90px 1fr auto auto; gap: 8px; align-items: center; margin-bottom: 10px; }
.check { display: inline-flex; align-items: center; gap: 4px; color: #64748b; font-size: 12px; white-space: nowrap; }
.mini-list { display: flex; flex-direction: column; gap: 6px; }
.mini-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border: 1px solid #eef2f7; border-radius: 10px; background: rgba(255,255,255,.86); font-size: 13px; }
.mini-row em { margin-left: 6px; color: #64748b; font-style: normal; font-size: 12px; }
.row-actions { display: flex; gap: 6px; flex-shrink: 0; }
@media (max-width: 768px) {
  .manage-grid { grid-template-columns: 1fr; }
  .shop-form { grid-template-columns: 1fr; }
  .mini-row { align-items: flex-start; flex-direction: column; }
}

.modal-mask { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 18px; background: rgba(15,23,42,.48); backdrop-filter: blur(8px); }
.modal-card { width: min(1080px, 100%); max-height: calc(100vh - 36px); overflow: hidden; border-radius: 20px; background: rgba(255,255,255,.98); box-shadow: 0 28px 80px rgba(15,23,42,.32); border: 1px solid rgba(226,232,240,.9); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid #e2e8f0; }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-body { max-height: calc(100vh - 112px); overflow: auto; padding: 14px 16px 18px; }
.modal-body h3 { margin: 14px 0 8px; font-size: 14px; color: #334155; }
.lottery-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; align-items: center; margin-bottom: 10px; }
@media (max-width: 768px) {
  .modal-mask { align-items: stretch; padding: 8px; }
  .modal-card { max-height: calc(100vh - 16px); border-radius: 16px; }
  .lottery-form { grid-template-columns: 1fr; }
}

.manager-layout { display: grid; grid-template-columns: 320px 1fr; gap: 14px; background: #f8fafc; }
.editor-panel, .data-panel { border: 1px solid #e2e8f0; border-radius: 16px; background: #fff; padding: 14px; }
.editor-panel { display: flex; flex-direction: column; gap: 10px; box-shadow: 0 10px 30px rgba(15,23,42,.04); }
.editor-panel label { display: grid; gap: 6px; color: #475569; font-size: 12px; font-weight: 700; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.section-title span { font-size: 16px; font-weight: 800; color: #0f172a; }
.section-title small { padding: 3px 8px; border-radius: 999px; background: #eef2ff; color: #4f46e5; }
.switch-line { display: flex !important; grid-template-columns: auto 1fr !important; align-items: center; gap: 8px !important; }
.editor-actions { display: flex; gap: 8px; margin-top: 4px; }
.form-two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tabbar { display: inline-flex; padding: 4px; margin-bottom: 12px; border-radius: 12px; background: #eef2f7; }
.tabbar button { border: 0; background: transparent; padding: 7px 12px; border-radius: 9px; color: #64748b; cursor: pointer; font-weight: 700; }
.tabbar button.active { background: #fff; color: #1d4ed8; box-shadow: 0 4px 12px rgba(15,23,42,.08); }
.data-table { overflow: auto; border: 1px solid #e2e8f0; border-radius: 14px; }
.table-head, .table-row { display: grid; grid-template-columns: 2.2fr .8fr .8fr 1.6fr; gap: 10px; align-items: center; padding: 10px 12px; min-width: 760px; }
.tx-table .table-head, .tx-table .table-row { grid-template-columns: 1.2fr 1.5fr .7fr .8fr; }
.table-head { position: sticky; top: 0; background: #f8fafc; color: #64748b; font-size: 12px; font-weight: 800; border-bottom: 1px solid #e2e8f0; }
.table-row { border-bottom: 1px solid #eef2f7; color: #334155; }
.table-row:last-child { border-bottom: 0; }
.table-row b, .table-row em, .table-row small { display: block; }
.table-row b { color: #0f172a; font-style: normal; }
.table-row em { color: #475569; font-style: normal; margin-top: 2px; }
.table-row small { color: #94a3b8; margin-top: 2px; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 80; padding: 10px 14px; border-radius: 12px; background: #0f172a; color: #fff; box-shadow: 0 18px 50px rgba(15,23,42,.28); font-weight: 700; }
.confirm-mask { position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(15,23,42,.46); backdrop-filter: blur(6px); }
.confirm-card { width: min(420px, 100%); border-radius: 18px; background: #fff; padding: 18px; box-shadow: 0 28px 80px rgba(15,23,42,.34); border: 1px solid #e2e8f0; }
.confirm-card h3 { margin: 0 0 8px; color: #0f172a; font-size: 18px; }
.confirm-card p { margin: 0; color: #475569; line-height: 1.6; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
@media (max-width: 900px) {
  .manager-layout { grid-template-columns: 1fr; }
  .form-two { grid-template-columns: 1fr; }
}

/* Admin template layout */
body { background: #f3f6fb; }
.admin-shell { min-height: 100vh; display: grid; grid-template-columns: 264px minmax(0, 1fr); background: #f3f6fb; color: #0f172a; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 18px; padding: 18px 14px; background: #0b1220; color: #e5e7eb; border-right: 1px solid rgba(148,163,184,.16); }
.side-brand { display: flex; align-items: center; gap: 12px; padding: 8px 8px 14px; border-bottom: 1px solid rgba(148,163,184,.16); }
.side-brand h1 { margin: 0; font-size: 17px; line-height: 1.1; color: #fff; }
.side-brand p { margin: 4px 0 0; color: #94a3b8; font-size: 12px; }
.sidebar .brand-icon { width: 40px; height: 40px; border-radius: 12px; box-shadow: 0 12px 30px rgba(0,0,0,.32); }
.side-section { display: grid; gap: 8px; padding: 0 4px; }
.side-label { color: #64748b; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.side-select { width: 100%; background: rgba(15,23,42,.9) !important; color: #e5e7eb !important; border-color: rgba(148,163,184,.26) !important; }
.side-nav { display: grid; gap: 6px; }
.side-nav a, .side-nav button { display: flex; align-items: center; justify-content: space-between; width: 100%; border: 0; border-radius: 12px; padding: 11px 12px; color: #cbd5e1; background: transparent; text-align: left; text-decoration: none; cursor: pointer; transition: background .16s, color .16s, transform .16s; }
.side-nav a:hover, .side-nav button:hover, .side-nav .active { background: rgba(99,102,241,.16); color: #fff; transform: translateX(2px); }
.side-nav span { font-size: 14px; font-weight: 750; }
.side-nav em { font-style: normal; color: #64748b; font-size: 11px; }
.side-footer { margin-top: auto; padding: 12px; border-radius: 14px; background: rgba(15,23,42,.82); border: 1px solid rgba(148,163,184,.14); display: grid; gap: 8px; }
.side-footer small { color: #64748b; }
.admin-main { min-width: 0; padding: 18px 20px 88px; }
.admin-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; min-height: 88px; padding: 18px 20px; margin-bottom: 16px; border: 1px solid #e2e8f0; border-radius: 20px; background: linear-gradient(135deg, rgba(255,255,255,.98), rgba(248,250,252,.94)); box-shadow: 0 18px 45px rgba(15,23,42,.07); }
.eyebrow { color: #4f46e5; font-size: 11px; font-weight: 900; letter-spacing: .12em; }
.admin-header h2 { margin: 3px 0; font-size: 25px; letter-spacing: -0.03em; }
.admin-header p { margin: 0; color: #64748b; font-size: 13px; }
.stats-grid { gap: 14px; margin-bottom: 14px; }
.stat-card { min-height: 96px; border-left: 0; border-radius: 18px !important; background: #fff !important; box-shadow: 0 12px 30px rgba(15,23,42,.06); border: 1px solid #e2e8f0 !important; position: relative; overflow: hidden; }
.stat-card::after { content: ''; position: absolute; right: -18px; top: -18px; width: 72px; height: 72px; border-radius: 999px; background: rgba(59,130,246,.12); }
.stat-card.red::after { background: rgba(239,68,68,.12); }
.stat-card.orange::after { background: rgba(245,158,11,.14); }
.stat-card.green::after { background: rgba(16,185,129,.14); }
.stat-card strong { font-size: 32px; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.main-grid { grid-template-columns: minmax(0, 1.25fr) minmax(420px, .75fr); gap: 14px; height: calc(100vh - 252px); min-height: 560px; }
.panel, .ban-panel { border-radius: 18px !important; border: 1px solid #e2e8f0 !important; box-shadow: 0 12px 30px rgba(15,23,42,.05); background: #fff !important; }
.chat-item { border-radius: 10px; margin-bottom: 8px; }
.send-box { left: 284px; right: 20px; bottom: 18px; border: 1px solid #e2e8f0; border-radius: 18px; box-shadow: 0 18px 50px rgba(15,23,42,.12); background: rgba(255,255,255,.94); }
.modal-card { border-radius: 22px; }
.modal-head { padding: 18px 20px; background: #f8fafc; }
.modal-head h2 { font-size: 20px; letter-spacing: -0.02em; }
@media (max-width: 1100px) {
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; }
  .side-brand { border-bottom: 0; padding-bottom: 8px; }
  .side-section { min-width: 240px; }
  .side-nav { grid-template-columns: repeat(3, minmax(120px, 1fr)); flex: 1; }
  .side-footer { display: none; }
  .send-box { left: 16px; right: 16px; }
  .main-grid { grid-template-columns: 1fr; height: auto; }
}
@media (max-width: 720px) {
  .admin-main { padding: 12px 12px 92px; }
  .admin-header { align-items: flex-start; flex-direction: column; }
  .side-nav { grid-template-columns: 1fr 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* Admin layout send box override */
.admin-shell .send-box { left: 284px; right: 20px; bottom: 18px; width: auto; transform: none; max-width: none; }
@media (max-width: 1100px) { .admin-shell .send-box { left: 16px; right: 16px; width: auto; transform: none; } }
@media (max-width: 520px) { .admin-shell .send-box { left: 8px; right: 8px; width: auto; transform: none; } }

/* Static admin composer */
.admin-shell .send-box { position: static; left: auto; right: auto; bottom: auto; width: 100%; transform: none; max-width: none; margin-top: 14px; }
.admin-main { padding-bottom: 20px; }
@media (max-width: 1100px) { .admin-shell .send-box { position: static; left: auto; right: auto; width: 100%; transform: none; } }
@media (max-width: 520px) { .admin-shell .send-box { position: static; left: auto; right: auto; width: 100%; transform: none; } }

/* Tab pages / keep-alive style admin pages */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at top left, #dbeafe, transparent 32%), linear-gradient(135deg, #0f172a, #1e293b); }
.login-card { width: min(380px, 100%); display: grid; gap: 12px; padding: 28px; border-radius: 24px; background: rgba(255,255,255,.96); box-shadow: 0 30px 90px rgba(0,0,0,.34); border: 1px solid rgba(226,232,240,.9); text-align: center; }
.login-card .brand-icon { margin: 0 auto 4px; }
.login-card h1 { margin: 0; font-size: 24px; }
.login-card p { margin: 0 0 8px; color: #64748b; }
.side-nav button.active { background: rgba(99,102,241,.22); color: #fff; }
.tab-page { min-height: calc(100vh - 144px); }
.page-panel { min-height: calc(100vh - 160px); }
.chat-page { position: relative; padding-bottom: 74px; }
.chat-page .chat-panel { height: calc(100vh - 222px); min-height: 520px; }
.log-page .log-panel { height: calc(100vh - 160px); min-height: 560px; }
.admin-shell .floating-chat-send { position: fixed; left: 284px; right: 20px; bottom: 18px; z-index: 40; width: auto; max-width: none; transform: none; margin: 0; background: rgba(255,255,255,.96); backdrop-filter: blur(14px); }
.admin-shell .send-box:not(.floating-chat-send) { position: static; }
@media (max-width: 1100px) { .admin-shell .floating-chat-send { left: 16px; right: 16px; } .tab-page { min-height: auto; } }
@media (max-width: 520px) { .admin-shell .floating-chat-send { left: 8px; right: 8px; bottom: 8px; } .chat-page .chat-panel { height: calc(100vh - 270px); min-height: 420px; } }

/* Remove standalone chat/log pages: composer belongs to dashboard */
.admin-shell .floating-chat-send { left: 284px; right: 20px; bottom: 18px; }
.main-grid { padding-bottom: 72px; }
@media (max-width: 1100px) { .admin-shell .floating-chat-send { left: 16px; right: 16px; } }
