/* ==========================================================================
   Racoon Protection — Design system v2
   Identité : noir encre + rouge alerte + gris pierre (tiré du logo)
   ========================================================================== */
:root {
    --ink: #0d0d0f;
    --ink-2: #17171a;
    --ink-3: #232327;
    --red: #d7141a;
    --red-600: #b30f14;
    --red-50: #fdeeee;
    --bg: #f4f3f1;
    --surface: #ffffff;
    --line: #e6e3df;
    --line-2: #d6d2cc;
    --text: #18181b;
    --muted: #6f6a64;
    --ok: #15803d;   --ok-50: #e8f6ed;
    --warn: #b45309; --warn-50: #fdf3e2;
    --danger: #c81e1e; --danger-50: #fdecec;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 2px rgba(16,16,20,.04), 0 6px 24px -12px rgba(16,16,20,.12);
    --sidebar: 264px;
    --font: 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --display: 'Barlow Condensed', 'Barlow', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--text); background: var(--bg); }
a { color: inherit; }
img { max-width: 100%; display: block; }
h1, h2, h3 { font-family: var(--display); letter-spacing: .01em; line-height: 1.1; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace; font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Sidebar ---------- */
.sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar); z-index: 40;
    background: var(--ink); color: #e9e7e4; display: flex; flex-direction: column;
    border-right: 1px solid #000;
    background-image: linear-gradient(180deg, rgba(215,20,26,.10), transparent 220px);
    transition: transform .25s ease;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 20px 18px; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,.07); }
.brand img { width: 48px; height: 48px; object-fit: contain; mix-blend-mode: lighten; }
.brand strong { display: block; font-family: var(--display); font-size: 19px; letter-spacing: .04em; text-transform: uppercase; color: #fff; line-height: 1.05; }
.brand small { color: #8f8a84; font-size: 12px; }
.nav { padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav a {
    display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 9px;
    text-decoration: none; color: #b5b0aa; font-weight: 600; font-size: 14.5px; position: relative;
}
.nav a i { width: 18px; text-align: center; font-size: 15px; }
.nav a:hover { background: var(--ink-3); color: #fff; }
.nav a.is-active { background: var(--ink-3); color: #fff; }
.nav a.is-active::before { content: ''; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--red); }
.nav a.is-active i { color: var(--red); }
.me { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.07); }
.me-avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--red); color: #fff; display: grid; place-items: center; font-weight: 700; font-family: var(--display); font-size: 18px; }
.me-info { flex: 1; min-width: 0; }
.me-info strong { display: block; font-size: 14px; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-info small { color: #8f8a84; font-size: 12px; }
.me .icon-btn { color: #b5b0aa; }
.me .icon-btn:hover { color: #fff; background: var(--ink-3); }

/* ---------- Main ---------- */
.main { margin-left: var(--sidebar); min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px;
    padding: 16px 32px; background: rgba(244,243,241,.88); backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 { font-size: 28px; font-weight: 800; text-transform: uppercase; }
.topbar-title p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.topbar-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.content { padding: 28px 32px 40px; flex: 1; width: 100%; max-width: 1400px; }
.foot { padding: 18px 32px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); }
.icon-btn.burger { display: none; }
.scrim { display: none; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 42px; padding: 0 18px; border-radius: var(--radius-sm); border: 1px solid transparent;
    font: 600 14.5px var(--font); cursor: pointer; text-decoration: none; white-space: nowrap;
    transition: background .15s, border-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-600); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover { background: var(--ink-3); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--line-2); }
.btn-ghost:hover { border-color: var(--text); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: #f1c4c4; }
.btn-danger:hover { background: var(--danger-50); }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13.5px; }
.btn-block { width: 100%; }
.icon-btn {
    width: 36px; height: 36px; border-radius: 8px; border: 0; background: transparent; color: var(--muted);
    display: inline-grid; place-items: center; cursor: pointer; font-size: 15px; text-decoration: none;
}
.icon-btn:hover { background: #ebe8e4; color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-50); color: var(--danger); }
.inline-form { display: inline; margin: 0; }

/* ---------- Cards / panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 19px; font-weight: 700; text-transform: uppercase; }
.panel-head a { white-space: nowrap; font-size: 13px; font-weight: 600; color: var(--red); text-decoration: none; }
.panel-body { padding: 20px; }
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; position: relative; overflow: hidden; box-shadow: var(--shadow); text-decoration: none; display: block; }
.stat::after { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--line-2); }
.stat.is-red::after { background: var(--red); }
.stat.is-ok::after { background: var(--ok); }
.stat.is-warn::after { background: #e59a1b; }
.stat-label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; display: flex; align-items: center; gap: 8px; }
.stat-value { font-family: var(--display); font-size: 40px; font-weight: 800; line-height: 1; margin-top: 10px; }
.stat-sub { font-size: 13px; color: var(--muted); margin-top: 6px; }
.meter { height: 6px; border-radius: 6px; background: #ece9e5; margin-top: 12px; overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--ok); border-radius: 6px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 11px 16px; background: #faf9f7; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid #f0eeeb; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fbfaf8; }
.table .actions { text-align: right; white-space: nowrap; }
.person { display: flex; align-items: center; gap: 12px; min-width: 200px; }
.person img { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; background: #eee; flex: none; }
.person strong { display: block; font-weight: 700; }
.person small { color: var(--muted); font-size: 12.5px; }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty i { font-size: 30px; display: block; margin-bottom: 10px; color: var(--line-2); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge-ok { background: var(--ok-50); color: var(--ok); }
.badge-warn { background: var(--warn-50); color: var(--warn); }
.badge-danger { background: var(--danger-50); color: var(--danger); }
.badge-neutral { background: #efedea; color: #57534e; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 6px; font-size: 12px; font-weight: 600; background: #efedea; color: #44403c; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field label .req { color: var(--red); }
.input, select.input, textarea.input {
    width: 100%; height: 44px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: var(--radius-sm);
    background: #fff; font: 500 15px var(--font); color: var(--text); outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; padding: 10px 14px; }
.input:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(13,13,15,.08); }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.section-label { font-family: var(--display); font-size: 15px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 26px 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.section-label:first-child { margin-top: 0; }
.input-icon { position: relative; }
.input-icon > i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: #a29d97; pointer-events: none; }
.input-icon .input { padding-left: 40px; }
.input-icon .reveal { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.input-icon .reveal + .input, .input-icon .input.has-reveal { padding-right: 44px; }
.filebox { display: flex; align-items: center; gap: 14px; padding: 12px; border: 1px dashed var(--line-2); border-radius: var(--radius-sm); background: #faf9f7; }
.filebox img { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.toolbar .grow { flex: 1 1 240px; }
.toolbar select.input, .toolbar .input { height: 40px; }
.pager { display: flex; gap: 6px; justify-content: space-between; align-items: center; padding: 12px 16px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }

/* ---------- Alerts ---------- */
.alert { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 18px; font-weight: 500; border: 1px solid; }
.alert-success { background: var(--ok-50); color: #14532d; border-color: #c4e7d0; }
.alert-error { background: var(--danger-50); color: #7f1d1d; border-color: #f3c7c7; }
.alert-warning { background: var(--warn-50); color: #78350f; border-color: #f2d9ad; }
.alert span { flex: 1; }
.alert-close { border: 0; background: transparent; font-size: 20px; cursor: pointer; color: inherit; opacity: .6; }

/* ---------- Lists ---------- */
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid #f0eeeb; text-decoration: none; }
.list-item:last-child { border-bottom: 0; }
a.list-item:hover { background: #fbfaf8; }
.list-icon { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; background: #efedea; color: #44403c; flex: none; }
.list-icon.red { background: var(--red-50); color: var(--red); }
.list-icon.ok { background: var(--ok-50); color: var(--ok); }
.list-icon.warn { background: var(--warn-50); color: var(--warn); }
.list-main { flex: 1; min-width: 0; }
.list-main strong { display: block; font-size: 14px; }
.list-main small { color: var(--muted); font-size: 12.5px; }

/* ---------- Tags ---------- */
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 5px 6px 5px 12px; border-radius: 999px; background: #f3f1ee; border: 1px solid var(--line); font-size: 13.5px; font-weight: 600; }
.tag .icon-btn { width: 24px; height: 24px; font-size: 12px; }
.row-form { display: flex; gap: 8px; margin-bottom: 14px; }

/* ---------- Site cards ---------- */
.site-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.site-card { display: block; text-decoration: none; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); transition: border-color .15s, transform .15s; }
.site-card:hover { border-color: var(--ink); transform: translateY(-2px); }
.site-card .pin { width: 42px; height: 42px; border-radius: 10px; background: var(--ink); color: #fff; display: grid; place-items: center; margin-bottom: 14px; }
.site-card h3 { font-size: 21px; text-transform: uppercase; }
.site-card .count { font-family: var(--display); font-size: 34px; font-weight: 800; margin-top: 10px; }
.site-card.is-muted .pin { background: #a8a29e; }

/* ---------- Dialog ---------- */
dialog.modal { border: 0; padding: 0; border-radius: 16px; width: min(720px, 94vw); max-height: 92vh; box-shadow: 0 30px 80px rgba(0,0,0,.35); }
dialog.modal::backdrop { background: rgba(13,13,15,.55); backdrop-filter: blur(3px); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 1; }
.modal-head h2 { font-size: 22px; text-transform: uppercase; }
.modal-body { padding: 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--line); background: #faf9f7; position: sticky; bottom: 0; }

/* ---------- Profile edit ---------- */
.profile-side { text-align: center; padding: 28px 22px; }
.avatar-xl { width: 150px; height: 150px; border-radius: 22px; object-fit: cover; margin: 0 auto; border: 4px solid #fff; box-shadow: 0 10px 30px -10px rgba(0,0,0,.35); background: #eee; }
.avatar-edit { position: relative; width: 150px; margin: 0 auto 16px; }
.avatar-edit label { position: absolute; right: -8px; bottom: -8px; width: 42px; height: 42px; border-radius: 50%; background: var(--red); color: #fff; display: grid; place-items: center; cursor: pointer; border: 3px solid #fff; }
.profile-side h2 { font-size: 24px; text-transform: uppercase; }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid #f0eeeb; font-size: 14px; text-align: left; }
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--muted); }
.kv strong { text-align: right; }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; background: var(--surface); }
.auth-art {
    position: relative; overflow: hidden; background: var(--ink); color: #fff;
    display: flex; flex-direction: column; justify-content: space-between; padding: 40px 48px;
}
.auth-art::before { content: ''; position: absolute; inset: 0; background:
    radial-gradient(600px 400px at 80% 110%, rgba(215,20,26,.45), transparent 60%),
    repeating-linear-gradient(135deg, rgba(255,255,255,.035) 0 2px, transparent 2px 18px); }
.auth-art > * { position: relative; }
.auth-art .logo { width: min(360px, 70%); margin: 0 auto; mix-blend-mode: lighten; }
.auth-art h2 { font-size: 46px; font-weight: 800; text-transform: uppercase; line-height: .95; }
.auth-art h2 em { font-style: normal; color: var(--red); }
.auth-art p { color: #b5b0aa; max-width: 420px; margin: 12px 0 0; }
.auth-tag { display: inline-flex; gap: 8px; align-items: center; font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: #b5b0aa; }
.auth-tag::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 4px rgba(34,197,94,.2); }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-box { width: 100%; max-width: 380px; }
.auth-box h1 { font-size: 36px; font-weight: 800; text-transform: uppercase; }
.auth-box > p { color: var(--muted); margin: 6px 0 28px; }
.auth-box .field { margin-bottom: 16px; }
.auth-box .btn { height: 48px; font-size: 15.5px; margin-top: 6px; }
.auth-mobile-logo { display: none; width: 110px; margin: 0 auto 20px; }

/* ---------- Verify (public) ---------- */
.verify { min-height: 100vh; display: flex; align-items: flex-start; justify-content: center; padding: 24px 16px; background: var(--bg); }
.vcard { width: 100%; max-width: 400px; background: #fff; border-radius: 20px; overflow: hidden; box-shadow: 0 20px 50px -20px rgba(0,0,0,.3); }
.vhead { padding: 28px 22px 70px; color: #fff; text-align: center; position: relative; }
.vhead.valid { background: var(--ok); }
.vhead.warning { background: #d97706; }
.vhead.invalid { background: var(--danger); }
.vicon { width: 76px; height: 76px; border-radius: 50%; background: #fff; display: grid; place-items: center; margin: 0 auto 14px; font-size: 38px; position: relative; }
.vhead.valid .vicon { color: var(--ok); } .vhead.warning .vicon { color: #d97706; } .vhead.invalid .vicon { color: var(--danger); }
.vicon::after { content: ''; position: absolute; inset: -6px; border-radius: 50%; border: 3px solid rgba(255,255,255,.7); animation: ping 2s infinite; }
@keyframes ping { from { transform: scale(1); opacity: .8; } to { transform: scale(1.45); opacity: 0; } }
.vhead h1 { font-size: 30px; font-weight: 800; text-transform: uppercase; }
.vhead .clock { font-size: 13px; opacity: .9; margin-top: 4px; font-weight: 600; }
.vbody { padding: 0 22px 22px; margin-top: -54px; position: relative; text-align: center; }
.vphoto { width: 116px; height: 116px; border-radius: 20px; object-fit: cover; margin: 0 auto 12px; border: 5px solid #fff; box-shadow: 0 8px 20px -8px rgba(0,0,0,.4); background: #eee; }
.vbody h2 { font-size: 24px; text-transform: uppercase; }
.vbody .role { color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: 13px; letter-spacing: .05em; margin: 2px 0 16px; }
.vbox { background: #faf9f7; border: 1px solid var(--line); border-radius: 12px; padding: 4px 14px; }
.vmsg { margin-top: 60px; padding: 16px; border-radius: 12px; background: var(--danger-50); color: #7f1d1d; font-size: 14px; }
.vbrand { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 18px; font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--muted); letter-spacing: .06em; }
.vbrand img { height: 24px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-main { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    body.nav-open .sidebar { transform: none; }
    body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 30; }
    .main { margin-left: 0; }
    .icon-btn.burger { display: inline-grid; }
    .topbar { padding: 12px 16px; }
    .topbar-title h1 { font-size: 22px; }
    .topbar-title p { display: none; }
    .content { padding: 18px 16px 32px; }
    .grid-2, .form-grid { grid-template-columns: 1fr; }
    .auth { grid-template-columns: 1fr; }
    .auth-art { display: none; }
    .auth-mobile-logo { display: block; }
    .hide-sm { display: none; }
}
@media (max-width: 560px) {
    .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat { padding: 14px; }
    .stat-value { font-size: 30px; }
    .topbar-actions .btn span { display: none; }
    .table td, .table th { padding: 10px 10px; }
    .person { min-width: 0; gap: 10px; }
    .panel-head { padding: 14px 16px; }
    .panel-head h2 { font-size: 17px; }
    .toolbar select.input { flex: 1 1 45%; width: auto !important; }
}
@media print { .sidebar, .topbar, .foot { display: none !important; } .main { margin: 0; } }
