:root {
    --bg: #f6f6f1;
    --panel: #ffffff;
    --ink: #18202f;
    --muted: #687080;
    --line: #dfe4df;
    --primary: #0d766d;
    --primary-dark: #095c55;
    --danger: #c94343;
    --warning: #9a6b11;
    --soft: #eef6f2;
    --shadow: 0 16px 38px rgba(30, 41, 59, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100%;
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
    background: var(--bg);
}

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

code {
    padding: 3px 7px;
    border-radius: 6px;
    color: #195c56;
    background: #edf8f3;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 18px;
    min-height: 64px;
    padding: 0 32px;
    border-bottom: 1px solid rgba(223, 228, 223, 0.88);
    background: rgba(246, 246, 241, 0.92);
    backdrop-filter: blur(16px);
}

.brand {
    font-weight: 800;
    white-space: nowrap;
}

.nav {
    display: flex;
    gap: 6px;
    flex: 1;
}

.nav a,
.logout {
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--muted);
    font-size: 14px;
}

.nav a.active,
.nav a:hover,
.logout:hover {
    color: var(--ink);
    background: #e9eee8;
}

.page {
    width: min(1280px, calc(100% - 40px));
    margin: 0 auto;
    padding: 30px 0 60px;
}

.page-head,
.hero-panel,
.panel-head,
.file-toolbar,
.form-actions,
.hero-actions,
.table-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.page-head,
.hero-panel {
    margin-bottom: 22px;
}

.page-head h1,
.hero-panel h1 {
    margin: 5px 0 0;
    font-size: clamp(30px, 4vw, 54px);
    line-height: 1.1;
}

.section-kicker {
    margin: 0;
    color: var(--primary);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.hero-panel {
    padding: 34px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: linear-gradient(135deg, #ffffff 0%, #eef7f4 100%);
    box-shadow: var(--shadow);
}

.stats-grid,
.grid {
    display: grid;
    gap: 18px;
}

.stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 18px;
}

.grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 18px;
}

.grid.compact {
    align-items: start;
}

.metric,
.panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.metric {
    padding: 22px;
}

.metric span {
    display: block;
    color: var(--muted);
    font-size: 14px;
}

.metric strong {
    display: block;
    margin-top: 8px;
    font-size: 34px;
}

.panel {
    margin-bottom: 18px;
    padding: 22px;
}

.panel-head {
    margin-bottom: 18px;
}

.panel-head h2 {
    margin: 4px 0 0;
    font-size: 22px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    background: #fff;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
}

.button:hover {
    border-color: #b9c5bc;
    background: #f7faf7;
}

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

.button.primary:hover {
    background: var(--primary-dark);
}

.button.danger {
    border-color: var(--danger);
    color: #fff;
    background: var(--danger);
}

.button.ghost {
    background: transparent;
}

.button.full {
    width: 100%;
}

.link,
.actions a,
.file-edit {
    color: var(--primary);
    font-weight: 700;
}

.form-stack {
    display: grid;
    gap: 16px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.wide {
    grid-column: 1 / -1;
}

label {
    display: grid;
    gap: 7px;
}

label span {
    color: #394150;
    font-size: 13px;
    font-weight: 800;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid #cfd8d0;
    border-radius: 8px;
    padding: 11px 12px;
    color: var(--ink);
    background: #fff;
    font: inherit;
}

input[type="checkbox"],
input[type="radio"] {
    width: auto;
}

textarea {
    resize: vertical;
    line-height: 1.6;
}

input:focus,
select:focus,
textarea:focus {
    outline: 3px solid rgba(13, 118, 109, 0.16);
    border-color: var(--primary);
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 13px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

th {
    color: #596171;
    font-size: 13px;
    font-weight: 800;
    background: #f8faf8;
}

tr:last-child td {
    border-bottom: 0;
}

.actions {
    display: flex;
    gap: 12px;
    white-space: nowrap;
}

.check-cell {
    width: 46px;
}

.empty {
    padding: 26px;
    color: var(--muted);
    text-align: center;
}

.count-pill {
    padding: 10px 15px;
    border: 1px solid #c9d8d2;
    border-radius: 999px;
    color: var(--primary-dark);
    background: #ecf7f3;
    font-weight: 800;
}

.alert {
    margin-bottom: 18px;
    padding: 13px 15px;
    border: 1px solid #cfd8d0;
    border-radius: 8px;
    background: #fff;
    font-weight: 700;
}

.alert.success {
    border-color: #b7d7c7;
    color: #106242;
    background: #ecf8f1;
}

.alert.error {
    border-color: #ecc0c0;
    color: #9f2f2f;
    background: #fff0f0;
}

.alert.warning {
    border-color: #ead69c;
    color: var(--warning);
    background: #fff8e6;
}

.login-body {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 24px;
    background: linear-gradient(135deg, #f6f6f1 0%, #e8f3ef 58%, #f8eee0 100%);
}

.login-box {
    width: min(420px, 100%);
    padding: 30px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow);
}

.login-box h1 {
    margin: 0 0 22px;
    font-size: 28px;
}

.file-actions-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 18px;
    margin: 18px 0;
}

.upload-box,
.mkdir-box {
    display: grid;
    gap: 12px;
    align-content: start;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfb;
}

.drop-zone {
    min-height: 126px;
    place-items: center;
    border: 1px dashed #a8b7ab;
    border-radius: 8px;
    background: #f6faf8;
    text-align: center;
}

.drop-zone input {
    width: min(360px, 100%);
    margin-top: 8px;
    background: #fff;
}

.breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    color: var(--muted);
    font-weight: 700;
}

.breadcrumbs a {
    color: var(--primary);
}

.file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 12px;
    margin-top: 14px;
}

.file-card {
    position: relative;
    display: grid;
    gap: 8px;
    min-height: 136px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.file-card.parent {
    align-content: center;
    color: var(--primary);
    background: #f4faf7;
}

.file-main {
    display: grid;
    gap: 8px;
    min-width: 0;
}

.file-icon {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    color: #617080;
    background: #eff2ef;
    font-size: 18px;
}

.file-icon.folder {
    color: #93670c;
    background: #fff2c9;
}

.file-card strong {
    overflow-wrap: anywhere;
    font-size: 15px;
}

.file-card small {
    color: var(--muted);
    font-size: 12px;
}

.file-check {
    position: absolute;
    top: 10px;
    right: 10px;
}

.file-edit {
    align-self: end;
    width: fit-content;
}

.code-editor {
    min-height: 480px;
    font-family: "Cascadia Mono", Consolas, monospace;
    font-size: 14px;
    line-height: 1.6;
}

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

@media (max-width: 900px) {
    .topbar {
        align-items: flex-start;
        flex-wrap: wrap;
        padding: 16px 20px;
    }

    .page {
        width: min(100% - 24px, 1280px);
        padding-top: 18px;
    }

    .hero-panel,
    .page-head,
    .panel-head,
    .file-toolbar,
    .form-actions,
    .hero-actions {
        align-items: flex-start;
        flex-direction: column;
    }

    .stats-grid,
    .grid.two,
    .form-grid,
    .file-actions-grid {
        grid-template-columns: 1fr;
    }

    .wide {
        grid-column: auto;
    }

    .panel,
    .hero-panel {
        padding: 18px;
    }
}
