* {
    box-sizing: border-box;
}

:root {
    color-scheme: dark;

    /* перенесено из style.css: темная enterprise-палитра */
    --bg: #0F172A;
    --surface: #1E293B;
    --surface2: #243044;
    --surface3: #2A3856;
    --border: rgba(99, 130, 175, 0.16);

    --blue: #3B82F6;
    --blue-dim: rgba(59, 130, 246, 0.14);
    --violet: #8B5CF6;
    --violet-dim: rgba(139, 92, 246, 0.14);
    --green: #10B981;
    --green-dim: rgba(16, 185, 129, 0.14);
    --amber: #F59E0B;
    --amber-dim: rgba(245, 158, 11, 0.14);
    --rose: #F43F5E;
    --rose-dim: rgba(244, 63, 94, 0.14);
    --cyan: #06B6D4;

    --text: #E2E8F0;
    --text2: #94A3B8;
    --text3: #64748B;

    --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    --sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, Helvetica, sans-serif;
    --r: 14px;

    /* совместимость со старым app.css */
    --panel: var(--surface);
    --panel-soft: rgba(36, 48, 68, 0.72);
    --ink: var(--text);
    --muted: var(--text2);
    --line: var(--border);
    --line-strong: rgba(99, 130, 175, 0.34);
    --accent: var(--green);
    --accent-strong: #059669;
    --accent-soft: var(--green-dim);
    --danger: var(--rose);
    --danger-soft: rgba(244, 63, 94, 0.12);
    --success: var(--green);
    --success-soft: rgba(16, 185, 129, 0.12);
    --shadow: 0 24px 80px rgba(0, 0, 0, 0.32), 0 0 36px rgba(59, 130, 246, 0.06);
}

html {
    min-height: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background:
        radial-gradient(circle at 12% -10%, rgba(59, 130, 246, 0.18), transparent 34%),
        radial-gradient(circle at 92% 4%, rgba(139, 92, 246, 0.16), transparent 32%),
        linear-gradient(180deg, #0B1120 0%, var(--bg) 48%, #0B1120 100%);
    font-family: var(--sans);
    font-size: 14px;
    line-height: 1.5;
    overflow-x: hidden;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(59, 130, 246, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(59, 130, 246, 0.035) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: linear-gradient(to bottom, rgba(0,0,0,0.9), rgba(0,0,0,0.22));
}

body > * {
    position: relative;
    z-index: 1;
}

button,
input,
textarea {
    font: inherit;
}

button,
a,
input,
textarea {
    outline-color: var(--green);
}

a {
    color: inherit;
    text-decoration: none;
}

/* ───────────────────────────────────────────
   TOP BAR
─────────────────────────────────────────── */
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: auto minmax(120px, 1fr) auto;
    align-items: center;
    gap: 18px;
    min-height: 76px;
    padding: 14px 20px;
    background: rgba(15, 23, 42, 0.82);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(18px);
    box-shadow: 0 1px 0 rgba(255,255,255,0.02), 0 18px 60px rgba(0,0,0,0.18);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.brand span,
.brand-mark,
.empty-icon {
    display: inline-grid;
    place-items: center;
    width: 42px;
    height: 42px;
    color: #fff;
    background: linear-gradient(135deg, var(--blue), var(--violet));
    border: 1px solid rgba(139, 92, 246, 0.45);
    border-radius: 11px;
    font-family: var(--mono);
    font-weight: 800;
    box-shadow: 0 0 28px rgba(139, 92, 246, 0.28), inset 0 1px 0 rgba(255,255,255,0.14);
}

.brand strong {
    display: block;
    color: var(--text);
    font-size: 19px;
    line-height: 1.1;
    letter-spacing: -0.35px;
}

.brand small {
    display: block;
    margin-top: 3px;
    color: var(--text2);
    font-family: var(--mono);
    font-size: 10.5px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.crumbs {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
    color: var(--text2);
    font-family: var(--mono);
    font-size: 11px;
    overflow: hidden;
    white-space: nowrap;
}

.crumbs a {
    max-width: 220px;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    border: 1px solid transparent;
    border-radius: 20px;
    padding: 4px 9px;
    transition: color .2s, background .2s, border-color .2s;
}

.crumbs a:hover,
.file-link:hover,
.folder-link:hover {
    color: var(--green);
}

.crumbs a:hover {
    background: var(--green-dim);
    border-color: rgba(16, 185, 129, 0.22);
}

.topbar-actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    min-width: 0;
}

.logout-form {
    margin: 0;
}

.hbadge {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0 12px;
    border-radius: 999px;
    color: var(--text2);
    background: rgba(30, 41, 59, 0.72);
    border: 1px solid var(--border);
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 1px;
    text-transform: uppercase;
    white-space: nowrap;
}

.hb-live {
    color: var(--green);
    background: rgba(16, 185, 129, 0.08);
    border-color: rgba(16, 185, 129, 0.32);
}

.hb-live::before {
    content: "●";
    margin-right: 6px;
    animation: blink 1.4s ease-in-out infinite;
}

.hb-ver {
    color: var(--text2);
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: .35; }
}

/* ───────────────────────────────────────────
   BUTTONS / FORMS
─────────────────────────────────────────── */
button,
.ghost-button,
.primary-button,
.danger-button,
.danger-solid-button {
    min-height: 36px;
    padding: 0 13px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: rgba(30, 41, 59, 0.82);
    color: var(--text);
    cursor: pointer;
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .2px;
    white-space: nowrap;
    transition: transform .18s ease, border-color .18s ease, background .18s ease, box-shadow .18s ease;
}

button:hover,
.ghost-button:hover {
    transform: translateY(-1px);
    border-color: var(--line-strong);
    background: rgba(36, 48, 68, 0.96);
    box-shadow: 0 8px 28px rgba(0,0,0,0.18);
}

.primary-button,
.login-card button {
    color: #06201A;
    border-color: rgba(16, 185, 129, 0.58);
    background: linear-gradient(135deg, #34D399, var(--green));
    box-shadow: 0 0 24px rgba(16, 185, 129, 0.20);
}

.primary-button:hover,
.login-card button:hover {
    color: #03130F;
    background: linear-gradient(135deg, #6EE7B7, var(--green));
    box-shadow: 0 0 30px rgba(16, 185, 129, 0.28);
}

.danger-button {
    min-height: 30px;
    padding: 0 10px;
    color: var(--rose);
    border-color: rgba(244, 63, 94, 0.28);
    background: rgba(244, 63, 94, 0.08);
}

.danger-button:hover {
    background: rgba(244, 63, 94, 0.14);
    border-color: rgba(244, 63, 94, 0.45);
}

.danger-solid-button {
    color: #fff;
    border-color: rgba(244, 63, 94, 0.8);
    background: linear-gradient(135deg, #F43F5E, #BE123C);
}

/* ───────────────────────────────────────────
   APP LAYOUT
─────────────────────────────────────────── */
.workspace {
    display: grid;
    grid-template-columns: minmax(400px, 36vw) minmax(0, 1fr);
    gap: 16px;
    height: calc(100vh - 76px);
    padding: 16px;
}

.panel {
    min-height: 0;
    background: rgba(30, 41, 59, 0.74);
    border: 1px solid var(--border);
    border-radius: var(--r);
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
    overflow: hidden;
}

.files-panel,
.editor-panel {
    display: flex;
    flex-direction: column;
}

.panel-head,
.editor-head,
.editor-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.panel-head,
.editor-head {
    background:
        linear-gradient(90deg, rgba(59, 130, 246, 0.08), transparent 54%),
        rgba(15, 23, 42, 0.28);
}

.panel-head h2,
.editor-head h1 {
    margin: 0;
    color: var(--text);
    font-size: 18px;
    line-height: 1.2;
    letter-spacing: -.25px;
}

.panel-head h2::before {
    content: "◈ ";
    color: var(--blue);
}

.editor-head h1::before {
    content: "⌁ ";
    color: var(--green);
}

.panel-head p,
.editor-head p {
    margin: 5px 0 0;
    color: var(--text2);
    font-family: var(--mono);
    font-size: 10.5px;
}

.editor-head p {
    word-break: break-all;
}

.editor-head p span {
    display: inline-block;
    margin-right: 8px;
    padding: 2px 7px;
    color: var(--blue);
    background: rgba(59, 130, 246, 0.12);
    border: 1px solid rgba(59, 130, 246, 0.22);
    border-radius: 6px;
    font-size: 10px;
    font-weight: 800;
}

.filter-row {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    background: rgba(36, 48, 68, 0.40);
}

.search-box,
.tool-form label,
.login-card label {
    display: grid;
    gap: 6px;
}

.search-box span,
.tool-form label span,
.login-card label span {
    color: var(--text2);
    font-family: var(--mono);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .7px;
    text-transform: uppercase;
}

.tools {
    display: grid;
    gap: 10px;
    padding: 14px;
    border-bottom: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.22);
}

.tool-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 8px;
}

input[type="text"],
input[type="password"],
input[type="search"],
.tools input:not([type]),
.tools input[type="file"] {
    min-height: 40px;
    width: 100%;
    min-width: 0;
    padding: 0 12px;
    color: var(--text);
    background: rgba(15, 23, 42, 0.72);
    border: 1px solid var(--border);
    border-radius: 9px;
    transition: border-color .18s, background .18s, box-shadow .18s;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
.tools input:not([type]):focus,
.tools input[type="file"]:focus {
    border-color: rgba(16, 185, 129, 0.52);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.10);
    background: rgba(15, 23, 42, 0.95);
}

input::placeholder {
    color: var(--text3);
}

input[type="search"] {
    padding-left: 37px;
    background:
        radial-gradient(circle at 17px 20px, transparent 0 5px, var(--text2) 5px 6px, transparent 6px),
        linear-gradient(90deg, transparent 0 34px, transparent 34px),
        rgba(15, 23, 42, 0.72);
}

/* ───────────────────────────────────────────
   FILE TABLE
─────────────────────────────────────────── */
.file-table {
    width: 100%;
    border-collapse: collapse;
}

.file-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 10px 12px;
    color: var(--text2);
    background: rgba(36, 48, 68, 0.96);
    border-bottom: 1px solid var(--border);
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .8px;
    text-align: left;
    text-transform: uppercase;
}

.file-table td {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(99, 130, 175, 0.10);
    color: var(--text2);
    vertical-align: middle;
    font-family: var(--mono);
    font-size: 11px;
}

.file-table tr {
    transition: background .16s, transform .16s;
}

.file-table tr:hover {
    background: rgba(59, 130, 246, 0.05);
}

.file-table .active-row {
    background: rgba(16, 185, 129, 0.08);
    box-shadow: inset 3px 0 0 var(--green);
}

.folder-link,
.file-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    max-width: 100%;
    color: var(--text);
}

.entry-badge {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    height: 24px;
    padding: 0 7px;
    border-radius: 6px;
    font-family: var(--mono);
    font-size: 9px;
    font-weight: 850;
    letter-spacing: .5px;
}

.folder-badge {
    color: var(--amber);
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.24);
}

.file-badge {
    color: var(--blue);
    background: rgba(59, 130, 246, 0.12);
    border: 1px solid rgba(59, 130, 246, 0.24);
}

.entry-name {
    min-width: 0;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.muted {
    color: var(--text3);
}

.row-actions {
    width: 1%;
    text-align: right;
}

.inline-delete {
    margin: 0;
}

.no-results td {
    color: var(--amber);
    padding: 18px 14px;
    text-align: center;
}

/* ───────────────────────────────────────────
   NOTICES
─────────────────────────────────────────── */
.notice {
    margin: 12px 14px 0;
    padding: 10px 12px;
    border: 1px solid transparent;
    border-radius: 9px;
    font-family: var(--mono);
    font-size: 10.5px;
}

.notice-success {
    color: var(--green);
    background: rgba(16, 185, 129, 0.10);
    border-color: rgba(16, 185, 129, 0.28);
}

.notice-error {
    color: var(--rose);
    background: rgba(244, 63, 94, 0.10);
    border-color: rgba(244, 63, 94, 0.28);
}

/* ───────────────────────────────────────────
   EDITOR
─────────────────────────────────────────── */
.editor-head {
    flex: 0 0 auto;
}

.mode-tabs {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
}

.mode-tabs a {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 8px 12px;
    color: var(--text2);
    background: rgba(30, 41, 59, 0.74);
    border: 1px solid var(--border);
    border-radius: 9px;
    font-family: var(--mono);
    font-size: 10.5px;
    font-weight: 700;
    transition: color .18s, background .18s, border-color .18s, transform .18s;
}

.mode-tabs a:hover {
    color: var(--text);
    transform: translateY(-1px);
    background: rgba(36, 48, 68, 0.96);
    border-color: var(--line-strong);
}

.mode-tabs a.active {
    color: #06201A;
    border-color: rgba(16, 185, 129, 0.58);
    background: linear-gradient(135deg, #34D399, var(--green));
}

.editor-form {
    display: flex;
    flex: 1;
    min-height: 0;
    flex-direction: column;
}

.source-editor {
    flex: 1;
    width: 100%;
    min-height: 0;
    padding: 18px;
    resize: none;
    border: 0;
    outline: none;
    color: #D8E3F0;
    background:
        linear-gradient(90deg, rgba(59, 130, 246, 0.055) 1px, transparent 1px) 0 0 / 44px 44px,
        linear-gradient(rgba(59, 130, 246, 0.035) 1px, transparent 1px) 0 0 / 44px 44px,
        #0B1220;
    font: 13px/1.58 var(--mono);
    tab-size: 4;
    caret-color: var(--green);
}

.source-editor::selection {
    background: rgba(16, 185, 129, 0.28);
}

.visual-frame {
    flex: 1;
    width: 100%;
    min-height: 0;
    border: 0;
    background: #fff;
}

.editor-actions {
    flex: 0 0 auto;
    border-top: 1px solid var(--border);
    border-bottom: 0;
    background: rgba(15, 23, 42, 0.34);
}

.save-state {
    color: var(--text2);
    font-family: var(--mono);
    font-size: 10.5px;
}

.save-state::before {
    content: "● ";
    color: var(--green);
}

.save-state.is-dirty {
    color: var(--amber);
    font-weight: 750;
}

.save-state.is-dirty::before {
    color: var(--amber);
}

/* ───────────────────────────────────────────
   EMPTY STATE
─────────────────────────────────────────── */
.empty-state {
    display: grid;
    place-content: center;
    gap: 14px;
    height: 100%;
    padding: 32px;
    color: var(--text2);
    text-align: center;
}

.empty-state h1 {
    margin: 0;
    color: var(--text);
    font-size: 24px;
    letter-spacing: -.35px;
}

.empty-state p {
    margin: 0 auto;
    max-width: 480px;
    color: var(--text2);
    font-family: var(--mono);
    font-size: 11px;
}

.empty-icon {
    margin: 0 auto;
    background: linear-gradient(135deg, var(--green), var(--blue));
    border-color: rgba(16, 185, 129, 0.4);
}

/* ───────────────────────────────────────────
   LOGIN
─────────────────────────────────────────── */
.login-screen {
    display: grid;
    place-items: center;
    padding: 20px;
    background:
        radial-gradient(circle at 20% 0%, rgba(59, 130, 246, 0.22), transparent 35%),
        radial-gradient(circle at 100% 0%, rgba(139, 92, 246, 0.18), transparent 36%),
        var(--bg);
}

.login-card {
    position: relative;
    width: min(430px, 100%);
    padding: 30px;
    background: rgba(30, 41, 59, 0.78);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: 0 30px 90px rgba(0,0,0,0.34), 0 0 50px rgba(59, 130, 246, 0.08);
    backdrop-filter: blur(18px);
    overflow: hidden;
}

.login-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: linear-gradient(90deg, var(--blue), var(--violet), var(--green));
}

.login-card h1 {
    margin: 16px 0 4px;
    color: var(--text);
    font-size: 30px;
    letter-spacing: -.5px;
}

.login-card p {
    margin: 0 0 22px;
    color: var(--text2);
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: .8px;
    text-transform: uppercase;
}

.login-card form {
    display: grid;
    gap: 14px;
}

.login-card .brand-mark {
    background: linear-gradient(135deg, var(--green), var(--blue));
}

/* ───────────────────────────────────────────
   DIALOG
─────────────────────────────────────────── */
.confirm-dialog {
    width: min(430px, calc(100vw - 32px));
    padding: 0;
    color: var(--text);
    background: rgba(30, 41, 59, 0.98);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 30px 100px rgba(0,0,0,0.5);
}

.confirm-dialog::backdrop {
    background: rgba(2, 6, 23, 0.72);
    backdrop-filter: blur(4px);
}

.confirm-dialog form {
    display: grid;
    gap: 12px;
    padding: 20px;
}

.confirm-dialog h2 {
    margin: 0;
    color: var(--text);
    font-size: 20px;
}

.confirm-dialog p {
    margin: 0;
    color: var(--text2);
    line-height: 1.45;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 6px;
}

/* ───────────────────────────────────────────
   RESPONSIVE
─────────────────────────────────────────── */
@media (max-width: 1180px) {
    .topbar-actions .hb-ver {
        display: none;
    }
}

@media (max-width: 1080px) {
    .workspace {
        grid-template-columns: 1fr;
        height: auto;
        min-height: calc(100vh - 76px);
    }

    .files-panel,
    .editor-panel {
        min-height: 540px;
    }
}

@media (max-width: 720px) {
    .topbar {
        grid-template-columns: 1fr auto;
        align-items: start;
        gap: 10px;
        padding: 12px;
    }

    .topbar-actions .hb-live {
        display: none;
    }

    .crumbs {
        grid-column: 1 / -1;
        order: 3;
        padding-top: 2px;
    }

    .workspace {
        padding: 10px;
    }

    .panel-head,
    .editor-head,
    .editor-actions {
        align-items: flex-start;
        flex-direction: column;
    }

    .mode-tabs {
        justify-content: flex-start;
    }

    .tool-form {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .topbar {
        position: static;
    }

    .workspace {
        gap: 10px;
        padding: 0;
    }

    .panel {
        border-right: 0;
        border-left: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .files-panel,
    .editor-panel {
        min-height: auto;
    }

    .file-table,
    .file-table tbody,
    .file-table tr,
    .file-table td {
        display: block;
        width: 100%;
    }

    .file-table thead {
        display: none;
    }

    .file-table tr {
        position: relative;
        padding: 12px 84px 12px 12px;
        border-bottom: 1px solid var(--border);
    }

    .file-table td {
        padding: 4px 0;
        border-bottom: 0;
    }

    .file-table td[data-label]:not(:first-child)::before {
        content: attr(data-label) ": ";
        color: var(--text3);
        font-size: 10px;
    }

    .row-actions {
        position: absolute;
        top: 12px;
        right: 12px;
        width: auto;
    }

    .entry-name {
        max-width: 100%;
    }

    .login-card {
        padding: 24px;
        border-radius: 14px;
    }
}
