/*
 * Cforten Platform — theme
 * Brand colour taken from www.cforten.tn (theme colour #002743).
 * Change the variables below to re-skin the whole platform.
 */
:root {
    --brand: #002743;          /* Cforten navy */
    --brand-700: #001c31;
    --brand-600: #0a3658;
    --brand-100: #e5edf3;
    --brand-50: #f2f6f9;
    --accent: #1f8ac0;         /* links, focus */
    --accent-50: #e8f4fa;

    --ok: #15803d;   --ok-bg: #e7f6ec;
    --warn: #a16207; --warn-bg: #fdf4dc;
    --bad: #b91c1c;  --bad-bg: #fdecec;
    --info: #1d5f99; --info-bg: #e8f1fa;

    --bg: #f3f5f8;
    --card: #ffffff;
    --line: #e1e6ec;
    --line-2: #eef1f5;
    --text: #0d1b2a;
    --text-2: #3b4a5c;
    --text-3: #6b7a8c;
    --text-4: #98a4b3;

    --r-s: 6px; --r-m: 10px; --r-l: 14px;
    --shadow: 0 1px 2px rgba(0, 39, 67, .06), 0 1px 3px rgba(0, 39, 67, .05);
    --shadow-l: 0 12px 32px -8px rgba(0, 39, 67, .18);
    --sidebar-w: 248px;
    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;

    /* Names used by the pagination partial */
    --c-primary: var(--brand); --c-primary-text: #fff; --c-border: var(--line);
    --c-text-1: var(--text); --c-text-2: var(--text-2); --c-text-3: var(--text-3); --c-text-4: var(--text-4);
    --c-bg-subtle: var(--brand-50);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); font-size: 14px; color: var(--text); background: var(--bg); line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; color: var(--text); line-height: 1.25; }
p { margin: 0; }
[x-cloak] { display: none !important; }
.menu.open > .popover { display: block; }
img { max-width: 100%; }

/* ── Shell ─────────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: var(--brand); color: #fff; position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; z-index: 40; transition: transform .2s ease; }
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 20px 18px; color: #fff; text-decoration: none !important; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand img { height: 34px; width: auto; }
.brand-mark { width: 36px; height: 36px; border-radius: 9px; background: #fff; color: var(--brand); display: grid; place-items: center; font-weight: 900; font-size: 1.05rem; letter-spacing: -.02em; }
.brand-name { font-weight: 800; letter-spacing: .06em; font-size: .95rem; }
.brand-sub { font-size: .7rem; color: rgba(255,255,255,.55); letter-spacing: .02em; }
.nav { padding: 14px 12px; flex: 1; overflow-y: auto; }
.nav-label { font-size: .66rem; text-transform: uppercase; letter-spacing: .1em; color: rgba(255,255,255,.4); padding: 14px 10px 6px; font-weight: 600; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 8px; color: rgba(255,255,255,.72); font-weight: 500; font-size: .87rem; text-decoration: none; position: relative; }
.nav a i { width: 18px; text-align: center; font-size: .9rem; opacity: .9; }
.nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav a.active { background: rgba(255,255,255,.12); color: #fff; font-weight: 600; }
.nav a.active::before { content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: #fff; }
.nav .count { margin-left: auto; background: #fff; color: var(--brand); border-radius: 999px; font-size: .68rem; font-weight: 700; padding: 1px 7px; }
.sidebar-foot { padding: 14px 20px; font-size: .7rem; color: rgba(255,255,255,.4); border-top: 1px solid rgba(255,255,255,.08); }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); padding: 12px 28px; display: flex; align-items: center; gap: 16px; min-height: 64px; }
.topbar .burger { display: none; background: none; border: 0; font-size: 1.1rem; color: var(--brand); cursor: pointer; padding: 6px; }
.topbar-titles { flex: 1; min-width: 0; }
.kicker { font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; color: var(--text-4); font-weight: 600; }
.page-title { font-size: 1.12rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.lang { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.lang a { padding: 5px 9px; font-size: .72rem; font-weight: 700; color: var(--text-3); text-decoration: none; }
.lang a.active { background: var(--brand); color: #fff; }
.menu { position: relative; }
.account-btn { display: flex; align-items: center; gap: 9px; background: none; border: 1px solid transparent; border-radius: 10px; padding: 4px 8px 4px 4px; cursor: pointer; font: inherit; color: var(--text); }
.account-btn:hover { border-color: var(--line); }
.account-btn small { display: block; color: var(--text-3); font-size: .7rem; text-align: left; }
.account-btn strong { display: block; font-size: .82rem; text-align: left; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-100); color: var(--brand); display: inline-grid; place-items: center; font-weight: 700; font-size: .78rem; flex-shrink: 0; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 96px; height: 96px; font-size: 1.6rem; border-radius: 18px; }
.avatar-md { width: 44px; height: 44px; font-size: .9rem; }
.popover { display: none; position: absolute; right: 0; top: calc(100% + 8px); background: #fff; border: 1px solid var(--line); border-radius: var(--r-m); box-shadow: var(--shadow-l); min-width: 220px; padding: 6px; }
.popover a, .popover button { display: flex; width: 100%; align-items: center; gap: 9px; padding: 9px 10px; border-radius: 7px; color: var(--text-2); background: none; border: 0; font: inherit; font-size: .85rem; cursor: pointer; text-decoration: none; }
.popover a:hover, .popover button:hover { background: var(--brand-50); }
.popover .sep { height: 1px; background: var(--line); margin: 5px 0; }

.content { padding: 26px 28px 40px; flex: 1; }
.footer { padding: 14px 28px; font-size: .74rem; color: var(--text-4); border-top: 1px solid var(--line); background: #fff; }

.flash { margin: 18px 28px 0; padding: 11px 14px; border-radius: var(--r-m); font-size: .86rem; display: flex; gap: 9px; align-items: center; border: 1px solid transparent; }
.flash-success { background: var(--ok-bg); color: var(--ok); border-color: #c6e8d2; }
.flash-error { background: var(--bad-bg); color: var(--bad); border-color: #f5c9c9; }
.flash-info { background: var(--info-bg); color: var(--info); border-color: #cfe1f3; }
.flash-warning { background: var(--warn-bg); color: var(--warn); border-color: #f2e0ac; }

/* ── Building blocks ───────────────────────────────────── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-l); box-shadow: var(--shadow); }
.card-body { padding: 20px 22px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 22px; border-bottom: 1px solid var(--line-2); }
.card-title { font-size: .95rem; font-weight: 700; display: flex; align-items: center; gap: 9px; }
.card-title i { color: var(--brand); opacity: .75; }
.card + .card { margin-top: 18px; }
.grid > .card { margin: 0; }
.muted { color: var(--text-3); }
.small { font-size: .8rem; }
.tiny { font-size: .72rem; }
.mt-1 { margin-top: 6px; } .mt-2 { margin-top: 12px; } .mt-3 { margin-top: 18px; } .mt-4 { margin-top: 26px; }
.mb-2 { margin-bottom: 12px; } .mb-3 { margin-bottom: 18px; }
.flex { display: flex; align-items: center; gap: 10px; }
.flex-wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.right { margin-left: auto; }
.grid { display: grid; gap: 18px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.layout-side { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.span-2 { grid-column: span 2; } .span-3 { grid-column: span 3; } .span-all { grid-column: 1 / -1; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 15px; border-radius: 9px; border: 1px solid var(--line); background: #fff; color: var(--text-2); font: inherit; font-size: .84rem; font-weight: 600; cursor: pointer; text-decoration: none !important; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s; }
.btn:hover { background: var(--brand-50); border-color: #cfd8e2; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-600); border-color: var(--brand-600); box-shadow: 0 4px 12px rgba(0,39,67,.22); }
.btn-danger { color: var(--bad); }
.btn-danger:hover { background: var(--bad-bg); border-color: #f2c2c2; }
.btn-success { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-success:hover { background: #116a32; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: 5px 10px; font-size: .78rem; border-radius: 7px; }
.btn-icon { padding: 6px 9px; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: .72rem; font-weight: 600; background: var(--line-2); color: var(--text-3); white-space: nowrap; }
.badge-success { background: var(--ok-bg); color: var(--ok); }
.badge-warning { background: var(--warn-bg); color: var(--warn); }
.badge-danger { background: var(--bad-bg); color: var(--bad); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-brand { background: var(--brand-100); color: var(--brand); }
.chip { display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--brand-50); border: 1px solid var(--brand-100); color: var(--brand); font-size: .76rem; font-weight: 500; margin: 0 4px 6px 0; }
.stars { color: #d39b0a; font-size: .78rem; letter-spacing: 1px; }

/* Stats */
.stat { padding: 18px 20px; display: flex; gap: 14px; align-items: center; text-decoration: none !important; color: inherit; }
.stat-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-100); color: var(--brand); font-size: 1.05rem; flex-shrink: 0; }
.stat-value { font-size: 1.6rem; font-weight: 800; line-height: 1.1; color: var(--text); }
.stat-label { font-size: .8rem; color: var(--text-3); }
.stat-sub { font-size: .72rem; color: var(--text-4); margin-top: 2px; }
a.card.stat:hover { border-color: #c8d3de; box-shadow: var(--shadow-l); }

/* Tables */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.table th { text-align: left; font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 600; padding: 11px 16px; background: var(--brand-50); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; color: var(--text-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fafbfd; }
.table .person { display: flex; align-items: center; gap: 11px; }
.table .person strong { color: var(--text); display: block; }
.table .person a { color: inherit; }
.table .actions { text-align: right; white-space: nowrap; }
.table-foot { padding: 12px 16px; border-top: 1px solid var(--line-2); }
.empty { text-align: center; padding: 48px 20px; color: var(--text-3); }
.empty i { font-size: 2rem; color: var(--brand-100); display: block; margin-bottom: 10px; }

/* Filters */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 14px 16px; border-bottom: 1px solid var(--line-2); }
.filters .field { flex: 0 1 170px; min-width: 130px; }
.filters .field-q { flex: 1 1 240px; min-width: 200px; }
.filters label { font-size: .7rem; color: var(--text-3); font-weight: 600; display: block; margin-bottom: 4px; text-transform: uppercase; letter-spacing: .05em; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs a { padding: 7px 13px; border-radius: 8px; color: var(--text-3); font-weight: 600; font-size: .82rem; text-decoration: none; }
.tabs a.active { background: var(--brand); color: #fff; }
.tabs a:hover:not(.active) { background: #fff; color: var(--text); }
.tabs .n { opacity: .65; font-weight: 500; margin-left: 3px; }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.form-grid.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
label.lbl { display: block; font-size: .8rem; font-weight: 600; color: var(--text-2); margin-bottom: 5px; }
label.lbl .req { color: var(--bad); }
.input, .select, .textarea { width: 100%; padding: 9px 12px; border: 1px solid #d5dde6; border-radius: 9px; font: inherit; font-size: .88rem; color: var(--text); background: #fff; transition: border-color .15s, box-shadow .15s; }
.input:focus, .select:focus, .textarea:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-50); }
.textarea { min-height: 96px; resize: vertical; }
.input-sm, .select-sm { padding: 7px 10px; font-size: .82rem; }
.hint { font-size: .74rem; color: var(--text-4); margin-top: 4px; }
.error { font-size: .76rem; color: var(--bad); margin-top: 4px; }
.is-invalid { border-color: #ef9a9a !important; }
.input-group { display: flex; }
.input-group .input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group .addon { padding: 9px 12px; border: 1px solid #d5dde6; border-left: 0; border-radius: 0 9px 9px 0; background: var(--brand-50); font-size: .82rem; color: var(--text-3); white-space: nowrap; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: .86rem; color: var(--text-2); cursor: pointer; }
.check input { accent-color: var(--brand); width: 16px; height: 16px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.checks .pill { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border: 1px solid #d5dde6; border-radius: 999px; font-size: .8rem; cursor: pointer; background: #fff; user-select: none; }
.checks .pill input { accent-color: var(--brand); }
.checks .pill:has(input:checked) { border-color: var(--brand); background: var(--brand-50); color: var(--brand); font-weight: 600; }
.segmented { display: inline-flex; border: 1px solid #d5dde6; border-radius: 10px; padding: 3px; background: var(--brand-50); gap: 3px; }
.segmented label { padding: 7px 14px; border-radius: 7px; cursor: pointer; font-size: .84rem; font-weight: 600; color: var(--text-3); display: flex; align-items: center; gap: 7px; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked) { background: #fff; color: var(--brand); box-shadow: var(--shadow); }
.form-section { padding: 22px; border-bottom: 1px solid var(--line-2); }
.form-section:last-child { border-bottom: 0; }
.form-section h3 { font-size: .95rem; font-weight: 700; margin-bottom: 4px; display: flex; gap: 9px; align-items: center; }
.form-section h3 i { color: var(--brand); opacity: .75; }
.form-section > .muted { margin-bottom: 16px; font-size: .82rem; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; padding: 16px 22px; background: var(--brand-50); border-top: 1px solid var(--line); border-radius: 0 0 var(--r-l) var(--r-l); position: sticky; bottom: 0; }
.repeat-item { border: 1px solid var(--line); border-radius: var(--r-m); padding: 16px; margin-bottom: 12px; background: #fcfdfe; position: relative; }
.repeat-item .remove { position: absolute; top: 10px; right: 10px; }
.repeat-item .num { font-size: .7rem; font-weight: 700; color: var(--text-4); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 10px; }
.upload { display: flex; align-items: center; gap: 16px; padding: 14px; border: 1px dashed #c9d4df; border-radius: var(--r-m); background: var(--brand-50); }
.upload .file-ico { width: 46px; height: 46px; border-radius: 10px; background: #fff; display: grid; place-items: center; color: var(--brand); font-size: 1.2rem; border: 1px solid var(--line); flex-shrink: 0; }
input[type=file].input { padding: 7px; font-size: .8rem; background: #fff; }

/* Detail pages */
.profile-head { display: flex; gap: 20px; align-items: flex-start; padding: 24px; }
.profile-head h2 { font-size: 1.35rem; font-weight: 800; }
.profile-head .headline { color: var(--text-2); margin-top: 3px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 10px; font-size: .83rem; color: var(--text-3); }
.meta i { color: var(--brand); opacity: .6; margin-right: 5px; width: 14px; text-align: center; }
dl.facts { display: grid; grid-template-columns: 140px 1fr; gap: 10px 14px; margin: 0; font-size: .85rem; }
dl.facts dt { color: var(--text-3); }
dl.facts dd { margin: 0; color: var(--text); font-weight: 500; word-break: break-word; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 18px 22px; border-left: 2px solid var(--brand-100); margin-left: 6px; }
.timeline li:last-child { padding-bottom: 0; border-left-color: transparent; }
.timeline li::before { content: ''; position: absolute; left: -7px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 3px solid var(--brand); }
.timeline .t-title { font-weight: 700; color: var(--text); }
.timeline .t-sub { color: var(--text-2); font-size: .85rem; }
.timeline .t-date { color: var(--text-4); font-size: .76rem; margin-top: 2px; }
.timeline .t-desc { color: var(--text-2); font-size: .84rem; margin-top: 6px; white-space: pre-line; }
.prose { white-space: pre-line; color: var(--text-2); font-size: .9rem; }
.progress { height: 8px; background: var(--line-2); border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.bar-row { display: grid; grid-template-columns: minmax(120px, 210px) 1fr 34px; align-items: center; gap: 10px; font-size: .82rem; margin-bottom: 9px; }
.bar-row .bar { height: 8px; background: var(--line-2); border-radius: 99px; overflow: hidden; }
.bar-row .bar span { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.bar-row b { text-align: right; color: var(--text); }
.list-row { display: flex; align-items: center; gap: 12px; padding: 11px 22px; border-bottom: 1px solid var(--line-2); color: inherit; text-decoration: none !important; }
.list-row:last-child { border-bottom: 0; }
.list-row:hover { background: #fafbfd; }
.map-frame { width: 100%; height: 260px; border: 0; border-radius: var(--r-m); display: block; }
.notice { padding: 14px 16px; border-radius: var(--r-m); background: var(--info-bg); color: var(--info); font-size: .85rem; display: flex; gap: 10px; }
.notice-warning { background: var(--warn-bg); color: var(--warn); }
.notice-danger { background: var(--bad-bg); color: var(--bad); }
.notice-success { background: var(--ok-bg); color: var(--ok); }

/* ── Auth pages ────────────────────────────────────────── */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-aside { background: var(--brand); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-aside::after { content: ''; position: absolute; width: 520px; height: 520px; border-radius: 50%; border: 70px solid rgba(255,255,255,.04); right: -180px; bottom: -200px; }
.auth-aside h1 { color: #fff; font-size: 2.1rem; font-weight: 800; line-height: 1.15; max-width: 440px; }
.auth-aside p { color: rgba(255,255,255,.7); margin-top: 14px; max-width: 420px; font-size: .95rem; }
.auth-points { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 12px; }
.auth-points li { display: flex; gap: 12px; align-items: center; color: rgba(255,255,255,.85); font-size: .9rem; }
.auth-points i { width: 32px; height: 32px; border-radius: 9px; background: rgba(255,255,255,.1); display: grid; place-items: center; font-size: .85rem; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: #fff; position: relative; }
.auth-box { width: 100%; max-width: 400px; }
.auth-box h2 { font-size: 1.5rem; font-weight: 800; }
.auth-box .sub { color: var(--text-3); margin: 6px 0 24px; }
.auth-box .field { margin-bottom: 14px; }
.auth-box .btn-primary { width: 100%; padding: 11px; font-size: .92rem; }
.auth-lang { position: absolute; top: 20px; right: 24px; }
.auth-alt { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); text-align: center; font-size: .86rem; color: var(--text-3); }

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 1100px) {
    .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .layout-side { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: none; box-shadow: var(--shadow-l); }
    .main { margin-left: 0; }
    .topbar .burger { display: block; }
    .topbar { padding: 10px 16px; }
    .content { padding: 18px 16px 32px; }
    .flash { margin: 14px 16px 0; }
    .g-2, .g-3, .form-grid, .form-grid.g-3 { grid-template-columns: 1fr; }
    .span-2, .span-3 { grid-column: auto; }
    .auth { grid-template-columns: 1fr; }
    .auth-aside { display: none; }
    .account-btn .who { display: none; }
    .profile-head { flex-direction: column; }
    dl.facts { grid-template-columns: 1fr; gap: 2px; }
    dl.facts dd { margin-bottom: 8px; }
    .hide-sm { display: none; }
}
@media print {
    .sidebar, .topbar, .footer, .no-print, .flash { display: none !important; }
    .main { margin: 0; }
    .content { padding: 0; }
    .card { box-shadow: none; border: 0; }
    .layout-side { grid-template-columns: 1fr 260px; }
}
