:root {
    --bg: #f3f6f7;
    --surface: #ffffff;
    --surface-muted: #eef3f4;
    --ink: #172126;
    --muted: #66747c;
    --line: #d7e0e3;
    --primary: #146c68;
    --primary-dark: #0f5552;
    --accent: #bd5b2d;
    --danger: #b42318;
    --danger-soft: #fff1ef;
    --success: #18794e;
    --success-soft: #ecf8f1;
    --warning: #9a6700;
    --warning-soft: #fff7df;
    --shadow: 0 12px 30px rgba(23, 33, 38, 0.07);
    --radius: 7px;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    background:
        linear-gradient(180deg, rgba(20, 108, 104, 0.06), transparent 210px),
        var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    line-height: 1.55;
}

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

a:hover {
    color: var(--primary-dark);
}

button,
input,
select,
textarea {
    font: inherit;
}

.app-shell {
    min-height: 100vh;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 62px;
    padding: 0 28px;
    border-bottom: 1px solid rgba(215, 224, 227, 0.9);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(14px);
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    color: var(--ink);
    font-weight: 750;
    letter-spacing: 0;
}

.brand-mark {
    display: grid;
    width: 32px;
    height: 32px;
    place-items: center;
    border-radius: 6px;
    background: var(--primary);
    color: white;
    font-size: 13px;
    font-weight: 800;
}

.topbar-nav {
    display: flex;
    align-items: center;
    gap: 6px;
}

.topbar-nav a {
    padding: 8px 10px;
    border-radius: 6px;
    color: var(--muted);
    font-weight: 650;
}

.topbar-nav a:hover,
.topbar-nav a.active {
    background: var(--surface-muted);
    color: var(--ink);
}

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

.account-name {
    color: var(--ink);
    font-weight: 700;
}

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

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

.page-head h1 {
    margin: 0;
    font-size: 26px;
    line-height: 1.2;
    letter-spacing: 0;
}

.page-head p {
    max-width: 720px;
    margin: 6px 0 0;
    color: var(--muted);
}

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

.stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

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

.stat-label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.stat-value {
    margin-top: 5px;
    font-size: 25px;
    font-weight: 780;
    line-height: 1.1;
}

.panel {
    overflow: hidden;
    margin-bottom: 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
    background: #fbfcfc;
}

.panel-header h2,
.panel-header h3 {
    margin: 0;
    font-size: 16px;
}

.panel-body {
    padding: 18px;
}

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

.site-card {
    display: flex;
    min-height: 188px;
    flex-direction: column;
    justify-content: space-between;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 7px 18px rgba(23, 33, 38, 0.04);
}

.site-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.site-card h3 {
    margin: 0;
    font-size: 18px;
}

.site-card p {
    margin: 5px 0 0;
    color: var(--muted);
}

.site-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
    gap: 16px;
}

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

.file-editor-list {
    display: grid;
    gap: 15px;
}

.site-editor-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    align-items: stretch;
    min-height: 460px;
}

.editor-right-stack {
    display: grid;
    grid-template-rows: minmax(0, 1.45fr) minmax(0, 1fr);
    gap: 14px;
    min-height: 0;
}

.file-card {
    padding: 17px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.file-card h3 {
    margin: 0 0 6px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 15px;
}

.file-meta {
    min-height: 48px;
    color: var(--muted);
}

.file-meta strong {
    color: var(--ink);
}

.file-editor-card {
    display: flex;
    height: 100%;
    min-height: 0;
    flex-direction: column;
}

.file-editor-field {
    display: flex;
    flex: 1;
    min-height: 0;
    margin-top: 14px;
}

.file-editor {
    flex: 1;
    min-height: 0;
    resize: none;
    background: #fbfdfd;
}

.note-editor-card .file-editor-field {
    flex: 1;
}

.note-editor-card textarea {
    flex: 1;
    min-height: 0;
}

.file-editor-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 11px;
}

.compact-domain-panel {
    margin-bottom: 14px;
    background: #fbfcfc;
    box-shadow: none;
}

.domain-strip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 11px 14px;
}

.domain-strip-main {
    display: flex;
    flex: 1;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.domain-strip-title {
    margin-right: 3px;
    white-space: nowrap;
    color: var(--muted);
    font-size: 12px;
    font-weight: 780;
    text-transform: uppercase;
}

.domain-add-form {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 7px;
}

.domain-add-form input {
    width: 190px;
    min-height: 34px;
}

.domain-add-form .btn {
    flex: 0 0 auto;
    white-space: nowrap;
}

.domain-chip a {
    color: var(--primary-dark);
    font-weight: 720;
}

.domain-remove {
    display: inline-grid;
    width: 19px;
    height: 19px;
    padding: 0;
    place-items: center;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: #8a969a;
    cursor: pointer;
    line-height: 1;
}

.domain-remove:hover {
    background: #f8dcd8;
    color: var(--danger);
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--surface-muted);
    color: var(--muted);
    font-size: 12px;
    font-weight: 750;
    white-space: nowrap;
}

.badge-success {
    background: var(--success-soft);
    color: var(--success);
}

.badge-danger {
    background: var(--danger-soft);
    color: var(--danger);
}

.badge-warning {
    background: var(--warning-soft);
    color: var(--warning);
}

.btn {
    display: inline-flex;
    min-height: 36px;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 7px 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
}

.btn:hover {
    border-color: #b8c6ca;
    color: var(--ink);
}

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

.btn-primary:hover {
    border-color: var(--primary-dark);
    background: var(--primary-dark);
    color: white;
}

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

.btn-small {
    min-height: 31px;
    padding: 5px 9px;
    font-size: 13px;
}

.btn-block {
    width: 100%;
}

.link-button {
    display: inline;
    padding: 0;
    border: 0;
    background: none;
    color: var(--primary);
    cursor: pointer;
    font-weight: 700;
}

.link-button.danger {
    color: var(--danger);
}

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

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

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field label {
    font-weight: 720;
}

.field small,
.help-text {
    color: var(--muted);
}

input[type="text"],
input[type="password"],
select,
textarea {
    width: 100%;
    border: 1px solid #c8d3d7;
    border-radius: 6px;
    background: white;
    color: var(--ink);
    outline: none;
}

input[type="text"],
input[type="password"],
select {
    min-height: 39px;
    padding: 8px 10px;
}

textarea {
    min-height: 120px;
    padding: 10px;
    resize: vertical;
}

textarea.code-editor {
    min-height: 430px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    line-height: 1.55;
    tab-size: 2;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(20, 108, 104, 0.11);
}

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

.checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
}

.table-wrap {
    overflow-x: auto;
}

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

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

th {
    background: #f8fafb;
    color: var(--muted);
    font-size: 12px;
    font-weight: 780;
    text-transform: uppercase;
}

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

.code {
    padding: 2px 5px;
    border-radius: 4px;
    background: var(--surface-muted);
    color: var(--ink);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
}

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

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

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

.divider {
    height: 1px;
    margin: 17px 0;
    background: var(--line);
}

.flash-stack {
    display: grid;
    gap: 9px;
    margin-bottom: 18px;
}

.flash {
    padding: 11px 13px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
}

.flash-success {
    border-color: #b8dfc8;
    background: var(--success-soft);
    color: var(--success);
}

.flash-error {
    border-color: #efc1bc;
    background: var(--danger-soft);
    color: var(--danger);
}

.flash-warning {
    border-color: #ead39a;
    background: var(--warning-soft);
    color: var(--warning);
}

.empty {
    padding: 38px 20px;
    border: 1px dashed #bdc9cd;
    border-radius: var(--radius);
    color: var(--muted);
    text-align: center;
}

.login-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
}

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

.login-head {
    margin-bottom: 22px;
}

.login-head .brand {
    margin-bottom: 18px;
}

.login-head h1 {
    margin: 0;
    font-size: 24px;
}

.login-head p {
    margin: 6px 0 0;
    color: var(--muted);
}

.detail-list {
    display: grid;
    gap: 12px;
}

.detail-row {
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr);
    gap: 14px;
}

.detail-row dt {
    color: var(--muted);
    font-weight: 700;
}

.detail-row dd {
    min-width: 0;
    margin: 0;
    overflow-wrap: anywhere;
}

.domain-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.domain-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 8px;
    border: 1px solid #cbdcda;
    border-radius: 6px;
    background: #f1f7f6;
}

.inline-form {
    display: flex;
    align-items: center;
    gap: 7px;
}

.inline-form input {
    min-width: 210px;
}

.warning-box {
    padding: 12px 13px;
    border: 1px solid #ead39a;
    border-radius: 6px;
    background: var(--warning-soft);
    color: #755000;
}

@media (max-width: 900px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
        gap: 10px;
        padding: 14px 20px;
    }

    .topbar-nav {
        width: 100%;
        overflow-x: auto;
        padding-bottom: 2px;
    }

    .account {
        width: 100%;
        justify-content: space-between;
    }

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

    .site-grid,
    .detail-grid,
    .file-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .site-editor-grid {
        grid-template-columns: 1fr;
        min-height: 0;
    }

    .editor-right-stack {
        grid-template-rows: none;
    }

    .file-editor-card {
        height: auto;
    }

    .file-editor {
        min-height: 195px;
    }

    .note-editor-card textarea {
        min-height: 110px;
    }
}

@media (max-width: 620px) {
    .container {
        width: min(100% - 24px, 1180px);
        padding-top: 20px;
    }

    .page-head {
        align-items: stretch;
        flex-direction: column;
    }

    .stats,
    .form-grid,
    .checkbox-list {
        grid-template-columns: 1fr;
    }

    .detail-row {
        grid-template-columns: 1fr;
        gap: 3px;
    }

    .inline-form {
        align-items: stretch;
        flex-direction: column;
    }

    .domain-strip {
        align-items: stretch;
        flex-direction: column;
    }

    .domain-add-form {
        align-items: stretch;
    }

    .domain-add-form input {
        width: 100%;
    }

    .inline-form input {
        min-width: 0;
    }
}
