:root {
    --bg: #f4f6f8;
    --panel: #ffffff;
    --border: #d9dee3;
    --text: #1f2933;
    --muted: #6b7280;
    --accent: #0e7490;
    --accent-weak: #ecfeff;
    --danger: #b91c1c;
    --danger-weak: #fee2e2;
    --success: #15803d;
    --success-weak: #dcfce7;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    letter-spacing: 0;
}

button, input, textarea {
    font: inherit;
}

.hidden {
    display: none !important;
}

.login-view {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-panel {
    width: 100%;
    max-width: 380px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 28px;
}

.login-brand {
    text-align: center;
    margin-bottom: 22px;
}

.brand-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-weak);
    color: var(--accent);
    border-radius: 8px;
}

.brand-icon.small {
    width: 34px;
    height: 34px;
    margin: 0 10px 0 0;
}

.login-brand h1,
.topbar-title h1 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
}

.login-brand p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

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

.field span {
    color: var(--muted);
    font-size: 13px;
}

.field input,
.field textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 9px 10px;
    background: #fff;
    color: var(--text);
    outline: none;
}

.field input:focus,
.field textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(14, 116, 144, 0.12);
}

.field textarea {
    resize: vertical;
    line-height: 1.5;
}

.form-error {
    min-height: 20px;
    color: var(--danger);
    font-size: 13px;
    margin-top: 10px;
}

.app-view {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: 60px;
    flex: 0 0 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
}

.topbar-title {
    display: flex;
    align-items: center;
}

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

.admin-name {
    color: var(--muted);
    margin-right: 6px;
}

.main {
    flex: 1;
    display: flex;
    min-height: 0;
}

.sidebar {
    width: 190px;
    flex: 0 0 190px;
    padding: 16px 10px;
    background: var(--panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    text-align: left;
}

.nav-item:hover {
    background: var(--bg);
}

.nav-item.active {
    background: var(--accent-weak);
    color: var(--accent);
    font-weight: 600;
}

.content {
    flex: 1;
    min-width: 0;
    padding: 22px;
    overflow: auto;
}

.view {
    display: none;
}

.view.active {
    display: block;
}

.view-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.view-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.table-wrap {
    overflow-x: auto;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
}

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

.data-table th,
.data-table td {
    text-align: left;
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table th {
    background: #fafbfc;
    color: var(--muted);
    font-weight: 500;
}

.data-table tbody tr:last-child td {
    border-bottom: 0;
}

.empty-cell {
    text-align: center;
    color: var(--muted);
    padding: 28px 14px !important;
}

.mono {
    font-family: "SF Mono", Menlo, Consolas, monospace;
    font-size: 13px;
}

.row-actions {
    display: flex;
    gap: 6px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 12px;
    background: var(--panel);
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
}

.btn:hover {
    background: var(--bg);
}

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

.btn-primary:hover {
    background: #0c667f;
}

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

.btn-danger:hover {
    background: var(--danger-weak);
}

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

.btn-block {
    width: 100%;
    justify-content: center;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    max-width: 760px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
}

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

.form-actions {
    display: flex;
    justify-content: flex-end;
}

.modal-mask {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 16px;
    overflow: auto;
    z-index: 100;
}

.modal {
    width: 100%;
    max-width: 720px;
    background: var(--panel);
    border-radius: 8px;
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.2);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.modal-body {
    padding: 18px;
}

.modal-body .form-grid {
    border: 0;
    border-radius: 0;
    padding: 0;
    max-width: none;
}

.detail-section {
    margin-bottom: 18px;
}

.detail-section h4 {
    margin: 0 0 10px;
    font-size: 14px;
    color: var(--muted);
    font-weight: 600;
}

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

.kv-item {
    padding: 10px 12px;
    background: #fafbfc;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.kv-item .k {
    color: var(--muted);
    font-size: 12px;
    display: block;
}

.kv-item .v {
    display: block;
    margin-top: 4px;
    word-break: break-all;
    white-space: pre-wrap;
}

.toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    max-width: 380px;
    padding: 11px 14px;
    border-radius: 6px;
    color: #fff;
    background: #111827;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.25);
    z-index: 200;
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--danger);
}

@media (max-width: 760px) {
    .main {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        flex: 0 0 auto;
        flex-direction: row;
        border-right: 0;
        border-bottom: 1px solid var(--border);
        padding: 8px 10px;
    }

    .nav-item {
        flex: 1;
        justify-content: center;
    }

    .content {
        padding: 14px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .kv-list {
        grid-template-columns: 1fr;
    }

    .topbar-actions .btn span {
        display: none;
    }
}
