:root {
    --bg: #f3f5f9;
    --card: #ffffff;
    --sidebar: #111827;
    --sidebar-hover: #1f2937;
    --sidebar-active: #2563eb;
    --text: #111827;
    --muted: #6b7280;
    --border: #e5e7eb;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #059669;
    --warning: #d97706;
    --danger: #dc2626;
    --radius: 10px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

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

a:hover {
    text-decoration: underline;
}

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

.sidebar {
    width: 230px;
    background: var(--sidebar);
    color: #e5e7eb;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-brand {
    padding: 20px;
    font-size: 16px;
    font-weight: 700;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.sidebar-nav {
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.nav-link {
    display: block;
    padding: 10px 14px;
    border-radius: 8px;
    color: #d1d5db;
    font-size: 14px;
    font-weight: 500;
}

.nav-link:hover {
    background: var(--sidebar-hover);
    color: #ffffff;
    text-decoration: none;
}

.nav-link.active {
    background: var(--sidebar-active);
    color: #ffffff;
}

.sidebar-footer {
    padding: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

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

.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 14px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.topbar h1 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.content {
    padding: 24px;
    max-width: 1400px;
    width: 100%;
}

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}

.alert-success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

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

.alert-info {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

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

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

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-bottom: 20px;
}

.card-title {
    margin: 0 0 14px 0;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-label {
    font-size: 13px;
    color: var(--muted);
}

.stat-value {
    font-size: 26px;
    font-weight: 700;
    margin-top: 6px;
}

.stat-sub {
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

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

th {
    background: #f9fafb;
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
}

tr:hover td {
    background: #f9fafb;
}

.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-green { background: #dcfce7; color: #166534; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-gray { background: #f3f4f6; color: #374151; }

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

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

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

label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 5px;
    color: #374151;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="url"],
select,
textarea {
    width: 100%;
    padding: 8px 11px;
    border: 1px solid #d1d5db;
    border-radius: 7px;
    font-size: 14px;
    background: #ffffff;
    font-family: inherit;
}

textarea {
    min-height: 86px;
    resize: vertical;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.checkbox-row input {
    width: auto;
}

.checkbox-row label {
    margin: 0;
    font-weight: 500;
}

.btn {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 7px;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    background: var(--primary);
    color: #ffffff;
    text-decoration: none;
}

.btn:hover {
    background: var(--primary-hover);
    text-decoration: none;
}

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

.btn-secondary {
    background: #e5e7eb;
    color: #1f2937;
}

.btn-secondary:hover {
    background: #d1d5db;
}

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

.btn-success:hover {
    background: #047857;
}

.btn-warning {
    background: var(--warning);
}

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

.btn-danger:hover {
    background: #b91c1c;
}

.inline-form {
    display: inline-block;
    margin: 0;
}

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

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.tab-pill {
    padding: 6px 12px;
    border-radius: 999px;
    background: #ffffff;
    border: 1px solid var(--border);
    color: #374151;
    font-size: 13px;
}

.tab-pill.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
}

.code-block {
    background: #111827;
    color: #f9fafb;
    padding: 12px;
    border-radius: 8px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 13px;
    white-space: pre-wrap;
    word-break: break-all;
}

.muted {
    color: var(--muted);
    font-size: 12px;
}

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

.login-card {
    width: 100%;
    max-width: 390px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 28px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
}

@media (max-width: 960px) {
    .grid-4, .grid-2, .form-grid {
        grid-template-columns: 1fr;
    }
    .app-shell {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
    }
}
