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

:root {
    --bg: #0d1017;
    --card: #161b26;
    --border: #262d3d;
    --text: #e6e9f0;
    --muted: #8b93a7;
    --accent: #5b7cfa;
    --accent-hover: #7391ff;
    --green: #3ecf8e;
    --red: #f2555a;
    --side: #10141f;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    font-size: 15px;
    min-height: 100vh;
}

#app { min-height: 100vh; }

h1 { font-size: 22px; margin-bottom: 8px; }
h2 { font-size: 16px; margin-bottom: 12px; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 16px;
}

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 860px) { .grid { grid-template-columns: 1fr; } }

.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--side);
    border-right: 1px solid var(--border);
    padding: 20px 14px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.brand { font-size: 18px; font-weight: 700; padding: 4px 10px 14px; }
.brand span { color: var(--accent); }

.side-section h3 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--muted);
    margin: 0 10px 6px;
}

.sidebar a {
    display: block;
    padding: 8px 10px;
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    margin-bottom: 2px;
}

.sidebar a:hover { background: #1a2030; text-decoration: none; }
.sidebar a.active { background: var(--accent); color: #fff; }

.logout { margin-top: auto; width: 100%; }

.main {
    flex: 1;
    max-width: 1060px;
    margin: 0 auto;
    padding: 24px 20px 64px;
    min-width: 0;
}

@media (max-width: 720px) {
    .layout { flex-direction: column; }
    .sidebar {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        border-right: none;
        border-bottom: 1px solid var(--border);
        gap: 8px;
    }
    .side-section { display: flex; align-items: center; gap: 4px; }
    .side-section h3 { display: none; }
    .logout { margin-top: 0; width: auto; }
}

.balance {
    background: linear-gradient(135deg, #1a2340, #161b26);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 24px;
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.balance .amount { font-size: 34px; font-weight: 700; color: var(--green); }
.balance .label { color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.balance button { width: auto; padding: 10px 22px; }

label { display: block; color: var(--muted); font-size: 13px; margin-bottom: 6px; }

input, select {
    width: 100%;
    background: #0d1017;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text);
    font-size: 14px;
    margin-bottom: 12px;
}

input:focus, select:focus { outline: none; border-color: var(--accent); }

button {
    background: var(--accent);
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
}

button:hover { background: var(--accent-hover); }
button.secondary { background: #232b3d; }
button.secondary:hover { background: #2d3650; }
button.danger { background: #3a2027; }
button.danger:hover { background: #4d2a34; }
button.small { width: auto; padding: 6px 12px; font-size: 12px; }

.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

.msg { margin-top: 10px; font-size: 13px; }
.msg.error { color: var(--red); }
.msg.ok { color: var(--green); }
.ok { color: var(--green); font-size: 13px; }

.keys {
    background: #0d1017;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    font-family: Consolas, monospace;
    font-size: 13px;
    white-space: pre;
    overflow-x: auto;
    margin-top: 12px;
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: none; }
td.mono { font-family: Consolas, monospace; }

.actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.actions button, .actions select { width: auto; margin: 0; padding: 5px 10px; font-size: 12px; }

.tag {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 20px;
    white-space: nowrap;
}
.tag.unused { background: #163a2b; color: var(--green); }
.tag.used { background: #232b3d; color: var(--muted); }
.tag.refunded { background: #3a2027; color: var(--red); }

.badge {
    background: var(--accent);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 20px;
    display: inline-block;
}

.tier-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }

.progress {
    background: #0d1017;
    border: 1px solid var(--border);
    border-radius: 20px;
    height: 12px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--green));
    border-radius: 20px;
    min-width: 2px;
}

.guide { margin-left: 20px; display: grid; gap: 8px; font-size: 14px; color: var(--text); }

.auth-box { max-width: 380px; margin: 10vh auto 0; }
.auth-box .card { padding: 28px; }
.auth-toggle { text-align: center; margin-top: 14px; font-size: 13px; color: var(--muted); }

.center { text-align: center; }
.muted { color: var(--muted); font-size: 13px; }
.mt { margin-top: 12px; }
.big-code { font-family: Consolas, monospace; font-size: 16px; color: var(--green); word-break: break-all; margin-top: 12px; }

.scope-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 600px) { .scope-grid { grid-template-columns: 1fr; } }

.scope-card {
    display: block;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    margin: 0;
    background: #0d1017;
}

.scope-card:hover { border-color: var(--accent); }

.scope-card input {
    width: auto;
    margin: 0 8px 0 0;
    display: inline-block;
    vertical-align: middle;
}

.scope-name {
    font-family: Consolas, monospace;
    color: var(--red);
    font-weight: 700;
    font-size: 13px;
    display: inline-block;
}

.btn-orange { background: #e8603c; width: auto; padding: 10px 20px; }
.btn-orange:hover { background: #f0744f; }

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 16px;
}

.modal {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    max-width: 520px;
    width: 100%;
}

.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.modal-head h2 { margin: 0; }
.modal-head button { width: auto; }

.warn-box {
    background: #3a2a1c;
    border: 1px solid #6b4a2a;
    border-radius: 8px;
    padding: 12px;
    font-size: 13px;
    margin-bottom: 14px;
    line-height: 1.5;
}

.token-box {
    background: #0d1017;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    font-family: Consolas, monospace;
    font-size: 13px;
    color: var(--green);
    word-break: break-all;
}

.modal .row { align-items: stretch; }
.modal .btn-orange { white-space: nowrap; }
