/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg:       #0f1117;
  --bg2:      #161b27;
  --bg3:      #1e2535;
  --border:   #2a3347;
  --primary:  #6366f1;
  --primary-h:#7577f3;
  --success:  #22c55e;
  --warning:  #f59e0b;
  --danger:   #ef4444;
  --info:     #38bdf8;
  --text:     #e2e8f0;
  --text2:    #94a3b8;
  --text3:    #64748b;
  --radius:   8px;
  --shadow:   0 4px 24px rgba(0,0,0,.4);
  --sidebar-w:240px;
}
html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Noto Sans SC', sans-serif; font-size: 14px; background: var(--bg); color: var(--text); line-height: 1.6; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-h); }
input, textarea, select { background: var(--bg3); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius); padding: 8px 12px; width: 100%; font-size: 14px; transition: border .2s; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.15); }
code { font-family: 'Courier New', monospace; background: var(--bg3); padding: 2px 6px; border-radius: 4px; font-size: 12px; color: var(--info); }

/* ── Login page ────────────────────────────────────────────────────────────── */
.mp-login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at 60% 30%, #1a1f35 0%, var(--bg) 70%); }
.mp-login-box { background: var(--bg2); border: 1px solid var(--border); border-radius: 16px; padding: 48px 40px; width: 100%; max-width: 420px; box-shadow: var(--shadow); }
.mp-login-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; }
.mp-login-logo svg { width: 40px; height: 40px; }
.mp-login-logo span { font-size: 22px; font-weight: 700; color: var(--text); }
.mp-login-box h2 { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.mp-login-sub { color: var(--text2); margin-bottom: 28px; font-size: 13px; }
.mp-form-group { margin-bottom: 18px; }
.mp-form-group label { display: block; font-size: 13px; color: var(--text2); margin-bottom: 6px; }
.mp-input-icon { position: relative; }
.mp-input-icon input { padding-right: 40px; }
.mp-toggle-pw { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); cursor: pointer; opacity: .6; user-select: none; }
.mp-toggle-pw:hover { opacity: 1; }
.mp-login-footer { text-align: center; margin-top: 24px; color: var(--text3); font-size: 12px; }

/* ── App layout ────────────────────────────────────────────────────────────── */
.mp-app { display: flex; min-height: 100vh; }
.mp-main { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow-x: hidden; }
.mp-content { flex: 1; padding: 24px; overflow-y: auto; }

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
.mp-sidebar { width: var(--sidebar-w); background: var(--bg2); border-right: 1px solid var(--border); display: flex; flex-direction: column; height: 100vh; position: sticky; top: 0; flex-shrink: 0; }
.mp-sidebar-logo { display: flex; align-items: center; gap: 10px; padding: 20px 16px; border-bottom: 1px solid var(--border); }
.mp-sidebar-logo svg { width: 36px; height: 36px; }
.mp-sidebar-logo span { font-size: 16px; font-weight: 700; }
.mp-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }
.mp-nav-group { margin-bottom: 20px; }
.mp-nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text3); padding: 0 8px; display: block; margin-bottom: 6px; }
.mp-nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius); color: var(--text2); transition: all .15s; cursor: pointer; }
.mp-nav-item:hover, .mp-nav-item.active { background: rgba(99,102,241,.12); color: var(--primary); }
.mp-nav-icon { font-size: 16px; width: 20px; text-align: center; }
.mp-sidebar-footer { padding: 16px; border-top: 1px solid var(--border); }
.mp-user-info { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.mp-user-avatar { width: 32px; height: 32px; background: var(--primary); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex-shrink: 0; }
.mp-user-name { font-size: 13px; font-weight: 600; }
.mp-user-role { font-size: 11px; color: var(--text3); }

/* ── Topbar ────────────────────────────────────────────────────────────────── */
.mp-topbar { height: 60px; background: var(--bg2); border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 24px; gap: 16px; flex-shrink: 0; }
.mp-sidebar-toggle { background: none; border: none; color: var(--text2); cursor: pointer; font-size: 18px; padding: 4px 8px; }
.mp-topbar-title { font-size: 16px; font-weight: 600; flex: 1; }
.mp-topbar-right { display: flex; align-items: center; gap: 16px; }
.mp-time { color: var(--text2); font-size: 13px; }
.mp-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 4px; }
.mp-dot-green { background: var(--success); box-shadow: 0 0 6px var(--success); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100%{ opacity:1 } 50%{ opacity:.4 } }
.mp-online-badge { font-size: 12px; color: var(--text2); }

/* ── Stats row ─────────────────────────────────────────────────────────────── */
.mp-stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.mp-stat-card { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; padding: 20px; display: flex; align-items: center; gap: 16px; }
.mp-stat-online { border-color: rgba(34,197,94,.3); background: rgba(34,197,94,.05); }
.mp-stat-icon { font-size: 28px; }
.mp-stat-val { font-size: 28px; font-weight: 700; line-height: 1; }
.mp-stat-label { font-size: 12px; color: var(--text2); margin-top: 4px; }

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.mp-card { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 24px; overflow: hidden; }
.mp-card-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.mp-card-header h3 { font-size: 15px; font-weight: 600; }
.mp-card-actions { display: flex; align-items: center; gap: 8px; }

/* ── Tables ────────────────────────────────────────────────────────────────── */
.mp-table-wrap { overflow-x: auto; }
.mp-table { width: 100%; border-collapse: collapse; }
.mp-table th { padding: 12px 16px; text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text3); border-bottom: 1px solid var(--border); white-space: nowrap; }
.mp-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13px; }
.mp-table tr:last-child td { border-bottom: none; }
.mp-table tr:hover td { background: rgba(255,255,255,.02); }
.mp-loading, .mp-empty { text-align: center; color: var(--text3); padding: 32px !important; }

/* ── Badges ────────────────────────────────────────────────────────────────── */
.mp-badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.mp-badge-green { background: rgba(34,197,94,.15); color: var(--success); }
.mp-badge-red   { background: rgba(239,68,68,.15);  color: var(--danger); }
.mp-tag { background: var(--bg3); color: var(--text2); border-radius: 4px; padding: 2px 6px; font-size: 11px; }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.mp-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 18px; border-radius: var(--radius); border: 1px solid transparent; cursor: pointer; font-size: 14px; font-weight: 500; transition: all .15s; white-space: nowrap; }
.mp-btn:disabled { opacity: .5; cursor: not-allowed; }
.mp-btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.mp-btn-primary:hover:not(:disabled) { background: var(--primary-h); }
.mp-btn-danger  { background: var(--danger);  color: #fff; border-color: var(--danger); }
.mp-btn-warning { background: var(--warning); color: #fff; border-color: var(--warning); }
.mp-btn-info    { background: var(--info);    color: #000; border-color: var(--info); }
.mp-btn-ghost   { background: transparent; color: var(--text2); border-color: var(--border); }
.mp-btn-ghost:hover { background: var(--bg3); color: var(--text); }
.mp-btn-full { width: 100%; }
.mp-btn-sm  { padding: 6px 12px; font-size: 13px; }
.mp-btn-xs  { padding: 3px 8px;  font-size: 12px; }
.mp-btn-icon { background: none; border: none; cursor: pointer; padding: 2px 4px; opacity: .6; }
.mp-btn-icon:hover { opacity: 1; }

/* ── Forms ─────────────────────────────────────────────────────────────────── */
.mp-form-row { margin-bottom: 16px; }
.mp-form-row label { display: block; font-size: 13px; color: var(--text2); margin-bottom: 6px; }
.mp-form-row small { display: block; font-size: 11px; color: var(--text3); margin-top: 4px; }
.mp-form-actions { display: flex; gap: 8px; align-items: center; margin-top: 20px; }
.mp-input-sm { padding: 6px 10px; width: auto; font-size: 13px; }
.mp-select-sm { padding: 5px 8px; width: auto; font-size: 13px; }
.mp-checkbox-group { display: flex; flex-wrap: wrap; gap: 12px; }
.mp-checkbox { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; }
.mp-checkbox input { width: auto; }

/* ── Switch toggle ─────────────────────────────────────────────────────────── */
.mp-switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.mp-switch input { display: none; }
.mp-slider { position: absolute; inset: 0; background: var(--bg3); border: 1px solid var(--border); border-radius: 12px; cursor: pointer; transition: .2s; }
.mp-switch input:checked + .mp-slider { background: var(--primary); border-color: var(--primary); }
.mp-slider::before { content: ''; position: absolute; width: 18px; height: 18px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: .2s; }
.mp-switch input:checked + .mp-slider::before { transform: translateX(20px); }

/* ── Tabs ──────────────────────────────────────────────────────────────────── */
.mp-tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--border); padding-bottom: 0; }
.mp-tab { background: none; border: none; color: var(--text2); cursor: pointer; padding: 10px 16px; font-size: 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all .15s; }
.mp-tab:hover { color: var(--text); }
.mp-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.mp-tab-panel { display: none; }
.mp-tab-panel.active { display: block; }
.mp-tabs-sm .mp-tab { font-size: 13px; padding: 8px 12px; }

/* ── Alerts ────────────────────────────────────────────────────────────────── */
.mp-alert { padding: 10px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 12px; }
.mp-alert-error   { background: rgba(239,68,68,.1);  color: var(--danger);  border: 1px solid rgba(239,68,68,.3); }
.mp-alert-success { background: rgba(34,197,94,.1);  color: var(--success); border: 1px solid rgba(34,197,94,.3); }

/* ── Toast notification ────────────────────────────────────────────────────── */
#mp-toast-container { position: fixed; top: 24px; right: 24px; z-index: 10000; display: flex; flex-direction: column; gap: 8px; }
.mp-toast { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 20px; min-width: 260px; box-shadow: var(--shadow); animation: slideIn .25s ease; font-size: 13px; }
.mp-toast-success { border-left: 3px solid var(--success); }
.mp-toast-error   { border-left: 3px solid var(--danger); }
.mp-toast-info    { border-left: 3px solid var(--info); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Modal ─────────────────────────────────────────────────────────────────── */
.mp-modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; }
.mp-modal-overlay, .mp-detail-overlay { position: absolute; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(4px); }
.mp-modal-box { position: relative; z-index: 1; background: var(--bg2); border: 1px solid var(--border); border-radius: 16px; width: 100%; max-width: 640px; box-shadow: var(--shadow); }
.mp-modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 24px; border-bottom: 1px solid var(--border); }
.mp-modal-header h3 { font-size: 16px; font-weight: 600; }
.mp-modal-close { background: none; border: none; cursor: pointer; font-size: 18px; color: var(--text2); }
.mp-modal-body { padding: 24px; max-height: 60vh; overflow-y: auto; }
.mp-modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; align-items: center; }
.mp-cmd-result { flex: 1; font-size: 12px; padding: 8px 12px; border-radius: var(--radius); }
.mp-cmd-success { background: rgba(34,197,94,.1); color: var(--success); }
.mp-cmd-error   { background: rgba(239,68,68,.1);  color: var(--danger); }
.mp-cmd-panel { display: none; }
.mp-cmd-panel.active { display: block; }

/* ── Detail panel (slide-in) ────────────────────────────────────────────────── */
.mp-detail-panel { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: stretch; justify-content: flex-end; }
.mp-detail-box { position: relative; z-index: 1; background: var(--bg2); border-left: 1px solid var(--border); width: 900px; max-width: 95vw; display: flex; flex-direction: column; }
.mp-detail-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 24px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.mp-detail-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); padding: 0 16px; flex-shrink: 0; overflow-x: auto; }
.mp-detail-body { flex: 1; overflow: auto; padding: 16px 24px; }
.mp-detail-footer { padding: 12px 24px; border-top: 1px solid var(--border); display: flex; gap: 8px; flex-shrink: 0; }
.mp-dtab-panel { display: none; }
.mp-dtab-panel.active { display: block; }
.mp-info-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.mp-info-row { display: flex; flex-direction: column; background: var(--bg3); border-radius: var(--radius); padding: 12px; }
.mp-info-label { font-size: 11px; color: var(--text3); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .05em; }
.mp-info-val { font-size: 14px; font-weight: 500; word-break: break-all; }

/* ── Screen page ────────────────────────────────────────────────────────────── */
.mp-screen-page { display: flex; flex-direction: column; height: 100vh; background: #000; color: #fff; }
.mp-screen-header { display: flex; align-items: center; justify-content: space-between; padding: 8px 16px; background: var(--bg2); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.mp-screen-title { display: flex; align-items: center; gap: 12px; font-size: 15px; }
.mp-screen-host { color: var(--text2); }
.mp-screen-controls { display: flex; gap: 8px; }
.mp-screen-body { flex: 1; overflow: auto; display: flex; align-items: center; justify-content: center; position: relative; }
#screen-canvas { max-width: 100%; max-height: 100%; display: block; }
.mp-screen-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.7); }
.mp-screen-placeholder { text-align: center; }
.mp-spinner { width: 40px; height: 40px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto 16px; }
@keyframes spin { to { transform: rotate(360deg); } }
.mp-screen-footer { display: flex; gap: 24px; padding: 6px 16px; background: var(--bg2); border-top: 1px solid var(--border); font-size: 12px; color: var(--text3); flex-shrink: 0; }
.mp-screen-error { color: var(--danger); padding: 40px; }
.mp-actions { display: flex; gap: 4px; }
.mp-link { color: var(--primary); }
.mp-usage[data-v] { font-size: 12px; }
.mp-create-apikey-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 12px 20px; background: var(--bg3); }
.mp-code { font-size: 11px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: middle; }

/* ── Scrollbar ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .mp-stats-row { grid-template-columns: repeat(2, 1fr); }
  .mp-sidebar { position: fixed; left: -var(--sidebar-w); z-index: 100; transition: left .25s; }
  .mp-sidebar.open { left: 0; }
  .mp-detail-box { width: 100%; }
}
@media (max-width: 480px) {
  .mp-stats-row { grid-template-columns: 1fr 1fr; }
  .mp-content { padding: 16px; }
  .mp-login-box { padding: 32px 20px; }
}
