:root {
    --bg:        #0a0a0b;
    --bg-2:      #0f0f11;
    --panel:     #141416;
    --panel-2:   #1c1c1f;
    --panel-3:   #242428;
    --border:    #2a2a2e;
    --border-2:  #34343a;
    --text:      #ececee;
    --muted:     #8a8a92;
    --accent:    #f2f2f4;   /* near-white = primary action */
    --accent-fg: #0c0c0d;   /* text on accent */
    --green:     #43b581;
    --red:       #e0555f;
    --amber:     #c9a14a;
    --radius:    12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: .9rem; }

.brand { font-weight: 800; letter-spacing: -.02em; color: var(--text); }
.ic { display: inline-block; vertical-align: -3px; flex-shrink: 0; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ───── Login ───── */
.screen { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card {
    background: var(--panel); border: 1px solid var(--border);
    border-radius: 16px; padding: 48px 40px; text-align: center;
    max-width: 380px; width: 100%;
}
.login-card .brand { font-size: 2rem; }
.login-card p { margin: 8px 0 28px; }

/* ───── Buttons ───── */
.btn {
    display: inline-flex; align-items: center; gap: 8px; justify-content: center;
    border: 1px solid transparent; border-radius: 9px; padding: 10px 16px; font: inherit;
    font-weight: 600; cursor: pointer; text-decoration: none; color: var(--text);
    transition: background .15s ease, border-color .15s ease, transform .08s ease;
}
.btn:active { transform: translateY(1px); }
.btn-sm { padding: 7px 11px; font-size: .85rem; }
.btn-discord { background: var(--panel-2); border-color: var(--border-2); width: 100%; }
.btn-discord:hover { background: var(--panel-3); }
.btn-primary { background: var(--accent); color: var(--accent-fg); }
.btn-primary:hover { background: #ffffff; }
.btn-ghost { background: transparent; border-color: var(--border-2); }
.btn-ghost:hover { background: var(--panel-2); }
.btn-danger { background: transparent; border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: rgba(224,85,95,.12); }

/* ───── Sidebar (left nav) ───── */
#app { display: flex; min-height: 100vh; }
.sidebar {
    width: 232px; flex-shrink: 0;
    display: flex; flex-direction: column;
    background: var(--panel); border-right: 1px solid var(--border);
    padding: 18px 14px; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { font-size: 1.25rem; padding: 6px 12px 20px; }
.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav button {
    display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
    background: transparent; border: none; color: var(--muted);
    padding: 10px 12px; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 500;
}
.nav button:hover { color: var(--text); background: var(--panel-2); }
.nav button.active { color: var(--text); background: var(--panel-3); }

.user { display: flex; flex-direction: column; gap: 11px; padding-top: 14px; border-top: 1px solid var(--border); }
.user-info { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-meta { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.user-meta #userName { font-weight: 600; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border-2); background: var(--panel-2); flex-shrink: 0; }
.badge {
    align-self: flex-start;
    font-size: .64rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
    padding: 2px 7px; border-radius: 5px; background: var(--panel-3); color: var(--text); border: 1px solid var(--border-2);
}
#logoutBtn { width: 100%; justify-content: center; }

/* ───── Layout ───── */
main { flex: 1; min-width: 0; padding: 30px 36px; }
.view h1 { font-size: 1.5rem; margin-bottom: 20px; font-weight: 700; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 14px; }

/* ───── Cards (client licenses) ───── */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.lic-card {
    background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 20px; position: relative; overflow: hidden;
}
.lic-key { font-family: ui-monospace, monospace; font-size: 1.02rem; font-weight: 700; letter-spacing: .03em; }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: .7rem; font-weight: 700; padding: 4px 9px; border-radius: 6px;
    background: var(--panel-3); color: var(--text); border: 1px solid var(--border-2); }
.pill.ok   { color: var(--green); border-color: rgba(67,181,129,.4); }
.pill.off  { color: var(--red);   border-color: rgba(224,85,95,.4); }
.pill.warn { color: var(--amber); border-color: rgba(201,161,74,.4); }
.pill.inf, .pill.auto { color: var(--muted); }
.tag { display: inline-block; background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
    border-radius: 6px; padding: 4px 9px; font-size: .8rem; margin: 3px 4px 0 0; }
.lic-sec { margin-top: 16px; }
.lic-sec h4 { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 8px; }
.ip-row { display: flex; align-items: center; justify-content: space-between; gap: 8px;
    background: var(--bg-2); border: 1px solid var(--border); border-radius: 7px; padding: 7px 11px; margin-bottom: 6px; }
.ip-row code { font-family: ui-monospace, monospace; font-size: .85rem; }
.icon-btn { display: inline-flex; align-items: center; background: transparent; border: none; color: var(--muted); cursor: pointer; padding: 2px; }
.icon-btn:hover { color: var(--red); }

/* ───── Stat cards ───── */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat {
    display: flex; align-items: flex-start; gap: 13px;
    background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 17px 18px;
}
.stat .ic { color: var(--muted); margin-top: 3px; }
.stat .n { font-size: 1.7rem; font-weight: 800; line-height: 1.1; }
.stat .l { color: var(--muted); font-size: .8rem; margin-top: 3px; }
.stat.green .n { color: var(--green); }
.stat.green .ic { color: var(--green); }
.stat.red .n { color: var(--red); }
.stat.red .ic { color: var(--red); }

/* ───── Panels / tables ───── */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.panel-head h2 { font-size: 1rem; font-weight: 600; }
.table-wrap { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 15px; font-size: .88rem; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; background: var(--bg-2); }
tr + tr td { border-top: 1px solid var(--border); }
td code { font-family: ui-monospace, monospace; }
td.wrap { white-space: normal; }
.plugins-cell { max-width: 360px; }
.plugins-cell .tag { margin: 2px 4px 2px 0; }
.copy { cursor: pointer; }
.copy:hover { color: #fff; text-decoration: underline; }
.t-actions { display: flex; gap: 6px; justify-content: flex-end; }

.input { background: var(--bg-2); border: 1px solid var(--border-2); color: var(--text);
    border-radius: 8px; padding: 10px 12px; font: inherit; width: 100%; }
.input:focus { outline: none; border-color: var(--muted); }
.search { max-width: 420px; margin-bottom: 16px; }
select.input { cursor: pointer; }

.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--border); border-radius: 9px; padding: 4px; margin-bottom: 16px; }
.seg-btn { background: transparent; border: none; color: var(--muted); padding: 7px 14px; border-radius: 6px; cursor: pointer; font: inherit; }
.seg-btn.active { background: var(--panel-3); color: var(--text); }

/* ───── Charts ───── */
.charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.charts-row .panel { margin-bottom: 0; }
.chart-box { position: relative; width: 100%; height: 300px; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center;
    color: var(--muted); font-size: .9rem; text-align: center; padding: 12px; }
@media (max-width: 880px) { .charts-row { grid-template-columns: 1fr; } }

/* ───── World globe (globe.gl) ───── */
.map-box { background: #000; border: 1px solid var(--border); border-radius: var(--radius);
    padding: 0; overflow: hidden; position: relative; width: 100%; height: 78vh; min-height: 520px; }
.map-box canvas { display: block; }

/* ───── Modal ───── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.65); display: grid; place-items: center; z-index: 100; padding: 20px; }
.modal-box { background: var(--panel); border: 1px solid var(--border-2); border-radius: 14px;
    padding: 24px; width: 100%; max-width: 440px; }
.modal-box h3 { margin-bottom: 18px; font-size: 1.1rem; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: .78rem; color: var(--muted); margin-bottom: 6px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }

/* ───── Toast ───── */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
    background: var(--panel-3); border: 1px solid var(--border-2); padding: 12px 18px; border-radius: 9px;
    box-shadow: 0 12px 30px rgba(0,0,0,.5); z-index: 200; font-weight: 500; max-width: 90vw; }
.toast.ok  { border-color: rgba(67,181,129,.5); }
.toast.err { border-color: rgba(224,85,95,.5); }

.empty { text-align: center; color: var(--muted); padding: 50px 20px; }
@media (max-width: 760px) {
    #app { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: static; flex-direction: row;
        align-items: center; flex-wrap: wrap; gap: 8px;
        border-right: none; border-bottom: 1px solid var(--border); padding: 12px 16px; }
    .sidebar .brand { padding: 0 8px 0 4px; }
    .nav { flex-direction: row; flex-wrap: wrap; flex: 1 1 100%; order: 3; }
    .nav button { width: auto; }
    .user { flex-direction: row; align-items: center; border-top: none; padding-top: 0; }
    #logoutBtn { width: auto; }
    th, td { white-space: normal; }
}
