:root{
  --bg: #F3F6FB;
  --card: #FFFFFF;
  --text: #0F1B3D;
  --muted: #64748B;
  --border: #E6EAF2;

  --primary: #1F3858;
  --primary-2: #1F3858;

  --gold:   #FFB703;
  --green:  #2ECC71;
  --purple: #9B59B6;
  --olive:  #585A3F;

  --sidebar: #ffffff;
  --sidebar-2: #ffffff;

  --radius-card: 0;
  --radius-btn: 0;

  --shadow-soft: 0 2px 8px rgba(15, 27, 61, 0.08);
  --shadow: 0 4px 16px rgba(15, 27, 61, 0.12);

  --w: 1120px;
}

*{ box-sizing:border-box; }
html, body{ height:100%; }

body{
  margin:0;
  /* font/color/bg now from tokens.css */
}

/* Links */
a{ color: var(--primary); text-decoration:none; }
a:hover{ filter: brightness(.85); }

/* ===== Layout (legacy — now handled by k-shell in tokens.css) ===== */
.app{
  display:flex;
  min-height:100vh;
  width:100%;
}
/* Legacy sidebar/topbar/content-wrapper: overridden by k-shell system */

/* ===== Sidebar ===== */
.sidebar{
  width:265px;
  flex: 0 0 265px;
  padding:18px 14px;
  background:#fff;
  color: var(--text);
  border-right: 1px solid var(--border);
  position:relative;
  z-index: 5;
}

.logo{
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px 10px 18px;
  font-size:20px;
  font-weight:800;
}

.menu a{
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px 12px;
  border-radius:0;
  color: var(--muted);
  font-weight:600;
  margin-bottom:2px;
  border-left: 3px solid transparent;
}
.menu a.active{
  background: rgba(31,56,88,.06);
  color: var(--primary);
  border-left-color: var(--primary);
  font-weight:700;
}
.menu a:hover:not(.active){
  background: rgba(31,56,88,.04);
  color: var(--primary);
  border-left-color: rgba(31,56,88,.2);
}

/* ===== Main ===== */
.main{
  flex:1;
  min-width:0;
  width:100%;
  display:flex;
  flex-direction:column;
}

/* ===== Topbar ===== */
.topbar{
  height:64px;
  background:#fff;
  border-bottom:2px solid var(--border);
  display:flex;
  align-items:center;
}

.topbar .wrap{
  width:100%;
  max-width:var(--w);
  margin:0 auto;
  padding:0 20px;
  display:flex;
  justify-content:space-between;
  align-items:center;
}

/* ===== Content ===== */
.content{
  flex:1;
  width:100%;
  min-width:0;
  margin:20px auto;
  padding:0 20px;
}

/* Wrapper standard de toutes les pages */
.page{
  width:100%;
  max-width:var(--w);
  margin:0 auto;
}

/* Header de page (titre + actions) */
.page-header{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:16px;
  margin-bottom:12px;
  flex-wrap:wrap;
}

/* Typography */
h1{ font-size:22px; margin:0 0 6px; }
h2{ font-size:18px; margin:0 0 10px; }
.muted{ color:var(--muted); }

/* ===== Cards ===== */
.card{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:0;
  box-shadow:var(--shadow-soft);
  padding:18px;
}

.card.card-filter{ padding:14px; }

/* ===== Buttons ===== */
.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  padding:10px 16px;
  border-radius:0;
  border:1px solid var(--border);
  background:#fff;
  color:var(--text);
  font-weight:600;
  cursor:pointer;
  white-space:nowrap;
}
.btn:hover{ background:#F0F4FA; }

.btn-primary{
  background:var(--primary);
  border-color:transparent;
  color:#fff;
}
.btn-primary:hover{ background:#E6EAF2; color:#1B2A4A; border-color:#d0d5dd; filter:none; }

.btn-danger{
  background:#ef4444;
  border-color:transparent;
  color:#fff;
}
.btn-danger:hover{ filter:brightness(1.08); }

.btn-sm{
  padding:7px 12px;
  border-radius:0;
  font-size:13px;
}

/* ===== Tables ===== */
.table-wrap{
  width:100%;
  overflow:auto;
  border-radius:0;
  border:1px solid var(--border);
}

.table{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
  min-width: 720px;
}

.table th{
  background:#F7F9FD;
  text-align:left;
  font-size:13px;
  color:var(--muted);
  font-weight:700;
  padding:12px 14px;
  border-bottom:2px solid var(--border);
  white-space:nowrap;
}

.table td{
  padding:12px 14px;
  border-bottom:1px solid var(--border);
  vertical-align:top;
}
.table tr:last-child td{ border-bottom:0; }

/* ===== Forms ===== */
.form-card{ max-width: 720px; }

.form-grid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:14px 16px;
}
@media (max-width: 860px){
  .form-grid{ grid-template-columns: 1fr; }
}

.field label{
  display:block;
  font-weight:700;
  margin-bottom:6px;
}

.input{
  width:100%;
  padding:10px 12px;
  border:1px solid var(--border);
  border-radius:0;
  background:#fff;
  color:var(--text);
  outline:none;
}

.input:focus{
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31,56,88,.12);
}

textarea.input{
  resize: vertical;
  min-height: 160px;
}

.help{
  margin-top:6px;
  color:var(--muted);
  font-size:13px;
}

.error{
  margin-top:6px;
  color:#b00020;
  font-weight:700;
  font-size:13px;
}

.form-actions{
  display:flex;
  gap:10px;
  margin-top:16px;
  flex-wrap:wrap;
}

/* Select styling */
select.input{
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 2px),
    calc(100% - 12px) calc(50% - 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

/* ===== Divider ===== */
.hr{
  height:1px;
  background:var(--border);
  border:0;
  margin:18px 0;
}

/* ===== Flash messages ===== */
.flash{
  max-width: var(--w);
  margin: 16px auto 0;
  padding: 12px 16px;
  border-radius: 0;
  font-weight: 700;
  box-shadow: none;
  border-left: 4px solid;
}

.flash-success{
  background: #e6f7ee;
  color: #065f46;
  border-color: #2ECC71;
}

.flash-error{
  background: #fee2e2;
  color: #7f1d1d;
  border-color: #ef4444;
}

/* ===== Badges ===== */
.badge{
  display:inline-flex;
  align-items:center;
  padding:4px 8px;
  border-radius:0;
  border:1px solid var(--border);
  background:#F7F9FD;
  color:var(--text);
  font-weight:800;
  font-size:12px;
  line-height:1;
  white-space:nowrap;
}

.badge-primary{
  border-color: rgba(31,56,88,.25);
  background: rgba(31,56,88,.08);
  color: var(--primary);
}

/* =========================================================
   Modal Kora
   ========================================================= */

.kora-modal-backdrop{
  position: fixed;
  inset: 0;
  background: rgba(12, 18, 28, .55);
  backdrop-filter: blur(2px);
  display: none;
  z-index: 9998;
}

.kora-modal{
  position: fixed;
  inset: 0;
  display: none;
  z-index: 9999;
  padding: 24px;
  overflow: auto;
}

.kora-modal-card{
  width: min(860px, calc(100% - 24px));
  margin: 56px auto;
  background: #fff;
  border-radius: 0;
  border: 1px solid rgba(15, 23, 42, .12);
  border-top: 3px solid var(--gold);
  box-shadow: 0 8px 40px rgba(0,0,0,.22);
  overflow: hidden;
  position: relative;
}

/* Close button */
.kora-modal-close{
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border-radius: 0;
  border: 1px solid rgba(15, 23, 42, .12);
  background: #fff;
  cursor: pointer;
  line-height: 1;
}
.kora-modal-close:hover{
  background: rgba(15, 23, 42, .06);
}

/* Header */
.kora-modal-header{
  padding: 18px 18px 10px;
  border-bottom: 2px solid rgba(15, 23, 42, .08);
}
.kora-modal-title{
  font-size: 16px;
  font-weight: 800;
  margin: 0;
}
.kora-modal-subtitle{
  font-size: 13px;
  opacity: .75;
  margin-top: 4px;
}

/* Body */
.kora-modal-body{
  padding: 14px 18px 12px;
}
.kora-modal-label{
  display:block;
  font-size: 12px;
  font-weight: 800;
  opacity: .85;
  margin-bottom: 8px;
}
.kora-modal-textarea{
  width: 100%;
  min-height: 260px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  padding: 12px 14px;
  border-radius: 0;
  border: 1px solid rgba(15, 23, 42, .16);
  background: #fff;
  resize: vertical;
}
.kora-modal-textarea:focus{
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31,56,88,.12);
}
.kora-modal-hint{
  margin-top: 8px;
  font-size: 12px;
  opacity: .70;
}

/* Footer */
.kora-modal-footer{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
  padding: 12px 18px 16px;
  border-top: 1px solid rgba(15, 23, 42, .08);
  background: rgba(15, 23, 42, .02);
}
.kora-modal-actions{
  display:flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Responsive */
@media (max-width: 640px){
  .kora-modal{ padding: 12px; }
  .kora-modal-card{ margin: 24px auto; }
  .kora-modal-footer{ flex-direction: column; align-items: stretch; }
  .kora-modal-actions{ justify-content: stretch; }
}

/* Nav logo */
.nav-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--primary);
    font-weight: 700;
    font-size: 1.2rem;
}
.nav-logo img {
    transition: opacity 0.2s ease;
}
.nav-logo:hover img {
    opacity: .85;
}

:root {
    --sidebar-width: 265px;
    --primary-blue: #1F3858;
    --bg-light: #f4f7fe;
}

/* Sidebar (duplicate block — kept for compatibility) */
.sidebar {
    width: var(--sidebar-width);
    background: #fff;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    border-right: 1px solid var(--border);
}

.sidebar-header {
    text-align: center;
    margin-bottom: 30px;
    padding-top: 10px;
}

.sidebar-header img {
    width: 60%;
    height: auto;
    display: block;
    margin: 0 auto 12px;
}

.sidebar-header .app-subtitle {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 1.2px;
}

/* Menu nav */
.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav li {
    margin-bottom: 2px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
    border-radius: 0;
    border-left: 3px solid transparent;
    transition: background .15s, border-color .15s;
}

.sidebar-nav a.active {
    background-color: rgba(31,56,88,.06);
    color: var(--primary);
    border-left-color: var(--primary);
    font-weight: 700;
    box-shadow: none;
}

.sidebar-nav a:hover:not(.active) {
    background-color: rgba(31,56,88,.04);
    color: var(--primary);
    border-left-color: rgba(31,56,88,.2);
}

/* =====================================================================
   HAMBURGER BUTTON
   ===================================================================== */
.hamburger-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 0;
  cursor: pointer;
  color: var(--muted);
  flex-shrink: 0;
}

/* Overlay sidebar mobile */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 199;
}
#sidebar-overlay.is-open {
  display: block;
}

/* =====================================================================
   CALENDRIER
   ===================================================================== */
.cal-desktop { display: block; }
.cal-mobile  { display: none;  }

@media (max-width: 768px) {
  .cal-desktop { display: none;  }
  .cal-mobile  { display: block; }
}

/* =====================================================================
   DASHBOARD
   ===================================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 300px;
  gap: 14px;
  align-items: start;
}

/* =====================================================================
   RESPONSIVE — Mobile (≤ 768px)
   ===================================================================== */
@media (max-width: 768px) {

  .hamburger-btn {
    display: flex;
  }

  .topbar-date {
    display: none;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
    z-index: 200;
    overflow-y: auto;
    width: 260px !important;
    flex: none !important;
  }
  .sidebar.is-open {
    transform: translateX(0);
  }

  .content-wrapper {
    margin-left: 0 !important;
  }

  .topbar .wrap {
    padding: 0 12px;
  }

  .table-wrap,
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .form-grid {
    grid-template-columns: 1fr !important;
  }

  .form-card {
    max-width: 100%;
  }

  .flash {
    margin: 10px 12px 0;
  }

  .form-actions {
    flex-direction: column;
  }

  .kpi-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .dash-grid {
    grid-template-columns: 1fr;
  }
}

/* =====================================================================
   RESPONSIVE — Très petit (≤ 480px)
   ===================================================================== */
@media (max-width: 480px) {
  .topbar {
    height: 54px;
  }
  h1 { font-size: 18px; }
  h2 { font-size: 15px; }

  .btn {
    padding: 9px 12px;
    font-size: .875rem;
  }
  .btn-sm {
    padding: 6px 10px;
    font-size: .78rem;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
