:root {
    --primary: #B21F29;
    --primary-dark: #8a1820;
    --primary-light: #d4444e;
    --bg: #f8f9fa;
    --card-bg: #ffffff;
    --text: #333333;
    --text-muted: #6c757d;
    --border: #dee2e6;
    --success: #28a745;
    --warning: #ffc107;
    --danger: #dc3545;
    --info: #17a2b8;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

/* Nav */
nav {
    background: var(--primary);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
nav .brand { color: white; font-weight: 700; font-size: 1.1rem; text-decoration: none; }
nav a { color: rgba(255,255,255,0.85); text-decoration: none; font-size: 0.9rem; }
nav a:hover { color: white; }
nav .spacer { flex: 1; }
nav .user-info { color: rgba(255,255,255,0.7); font-size: 0.85rem; }

/* Layout */
.container { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }

/* Cards */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.card h2 { font-size: 1.1rem; margin-bottom: 0.75rem; color: var(--primary); }

/* Stats row */
.stats { display: flex; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.stat {
    flex: 1;
    min-width: 140px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
}
.stat .number { font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat .label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th { text-align: left; padding: 0.6rem; border-bottom: 2px solid var(--border); color: var(--text-muted); font-size: 0.8rem; text-transform: uppercase; }
td { padding: 0.6rem; border-bottom: 1px solid var(--border); }
tr:hover { background: #f1f3f5; }

/* Badges */
.badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-pending { background: #fff3cd; color: #856404; }
.badge-approved { background: #d4edda; color: #155724; }
.badge-corrected { background: #f8d7da; color: #721c24; }
.badge-sorted { background: #d1ecf1; color: #0c5460; }
.badge-drafted { background: #e2d5f1; color: #432874; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.4rem 0.8rem;
    border: none;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
    text-decoration: none;
    font-weight: 500;
    transition: background 0.15s;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #218838; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #c82333; }
.btn-warning { background: var(--warning); color: #212529; }
.btn-sm { padding: 0.25rem 0.5rem; font-size: 0.8rem; }
.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { background: var(--bg); }

/* Forms */
input, select, textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.9rem;
    font-family: inherit;
}
textarea { min-height: 100px; resize: vertical; }
label { display: block; font-weight: 500; margin-bottom: 0.25rem; font-size: 0.9rem; }
.form-group { margin-bottom: 1rem; }
.form-inline { display: flex; gap: 0.5rem; align-items: end; }
.form-check { display: flex; align-items: center; gap: 0.4rem; }
.form-check input { width: auto; }

/* Flashes */
.flash {
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}
.flash-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.flash-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.flash-info { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }

/* Login page */
.login-container {
    max-width: 400px;
    margin: 4rem auto;
    padding: 2rem;
}
.login-container h1 {
    text-align: center;
    color: var(--primary);
    margin-bottom: 1.5rem;
}

/* Modal */
.modal-backdrop {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 100;
    align-items: center;
    justify-content: center;
}
.modal-backdrop.active { display: flex; }
.modal {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}
.modal h3 { margin-bottom: 1rem; color: var(--primary); }

/* Rule badges */
.rule-type {
    display: inline-block;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}
.rule-sorting { background: #d1ecf1; color: #0c5460; }
.rule-drafting { background: #e2d5f1; color: #432874; }
.rule-behavior { background: #fff3cd; color: #856404; }

.text-muted { color: var(--text-muted); }
.text-small { font-size: 0.8rem; }
.mt-1 { margin-top: 0.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
