:root {
    color-scheme: light;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --border: #dcdfe6;
    --text: #303133;
    --muted: #6b7280;
    --background: #f4f6f9;
    --content-card-min-width: 1100px;
}

* { box-sizing: border-box; }

html, body {
    min-height: 100%;
    margin: 0;
    background: var(--background);
    color: var(--text);
    font-family: "Microsoft YaHei", Arial, sans-serif;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
[v-cloak] { display: none; }

.guest-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
    background: linear-gradient(145deg, #eef4ff, #f7f8fb 55%, #edf2f7);
}

.auth-card, .content-card {
    background: #fff;
    border: 1px solid #ebeef5;
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(31, 41, 55, .06);
}

.auth-card { width: 420px; max-width: 100%; padding: 36px; }
.auth-title { font-size: 24px; font-weight: 700; text-align: center; }
.auth-subtitle { margin: 10px 0 28px; color: var(--muted); text-align: center; }

.form-label { display: block; margin: 18px 0 8px; font-size: 14px; font-weight: 600; }
.form-input {
    width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--border);
    border-radius: 6px; background: #fff; color: var(--text); outline: none;
}
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .1); }

.primary-button {
    display: inline-flex; align-items: center; justify-content: center; min-height: 40px;
    padding: 0 18px; border: 0; border-radius: 6px; background: var(--primary);
    color: #fff; cursor: pointer; font-size: 14px;
}
.primary-button:hover { background: var(--primary-dark); color: #fff; }
.full-width { width: 100%; margin-top: 26px; }
.inline-button { margin-top: 8px; }
.form-actions { display: flex; justify-content: flex-end; margin-top: 24px; }

.form-errors, .flash-message { margin: 16px 0; padding: 12px 14px; border-radius: 6px; font-size: 14px; }
.form-errors { border: 1px solid #fca5a5; background: #fef2f2; color: #b91c1c; }
.flash-message.success { border: 1px solid #86efac; background: #f0fdf4; color: #166534; }
.flash-message.warning { border: 1px solid #fcd34d; background: #fffbeb; color: #92400e; }

.app-header {
    display: flex; align-items: center; min-height: 62px; padding: 0 28px;
    background: #fff; border-bottom: 1px solid #e5e7eb;
}
.brand { color: #111827; font-size: 18px; font-weight: 700; }
.app-nav { display: flex; gap: 8px; margin-left: 38px; }
.app-nav a { padding: 20px 14px 17px; color: #4b5563; border-bottom: 3px solid transparent; }
.app-nav a.active { color: var(--primary); border-bottom-color: var(--primary); }
.account-area { display: flex; align-items: center; gap: 16px; margin-left: auto; font-size: 14px; }
.account-area form { margin: 0; }
.link-button { padding: 0; border: 0; background: none; color: var(--primary); cursor: pointer; }

.app-main { width: 100%; max-width: none; margin: 0; padding: 28px; }
.page-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-heading h1, .content-card h1 { margin: 0 0 8px; font-size: 24px; }
.page-heading p { margin: 0; color: var(--muted); }
.content-card { padding: 24px; }
.content-card:not(.narrow-card) { min-width: var(--content-card-min-width); }
.narrow-card { max-width: 560px; margin: 20px auto; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 18px; margin-bottom: 20px; }
.stat-card { padding: 22px; border: 1px solid #e5e7eb; border-radius: 9px; background: #fff; }
.stat-card span { display: block; color: var(--muted); }
.stat-card strong { display: block; margin-top: 10px; font-size: 30px; }
.stat-card .stat-value-small { font-size: 22px; }
.empty-state { text-align: center; color: var(--muted); }

.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.toolbar-spacer { flex: 1; }
.table-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.pagination-row { display: flex; justify-content: flex-end; margin-top: 20px; }
.section-gap { margin-bottom: 18px; }
.muted-text { color: var(--muted); }
.form-grid { display: grid; gap: 0 18px; }
.form-grid.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.option-status { float: right; margin-left: 18px; color: var(--muted); font-size: 12px; }
.padded-empty { padding: 54px 20px; }
.permission-source { margin-top: 18px; padding: 18px; border: 1px solid #e5e7eb; border-radius: 8px; }
.permission-source-header { display: flex; align-items: center; justify-content: space-between; gap: 24px; color: var(--muted); }
.permission-source-title { min-width: 0; }
.permission-source-title strong, .permission-source-title span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.permission-source-title strong { color: var(--text); }
.permission-source-title span { margin-top: 6px; }
.permission-source-actions { display: flex; flex: none; flex-wrap: wrap; align-items: center; gap: 18px; }
.sql-editor textarea, .sql-preview { font-family: Consolas, "Courier New", monospace; line-height: 1.6; }
.sql-preview { max-height: 360px; overflow: auto; padding: 16px; border: 1px solid #e5e7eb; border-radius: 6px; background: #111827; color: #e5e7eb; white-space: pre-wrap; word-break: break-word; }
.validation-list { margin: 6px 0 0; padding-left: 20px; }
.detail-tags { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 18px; }
.approval-form { margin-top: 20px; padding-top: 18px; border-top: 1px solid #e5e7eb; }
.result-table-wrap { width: 100%; overflow-x: auto; }
.audit-filter-row { flex-wrap: wrap; }
.execution-filter-row { flex-wrap: wrap; }
.audit-json { max-height: 360px; overflow: auto; white-space: pre-wrap; word-break: break-all; }

@media (max-width: 760px) {
    .app-header { flex-wrap: wrap; gap: 10px; padding: 14px 18px; }
    .app-nav { order: 3; width: 100%; margin-left: 0; }
    .app-nav a { padding: 10px; }
    .account-area { margin-left: 0; }
    .app-main { padding: 18px; }
    .stat-grid { grid-template-columns: 1fr; }
    .toolbar { align-items: stretch; flex-direction: column; }
    .toolbar-spacer { display: none; }
    .form-grid.two-columns { grid-template-columns: 1fr; }
    .form-actions .primary-button { width: 100%; }
    .permission-source-header { align-items: flex-start; flex-direction: column; gap: 14px; }
    .permission-source-actions { align-items: flex-start; flex-direction: column; gap: 10px; }
}
