:root {
    --bg: #09000f;
    --surface: #0f0520;
    --surface-2: #170830;
    --border: rgba(139, 92, 246, 0.16);
    --border-hover: rgba(139, 92, 246, 0.32);
    --purple: #8b5cf6;
    --purple-lt: #a78bfa;
    --purple-dim: rgba(139, 92, 246, 0.1);
    --purple-glow: rgba(139, 92, 246, 0.2);
    --text: #ede9f5;
    --text-2: #9585b4;
    --muted: #4a3f60;
    --green: #4ade80;
    --red: #f87171;
    --yellow: #fbbf24;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; font-size: inherit; color: inherit; }
input, textarea, select { font-family: inherit; font-size: inherit; }

.shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    background: radial-gradient(ellipse at 60% 0%, rgba(109, 40, 217, 0.1) 0%, transparent 50%), var(--bg);
}

.auth-card {
    width: min(420px, 100%);
    padding: 2rem 2.25rem;
    border-radius: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}

.brand-row {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.mark {
    display: block;
    width: 7px;
    height: 7px;
    border-radius: 2px;
    background: var(--purple);
    box-shadow: 0 0 8px var(--purple-glow);
}

.brand-name {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--purple-lt);
}

.actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.auth-card h1 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
}

.auth-card > p {
    font-size: 0.85rem;
    color: var(--text-2);
    margin-top: -0.25rem;
}

.auth-card form {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.field label {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-2);
}

.field input, .field textarea {
    padding: 0.7rem 0.85rem;
    border-radius: 6px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 150ms;
    width: 100%;
}

.field input:focus, .field textarea:focus { border-color: var(--purple); }
.field input::placeholder, .field textarea::placeholder { color: var(--muted); }

.btn-primary {
    width: 100%;
    height: 2.6rem;
    border-radius: 6px;
    background: var(--purple);
    color: #fff;
    font-weight: 600;
    font-size: 0.9rem;
    transition: opacity 150ms;
}
.btn-primary:hover { opacity: 0.85; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 1.5rem;
    height: 2.6rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    transition: opacity 150ms;
    border: none;
    cursor: pointer;
    font-family: inherit;
}

.btn.primary {
    background: var(--purple);
    color: #fff;
}

.btn.primary:hover { opacity: 0.85; }

.btn.secondary {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn.secondary:hover { background: var(--surface); }

.err {
    font-size: 0.82rem;
    color: var(--red);
    padding: 0.55rem 0.75rem;
    border-radius: 5px;
    background: rgba(248, 113, 113, 0.07);
    border: 1px solid rgba(248, 113, 113, 0.18);
}

.foot {
    text-align: center;
    font-size: 0.82rem;
    color: var(--muted);
}
.foot a { color: var(--purple-lt); }
.foot a:hover { text-decoration: underline; }

.back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.8rem;
    height: 1.8rem;
    border-radius: 5px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 0.75rem;
    transition: color 150ms;
}
.back:hover { color: var(--text-2); }

.dashboard-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 1.25rem 0.75rem;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-top { display: flex; flex-direction: column; gap: 1.75rem; }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0 0.35rem;
}

.sidebar-brand span:last-child {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--purple-lt);
}

nav { display: flex; flex-direction: column; gap: 0.15rem; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.75rem;
    border-radius: 6px;
    font-size: 0.84rem;
    font-weight: 500;
    color: var(--muted);
    transition: background 150ms, color 150ms;
}
.nav-item i { width: 1rem; text-align: center; font-size: 0.82rem; }
.nav-item:hover { background: var(--surface-2); color: var(--text-2); }
.nav-item.active { background: var(--purple-dim); color: var(--purple-lt); border: 1px solid var(--border); }

.nav-divider { height: 1px; background: var(--border); margin: 0.35rem 0.4rem; }

.sidebar-bottom {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 0.35rem 0;
    border-top: 1px solid var(--border);
}

.sidebar-user { display: flex; align-items: center; gap: 0.5rem; flex: 1; min-width: 0; }

.uavatar {
    width: 1.8rem;
    height: 1.8rem;
    border-radius: 50%;
    background: var(--purple-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--purple-lt);
    font-size: 0.7rem;
    flex-shrink: 0;
}

.uname {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-2);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.logout-btn {
    width: 1.8rem;
    height: 1.8rem;
    border-radius: 5px;
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    flex-shrink: 0;
    transition: background 150ms, color 150ms;
}
.logout-btn:hover { background: rgba(248, 113, 113, 0.1); color: var(--red); }

.main-content {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    padding: 2rem 2.25rem;
}

.page-hdr { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 2rem; }
.page-hdr h1 { font-size: 1.4rem; font-weight: 700; color: var(--text); }
.page-hdr .sub { font-size: 0.82rem; color: var(--muted); }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.stat-card {
    padding: 1rem 1.1rem;
    border-radius: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
}
.stat-card.warn { border-color: rgba(251, 191, 36, 0.25); background: rgba(251, 191, 36, 0.04); }

.stat-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--muted);
    margin-bottom: 0.4rem;
}

.stat-val {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-2);
}
.stat-val.ok { color: var(--green); }
.stat-val.bad { color: var(--red); }
.stat-val.warn { color: var(--yellow); }
.stat-val.sm { font-size: 0.78rem; }
.stat-val.mono { font-family: 'Courier New', monospace; }

.section { display: flex; flex-direction: column; gap: 0.65rem; margin-bottom: 2rem; }

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.section-title {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
}

.badge {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
    background: var(--purple-dim);
    color: var(--purple-lt);
    border: 1px solid var(--border);
}

.hwid-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;
    padding: 1rem 1.15rem;
    border-radius: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    flex-wrap: wrap;
}

.hwid-info { display: flex; align-items: flex-start; gap: 0.75rem; flex: 1; min-width: 200px; }
.hwid-info > i { color: var(--muted); font-size: 1rem; margin-top: 0.1rem; flex-shrink: 0; }
.hwid-info p { font-size: 0.82rem; color: var(--text-2); line-height: 1.5; }
.hwid-limit { color: var(--muted) !important; margin-top: 0.2rem; font-size: 0.75rem !important; }

.btn-hwid {
    padding: 0 1.1rem;
    height: 2.3rem;
    border-radius: 6px;
    background: var(--purple);
    color: #fff;
    font-weight: 600;
    font-size: 0.84rem;
    white-space: nowrap;
    flex-shrink: 0;
    transition: opacity 150ms;
}
.btn-hwid:hover:not(:disabled) { opacity: 0.85; }
.btn-hwid:disabled { opacity: 0.35; cursor: not-allowed; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }

.toast-stack {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 100;
    pointer-events: none;
}

.toast {
    padding: 0.7rem 1rem;
    border-radius: 7px;
    background: var(--surface);
    border: 1px solid var(--purple);
    color: var(--purple-lt);
    font-size: 0.83rem;
    font-weight: 500;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    max-width: 320px;
    animation: slide-in 200ms ease;
}

@keyframes slide-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(9, 0, 15, 0.82);
    display: grid;
    place-items: center;
    padding: 1rem;
    z-index: 50;
    backdrop-filter: blur(4px);
}

.modal {
    width: min(480px, 100%);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}
.modal.lg { width: min(640px, 100%); }
.modal.wide { width: min(560px, 100%); }

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    gap: 0.75rem;
}

.modal-title { font-weight: 600; font-size: 0.92rem; color: var(--text); display: flex; align-items: center; gap: 0.4rem; }

.close-btn {
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 4px;
    background: var(--surface-2);
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    transition: color 150ms;
    flex-shrink: 0;
}
.close-btn:hover { color: var(--text-2); }

.modal-body {
    padding: 1.1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    overflow-y: auto;
}

.modal-foot {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    align-items: center;
    padding: 0.9rem 1.25rem;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.modal-scroll { overflow-y: auto; display: flex; flex-direction: column; }

.btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0 1.1rem;
    height: 2.3rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.84rem;
    transition: opacity 150ms;
    white-space: nowrap;
}
.btn:hover:not(:disabled) { opacity: 0.85; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.primary { background: var(--purple); color: #fff; }
.btn.ghost { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.btn.danger { background: rgba(248, 113, 113, 0.12); color: var(--red); border: 1px solid rgba(248, 113, 113, 0.2); }
.btn.approve { background: rgba(74, 222, 128, 0.12); color: var(--green); border: 1px solid rgba(74, 222, 128, 0.2); }
.btn.deny { background: rgba(248, 113, 113, 0.1); color: var(--red); border: 1px solid rgba(248, 113, 113, 0.2); }
.btn.sm { height: 2rem; padding: 0 0.85rem; font-size: 0.78rem; }

.msg { font-size: 0.82rem; color: var(--red); padding: 0.55rem 0.75rem; border-radius: 5px; background: rgba(248, 113, 113, 0.07); border: 1px solid rgba(248, 113, 113, 0.18); }
.msg.ok { color: var(--green); background: rgba(74, 222, 128, 0.07); border-color: rgba(74, 222, 128, 0.18); }

.inline-msg { font-size: 0.8rem; color: var(--red); }
.inline-msg.ok { color: var(--green); }

.loader { display: flex; align-items: center; gap: 0.6rem; color: var(--purple-lt); font-size: 0.88rem; padding: 1rem 0; }

.err-box { display: flex; align-items: center; gap: 0.5rem; padding: 0.75rem 1rem; border-radius: 6px; background: rgba(248, 113, 113, 0.07); border: 1px solid rgba(248, 113, 113, 0.18); color: var(--red); font-size: 0.85rem; }

.mono { font-family: 'Courier New', monospace; }

.trigger-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.75rem;
}

.trigger-card {
    padding: 1rem 1.1rem;
    border-radius: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    transition: border-color 200ms;
}
.trigger-card:hover { border-color: var(--border-hover); }

.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.5rem; }
.card-name-row { display: flex; align-items: center; gap: 0.5rem; flex: 1; min-width: 0; }

.tname { font-size: 0.88rem; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.lines-badge {
    font-size: 0.68rem;
    font-weight: 600;
    font-family: 'Courier New', monospace;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    background: var(--surface-2);
    color: var(--muted);
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.card-acts { display: flex; gap: 0.25rem; flex-shrink: 0; }

.icon-btn {
    width: 1.65rem;
    height: 1.65rem;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    background: var(--surface-2);
    color: var(--muted);
    border: 1px solid transparent;
    transition: background 150ms, color 150ms;
}
.icon-btn:hover { background: var(--purple-dim); color: var(--purple-lt); border-color: var(--border); }
.icon-btn.danger:hover { background: rgba(248, 113, 113, 0.1); color: var(--red); }

.blurred-body {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    filter: blur(4px);
    transition: filter 220ms ease;
    user-select: none;
    pointer-events: none;
}
.trigger-card:hover .blurred-body {
    filter: blur(0);
    user-select: auto;
    pointer-events: auto;
}

.resource-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 0.18rem 0.5rem;
    border-radius: 4px;
    background: var(--purple-dim);
    color: var(--purple-lt);
    border: 1px solid var(--border);
    width: fit-content;
}

.tdesc { font-size: 0.77rem; color: var(--muted); line-height: 1.45; }

.code-preview {
    background: #0c0420;
    border: 1px solid rgba(139, 92, 246, 0.12);
    border-radius: 5px;
    padding: 0.55rem 0.75rem;
}
.code-preview pre { font-family: 'Courier New', monospace; font-size: 0.74rem; color: #c084fc; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 0; }
.code-preview .more { display: block; font-size: 0.68rem; color: var(--muted); font-family: 'Courier New', monospace; margin-top: 0.25rem; }

.card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 0.1rem; }
.ts { font-size: 0.7rem; color: var(--muted); font-family: 'Courier New', monospace; }
.view-btn { font-size: 0.72rem; font-weight: 600; color: var(--purple-lt); background: none; padding: 0; opacity: 0.7; transition: opacity 150ms; }
.view-btn:hover { opacity: 1; }

.empty-state { display: flex; flex-direction: column; align-items: center; gap: 0.75rem; padding: 4rem 2rem; border: 1px dashed rgba(139, 92, 246, 0.2); border-radius: 8px; color: var(--muted); font-size: 0.88rem; text-align: center; }
.empty-state i { font-size: 1.6rem; opacity: 0.3; }

.confirm-card { width: min(320px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1.75rem 1.5rem; display: flex; flex-direction: column; align-items: center; gap: 0.4rem; text-align: center; }
.confirm-icon { width: 2.5rem; height: 2.5rem; border-radius: 50%; background: rgba(248, 113, 113, 0.1); border: 1px solid rgba(248, 113, 113, 0.2); color: var(--red); display: flex; align-items: center; justify-content: center; margin-bottom: 0.5rem; }
.confirm-title { font-weight: 600; color: var(--text); font-size: 0.95rem; }

table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 2rem;
}

table th, table td {
    padding: 0.5rem;
    border: 1px solid var(--border);
    text-align: left;
}

table th {
    background: var(--surface-2);
}

@media (max-width: 768px) {
    .dashboard-layout {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        height: auto;
        position: static;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .main-content {
        padding: 1rem;
    }
    .sidebar-top {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
    nav {
        flex-direction: row;
        gap: 1rem;
    }
    .nav-item {
        padding: 0.5rem 0.75rem;
    }
    .sidebar-bottom {
        display: none;
    }
    .shell {
        padding: 1rem;
    }
    .auth-card {
        padding: 1.5rem 1.5rem;
    }
    .actions {
        flex-direction: row;
        gap: 1rem;
    }
}