:root {
    --bg: #0c0e14;
    --surface: #151822;
    --surface-2: #1c2030;
    --border: #2a3045;
    --text: #eef1f7;
    --muted: #98a2b8;
    --primary: #5865f2;
    --primary-hover: #4752c4;
    --green: #23a55a;
    --red: #da373c;
    --yellow: #fee75c;
    --radius: 12px;
}

* {
    box-sizing: border-box;
    font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
}

.hidden {
    display: none !important;
}

/* Login */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: radial-gradient(circle at top, #1f2440 0%, var(--bg) 60%);
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

.login-brand {
    text-align: center;
    margin-bottom: 24px;
}

.brand-badge {
    font-size: 36px;
    margin-bottom: 8px;
}

.login-brand h1 {
    margin: 0;
    font-size: 22px;
    letter-spacing: 0.04em;
}

.login-brand p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
}

/* Shell */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 18px;
    flex-shrink: 0;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.guild-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    object-fit: cover;
}

.sidebar-title {
    font-weight: 700;
    font-size: 15px;
}

.bot-pill {
    font-size: 12px;
    color: #57f287;
    margin-top: 2px;
}

.nav-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 18px;
    flex: 1;
}

.nav-item {
    background: transparent;
    color: var(--muted);
    border: none;
    border-radius: 10px;
    padding: 11px 14px;
    text-align: left;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.nav-item:hover {
    background: var(--surface-2);
    color: var(--text);
}

.nav-item.active {
    background: var(--primary);
    color: #fff;
}

.sidebar-footer {
    border-top: 1px solid var(--border);
    padding-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.schedule-badge {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 12px;
    color: var(--muted);
    text-align: center;
}

.main-content {
    flex: 1;
    padding: 24px 28px;
    overflow-x: hidden;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 22px;
    gap: 12px;
    flex-wrap: wrap;
}

.topbar h2 {
    margin: 0;
    font-size: 22px;
}

.topbar-actions {
    display: flex;
    gap: 8px;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* Cards & Grids */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.stat-card, .card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
}

.stat-label {
    font-size: 12px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 22px;
    font-weight: 700;
    margin: 6px 0 4px;
}

.stat-sub {
    font-size: 12px;
    color: var(--muted);
}

.section-heading {
    margin: 0 0 12px;
    font-size: 16px;
}

.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
    gap: 14px;
}

.module-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.card-header h3 {
    margin: 0;
    font-size: 16px;
}

.two-col {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 16px;
}

.editor-layout {
    display: grid;
    grid-template-columns: 1.2fr 0.9fr;
    gap: 18px;
    align-items: start;
}

@media (max-width: 1080px) {
    .editor-layout {
        grid-template-columns: 1fr;
    }
    .app-shell {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .nav-list {
        flex-direction: row;
        flex-wrap: wrap;
    }
}

/* Subtabs */
.subtab-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.subtab {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--muted);
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}

.subtab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.subtab-panel {
    display: none;
}

.subtab-panel.active {
    display: block;
}

/* Inputs & Forms */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.full-span {
    grid-column: 1 / -1;
}

.field-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    margin: 8px 0 5px;
}

.input {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    padding: 9px 11px;
    font-size: 13px;
    outline: none;
}

.input:focus {
    border-color: var(--primary);
}

.input-sm {
    padding: 6px 10px;
    font-size: 12px;
    width: auto;
}

.input-xs {
    padding: 4px 8px;
    font-size: 12px;
    width: auto;
}

.input-color {
    height: 38px;
    padding: 3px;
    cursor: pointer;
}

.textarea {
    resize: vertical;
    min-height: 70px;
    font-family: inherit;
}

.muted {
    color: var(--muted);
    font-size: 13px;
    margin-top: 0;
}

.inline-toggles {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin: 12px 0;
}

.check-row {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
}

.btn-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.btn {
    border: none;
    border-radius: 8px;
    padding: 9px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: opacity 0.15s ease;
}

.btn:hover {
    opacity: 0.9;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-secondary {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-danger {
    background: var(--red);
    color: #fff;
}

.btn-ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-xs {
    padding: 4px 9px;
    font-size: 11px;
}

.btn-full {
    width: 100%;
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #3b4259;
    transition: 0.2s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    transition: 0.2s;
    border-radius: 50%;
}

input:checked + .slider {
    background: var(--green);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

/* Helper chips & misc */
.chip-bar {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin: 8px 0 4px;
}

.chip {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 3px 8px;
    font-size: 11px;
    color: #93a3ff;
    cursor: pointer;
}

.row-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.helper-chips {
    display: flex;
    gap: 6px;
    align-items: center;
}

.inline-form {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.upload-box {
    background: var(--surface-2);
    border: 1px dashed var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    margin-top: 10px;
}

/* Discord Live Preview */
.discord-preview {
    background: #313338;
    border-radius: 10px;
    padding: 16px;
    color: #dbdee1;
    font-size: 14px;
    line-height: 1.45;
}

.dc-msg-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}

.dc-bot-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    background: #5865f2;
}

.dc-bot-name {
    font-weight: 600;
    color: #fff;
}

.dc-app-tag {
    background: #5865f2;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
}

.dc-content {
    margin: 4px 0 8px 44px;
    white-space: pre-wrap;
    word-break: break-word;
}

.dc-embed {
    margin-left: 44px;
    background: #2b2d31;
    border-left: 4px solid #111214;
    border-radius: 4px;
    padding: 12px 14px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
}

.dc-embed-author {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 6px;
}

.dc-embed-author img {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    object-fit: cover;
}

.dc-embed-title {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 6px;
}

.dc-embed-desc {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 13px;
}

.dc-embed-thumb {
    width: 72px;
    height: 72px;
    border-radius: 8px;
    object-fit: cover;
}

.dc-embed-image {
    grid-column: 1 / -1;
    max-width: 100%;
    max-height: 240px;
    border-radius: 6px;
    object-fit: cover;
    margin-top: 4px;
}

.dc-embed-fields {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
    margin-top: 8px;
}

.dc-embed-field-name {
    font-weight: 700;
    font-size: 13px;
    color: #fff;
}

.dc-embed-field-val {
    font-size: 13px;
    white-space: pre-wrap;
}

.dc-embed-footer {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: #949ba4;
    margin-top: 6px;
}

.dc-embed-footer img {
    width: 18px;
    height: 18px;
    border-radius: 50%;
}

.dc-mention {
    background: rgba(88, 101, 242, 0.3);
    color: #c9cdfb;
    border-radius: 3px;
    padding: 0 3px;
    font-weight: 500;
}

/* Lists & Grids */
.log-cat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.log-cat-item {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.fields-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.field-editor-row {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
    display: grid;
    grid-template-columns: 1fr 1.4fr auto auto;
    gap: 8px;
    align-items: center;
}

.mini-list, .leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 360px;
    overflow-y: auto;
}

.list-row {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}

.backup-actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 12px;
}

.backup-tile {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
}

.backup-tile h4 {
    margin: 0 0 8px;
    font-size: 14px;
}

.summary-pill-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.summary-pill {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
}

.error-box {
    background: rgba(218, 55, 60, 0.16);
    border: 1px solid var(--red);
    color: #ffb4b6;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 12px;
    margin-top: 10px;
}

.result-box {
    margin-top: 10px;
    background: rgba(35, 165, 90, 0.16);
    border: 1px solid var(--green);
    color: #9ff7be;
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 13px;
}

.result-box a {
    color: #fff;
    font-weight: 600;
}

.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    color: var(--text);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.toast.success { border-left-color: var(--green); }
.toast.error { border-left-color: var(--red); }

.mt-4 { margin-top: 4px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.align-end { display: flex; align-items: flex-end; padding-bottom: 6px; }

/* Multi-Role Auto-Assign Pills */
.role-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    min-height: 44px;
    align-items: center;
}

.role-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: #23283d;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
}

.role-pill.warn {
    border-color: var(--yellow);
    background: rgba(254, 231, 92, 0.12);
}

.role-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.role-pill-remove {
    background: transparent;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    padding: 0 2px;
}

.role-pill-remove:hover {
    color: #ff6b6b;
}
