/* RGEF Console — minimal, flat */
:root {
    --bg: #f5f7fa;
    --surface: #ffffff;
    --surface-alt: #fafbfc;
    --primary: #1e3a5f;
    --accent: #0d9488;
    --accent-hover: #0f766e;
    --border: #dde3ea;
    --text: #1e293b;
    --text-muted: #64748b;
    --error: #dc2626;
    --success: #16a34a;
    --radius: 4px;
    --font: "Segoe UI", system-ui, -apple-system, sans-serif;
    --mono: Consolas, "Courier New", monospace;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    height: 100%;
}

body {
    margin: 0;
    height: 100%;
    overflow: hidden;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

.console-shell {
    height: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.app-header {
    flex-shrink: 0;
    background: var(--primary);
    color: #fff;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #152a45;
}

.app-header h1 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 600;
}

.subtitle {
    margin: 0.2rem 0 0;
    font-size: 0.85rem;
    opacity: 0.85;
}

.layout {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    flex-shrink: 0;
}

.sidebar-label {
    margin: 0 0 0.5rem;
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-align: left;
    background: transparent;
    border: none;
    border-left: 2px solid transparent;
    color: var(--text-muted);
    padding: 0.5rem 0.6rem;
    border-radius: 0;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
}

.nav-btn i {
    font-size: 1rem;
    line-height: 1;
}

.nav-btn:hover {
    color: var(--primary);
    background: var(--surface-alt);
}

.nav-btn.active {
    color: var(--primary);
    border-left-color: var(--accent);
    background: var(--surface-alt);
}

.sidebar-foot {
    flex-shrink: 0;
    margin-top: auto;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.7rem;
}

.main {
    min-height: 0;
    min-width: 0;
    padding: 1.25rem 1.5rem 2rem;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.tool-section {
    margin-bottom: 1.25rem;
}

.tool-section:last-child {
    margin-bottom: 0;
}

.tool-section__title {
    margin: 0 0 0.75rem;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.tool-header h2 {
    margin: 0 0 0.25rem;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
}

.tool-header p,
.view-lead {
    margin: 0 0 1rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
}

.tab {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    padding: 0.5rem 0.85rem;
    margin-bottom: -1px;
    border-radius: 0;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
}

.tab:hover {
    color: var(--text);
}

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.panel { display: none; }
.panel.active { display: block; }

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.panel > .card {
    margin-bottom: 1rem;
}

.panel > .card:last-child {
    margin-bottom: 0;
}

@media (max-width: 900px) {
    .console-shell {
        height: auto;
        min-height: 100vh;
        overflow: visible;
    }

    body {
        overflow: auto;
    }

    .layout {
        grid-template-columns: 1fr;
        overflow: visible;
    }

    .sidebar {
        overflow: visible;
    }

    .main {
        overflow: visible;
    }

    .grid-2 { grid-template-columns: 1fr; }
    .main { padding: 1rem; }
}

.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1rem 1.15rem;
    border: 1px solid var(--border);
    margin-bottom: 0;
}

.grid-2 .card,
.tool-section .card + .card {
    margin-bottom: 0;
}

.tool-section .grid-2 {
    margin-bottom: 0;
}

.card h3 {
    margin: 0 0 0.85rem;
    font-size: 0.9rem;
    color: var(--text);
    font-weight: 600;
}

.field {
    margin-bottom: 0.75rem;
}

.field label {
    display: block;
    font-weight: 500;
    font-size: 0.8rem;
    margin-bottom: 0.25rem;
    color: var(--text-muted);
}

.field input,
.field select,
.field textarea {
    width: 100%;
    padding: 0.45rem 0.6rem;
    font-size: 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.field-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.65rem;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
}

.check-row label {
    font-weight: 400;
    color: var(--text);
}

.btn {
    padding: 0.45rem 0.9rem;
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
    border-color: #94a3b8;
}

.btn-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.table-wrap {
    overflow: auto;
    max-height: 420px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

th, td {
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

th {
    background: var(--surface-alt);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    position: sticky;
    top: 0;
}

tr:last-child td {
    border-bottom: none;
}

td.mono, .mono {
    font-family: var(--mono);
}

.badge {
    display: inline-block;
    padding: 0.1rem 0.35rem;
    border-radius: 2px;
    font-size: 0.72rem;
    font-weight: 500;
    background: var(--surface-alt);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.badge-pwd {
    background: var(--surface);
    color: var(--text);
    font-family: var(--mono);
}

.msg,
.message {
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius);
    margin-top: 0.65rem;
    font-size: 0.85rem;
    border: 1px solid var(--border);
}

.msg.ok,
.message.success {
    background: var(--surface);
    color: var(--success);
    border-color: #bbf7d0;
}

.msg.err,
.message.error {
    background: var(--surface);
    color: var(--error);
    border-color: #fecaca;
}

.hidden { display: none !important; }

.preview-login {
    font-family: var(--mono);
    font-size: 1.15rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    margin: 0.35rem 0;
    color: var(--text);
}

.stats {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.85rem;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.8rem;
    min-width: 90px;
}

.stat strong {
    display: block;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.2;
}

textarea.export {
    width: 100%;
    min-height: 160px;
    font-family: var(--mono);
    font-size: 0.78rem;
}

.tree-example {
    font-size: 0.78rem;
    line-height: 1.5;
    color: var(--text-muted);
    margin: 0;
}

.hint-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0.65rem 0 0;
}

.config-dl {
    margin: 0;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.35rem 1rem;
    font-size: 0.85rem;
}

.config-dl dt {
    margin: 0;
    color: var(--text-muted);
    font-weight: 500;
}

.config-dl dd {
    margin: 0;
    word-break: break-all;
}

.config-panel {
    margin-bottom: 0.75rem;
}

body.modal-open {
    overflow: hidden;
}

.modal-root {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-root[hidden] {
    display: none;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
}

.modal-dialog {
    position: relative;
    z-index: 1;
    width: min(440px, 100%);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.18);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1rem 0.5rem;
}

.modal-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.modal-close {
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.15rem 0.35rem;
}

.modal-body {
    padding: 0.75rem 1rem 1rem;
}

.modal-message {
    margin: 0;
    color: var(--text);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0 1rem 1rem;
}

.btn-danger {
    background: var(--error);
    border-color: var(--error);
    color: #fff;
}

.btn-danger:hover {
    background: #b91c1c;
    border-color: #b91c1c;
}
