/* ============ AUTH GATE ============ */
.gate {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 20px;
}
.gate-grid {
    position: fixed;
    inset: 0;
    background-image:
            linear-gradient(var(--line) 1px, transparent 1px),
            linear-gradient(90deg, var(--line) 1px, transparent 1px);
    background-size: 40px 40px;
    opacity: 0.25;
    z-index: 0;
    pointer-events: none;
    mask-image: radial-gradient(ellipse at center, #000 0%, transparent 70%);
    -webkit-mask-image: radial-gradient(ellipse at center, #000 0%, transparent 70%);
}
.gate-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 400px;
    background: var(--bg-1);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 32px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.4);
    animation: rise .4s cubic-bezier(.2,.8,.2,1);
}
.brand { margin-bottom: 24px; }
.brand-name {
    font-family: var(--disp);
    font-weight: 900;
    font-size: 28px;
    letter-spacing: 0.04em;
    color: var(--amber);
    display: block;
}
.brand-name.sm { font-size: 18px; color: var(--txt); letter-spacing: 0.06em; }
.brand-sub {
    display: block;
    font-size: 12px;
    color: var(--txt-dim);
    margin-top: 2px;
    letter-spacing: 0.04em;
}
.gate-step { display: flex; flex-direction: column; gap: 8px; }
.gate-hint { font-size: 11px; color: var(--txt-faint); margin-top: 12px; text-align: center; }
.gate-error {
    margin-top: 14px;
    padding: 10px 12px;
    background: rgba(248,113,113,0.08);
    border: 1px solid rgba(248,113,113,0.3);
    border-radius: var(--r);
    color: var(--red);
    font-size: 12px;
    animation: fade .2s;
}

/* ============ TABS ============ */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--line);
}
.tab {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--txt-dim);
    font-family: var(--mono);
    font-size: 13px;
    padding: 8px 14px;
    cursor: pointer;
    transition: all .12s;
    margin-bottom: -1px;
}
.tab:hover { color: var(--txt); }
.tab.active { color: var(--amber); border-bottom-color: var(--amber); }

/* ============ APP SHELL ============ */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    padding: 0 24px;
    border-bottom: 1px solid var(--line);
    background: var(--bg-1);
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 28px; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.nav { display: flex; gap: 2px; }
.nav-item {
    background: transparent;
    border: none;
    color: var(--txt-dim);
    font-family: var(--mono);
    font-size: 13px;
    padding: 8px 14px;
    border-radius: var(--r);
    cursor: pointer;
    transition: all .12s;
}
.nav-item:hover { color: var(--txt); background: var(--bg-3); }
.nav-item.active { color: var(--amber); background: var(--bg-3); }

.balance-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-radius: 100px;
    padding: 5px 12px;
    font-size: 12px;
    color: var(--txt-dim);
}
.balance-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 8px var(--green);
}
.balance-dot.warn { background: var(--amber); box-shadow: 0 0 8px var(--amber); }
.balance-dot.danger { background: var(--red); box-shadow: 0 0 8px var(--red); animation: pulse 1.2s infinite; }

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--txt);
}
.role-badge {
    background: var(--amber);
    color: #1a1205;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 7px;
    border-radius: 100px;
}

/* ============ MODALS ============ */
.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(5,6,8,0.6);
    animation: fade .2s;
}
.modal-card {
    position: relative;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    background: var(--bg-1);
    border: 1px solid var(--line-2);
    border-radius: 10px;
    box-shadow: 0 24px 70px rgba(0,0,0,0.5);
    animation: rise .25s cubic-bezier(.2,.8,.2,1);
}
.modal-card.sm { max-width: 420px; }
.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--line);
}
.modal-head h2 { font-family: var(--disp); font-weight: 800; font-size: 18px; }
.modal-body { padding: 20px 22px; display: flex; flex-direction: column; gap: 16px; }
.modal-text { color: var(--txt-dim); font-size: 13px; line-height: 1.6; }
.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 22px;
    border-top: 1px solid var(--line);
}
.launch-target {
    padding: 12px 22px;
    background: var(--bg-2);
    border-bottom: 1px solid var(--line);
    font-size: 12px;
    color: var(--txt-dim);
}
.launch-target b { color: var(--txt); font-weight: 600; }

.field { display: flex; flex-direction: column; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ============ SEGMENTED CONTROL ============ */
.seg {
    display: inline-flex;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 2px;
    gap: 2px;
}
.seg-btn {
    background: transparent;
    border: none;
    color: var(--txt-dim);
    font-family: var(--mono);
    font-size: 12px;
    padding: 6px 14px;
    border-radius: 3px;
    cursor: pointer;
    transition: all .12s;
}
.seg-btn:hover { color: var(--txt); }
.seg-btn.active { background: var(--bg-3); color: var(--amber); }

/* ============ TABLES ============ */
.table-wrap {
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    overflow-x: auto;
}
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
    text-align: left;
    padding: 11px 14px;
    background: var(--bg-2);
    color: var(--txt-dim);
    font-weight: 500;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.data-table td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--line);
    color: var(--txt);
    vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg-2); }
.data-table .amount { font-family: var(--mono); color: var(--cyan); }
.data-table .amount.over { color: var(--red); }
.user-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ============ TAGS / STATUS ============ */
.tag {
    display: inline-block;
    background: var(--bg-3);
    color: var(--txt-dim);
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid var(--line);
    white-space: nowrap;
}
.tag.status-running { color: var(--green); border-color: rgba(74,222,128,0.3); }
.tag.status-pending { color: var(--amber); border-color: rgba(255,174,59,0.3); }
.tag.status-stopping { color: var(--blue); border-color: rgba(96,165,250,0.3); }
.tag.status-stopped { color: var(--txt-faint); }
.tag.status-failed { color: var(--red); border-color: rgba(248,113,113,0.3); }

.role-tag {
    display: inline-block;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 100px;
    background: var(--bg-3);
    color: var(--txt-dim);
    border: 1px solid var(--line);
}
.role-tag.admin { color: var(--amber); border-color: rgba(255,174,59,0.35); }

/* ============ DETAIL VIEWER ============ */
.detail-list { display: flex; flex-direction: column; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.detail-row { display: grid; grid-template-columns: 140px 1fr; gap: 12px; padding: 10px 14px; background: var(--bg-1); }
.detail-k { color: var(--txt-faint); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
.detail-v { color: var(--txt); font-size: 13px; word-break: break-word; }

/* ============ TOASTS ============ */
.toasts {
    position: fixed;
    top: 70px;
    right: 20px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 340px;
}
.toast {
    background: var(--bg-2);
    border: 1px solid var(--line-2);
    border-left: 3px solid var(--txt-faint);
    border-radius: var(--r);
    padding: 12px 14px;
    box-shadow: 0 12px 30px rgba(0,0,0,0.4);
    animation: toastIn .3s cubic-bezier(.2,.8,.2,1);
}
.toast.ok { border-left-color: var(--green); }
.toast.err { border-left-color: var(--red); }
.toast.info { border-left-color: var(--blue); }
.toast-title { font-size: 13px; font-weight: 600; color: var(--txt); }
.toast-msg { font-size: 12px; color: var(--txt-dim); margin-top: 3px; word-break: break-word; }