/* ===== Admin CSS ===== */
:root {
    --a-bg: #f5f6f8;
    --a-surface: #fff;
    --a-border: #e2e5ea;
    --a-text: #1f2328;
    --a-muted: #6b7280;
    --a-primary: #2563eb;
    --a-primary-hover: #1d4ed8;
    --a-danger: #dc2626;
    --a-danger-hover: #b91c1c;
    --a-radius: 6px;
    --a-shadow: 0 1px 2px rgba(0,0,0,.05);
}

*, *::before, *::after { box-sizing: border-box; }

body.admin {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
        "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--a-text);
    background: var(--a-bg);
}

.a-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ===== Topbar ===== */
.a-topbar {
    background: var(--a-surface);
    border-bottom: 1px solid var(--a-border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.a-topbar__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 52px;
}

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

.a-brand strong { font-size: 15px; }
.a-brand small { color: var(--a-muted); margin-left: 4px; font-size: 12px; }

.a-topbar__nav {
    display: flex;
    align-items: center;
    gap: 12px;
}

.a-topbar__nav a {
    color: var(--a-muted);
    text-decoration: none;
    font-size: 13px;
}

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

/* ===== Buttons ===== */
.a-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid var(--a-border);
    border-radius: var(--a-radius);
    background: var(--a-surface);
    color: var(--a-text);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s;
}

.a-btn:hover { border-color: #c5c9d0; background: #f9fafb; }

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

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

.a-btn--danger {
    color: var(--a-danger);
    border-color: #fecaca;
}

.a-btn--danger:hover { background: #fef2f2; border-color: var(--a-danger); }

.a-btn--ghost {
    border-color: transparent;
    background: transparent;
}

.a-btn--ghost:hover { background: #f3f4f6; }

.a-btn--sm { padding: 3px 10px; font-size: 12px; }

.a-btn--block { width: 100%; justify-content: center; padding: 8px; }

/* ===== Main ===== */
.a-main { padding: 24px 20px 60px; }

.a-flash {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
    border-radius: var(--a-radius);
    padding: 10px 14px;
    margin-bottom: 16px;
    font-size: 13px;
}

/* ===== Toolbar ===== */
.a-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.a-toolbar__actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.a-search {
    display: flex;
    gap: 8px;
    flex: 1;
    min-width: 200px;
}

.a-search input {
    flex: 1;
    padding: 6px 12px;
    border: 1px solid var(--a-border);
    border-radius: var(--a-radius);
    font-size: 13px;
    background: var(--a-surface);
}

.a-search input:focus {
    outline: none;
    border-color: var(--a-primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, .15);
}

/* ===== 批量操作 ===== */
.a-bulk {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    border-radius: var(--a-radius);
    padding: 8px 12px;
    margin-bottom: 12px;
}

.a-bulk[hidden] { display: none; }

.a-bulk__count { font-size: 13px; white-space: nowrap; }

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

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

.a-select {
    padding: 5px 8px;
    border: 1px solid var(--a-border);
    border-radius: var(--a-radius);
    background: var(--a-surface);
    font-size: 13px;
    color: var(--a-text);
}

.a-select:focus {
    outline: none;
    border-color: var(--a-primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, .15);
}

.a-col-check { width: 36px; text-align: center; }

.a-table input[type="checkbox"] {
    width: 15px;
    height: 15px;
    cursor: pointer;
    accent-color: var(--a-primary);
    vertical-align: middle;
}

.a-row-selected td { background: #eef2ff; }

/* ===== Table ===== */
.a-table-wrap {
    background: var(--a-surface);
    border: 1px solid var(--a-border);
    border-radius: var(--a-radius);
    overflow-x: auto;
    box-shadow: var(--a-shadow);
}

.a-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

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

.a-table thead th {
    background: #f9fafb;
    font-weight: 600;
    color: var(--a-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .03em;
    position: sticky;
    top: 0;
}

.a-table tbody tr:last-child td { border-bottom: none; }

.a-table tbody tr:hover { background: #fafbfc; }

.a-col-drag { width: 32px; text-align: center; }
.a-col-actions { width: 130px; text-align: right; }

.a-col-actions form { display: inline; }

.a-drag-handle {
    cursor: grab;
    color: #c5c9d0;
    font-size: 16px;
    user-select: none;
}

.a-drag-handle:hover { color: var(--a-muted); }

.a-dragging { opacity: .4; }

.a-drag-over td { box-shadow: inset 0 -2px 0 var(--a-primary); }

.a-site-cell {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.a-site-cell__icon { font-size: 20px; flex-shrink: 0; line-height: 1; }

.a-site-cell__name a {
    color: var(--a-text);
    text-decoration: none;
    font-weight: 500;
}

.a-site-cell__name a:hover { color: var(--a-primary); }

.a-site-cell__desc {
    color: var(--a-muted);
    font-size: 12px;
    margin-top: 2px;
}

.a-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
    background: #f3f4f6;
    color: var(--a-muted);
}

.a-badge--env-prod { background: #dbeafe; color: #1e40af; }
.a-badge--env-staging { background: #fef3c7; color: #92400e; }
.a-badge--env-dev { background: #f3e8ff; color: #6b21a8; }
.a-badge--env-demo { background: #dcfce7; color: #166534; }

.a-code {
    font-family: "SF Mono", "Menlo", "Monaco", "Consolas", monospace;
    font-size: 13px;
    font-weight: 600;
    color: var(--a-primary);
    background: #eff6ff;
    padding: 2px 8px;
    border-radius: 4px;
    letter-spacing: .05em;
}

.a-ai-plan {
    display: inline-block;
    font-size: 12px;
    color: #6d28d9;
    background: #f5f3ff;
    padding: 2px 8px;
    border-radius: 4px;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}

.a-fieldset.a-ai {
    border-color: #c7d2fe;
    background: #f5f7ff;
}

.a-ai__actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.a-ai__actions .a-btn {
    white-space: nowrap;
}

.a-ai__actions .a-field__hint {
    margin: 0;
}

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

.a-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
    background: #9ca3af;
}

.a-dot--online { background: #22c55e; }
.a-dot--maintenance { background: #f59e0b; }
.a-dot--offline { background: #ef4444; }

.a-empty {
    text-align: center;
    padding: 40px 20px !important;
    color: var(--a-muted);
}

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

.a-hint {
    margin-top: 12px;
    font-size: 12px;
    color: var(--a-muted);
    text-align: center;
}

/* ===== Forms ===== */
.a-form-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.a-form-header h1 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.a-form {
    background: var(--a-surface);
    border: 1px solid var(--a-border);
    border-radius: var(--a-radius);
    padding: 24px;
    box-shadow: var(--a-shadow);
}

.a-fieldset {
    border: none;
    padding: 0;
    margin: 0 0 24px;
}

.a-fieldset:last-of-type { margin-bottom: 0; }

.a-fieldset legend {
    font-size: 13px;
    font-weight: 600;
    color: var(--a-muted);
    text-transform: uppercase;
    letter-spacing: .03em;
    padding: 0 0 8px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--a-border);
    width: 100%;
}

.a-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.a-row--3 {
    grid-template-columns: 1fr 1fr 1fr;
}

@media (max-width: 640px) {
    .a-row, .a-row--3 { grid-template-columns: 1fr; }
}

.a-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}

.a-field label {
    font-size: 12px;
    font-weight: 500;
    color: var(--a-muted);
}

.a-field--req label::after {
    content: ' *';
    color: var(--a-danger);
}

.a-field input,
.a-field select,
.a-field textarea {
    padding: 7px 10px;
    border: 1px solid var(--a-border);
    border-radius: var(--a-radius);
    font-size: 13px;
    font-family: inherit;
    background: var(--a-surface);
    color: var(--a-text);
}

.a-field input:focus,
.a-field select:focus,
.a-field textarea:focus {
    outline: none;
    border-color: var(--a-primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, .15);
}

.a-field textarea { resize: vertical; min-height: 60px; }

.a-field__hint {
    font-size: 11px;
    color: var(--a-muted);
    margin-top: 2px;
}

.a-form__actions {
    display: flex;
    gap: 10px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--a-border);
}

.a-check {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    margin: 8px 0 16px;
    cursor: pointer;
}

/* ===== Alert ===== */
.a-alert {
    border-radius: var(--a-radius);
    padding: 10px 14px;
    margin-bottom: 16px;
    font-size: 13px;
}

.a-alert--error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

/* ===== Login ===== */
.a-login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.a-login-card {
    width: 100%;
    max-width: 360px;
    background: var(--a-surface);
    border: 1px solid var(--a-border);
    border-radius: 8px;
    padding: 32px;
    box-shadow: 0 4px 12px rgba(0,0,0,.06);
}

.a-login-card__title {
    text-align: center;
    font-size: 20px;
    margin: 0 0 4px;
}

.a-login-card__sub {
    text-align: center;
    color: var(--a-muted);
    font-size: 13px;
    margin: 0 0 24px;
}

/* ===== 图标选择 ===== */
.a-icon-picker {
    display: flex;
    gap: 8px;
}

.a-icon-picker input { flex: 1; }

.a-icon-modal { max-width: 620px; }

.a-icon-search {
    width: 100%;
    margin-bottom: 12px;
    padding: 7px 10px;
}

.a-icon-groups {
    max-height: 420px;
    overflow-y: auto;
    padding-right: 4px;
}

.a-icon-group { margin-bottom: 14px; }

.a-icon-group:last-child { margin-bottom: 0; }

.a-icon-group[hidden] { display: none; }

.a-icon-group__title {
    font-size: 12px;
    font-weight: 600;
    color: var(--a-muted);
    margin-bottom: 6px;
}

.a-icon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
    gap: 4px;
}

.a-icon-cell {
    border: 1px solid var(--a-border);
    background: var(--a-surface);
    border-radius: 6px;
    font-size: 22px;
    line-height: 1;
    padding: 8px 0;
    cursor: pointer;
    transition: background .12s, border-color .12s, transform .12s;
}

.a-icon-cell[hidden] { display: none; }

.a-icon-cell:hover {
    background: #eef2ff;
    border-color: var(--a-primary);
    transform: scale(1.08);
}

.a-icon-cell--active {
    border-color: var(--a-primary);
    background: #eef2ff;
}

/* ===== Modal ===== */
.a-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.a-modal__card {
    background: var(--a-surface);
    border-radius: 8px;
    padding: 24px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
}

.a-modal__card h3 {
    margin: 0 0 8px;
    font-size: 16px;
}

.a-modal__hint {
    color: var(--a-muted);
    font-size: 13px;
    margin: 0 0 16px;
}

.a-modal__actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}
