:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --bg: #f6f7fb;
    --surface: #ffffff;
    --border: #e5e7eb;
    --text: #1f2937;
    --muted: #6b7280;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --radius: 10px;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 1080px; margin: 0 auto; padding: 12px 20px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;}
.brand { font-weight: 700; font-size: 18px; color: var(--text); }
.brand:hover { text-decoration: none; }
nav a { margin-right: 14px; font-size: 14px; color: var(--text); font-weight: 500; }
nav a.btn-link { color: var(--danger); }
.user-chip { font-size: 13px; color: var(--muted); margin-right: 14px; }

.container { max-width: 1080px; margin: 0 auto; padding: 24px 20px; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}
.card h2, .card h3 { margin-top: 0; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 720px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14px; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=datetime-local], input[type=url], select, textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 14px;
    background: #fff;
    color: var(--text);
    font-family: inherit;
}
textarea { resize: vertical; }
.form-group { margin-bottom: 14px; }
.help-text { font-size: 12.5px; color: var(--muted); margin-top: -10px; margin-bottom: 14px; }

.btn {
    display: inline-block;
    padding: 9px 18px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; color: #fff; }
.btn-secondary { background: #e5e7eb; color: var(--text); }
.btn-secondary:hover { background: #d1d5db; color: var(--text); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }

.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; }
.alert-success { background: #dcfce7; color: #166534; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-warning { background: #fef3c7; color: #92400e; }
.alert-info { background: #dbeafe; color: #1e40af; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-muted { background: #f3f4f6; color: #4b5563; }
.badge-info { background: #dbeafe; color: #1e40af; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: .03em; }

.checkbox-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px 16px; margin-bottom: 10px;}
.checkbox-grid label { font-weight: 400; display: flex; align-items: center; gap: 6px; margin-bottom: 4px;}
.checkbox-grid input { width: auto; margin: 0; }

fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 14px; margin-bottom: 16px; }
legend { font-weight: 700; padding: 0 6px; }

.site-footer { text-align: center; color: var(--muted); font-size: 13px; padding: 20px; }

/* Simple editor */
.editor-toolbar { display: flex; gap: 4px; border: 1px solid var(--border); border-bottom: none; border-radius: 8px 8px 0 0; padding: 6px; background: #fafafa; flex-wrap: wrap; }
.editor-toolbar button {
    border: 1px solid transparent; background: transparent; padding: 6px 10px; border-radius: 6px; cursor: pointer; font-size: 13px;
}
.editor-toolbar button:hover { background: #eee; }
.editor-content {
    min-height: 160px; border: 1px solid var(--border); border-radius: 0 0 8px 8px;
    padding: 12px; background: #fff; font-size: 14px; margin-bottom: 6px;
}
.editor-content:focus { outline: 2px solid var(--primary); outline-offset: -1px; }

.editor-content table, .instructions-content table {
    border-collapse: collapse;
    width: auto;
    max-width: 100%;
    margin: 10px 0;
}
.editor-content table th, .editor-content table td,
.instructions-content table th, .instructions-content table td {
    border: 1px solid var(--border);
    padding: 6px 10px;
    text-align: left;
}
.editor-content table th, .instructions-content table th {
    background: #f3f4f6;
    font-weight: 600;
}

.stat-box { text-align: center; padding: 18px; }
.stat-box .num { font-size: 28px; font-weight: 700; color: var(--primary); }
.stat-box .label { font-size: 13px; color: var(--muted); }

.flex-between { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.small { font-size: 13px; color: var(--muted); }
.mt-0{margin-top:0} .mb-0{margin-bottom:0}