:root {
    --bg: #f6f7f9;
    --panel: #ffffff;
    --line: #d9dee7;
    --text: #202733;
    --muted: #697386;
    --primary: #1f6feb;
    --primary-dark: #185abc;
    --danger: #c93535;
    --ok: #1f7a4d;
    --soft: #eef4ff;
}

* {
    box-sizing: border-box;
}

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

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

.topbar {
    height: 58px;
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 0 24px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
}

.brand {
    font-size: 18px;
    font-weight: 700;
    white-space: nowrap;
}

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

.nav a {
    color: var(--text);
    padding: 8px 10px;
    border-radius: 6px;
}

.nav a:hover {
    background: var(--soft);
}

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

.page {
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px;
}

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

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 6px;
    font-size: 24px;
}

h2 {
    font-size: 17px;
}

.toolbar p,
.muted {
    color: var(--muted);
}

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

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

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

.link {
    border: 0;
    background: transparent;
    padding: 0;
    color: var(--primary);
}

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

.card,
.tree-shell,
.login-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
}

.operation-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 18px;
}

.operation-card {
    min-height: 360px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
}

.operation-card h2 {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}

.operation-file-list {
    margin: 0;
    padding-left: 24px;
}

.operation-file-list li {
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}

.operation-file-list a {
    color: var(--text);
    font-weight: 600;
}

.operation-file-list span {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
}

.login-panel {
    width: min(420px, 100%);
    margin: 72px auto;
}

.form {
    display: grid;
    gap: 14px;
}

label {
    display: grid;
    gap: 6px;
    color: var(--muted);
}

input,
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px 10px;
    background: #fff;
    color: var(--text);
    font: inherit;
}

.grid {
    display: grid;
    gap: 18px;
}

.grid.two {
    grid-template-columns: 360px minmax(0, 1fr);
}

.grid.four {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

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

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

.table th {
    color: var(--muted);
    font-weight: 600;
    background: #fbfcfe;
}

.inline-form,
.actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.row-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.filterbar {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}

.filterbar input {
    max-width: 320px;
}

.tree,
.tree ul {
    list-style: none;
    margin: 0;
    padding-left: 22px;
}

.tree {
    padding-left: 0;
}

.tree li {
    margin: 3px 0;
}

.tree-row {
    min-height: 38px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 6px;
    border-radius: 6px;
}

.tree-row:hover {
    background: #f0f5ff;
}

.toggle {
    width: 26px;
    height: 26px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: var(--muted);
}

.placeholder {
    border: 0;
}

.collapsed > ul {
    display: none;
}

.folder,
.file-icon {
    min-width: 34px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
    background: #eef1f5;
    color: #485467;
    font-size: 11px;
    font-weight: 700;
}

.file-icon {
    background: #fff4df;
    color: #805500;
}

.node-name {
    min-width: 160px;
    color: var(--text);
    font-weight: 600;
}

.file-row .node-name {
    font-weight: 500;
}

.level-tag {
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 2px 7px;
    font-size: 12px;
}

.dir-list-name {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
}

.tree-indent {
    width: 24px;
    height: 1px;
    display: inline-block;
}

.tree-branch {
    width: 18px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.upload-inline {
    margin-left: auto;
    display: flex;
    gap: 8px;
    align-items: center;
}

.upload-inline input[type="file"] {
    width: 230px;
    padding: 6px;
}

.delete-inline {
    margin-left: 6px;
}

.small-action {
    margin-left: auto;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 4px 10px;
    color: var(--primary);
    background: #fff;
    font-size: 12px;
    font-weight: 600;
}

.permission-tools {
    display: flex;
    gap: 8px;
}

.selected-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    background: #fbfcfe;
}

.selected-box span {
    color: var(--text);
    font-weight: 600;
}

.switch-line {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
}

.switch-line input {
    width: auto;
}

.employee-picker {
    max-height: 420px;
    overflow: auto;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfe;
}

.available-list:not(.no-matches) .no-result {
    display: none;
}

.available-list.no-matches .no-result {
    display: block;
}

.dual-picker {
    display: grid;
    grid-template-rows: minmax(180px, 1fr) minmax(140px, 0.7fr);
    gap: 12px;
    min-height: 520px;
}

.dual-picker section {
    min-height: 0;
    display: grid;
    grid-template-rows: auto 1fr;
    gap: 8px;
}

.dual-picker h3 {
    margin: 0;
    font-size: 15px;
}

.pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--muted);
}

.directory-picker {
    max-height: 560px;
    overflow: auto;
    display: grid;
    gap: 8px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfe;
}

.directory-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
}

.directory-option input {
    width: auto;
}

.directory-option small {
    margin-left: auto;
    color: var(--muted);
    font-size: 12px;
}

.employee-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
}

.employee-option input {
    width: auto;
}

.employee-option span {
    display: grid;
    gap: 2px;
}

.employee-option small {
    color: var(--muted);
}

.perm-fieldset {
    display: flex;
    gap: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
}

.perm-fieldset label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text);
}

.perm-fieldset input {
    width: auto;
}

.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 20;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(16, 24, 40, 0.38);
}

.modal-backdrop.open {
    display: flex;
}

.modal-panel {
    width: min(860px, 100%);
    max-height: min(760px, 90vh);
    display: flex;
    flex-direction: column;
    gap: 12px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--panel);
    padding: 18px;
    box-shadow: 0 24px 60px rgba(16, 24, 40, 0.2);
}

.modal-head,
.modal-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.modal-head h2 {
    margin-bottom: 0;
}

.employee-search {
    width: 100%;
}

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

.alert {
    border: 1px solid #bfd4ff;
    background: #eef4ff;
    color: #24416e;
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 14px;
}

.alert.danger {
    border-color: #f1b7b7;
    background: #fff0f0;
    color: #842727;
}

.stat {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
}

.stat b {
    display: block;
    font-size: 28px;
}

.stat span {
    color: var(--muted);
}

.preview-frame {
    width: 100%;
    height: calc(100vh - 150px);
    border: 1px solid var(--line);
    background: #fff;
}

.preview-image {
    display: flex;
    justify-content: center;
    background: #1f2329;
    border-radius: 8px;
    padding: 18px;
}

.preview-image img {
    max-width: 100%;
    max-height: calc(100vh - 180px);
    object-fit: contain;
}

.sheet-preview {
    overflow: auto;
    max-height: calc(100vh - 190px);
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.sheet-table {
    width: max-content;
    min-width: 100%;
    border-collapse: collapse;
}

.sheet-table td {
    min-width: 110px;
    max-width: 280px;
    border: 1px solid var(--line);
    padding: 8px 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: #fff;
}

.sheet-table tr:first-child td {
    background: #f7f9fc;
    font-weight: 700;
}

.doc-preview {
    max-width: 920px;
    margin: 0 auto;
    padding: 36px 46px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    line-height: 1.8;
}

.doc-preview p {
    margin: 0 0 12px;
}

.doc-inline-image {
    margin: 16px 0;
}

.doc-inline-image img {
    max-width: 100%;
    max-height: 720px;
    object-fit: contain;
    display: block;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
}

.preview-note {
    margin-top: 12px;
    color: var(--muted);
    text-align: center;
}

.office-image-gallery {
    max-width: 920px;
    margin: 16px auto 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.office-image-gallery img {
    width: 100%;
    max-height: 420px;
    object-fit: contain;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 8px;
}

@media (max-width: 860px) {
    .topbar,
    .toolbar,
    .tree-row,
    .upload-inline {
        align-items: stretch;
        flex-direction: column;
    }

    .topbar {
        height: auto;
        padding: 14px;
    }

    .nav,
    .account,
    .filterbar {
        flex-wrap: wrap;
    }

    .grid.two,
    .grid.four {
        grid-template-columns: 1fr;
    }

    .upload-inline {
        margin-left: 0;
        width: 100%;
    }

    .upload-inline input[type="file"] {
        width: 100%;
    }
}
