* {
    box-sizing: border-box;
}

:root {
    --bg: #f4f6f8;
    --panel: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --line: #e2e6ea;
    --accent: #2563eb;
    --accent-dark: #1d4ed8;
    --danger: #c0262d;
    --ok: #15803d;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid var(--accent);
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-size: 14px;
    line-height: 1.2;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.btn:hover {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
    text-decoration: none;
}

.btn-ghost {
    background: transparent;
    color: var(--text);
    border-color: var(--line);
}

.btn-ghost:hover {
    background: #eef1f5;
    border-color: #cfd6de;
}

.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
}

.btn-danger:hover {
    background: #9f1f25;
    border-color: #9f1f25;
}

.btn-wide {
    width: 100%;
    margin-top: 12px;
}

.btn-block {
    width: 100%;
    padding: 11px 14px;
    font-size: 15px;
}

/* ---- Login ---- */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(160deg, #eef2f7 0%, #e3e9f1 100%);
}

.login-card {
    width: 100%;
    max-width: 380px;
    padding: 32px 28px;
    background: var(--panel);
    border-radius: 16px;
    box-shadow: var(--shadow);
}

.login-card h1 {
    margin: 0 0 20px;
    font-size: 20px;
    font-weight: 600;
    text-align: center;
}

.login-form label {
    display: block;
    margin-bottom: 14px;
    font-size: 13px;
    color: var(--muted);
}

.login-form input {
    width: 100%;
    margin-top: 6px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 15px;
    color: var(--text);
    background: #fff;
    outline: none;
}

.login-form input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* ---- Flash ---- */

.flash {
    padding: 10px 14px;
    margin-bottom: 12px;
    border-radius: 8px;
    font-size: 13px;
}

.flash-error {
    background: #fdecec;
    color: #9f1f25;
    border: 1px solid #f5c2c4;
}

.flash-success {
    background: #eaf6ee;
    color: var(--ok);
    border: 1px solid #bfe5cb;
}

/* ---- Panel layout ---- */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 22px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 20;
}

.brand {
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.top-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.usage {
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
}

.inline {
    display: inline;
    margin: 0;
}

.layout {
    display: flex;
    align-items: flex-start;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    gap: 20px;
}

.sidebar {
    flex: 0 0 240px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
    position: sticky;
    top: 78px;
    max-height: calc(100vh - 98px);
    overflow-y: auto;
}

.folder-root {
    display: block;
    padding: 8px 10px;
    border-radius: 7px;
    color: var(--text);
    font-weight: 500;
}

.folder-root.active {
    background: #e8efff;
    color: var(--accent-dark);
}

.folder-tree,
.folder-children {
    list-style: none;
    margin: 0;
    padding: 0;
}

.folder-children {
    padding-left: 14px;
}

.folder-item > a {
    display: block;
    padding: 7px 10px;
    border-radius: 7px;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.folder-item > a:hover {
    background: #f1f4f8;
    text-decoration: none;
}

.folder-item.active > a {
    background: #e8efff;
    color: var(--accent-dark);
    font-weight: 500;
}

.content {
    flex: 1 1 auto;
    min-width: 0;
}

.crumbs {
    margin-bottom: 12px;
    color: var(--muted);
    font-size: 13px;
    word-break: break-word;
}

.crumbs .sep {
    margin: 0 6px;
    color: #b6bec8;
}

/* ---- Dropzone ---- */

.dropzone {
    position: relative;
    padding: 26px 18px;
    margin-bottom: 16px;
    border: 2px dashed #c7d0db;
    border-radius: var(--radius);
    background: #fbfcfe;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone:hover,
.dropzone.drag {
    border-color: var(--accent);
    background: #f3f7ff;
}

.dz-title {
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 6px;
}

.dz-hint {
    font-size: 12px;
    color: var(--muted);
}

.progress {
    display: none;
    height: 6px;
    margin-top: 14px;
    background: #e6eaf0;
    border-radius: 4px;
    overflow: hidden;
}

.progress.show {
    display: block;
}

.progress-bar {
    height: 100%;
    width: 0;
    background: var(--accent);
    transition: width 0.1s linear;
}

/* ---- Toolbar ---- */

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

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

.search input[type="search"] {
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 14px;
    min-width: 200px;
    outline: none;
}

.search input[type="search"]:focus {
    border-color: var(--accent);
}

.search select {
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
}

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

/* ---- Files table ---- */

.files {
    width: 100%;
    border-collapse: collapse;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.files th,
.files td {
    padding: 11px 14px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

.files thead th {
    background: #f8fafc;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
    font-weight: 600;
}

.files tbody tr:last-child td {
    border-bottom: none;
}

.files tbody tr:hover {
    background: #f9fbfd;
}

.fname {
    max-width: 340px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

.fsize,
.fdate {
    color: var(--muted);
    white-space: nowrap;
}

.factions {
    white-space: nowrap;
    text-align: right;
}

.files th.actions {
    text-align: right;
}

.lnk {
    display: inline-block;
    padding: 4px 8px;
    margin-left: 4px;
    border: none;
    background: none;
    color: var(--accent);
    font-size: 13px;
    cursor: pointer;
    border-radius: 6px;
}

.lnk:hover {
    background: #eef3ff;
    text-decoration: none;
}

.lnk-danger {
    color: var(--danger);
}

.lnk-danger:hover {
    background: #fdecec;
}

.empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--muted);
    background: var(--panel);
    border: 1px dashed var(--line);
    border-radius: var(--radius);
}

.pager {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 16px;
}

.page {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    font-size: 13px;
}

.page.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* ---- Dialogs ---- */

dialog {
    width: 100%;
    max-width: 420px;
    padding: 0;
    border: none;
    border-radius: 14px;
    box-shadow: 0 20px 50px rgba(16, 24, 40, 0.25);
}

dialog::backdrop {
    background: rgba(17, 24, 39, 0.45);
}

.dialog-form {
    padding: 22px;
}

.dialog-form h3 {
    margin: 0 0 16px;
    font-size: 17px;
    font-weight: 600;
}

.dialog-form input,
.dialog-form select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    background: #fff;
}

.dialog-form input:focus,
.dialog-form select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

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

/* ---- Responsive ---- */

@media (max-width: 860px) {
    .layout {
        display: block;
        padding: 14px;
    }

    .sidebar {
        position: static;
        max-height: none;
        margin-bottom: 16px;
    }

    .fname {
        max-width: 180px;
    }

    .files th,
    .files td {
        padding: 9px 10px;
    }

    .factions {
        white-space: normal;
    }
}

@media (max-width: 620px) {
    .topbar {
        flex-wrap: wrap;
        padding: 12px 14px;
    }

    .usage {
        display: none;
    }

    .search {
        width: 100%;
    }

    .search input[type="search"] {
        flex: 1 1 auto;
        min-width: 0;
    }

    .files thead {
        display: none;
    }

    .files,
    .files tbody,
    .files tr,
    .files td {
        display: block;
        width: 100%;
    }

    .files tr {
        padding: 10px 12px;
        border-bottom: 1px solid var(--line);
    }

    .files td {
        border: none;
        padding: 4px 0;
    }

    .fname {
        max-width: none;
        white-space: normal;
        word-break: break-word;
    }

    .factions {
        text-align: left;
        padding-top: 8px;
    }

    .lnk {
        margin-left: 0;
        margin-right: 6px;
        padding: 4px 0;
    }
}
