/* Fossil-Manager — 代码托管控制台
   色：#191919 / #fff / #f4f3f3；字：Inter；动效仅 200ms 颜色 */

:root {
    --ink: #191919;
    --muted: #6b6b6b;
    --faint: #9a9a9a;
    --paper: #ffffff;
    --wash: #f4f3f3;
    --line: #e8e8e8;
    --sidebar: 220px;
    --radius: 6px;
    --ease: 200ms ease;
    --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
    font-family: var(--font);
    background: var(--paper);
    color: var(--ink);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ----- 品牌 / 顶栏 ----- */

.brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--ink);
}

.brand-mark { width: 18px; height: 18px; display: block; }
.brand-name { font-size: 14px; font-weight: 600; letter-spacing: -0.02em; }

.topbar-public {
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    border-bottom: 1px solid var(--line);
}

.topbar-public .nav-links,
.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar {
    height: 52px;
    justify-content: flex-end;
    padding: 0 28px;
    border-bottom: 1px solid var(--line);
    flex-shrink: 0;
}

.topbar a,
.nav-links a {
    font-size: 13px;
    color: var(--muted);
    text-decoration: none;
    transition: color var(--ease);
}

.topbar a:hover,
.nav-links a:hover { color: var(--ink); }

.nav-user { font-size: 13px; font-weight: 500; }

.auth-page .topbar-public .nav-links { display: none; }

/* ----- 管理壳 ----- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar);
    flex-shrink: 0;
    border-right: 1px solid var(--line);
    background: #fafafa;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar .brand { padding: 8px 10px 16px; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }

.side-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius);
    text-decoration: none;
    color: #444;
    font-size: 13px;
    transition: background var(--ease), color var(--ease);
}

.side-link svg { width: 15px; height: 15px; opacity: 0.65; flex-shrink: 0; }

.side-link:hover { background: var(--wash); color: var(--ink); }

.side-link.is-active {
    background: var(--wash);
    color: var(--ink);
    font-weight: 600;
}

.side-link.is-active svg { opacity: 1; }

.frame { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.admin-main,
.page-main {
    flex: 1;
    padding: 24px 28px 48px;
}

body:not(.is-admin) .page-main {
    padding: 28px 48px 56px;
}

.admin-main { max-width: 1080px; }

.public-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ----- 页头 ----- */

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 20px;
}

.page-head h1 {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.3;
}

.page-head .lede,
.lede {
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
}

.page-head-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* ----- 按钮 ----- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    padding: 0 12px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background var(--ease), border-color var(--ease), color var(--ease);
}

.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #333; }

.btn-secondary { background: var(--wash); color: var(--ink); }
.btn-secondary:hover { background: #eaeaea; }

.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--ink); background: var(--wash); }

.btn-danger {
    background: #fff;
    color: var(--ink);
    border-color: var(--line);
}
.btn-danger:hover { background: var(--wash); }

.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }

.btn-link {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    padding: 0;
    transition: color var(--ease);
}
.btn-link:hover { color: var(--ink); }

/* ----- 表单 ----- */

.form-group { margin-bottom: 14px; }

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="url"],
.form-input {
    width: 100%;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-size: 13px;
    font-family: inherit;
    color: var(--ink);
    background: var(--paper);
    transition: border-color var(--ease), box-shadow var(--ease);
}

.form-group input:focus,
.form-input:focus {
    outline: none;
    border-color: var(--ink);
    box-shadow: 0 0 0 3px rgba(25, 25, 25, 0.06);
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: var(--faint);
    font-size: 12px;
}

.form-group small code {
    font-size: 11px;
    background: var(--wash);
    padding: 1px 4px;
    border-radius: 3px;
}

.form-actions { display: flex; gap: 8px; margin-top: 18px; align-items: center; }

.narrow { max-width: 480px; }

.settings-item {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: 10px;
    background: #fff;
}

.settings-item summary {
    padding: 12px 14px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.settings-item summary::-webkit-details-marker { display: none; }

.settings-item summary::after {
    content: "";
    width: 6px;
    height: 6px;
    border-right: 1.5px solid var(--muted);
    border-bottom: 1.5px solid var(--muted);
    transform: rotate(45deg);
    transition: transform var(--ease);
}

.settings-item[open] summary::after {
    transform: rotate(225deg);
}

.settings-item summary:hover { background: #fafafa; }

.settings-body {
    padding: 4px 14px 16px;
    border-top: 1px solid var(--line);
}

.alert {
    padding: 10px 12px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 13px;
    border: 1px solid var(--line);
    background: var(--wash);
}

.alert-error { background: #fff; border-color: var(--ink); }

/* ----- 表格 ----- */

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

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

.data-table th {
    text-align: left;
    font-size: 12px;
    font-weight: 500;
    color: var(--faint);
    padding: 8px 10px;
    border-bottom: 1px solid var(--line);
}

.data-table td {
    padding: 10px;
    border-bottom: 1px solid #f2f2f2;
    font-size: 13px;
    color: #444;
    vertical-align: middle;
}

.data-table tbody tr:hover td { background: #fafafa; }

.data-table td a.repo-name {
    color: var(--ink);
    text-decoration: none;
    font-weight: 500;
}
.data-table td a.repo-name:hover { text-decoration: underline; }

.row-actions { display: flex; gap: 4px; justify-content: flex-end; }

/* ----- 指标条 ----- */

.metrics {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: 28px;
    overflow: hidden;
}

.metric {
    padding: 14px 16px;
    border-right: 1px solid var(--line);
}
.metric:last-child { border-right: none; }

.metric .lbl {
    font-size: 12px;
    color: var(--faint);
    margin-bottom: 4px;
}

.metric .num {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
}

.section { margin-top: 28px; }

.section h2 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 10px;
}

.hairline { height: 1px; background: var(--line); border: 0; margin: 24px 0; }

.empty { padding: 20px 0; color: var(--faint); font-size: 13px; }

/* ----- 公开目录 ----- */

.catalog {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
}

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

.catalog-head h1 {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.repo-filter { position: relative; }
.repo-filter svg {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}
.repo-filter form { margin: 0; }
.repo-filter input {
    height: 32px;
    padding: 0 10px 0 30px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-size: 13px;
    width: 240px;
    font-family: inherit;
    background: #fff;
}
.repo-filter input:focus {
    outline: none;
    border-color: var(--ink);
    box-shadow: 0 0 0 3px rgba(25, 25, 25, 0.06);
}
.repo-filter button { display: none; }

.repo-content {
    display: flex;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    min-height: 280px;
    overflow: hidden;
}

.repo-nav {
    flex: 0 0 160px;
    padding: 8px;
    border-right: 1px solid var(--line);
    background: #fafafa;
}

.repo-nav-item {
    display: block;
    padding: 6px 10px;
    font-size: 13px;
    color: var(--muted);
    text-decoration: none;
    border-radius: 4px;
}

.repo-nav-item:hover { color: var(--ink); background: var(--wash); }

.repo-nav-item.active {
    color: var(--ink);
    font-weight: 600;
    background: var(--wash);
}

.repo-list-wrapper { flex: 1; min-width: 0; overflow-x: auto; }

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

.repo-table thead th {
    text-align: left;
    font-size: 12px;
    font-weight: 500;
    color: var(--faint);
    padding: 8px 14px;
    border-bottom: 1px solid var(--line);
}

.repo-table tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid #f2f2f2;
    font-size: 13px;
    color: #555;
}

.repo-table .desc-col {
    color: var(--muted);
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.repo-table .tl-col {
    width: 100px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.repo-table .time-col {
    width: 160px;
    white-space: nowrap;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.repo-table tbody tr:hover td { background: #fafafa; }

.repo-table td.name-col a {
    color: var(--ink);
    text-decoration: none;
    font-weight: 500;
}
.repo-table td.name-col a:hover { text-decoration: underline; }

.repo-table .empty-msg {
    padding: 48px 12px;
    text-align: center;
    color: var(--faint);
}

.pagination {
    display: flex;
    justify-content: space-between;
    padding: 12px 8px 0;
    font-size: 13px;
    color: var(--faint);
}

.pagination-links { display: flex; gap: 12px; }
.pagination-links a { color: var(--ink); text-decoration: none; }
.pagination-links a:hover { text-decoration: underline; }

/* ----- 登录 ----- */

.auth-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.auth-card { width: 100%; max-width: 360px; }
.auth-card h1 { font-size: 22px; font-weight: 600; margin-bottom: 20px; }

/* ----- 详情 ----- */

.meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 24px;
    padding: 12px 0;
    margin-bottom: 24px;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    font-size: 13px;
    color: var(--muted);
}

.meta-row strong { color: var(--ink); font-weight: 500; margin-left: 6px; }

.panel {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 18px 18px;
    margin-bottom: 16px;
}

.panel h2 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 14px;
}

.danger-zone {
    margin-top: 32px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.danger-zone h2 { font-size: 14px; font-weight: 600; margin-bottom: 6px; }

/* ----- 远程 ----- */

.group-block { margin-bottom: 24px; }

.group-block h3 {
    font-size: 12px;
    font-weight: 600;
    color: var(--faint);
    margin-bottom: 6px;
}

.remote-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 8px 4px;
    border-bottom: 1px solid #f2f2f2;
}

.remote-row a { color: var(--ink); text-decoration: none; font-weight: 500; }
.remote-row a:hover { text-decoration: underline; }

/* ----- 错误 / 页脚 ----- */

.error-screen { min-height: 50vh; display: flex; align-items: center; }
.error-screen h1 { font-size: 40px; font-weight: 600; letter-spacing: -0.03em; }
.error-screen p { margin: 8px 0 20px; color: var(--muted); }

.footer {
    text-align: center;
    padding: 16px;
    color: var(--faint);
    font-size: 12px;
    border-top: 1px solid var(--line);
}

.footer a { color: var(--faint); text-decoration: none; }
.footer a:hover { color: var(--ink); }
.footer-sep { margin: 0 8px; color: #ccc; }
.police-icon { width: 14px; height: 14px; vertical-align: middle; margin-right: 3px; }

/* ----- 模态 ----- */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(25, 25, 25, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-box {
    background: #fff;
    border-radius: 8px;
    padding: 22px;
    width: 400px;
    max-width: 92vw;
    border: 1px solid var(--line);
}

.modal-box h3 { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.modal-box p { font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

/* ----- 响应式 ----- */

@media (max-width: 800px) {
    .shell { flex-direction: column; }
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        border-right: none;
        border-bottom: 1px solid var(--line);
        padding: 10px 12px;
    }
    .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
    .admin-main, .page-main, .topbar-public,
    body:not(.is-admin) .page-main { padding-left: 16px; padding-right: 16px; }
    .metrics { grid-template-columns: 1fr 1fr; }
    .metric { border-bottom: 1px solid var(--line); }
    .catalog-head { flex-direction: column; align-items: stretch; }
    .repo-filter input { width: 100%; }
    .repo-content { flex-direction: column; }
    .repo-nav { flex: none; width: 100%; border-right: none; border-bottom: 1px solid var(--line); display: flex; gap: 4px; }
    .page-head { flex-direction: column; }
}
