:root {
    --brand:       #DE0437;
    --brand-dark:  #b0032c;
    --bg:          #f4f5f7;
    --surface:     #ffffff;
    --border:      #e0e0e0;
    --text:        #1a1a2e;
    --text-muted:  #6b7280;
    --danger:      #dc2626;
    --success:     #16a34a;
    --warn:        #d97706;
    --radius:      8px;
    --shadow:      0 1px 4px rgba(0,0,0,.10);
    --sidebar-w:   340px;
}

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

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

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { font-weight: 600; line-height: 1.2; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: .45rem .9rem; border-radius: var(--radius); border: none;
    font-size: 13px; font-weight: 500; cursor: pointer; transition: opacity .15s, background .15s;
    text-decoration: none;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn--primary  { background: var(--brand);   color: #fff; }
.btn--primary:hover { background: var(--brand-dark); }
.btn--secondary{ background: #334155; color: #fff; }
.btn--ghost    { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn--ghost:hover { background: var(--bg); }
.btn--danger   { background: var(--danger); color: #fff; }
.btn--full     { width: 100%; }
.btn--sm       { padding: .3rem .65rem; font-size: 12px; }
.btn--xs       { padding: .2rem .45rem; font-size: 11px; }

/* Top bar */
.top-bar {
    display: flex; align-items: center; gap: 1rem;
    padding: .65rem 1.25rem; background: var(--surface);
    border-bottom: 1px solid var(--border); box-shadow: var(--shadow);
    position: sticky; top: 0; z-index: 100;
}
.logo-link { font-size: 1.1rem; font-weight: 700; color: var(--brand); text-decoration: none; }
.top-nav   { display: flex; gap: .5rem; }
.nav-link  { padding: .3rem .6rem; border-radius: 5px; color: var(--text-muted); font-size: 13px; }
.nav-link.active, .nav-link:hover { color: var(--brand); background: rgba(222,4,55,.06); text-decoration: none; }
.top-actions { margin-left: auto; display: flex; gap: .5rem; align-items: center; }
.user-badge  { font-size: 13px; color: var(--text-muted); }

/* Modal */
.modal {
    position: fixed; inset: 0; background: rgba(0,0,0,.4);
    display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.modal.hidden { display: none; }
.modal-box {
    background: var(--surface); border-radius: var(--radius);
    padding: 1.5rem; width: 100%; max-width: 420px; box-shadow: 0 8px 32px rgba(0,0,0,.2);
}
.modal-box h2 { margin-bottom: 1rem; }
.modal-box label { display: block; margin-bottom: .75rem; font-size: 13px; font-weight: 500; }
.modal-box label input, .modal-box label select {
    display: block; width: 100%; margin-top: .25rem;
    padding: .45rem .7rem; border: 1px solid var(--border); border-radius: 6px; font-size: 14px;
}
.modal-actions { display: flex; gap: .5rem; margin-top: 1.25rem; justify-content: flex-end; }

/* Form */
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: 13px; font-weight: 500; margin-bottom: .3rem; }
.field input {
    width: 100%; padding: .5rem .75rem; border: 1px solid var(--border);
    border-radius: 6px; font-size: 14px; transition: border-color .15s;
}
.field input:focus { outline: none; border-color: var(--brand); }
.form-error { color: var(--danger); font-size: 13px; margin-top: .5rem; }

/* Tags / Badges */
.tag { display: inline-block; padding: .15rem .5rem; border-radius: 12px; font-size: 11px; font-weight: 500; background: #e2e8f0; color: #475569; }
.tag--admin    { background: #fef3c7; color: #92400e; }
.tag--sysadmin { background: #fee2e2; color: #991b1b; }
.badge { display: inline-flex; align-items: center; justify-content: center;
    min-width: 20px; height: 20px; padding: 0 .35rem; border-radius: 10px;
    font-size: 11px; font-weight: 600; background: var(--bg); color: var(--text); }
.badge--warn { background: #fef3c7; color: var(--warn); }

/* Dropdown */
.dropdown {
    position: absolute; top: 100%; left: 0; z-index: 200;
    min-width: 140px; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow); list-style: none; overflow: hidden;
}
.dropdown.hidden { display: none; }
.dropdown li { padding: .55rem .85rem; cursor: pointer; font-size: 13px; }
.dropdown li:hover { background: var(--bg); }
.dropdown-wrap { position: relative; }

/* Toast */
.toast {
    position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999;
    padding: .7rem 1.1rem; border-radius: var(--radius); color: #fff;
    font-size: 13px; font-weight: 500; box-shadow: 0 4px 16px rgba(0,0,0,.2);
    opacity: 0; transform: translateY(8px); transition: opacity .25s, transform .25s;
    background: #334155;
}
.toast--show  { opacity: 1; transform: none; }
.toast--success { background: var(--success); }
.toast--warn    { background: var(--warn); }
.toast--error   { background: var(--danger); }

.hidden { display: none !important; }
.loading { padding: 2rem; text-align: center; color: var(--text-muted); }
.icon-btn { background: none; border: none; cursor: pointer; padding: .25rem; font-size: 16px; }
.hint { font-size: 13px; color: var(--text-muted); margin-bottom: 1rem; }
