/* ===== Colissimo Tunisie — Design System ===== */
:root {
  /* Charte Colissimo Tunisie : charbon + ambre + vert émeraude */
  --navy: #2b2b2b;      /* sidebar charbon */
  --navy-2: #363636;
  --navy-3: #444;
  --blue: #009b57;      /* vert émeraude = couleur d'action primaire */
  --blue-d: #007a46;
  --yellow: #f0b040;    /* ambre de marque */
  --yellow-d: #db9a1f;
  --bg: #f5f6f4;
  --card: #ffffff;
  --text: #303030;
  --muted: #7a7f7c;
  --border: #e7e9e6;
  --green: #009b57;
  --green-bg: #e1f5ec;
  --red: #d94141;
  --red-bg: #fdeaea;
  --orange: #e09422;
  --orange-bg: #fdf1df;
  --purple: #7c3aed;
  --cyan: #0891b2;
  --shadow: 0 1px 3px rgba(16,30,54,.08), 0 1px 2px rgba(16,30,54,.04);
  --shadow-lg: 0 10px 30px rgba(16,30,54,.12);
  --radius: 12px;
  --sidebar-w: 244px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ===== Login ===== */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.login-hero {
  background: linear-gradient(150deg, #2b2b2b 0%, #1f2b25 55%, #063e28 100%);
  color: #fff; padding: 60px; display: flex; flex-direction: column; justify-content: center;
  position: relative; overflow: hidden;
}
.login-hero::after {
  content: ''; position: absolute; right: -90px; top: -60px; width: 380px; height: 380px;
  background: radial-gradient(circle, rgba(240,176,64,.22), transparent 70%);
}
.login-hero::before {
  content: ''; position: absolute; left: -100px; bottom: -100px; width: 340px; height: 340px;
  background: radial-gradient(circle, rgba(0,155,87,.25), transparent 70%);
}
.login-hero .hero-logo { height: 46px; margin-bottom: 26px; position: relative; z-index: 1; }
.login-hero .brand-lg { font-size: 30px; font-weight: 800; letter-spacing: -.5px; margin-bottom: 8px; position: relative; z-index: 1; }
.login-hero .brand-lg span { color: var(--yellow); }
.login-hero p { color: #cfd6d1; max-width: 400px; margin-top: 6px; position: relative; z-index: 1; }
.login-hero .arabic { font-size: 18px; color: var(--yellow); margin-top: 4px; direction: rtl; }
.login-hero .feats { margin-top: 34px; display: flex; flex-direction: column; gap: 14px; position: relative; z-index: 1; }
.login-hero .feat { display: flex; align-items: center; gap: 12px; color: #e4e9e5; }
.login-hero .feat .ic { width: 34px; height: 34px; border-radius: 9px; background: rgba(255,255,255,.1); display: grid; place-items: center; font-size: 17px; }
.login-form-side { display: grid; place-items: center; padding: 40px; }
.login-card { width: 100%; max-width: 380px; }
.login-card h2 { font-size: 22px; margin-bottom: 6px; }
.login-card .sub { color: var(--muted); margin-bottom: 26px; }

/* ===== Layout ===== */
.layout { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
  background: var(--navy); color: #c7d2e6; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .logo { padding: 20px 18px 14px; display: flex; align-items: center; gap: 10px; }
.sidebar .logo img { height: 34px; width: auto; }
.side-role { margin: 4px 16px 12px; padding: 9px 12px; background: rgba(255,255,255,.06); border-radius: 8px; font-size: 12px; color: #b7bdb9; }
.side-role b { color: #fff; display: block; font-size: 13px; }
.side-role .rl { color: var(--yellow); font-weight: 600; }
.nav { flex: 1; overflow-y: auto; padding: 6px 12px; }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: #64769a; margin: 16px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 9px;
  color: #c7d2e6; font-weight: 500; margin-bottom: 2px; transition: .12s;
}
.nav a .ic { width: 20px; text-align: center; font-size: 16px; opacity: .9; }
.nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav a.active { background: var(--blue); color: #fff; box-shadow: 0 4px 12px rgba(27,110,243,.4); }
.nav a .badge-count { margin-left: auto; background: var(--yellow); color: var(--navy); font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 20px; }
.sidebar .side-foot { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; color: #7d8db0; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 62px; background: var(--card); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 26px; gap: 18px; position: sticky; top: 0; z-index: 20;
}
.topbar .page-title { font-size: 18px; font-weight: 700; }
.topbar .spacer { flex: 1; }
.topbar .search { position: relative; }
.topbar .search input { width: 260px; padding: 8px 12px 8px 34px; border: 1px solid var(--border); border-radius: 9px; background: var(--bg); }
.topbar .search::before { content: '🔍'; position: absolute; left: 11px; top: 8px; font-size: 13px; opacity: .6; }
.topbar .user-chip { display: flex; align-items: center; gap: 10px; }
.topbar .avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg,var(--blue),var(--purple)); color: #fff; display: grid; place-items: center; font-weight: 700; }
.topbar .user-chip .who { font-size: 13px; } .topbar .user-chip .who b { display: block; } .topbar .user-chip .who small { color: var(--muted); }
.content { padding: 24px 26px 40px; flex: 1; }

/* ===== KPI cards ===== */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px,1fr)); gap: 16px; margin-bottom: 22px; }
.kpi {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.kpi .k-top { display: flex; justify-content: space-between; align-items: flex-start; }
.kpi .k-label { color: var(--muted); font-size: 13px; font-weight: 500; }
.kpi .k-ic { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-size: 19px; }
.kpi .k-val { font-size: 28px; font-weight: 800; margin-top: 10px; letter-spacing: -.5px; }
.kpi .k-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.kpi.accent-blue .k-ic { background: #e8f0fe; color: var(--blue); }
.kpi.accent-green .k-ic { background: var(--green-bg); color: var(--green); }
.kpi.accent-orange .k-ic { background: var(--orange-bg); color: var(--orange); }
.kpi.accent-red .k-ic { background: var(--red-bg); color: var(--red); }
.kpi.accent-purple .k-ic { background: #f1e9fe; color: var(--purple); }
.kpi.accent-cyan .k-ic { background: #e0f5fa; color: var(--cyan); }
.kpi.accent-yellow .k-ic { background: #fff6d6; color: var(--yellow-d); }

/* ===== Panels & grid ===== */
.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; margin-bottom: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 18px; margin-bottom: 18px; }
.panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-head { padding: 16px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.panel-head h3 { font-size: 15px; font-weight: 700; }
.panel-head .sub { font-size: 12px; color: var(--muted); }
.panel-body { padding: 18px; }

/* ===== Table ===== */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th { text-align: left; padding: 11px 14px; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .3px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tbody tr { transition: .1s; }
table.tbl tbody tr:hover { background: #fafbfe; }
table.tbl .mono { font-family: 'SF Mono', ui-monospace, Menlo, monospace; font-size: 12.5px; color: var(--blue-d); font-weight: 600; }
.row-click { cursor: pointer; }

/* ===== Badges ===== */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.b-gray { background: #eef1f6; color: #566; }
.b-blue { background: #e8f0fe; color: var(--blue-d); }
.b-green { background: var(--green-bg); color: var(--green); }
.b-orange { background: var(--orange-bg); color: var(--orange); }
.b-red { background: var(--red-bg); color: var(--red); }
.b-purple { background: #f1e9fe; color: var(--purple); }
.b-cyan { background: #e0f5fa; color: var(--cyan); }
.b-yellow { background: #fff6d6; color: var(--yellow-d); }

/* ===== Buttons ===== */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 16px; border-radius: 9px; border: 1px solid transparent; font-weight: 600; font-size: 13.5px; transition: .12s; background: var(--bg); color: var(--text); }
.btn:hover { filter: brightness(.97); }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-d); }
.btn-dark { background: var(--navy); color: #fff; }
.btn-yellow { background: var(--yellow); color: var(--navy); }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-danger { background: var(--red); color: #fff; }
.btn-success { background: var(--green); color: #fff; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ===== Forms ===== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12.5px; font-weight: 600; color: #46506a; }
.field input, .field select, .field textarea {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 9px; background: #fff; color: var(--text); width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(27,110,243,.12); }
.field textarea { resize: vertical; min-height: 72px; }

/* ===== Toolbar (filters) ===== */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar input, .toolbar select { padding: 8px 12px; border: 1px solid var(--border); border-radius: 9px; background: #fff; }
.toolbar .grow { flex: 1; min-width: 180px; }

/* ===== Modal ===== */
.modal-back { position: fixed; inset: 0; background: rgba(15,27,51,.5); display: grid; place-items: center; z-index: 100; padding: 20px; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal.wide { max-width: 760px; }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; background: #fff; }
.modal-head h3 { font-size: 17px; }
.modal-head .x { background: none; border: none; font-size: 22px; color: var(--muted); line-height: 1; }
.modal-body { padding: 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; position: sticky; bottom: 0; background: #fff; }

/* ===== Toast ===== */
#toast-container { position: fixed; top: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast { background: #fff; border-left: 4px solid var(--blue); border-radius: 9px; padding: 13px 18px; box-shadow: var(--shadow-lg); min-width: 260px; animation: slidein .2s; font-size: 13.5px; }
.toast.ok { border-color: var(--green); } .toast.err { border-color: var(--red); }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } }

/* ===== Timeline ===== */
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding-bottom: 18px; }
.tl-item::before { content: ''; position: absolute; left: -23px; top: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--blue); border: 3px solid #fff; box-shadow: 0 0 0 2px var(--blue); }
.tl-item.done::before { background: var(--green); box-shadow: 0 0 0 2px var(--green); }
.tl-item .tl-title { font-weight: 600; }
.tl-item .tl-meta { font-size: 12px; color: var(--muted); }

/* ===== Chat / SAV messages ===== */
.chat { display: flex; flex-direction: column; gap: 12px; max-height: 420px; overflow-y: auto; padding: 4px; }
.msg { max-width: 78%; padding: 10px 14px; border-radius: 12px; background: #eef1f6; }
.msg.mine { align-self: flex-end; background: #e8f0fe; }
.msg.internal { background: #fff8e1; border: 1px dashed var(--yellow-d); }
.msg .m-head { font-size: 11.5px; color: var(--muted); margin-bottom: 3px; display: flex; gap: 8px; align-items: center; }
.msg .m-body { font-size: 13.5px; white-space: pre-wrap; }

/* ===== Misc ===== */
.empty { text-align: center; padding: 40px; color: var(--muted); }
.empty .big { font-size: 40px; margin-bottom: 8px; }
.flex { display: flex; align-items: center; gap: 10px; }
.gap { gap: 10px; } .wrap { flex-wrap: wrap; }
.muted { color: var(--muted); }
.right { text-align: right; } .center { text-align: center; }
.mt { margin-top: 16px; } .mb { margin-bottom: 16px; }
.nowrap { white-space: nowrap; }
.tnd::after { content: ' DT'; font-size: .82em; color: var(--muted); font-weight: 500; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--border); border-top-color: var(--blue); border-radius: 50%; animation: spin .7s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; margin-top: 8px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.chart-legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

@media (max-width: 1000px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .login-wrap { grid-template-columns: 1fr; } .login-hero { display: none; }
}
@media (max-width: 720px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -260px; z-index: 50; transition: .2s; width: 240px; }
  .sidebar.open { left: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .topbar .search input { width: 150px; }
}
