:root {
    --bg: #0d0d0f;
    --panel: #171719;
    --panel-2: #202024;
    --line: #34343a;
    --text: #f4f4f5;
    --muted: #b7b7bd;
    --red: #e0252f;
    --red-dark: #8f1119;
    --red-soft: #3a0d12;
    --focus: #ff5962;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.55 Arial, Helvetica, sans-serif;
}

button, input {
    font: inherit;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-panel {
    width: min(520px, 100%);
    background: var(--panel);
    border: 1px solid var(--line);
    border-top: 4px solid var(--red);
    padding: 32px;
    border-radius: 8px;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--red);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 24px;
    background: #101012;
    border-bottom: 1px solid var(--line);
}

h1, h2, h3 {
    margin: 0;
    line-height: 1.2;
}

.userbox {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
}

.userbox strong {
    color: var(--text);
    background: var(--red-soft);
    border: 1px solid var(--red-dark);
    border-radius: 999px;
    padding: 4px 10px;
}

a { color: #ff737a; }

.tabs {
    display: flex;
    gap: 8px;
    padding: 12px 24px 0;
    background: var(--bg);
}

.tab, button {
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel-2);
    color: var(--text);
    padding: 8px 12px;
    cursor: pointer;
}

.tab.active, .primary {
    border-color: var(--red);
    background: var(--red-dark);
    color: white;
}

.ghost { background: transparent; }
.danger { background: #3b1012; border-color: #8f1119; color: #fff; }

.layout {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 20px;
    padding: 20px 24px 32px;
}

.sidebar {
    align-self: start;
    position: sticky;
    top: 92px;
    display: grid;
    gap: 14px;
}

.search span {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
}

input {
    width: 100%;
    background: #101012;
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 12px;
}

input:focus, .rich-editor:focus {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

.filters {
    display: grid;
    gap: 8px;
}

.filter {
    text-align: left;
}

.filter.active {
    border-color: var(--red);
    background: var(--red-soft);
}

.role-note, .hint {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.error {
    color: #ff9ea3;
    background: #3b1012;
    padding: 10px;
    border-radius: 6px;
}

.content-view { display: none; min-width: 0; }
.content-view.active { display: block; }

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

.view-head p {
    margin: 4px 0 0;
    color: var(--muted);
}

.faq-list {
    display: grid;
    gap: 10px;
}

.faq-item {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.faq-question {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    background: var(--panel);
    border: 0;
    border-bottom: 1px solid transparent;
    text-align: left;
}

.faq-question:hover { background: #1d1d21; }

.badge {
    flex: 0 0 auto;
    background: #11151d;
    color: #fff;
    border: 1px solid #303846;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 12px;
}

.faq-body {
    display: none;
    padding: 16px;
    border-top: 1px solid var(--line);
    color: #f6f6f7;
}

.faq-item.open .faq-body { display: block; }
.faq-body h2, .faq-body h3 { margin: 18px 0 8px; }
.faq-body p { margin: 0 0 12px; }
.faq-body li { margin: 4px 0; }
.faq-body table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.faq-body td, .faq-body th { border: 1px solid var(--line); padding: 8px; vertical-align: top; }
.faq-body mark, .rich-editor mark { background: #5a1015; color: #fff; }

.item-actions {
    display: flex;
    gap: 8px;
    padding: 0 16px 14px;
}

.table-wrap {
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.command-table {
    width: 100%;
    min-width: 980px;
    border-collapse: collapse;
    background: var(--panel);
}

.command-table th, .command-table td {
    border-bottom: 1px solid var(--line);
    padding: 10px;
    text-align: left;
    vertical-align: top;
}

.command-table th {
    position: sticky;
    top: 0;
    background: #111114;
    color: #fff;
}

.command-table td[contenteditable="true"] {
    background: #111114;
    outline: 1px dashed #4c4c55;
}

.editor-dialog {
    width: min(860px, calc(100vw - 32px));
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: var(--text);
    padding: 0;
}

.editor-dialog::backdrop { background: rgba(0,0,0,.72); }

.editor {
    display: grid;
    gap: 14px;
    padding: 18px;
}

.editor-head, .editor-actions, .command-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.command-actions {
    justify-content: flex-end;
    flex-wrap: wrap;
}

.command-table input,
.command-table select {
    min-width: 150px;
    width: 100%;
    background: #101012;
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.rich-editor {
    min-height: 280px;
    max-height: 55vh;
    overflow: auto;
    background: #101012;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 14px;
}

@media (max-width: 820px) {
    .topbar, .view-head, .userbox {
        align-items: flex-start;
        flex-direction: column;
    }
    .layout {
        grid-template-columns: 1fr;
    }
    .sidebar {
        position: static;
    }
}
