/* ==========================================================
   tuz_management - Feuille de style (thèmes clair / sombre)
   Palette issue du logo Tuz Corporation (vert olive)
   ========================================================== */
:root {
  --brand: #6f8a1f;
  --brand-600: #5d7419;
  --brand-700: #4a5d13;
  --brand-300: #a9c05a;
  --brand-100: #eef3d9;
  --brand-50: #f6f9ec;
  --accent: #d64a3a;
  --bg: #f3f5ee;
  --surface: #ffffff;
  --surface-2: #f8faf3;
  --border: #e1e6d3;
  --text: #25301a;
  --muted: #7b8566;
  --sidebar-bg: #ffffff;
  --shadow: 0 1px 2px rgba(37,48,26,.05), 0 4px 16px rgba(37,48,26,.06);
  --radius: 14px;
  --sidebar-w: 260px;
  --bs-primary: #6f8a1f;
  --bs-primary-rgb: 111,138,31;
  --bs-link-color: #5d7419;
  --bs-link-hover-color: #4a5d13;
  --bs-body-font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
[data-bs-theme="dark"] {
  --brand: #8fae2c;
  --brand-600: #a2c036;
  --brand-700: #b9d65a;
  --brand-300: #8fae2c;
  --brand-100: #232d14;
  --brand-50: #1b2310;
  --bg: #0e130b;
  --surface: #161d12;
  --surface-2: #1c2517;
  --border: #29341f;
  --text: #e6ecd9;
  --muted: #94a07f;
  --sidebar-bg: #121910;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.35);
  --bs-primary: #8fae2c;
  --bs-primary-rgb: 143,174,44;
  --bs-link-color: #a2c036;
  --bs-link-hover-color: #b9d65a;
  --bs-body-bg: #0e130b;
  --bs-body-color: #e6ecd9;
  --bs-border-color: #29341f;
  --bs-secondary-bg: #1c2517;
  --bs-tertiary-bg: #1c2517;
}
html, body { height: 100%; }
body { background: var(--bg); color: var(--text); font-family: var(--bs-body-font-family); -webkit-font-smoothing: antialiased; }
a { text-decoration: none; }
.text-muted { color: var(--muted) !important; }
.form-control, .form-select { background-color: var(--surface); border-color: var(--border); color: var(--text); border-radius: 10px; }
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 .2rem rgba(111,138,31,.18); background-color: var(--surface); color: var(--text); }
.input-group-text { background: var(--surface-2); border-color: var(--border); color: var(--muted); }
.form-label { font-weight: 500; font-size: .85rem; margin-bottom: .3rem; }
.form-control-lg, .btn-lg { border-radius: 12px; }

/* ---------- Boutons ---------- */
.btn { border-radius: 10px; font-weight: 500; }
.btn-brand { background: linear-gradient(135deg, var(--brand), var(--brand-600)); color: #fff; border: 0; box-shadow: 0 2px 8px rgba(111,138,31,.3); }
.btn-brand:hover, .btn-brand:focus { color: #fff; filter: brightness(1.08); transform: translateY(-1px); }
.btn-brand:active { transform: translateY(0); }
[data-bs-theme="dark"] .btn-brand { color: #0e130b; }
[data-bs-theme="dark"] .btn-brand:hover { color: #0e130b; }
.btn-icon { width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); color: var(--text); padding: 0; }
.btn-icon:hover { background: var(--brand-100); color: var(--brand-600); }
.btn-outline-secondary { --bs-btn-color: var(--text); --bs-btn-border-color: var(--border); --bs-btn-hover-bg: var(--brand-100); --bs-btn-hover-color: var(--brand-600); --bs-btn-hover-border-color: var(--brand-300); }

/* ---------- Mise en page ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: var(--sidebar-bg); border-right: 1px solid var(--border); position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; z-index: 1040; transition: transform .25s ease; }
.sidebar-brand { display: flex; align-items: center; gap: .75rem; padding: 1.1rem 1.1rem .9rem; color: var(--text); }
.sidebar-brand img { width: 44px; height: 44px; object-fit: contain; border-radius: 10px; background: #fff; padding: 2px; border: 1px solid var(--border); }
.sidebar-brand strong { display: block; font-size: 1rem; line-height: 1.1; }
.sidebar-brand small { color: var(--muted); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: .3rem .75rem; }
.nav-section { font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); padding: 1rem .75rem .35rem; font-weight: 600; }
.nav-link-app { display: flex; align-items: center; gap: .75rem; padding: .6rem .8rem; border-radius: 10px; color: var(--text); font-weight: 500; font-size: .92rem; margin-bottom: 2px; transition: background .15s, color .15s; }
.nav-link-app i { font-size: 1.1rem; color: var(--muted); width: 1.3rem; text-align: center; }
.nav-link-app:hover { background: var(--brand-50); color: var(--brand-600); }
.nav-link-app.active { background: linear-gradient(135deg, var(--brand), var(--brand-600)); color: #fff; box-shadow: 0 4px 12px rgba(111,138,31,.3); }
.nav-link-app.active i { color: #fff; }
[data-bs-theme="dark"] .nav-link-app.active, [data-bs-theme="dark"] .nav-link-app.active i { color: #0e130b; }
.nav-badge { margin-left: auto; background: var(--accent); color: #fff; border-radius: 20px; font-size: .7rem; padding: .1rem .5rem; font-weight: 700; }
.sidebar-footer { padding: .9rem; border-top: 1px solid var(--border); }
.user-chip { display: flex; align-items: center; gap: .6rem; }
.user-chip-info strong { display: block; font-size: .85rem; line-height: 1.15; }
.user-chip-info small { color: var(--muted); font-size: .72rem; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg, var(--brand-300), var(--brand)); color: #fff; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; font-size: .85rem; flex: none; }
.avatar-sm { width: 32px; height: 32px; font-size: .75rem; }
.avatar-lg { width: 52px; height: 52px; font-size: 1.1rem; }
.avatar-xl { width: 84px; height: 84px; font-size: 1.8rem; }
.app-content { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: .75rem; padding: .7rem 1.5rem; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.idle-pill { align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: .25rem .7rem; font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.idle-pill.warn { color: #fff; background: var(--accent); border-color: var(--accent); }
.main-area { padding: 1.5rem; flex: 1; animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.25rem; }
.page-head h1 { font-size: 1.55rem; font-weight: 700; margin: 0 0 .15rem; letter-spacing: -.01em; }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1035; }

/* ---------- Cartes ---------- */
.card-app { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; }
.card-app.p-0 { overflow: hidden; }
.card-title { font-size: 1rem; font-weight: 600; margin-bottom: 1rem; }
.stat-card { display: flex; gap: .9rem; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem; height: 100%; transition: transform .15s; }
.stat-card:hover { transform: translateY(-2px); }
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; flex: none; background: var(--brand-100); color: var(--brand-600); }
.tone-success .stat-icon { background: rgba(46,158,107,.14); color: #2e9e6b; }
.tone-warning .stat-icon { background: rgba(224,160,30,.16); color: #c98a0a; }
.tone-danger .stat-icon { background: rgba(214,74,58,.14); color: var(--accent); }
.tone-info .stat-icon { background: rgba(48,134,200,.14); color: #3086c8; }
.stat-label { font-size: .78rem; color: var(--muted); font-weight: 500; }
.stat-value { font-size: 1.35rem; font-weight: 700; line-height: 1.2; word-break: break-word; }
.stat-sub { font-size: .72rem; color: var(--muted); }
.mini-stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: .8rem; font-size: .78rem; color: var(--muted); }
.mini-stat span { display: block; font-size: 1.6rem; font-weight: 700; color: var(--text); line-height: 1.1; }
.chart-box { position: relative; height: 240px; }
.list-bars { list-style: none; padding: 0; margin: 0; }
.list-bars li { margin-bottom: .75rem; font-size: .88rem; }
.list-bars .bar, .svc-tile .bar { height: 8px; background: var(--brand-100); border-radius: 8px; overflow: hidden; margin-top: .25rem; }
.list-bars .bar div, .svc-tile .bar div { height: 100%; background: linear-gradient(90deg, var(--brand-300), var(--brand)); border-radius: 8px; }
.big-amount { font-size: 2rem; font-weight: 800; color: var(--brand-600); letter-spacing: -.02em; }

/* ---------- Clients par service ---------- */
.client-total { height: 100%; min-height: 120px; display: flex; align-items: center; gap: 1rem; padding: 1.1rem 1.25rem; border-radius: var(--radius); color: #fff; background: radial-gradient(circle at 15% 15%, #8fae2c 0%, #5d7419 60%, #3f5010 100%); box-shadow: 0 6px 18px rgba(93,116,25,.35); }
.client-total i { font-size: 2.4rem; opacity: .9; }
.client-total span { display: block; font-size: 2.6rem; font-weight: 800; line-height: 1; letter-spacing: -.02em; }
.client-total div { font-size: .85rem; opacity: .95; }
.svc-tile { display: block; height: 100%; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: .8rem .9rem; color: var(--text); transition: border-color .15s, transform .15s; }
.svc-tile:hover { border-color: var(--brand-300); transform: translateY(-2px); color: var(--text); }
.svc-tile-name { font-weight: 600; font-size: .9rem; }
.svc-tile-n { font-size: 1.5rem; color: var(--brand-600); line-height: 1; }
.svc-chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.svc-chip { display: inline-flex; align-items: center; gap: .6rem; padding: .4rem .5rem .4rem .9rem; background: var(--surface); border: 1px solid var(--border); border-radius: 30px; font-size: .85rem; color: var(--text); font-weight: 500; transition: border-color .15s; }
.svc-chip strong { background: var(--brand-100); color: var(--brand-600); border-radius: 20px; padding: .1rem .6rem; font-size: .8rem; }
a.svc-chip:hover { border-color: var(--brand-300); color: var(--brand-600); }
.svc-chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.svc-chip.active strong { background: rgba(255,255,255,.22); color: #fff; }
[data-bs-theme="dark"] .svc-chip.active, [data-bs-theme="dark"] .svc-chip.active strong { color: #0e130b; }

/* ---------- Tableaux ---------- */
.table-app { --bs-table-bg: transparent; --bs-table-color: var(--text); --bs-table-border-color: var(--border); margin-bottom: 0; }
.table-app thead th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; padding: .75rem 1rem; }
.table-app td, .table-app tfoot td { padding: .75rem 1rem; font-size: .88rem; border-color: var(--border); }
.table-app tbody tr:hover { background: var(--brand-50); }
.text-truncate-cell { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-muted { opacity: .6; }
.row-danger { background: rgba(214,74,58,.07); }
.log-details { max-width: 520px; word-break: break-word; }
.badge-soft { font-weight: 600; padding: .35em .65em; border-radius: 8px; font-size: .72rem; }
.badge-success { background: rgba(46,158,107,.15); color: #2e9e6b; }
.badge-warning { background: rgba(224,160,30,.18); color: #b97c06; }
.badge-danger { background: rgba(214,74,58,.15); color: var(--accent); }
.badge-info { background: rgba(48,134,200,.15); color: #3086c8; }
.badge-secondary { background: rgba(120,130,100,.18); color: var(--muted); }
.badge-brand { background: var(--brand-100); color: var(--brand-600); }
[data-bs-theme="dark"] .badge-warning { color: #f0b73c; }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty-state i { font-size: 2.4rem; opacity: .5; }
.empty-state p { margin: .5rem 0 0; }
.file-chip { display: inline-flex; align-items: center; gap: .3rem; padding: .15rem .55rem; background: var(--brand-100); color: var(--brand-600); border-radius: 20px; font-size: .78rem; margin: 0 .25rem .25rem 0; }

/* ---------- Onglets, pagination ---------- */
.nav-pills-app { display: flex; gap: .4rem; flex-wrap: wrap; padding: 0; list-style: none; }
.nav-pills-app .nav-link { color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: .45rem .9rem; font-size: .88rem; font-weight: 500; }
.nav-pills-app .nav-link:hover { border-color: var(--brand-300); color: var(--brand-600); }
.nav-pills-app .nav-link.active { background: var(--brand); border-color: var(--brand); color: #fff; }
[data-bs-theme="dark"] .nav-pills-app .nav-link.active { color: #0e130b; }
.pagination { --bs-pagination-bg: var(--surface); --bs-pagination-border-color: var(--border); --bs-pagination-color: var(--text); --bs-pagination-active-bg: var(--brand); --bs-pagination-active-border-color: var(--brand); --bs-pagination-hover-bg: var(--brand-100); --bs-pagination-disabled-bg: var(--surface-2); --bs-pagination-hover-color: var(--brand-600); }

/* ---------- Divers ---------- */
.callout { padding: .75rem 1rem; border-radius: 12px; font-size: .9rem; border-left: 4px solid; }
.callout-warning { background: rgba(224,160,30,.1); border-color: #e0a01e; }
.callout-info { background: rgba(48,134,200,.1); border-color: #3086c8; }
.callout-success { background: rgba(46,158,107,.1); border-color: #2e9e6b; }
.callout-danger { background: rgba(214,74,58,.1); border-color: var(--accent); }
.info-list { display: grid; grid-template-columns: 110px 1fr; gap: .45rem .75rem; font-size: .88rem; }
.info-list dt { color: var(--muted); font-weight: 500; }
.info-list dd { margin: 0; word-break: break-word; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 .3rem; }
.timeline li { position: relative; display: flex; gap: .85rem; padding-bottom: 1.1rem; }
.timeline li:not(:last-child)::before { content: ''; position: absolute; left: 7px; top: 18px; bottom: 0; width: 2px; background: var(--border); }
.tl-dot { width: 16px; height: 16px; border-radius: 50%; background: var(--surface); border: 3px solid var(--border); flex: none; margin-top: 3px; }
.timeline li.done .tl-dot { border-color: #2e9e6b; background: #2e9e6b; }
.timeline li.rejected .tl-dot { border-color: var(--accent); background: var(--accent); }
.timeline li.current .tl-dot { border-color: #e0a01e; background: #fff; box-shadow: 0 0 0 4px rgba(224,160,30,.2); }
.year-label { font-weight: 700; color: var(--brand-600); margin: .5rem 0 .6rem; padding-bottom: .25rem; border-bottom: 1px dashed var(--border); }
.settings-logo { max-width: 150px; max-height: 150px; object-fit: contain; border: 1px solid var(--border); border-radius: 12px; padding: 6px; background: #fff; }
.flow { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.flow-node { background: var(--brand-50); border: 1px solid var(--brand-300); color: var(--text); border-radius: 12px; padding: .55rem .9rem; font-size: .85rem; font-weight: 600; display: flex; align-items: center; gap: .45rem; }
.flow-node i { color: var(--brand); }
.flow-final { background: var(--brand); color: #fff; border-color: var(--brand); }
.flow-final i { color: #fff; }
.flow-arrow { color: var(--muted); }
.pin-input { letter-spacing: .6em; font-weight: 700; }
.list-app .list-group-item { background: transparent; border-color: var(--border); color: var(--text); }
.modal-content { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; color: var(--text); }
.modal-header, .modal-footer { border-color: var(--border); }
.dropdown-menu { background: var(--surface); border-color: var(--border); }
.alert { border-radius: 12px; }
.toast { border-radius: 12px; border: 0; box-shadow: var(--shadow); }
.idle-warning { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--accent); color: #fff; padding: .8rem 1.2rem; border-radius: 14px; box-shadow: 0 8px 30px rgba(0,0,0,.3); z-index: 3000; display: flex; align-items: center; }
.ptr-loader { position: fixed; top: 0; left: 0; height: 3px; width: 0; background: linear-gradient(90deg, var(--brand-300), var(--brand)); z-index: 4000; transition: width .3s ease, opacity .3s; opacity: 0; }
.ptr-loader.on { opacity: 1; }

/* ---------- Connexion / pages nues ---------- */
.auth-body { min-height: 100vh; background: var(--bg); }
.auth-wrap { min-height: 100vh; display: flex; }
.auth-wrap.single { justify-content: center; }
.auth-side { flex: 1.1; background: radial-gradient(circle at 20% 20%, #8fae2c 0%, #5d7419 45%, #34430c 100%); color: #fff; align-items: center; justify-content: center; padding: 3rem; position: relative; overflow: hidden; }
.auth-side::after { content: ''; position: absolute; width: 520px; height: 520px; border-radius: 50%; border: 2px solid rgba(255,255,255,.12); right: -180px; bottom: -180px; box-shadow: 0 0 0 40px rgba(255,255,255,.04), 0 0 0 90px rgba(255,255,255,.03); }
.auth-side-inner { max-width: 460px; position: relative; z-index: 1; }
.auth-side-logo { width: 150px; height: 150px; object-fit: contain; background: #fff; border-radius: 24px; padding: 8px; margin-bottom: 1.8rem; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.auth-side h2 { font-weight: 700; font-size: 1.85rem; line-height: 1.25; margin-bottom: 1.5rem; }
.auth-points { list-style: none; padding: 0; margin: 0; }
.auth-points li { padding: .5rem 0; font-size: 1rem; opacity: .95; }
.auth-points i { margin-right: .6rem; background: rgba(255,255,255,.18); width: 34px; height: 34px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; }
.auth-panel { flex: 1; display: flex; align-items: center; justify-content: center; padding: 2rem 1.25rem; }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 2rem; box-shadow: var(--shadow); }
.auth-card.wide { max-width: 560px; }
.auth-logo { height: 56px; width: auto; max-width: 180px; object-fit: contain; }
.auth-title { font-size: 1.6rem; font-weight: 700; margin-bottom: .25rem; }
.error-page { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 2rem; }
.error-logo { height: 90px; margin-bottom: 1rem; }
.error-code { font-size: 7rem; font-weight: 800; line-height: 1; background: linear-gradient(135deg, var(--brand-300), var(--brand-700)); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .sidebar.open { transform: none; }
  .sidebar-backdrop.show { display: block; }
  .app-content { margin-left: 0; }
  .main-area { padding: 1rem; }
  .topbar { padding: .6rem 1rem; }
  .page-head h1 { font-size: 1.3rem; }
  .auth-wrap { flex-direction: column; }
}
@media print { .sidebar, .topbar, .page-actions, .btn { display: none !important; } .app-content { margin: 0; } }
