:root {
  --ocean: #0b6e99; --ocean-deep: #084d6b; --teal: #0e9488; --coral: #ff7a4d;
  --ink: #15303b; --ink-soft: #5b7482; --bg: #f4f7f9; --card: #fff; --line: #e3eaef;
  --ok: #16a34a; --warn: #f59e0b; --danger: #dc2626; --radius: 14px;
  --shadow: 0 10px 30px -18px rgba(21,48,59,.4);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', system-ui, sans-serif; background: var(--bg); color: var(--ink); }
.hidden { display: none !important; }
a { color: var(--ocean); text-decoration: none; }
code { background: #eef3f6; padding: .1rem .4rem; border-radius: 6px; font-size: .85em; }

.btn { font: inherit; font-weight: 600; border: none; border-radius: 10px; padding: .6rem 1.1rem; cursor: pointer; transition: all .15s; display: inline-flex; align-items: center; gap: .4rem; }
.btn-primary { background: var(--coral); color: #fff; }
.btn-primary:hover { background: #ff6a37; }
.btn-ghost { background: #fff; border: 1.5px solid var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--ocean); color: var(--ocean); }
.btn-sm { padding: .35rem .7rem; font-size: .85rem; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, var(--ocean-deep), var(--teal)); padding: 1rem; }
.login-box { background: #fff; padding: 2.5rem; border-radius: 20px; width: 100%; max-width: 380px; box-shadow: var(--shadow); display: grid; gap: 1rem; text-align: center; }
.login-logo { font-size: 1.6rem; font-weight: 700; }
.login-logo strong { color: var(--ocean); }
.login-box p { color: var(--ink-soft); font-size: .92rem; }
.login-box input { padding: .8rem 1rem; border: 1.5px solid var(--line); border-radius: 10px; font: inherit; }
.login-hint { font-size: .82rem; }
.login-err { color: var(--danger); font-size: .88rem; min-height: 1rem; }

/* Layout */
.app { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar { background: var(--ocean-deep); color: #fff; display: flex; flex-direction: column; padding: 1.5rem 1rem; position: sticky; top: 0; height: 100vh; }
.brand { font-size: 1.5rem; font-weight: 700; padding: .5rem; margin-bottom: 1.5rem; }
.brand strong { color: var(--coral); }
.menu { display: grid; gap: .3rem; }
.menu-item { background: none; border: none; color: rgba(255,255,255,.8); font: inherit; font-weight: 500; text-align: left; padding: .7rem .9rem; border-radius: 10px; cursor: pointer; display: flex; align-items: center; gap: .7rem; transition: all .15s; }
.menu-item:hover { background: rgba(255,255,255,.1); color: #fff; }
.menu-item.active { background: var(--coral); color: #fff; }
.menu-item em { margin-left: auto; background: rgba(255,255,255,.25); border-radius: 999px; font-style: normal; font-size: .75rem; padding: .1rem .5rem; min-width: 1.4rem; text-align: center; }
.menu-item em:empty { display: none; }
.sidebar-foot { margin-top: auto; display: grid; gap: .5rem; padding-top: 1rem; border-top: 1px solid rgba(255,255,255,.15); }
.sidebar-foot a, .sidebar-foot button { color: rgba(255,255,255,.8); background: none; border: none; text-align: left; font: inherit; cursor: pointer; padding: .4rem .5rem; border-radius: 8px; }
.sidebar-foot button:hover, .sidebar-foot a:hover { background: rgba(255,255,255,.1); color: #fff; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar { background: #fff; border-bottom: 1px solid var(--line); padding: 1.1rem 2rem; display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; z-index: 10; }
.topbar h1 { font-size: 1.4rem; }
.topbar-actions { display: flex; gap: .6rem; }
.content { padding: 2rem; overflow-x: auto; }

/* Dashboard */
.kpis { display: grid; grid-template-columns: repeat(4,1fr); gap: 1.2rem; margin-bottom: 2rem; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.3rem; box-shadow: var(--shadow); }
.kpi-val { font-size: 2rem; font-weight: 700; color: var(--ocean); }
.kpi-lab { color: var(--ink-soft); font-size: .9rem; }
.kpi.alert .kpi-val { color: var(--coral); }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); margin-bottom: 1.5rem; }
.panel h2 { font-size: 1.1rem; margin-bottom: 1rem; }

/* Tables */
table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
th, td { padding: .85rem 1rem; text-align: left; border-bottom: 1px solid var(--line); font-size: .92rem; }
th { background: #f0f5f8; font-weight: 600; cursor: pointer; user-select: none; white-space: nowrap; }
th:hover { color: var(--ocean); }
th .arrow { opacity: .4; font-size: .75rem; }
th.sorted .arrow { opacity: 1; color: var(--coral); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafcfd; }

.badge { display: inline-block; padding: .2rem .65rem; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.badge.en_attente, .badge.nouveau { background: #fef3c7; color: #92400e; }
.badge.confirme, .badge.approuve, .badge.envoye, .badge.accepte { background: #dcfce7; color: #166534; }
.badge.termine, .badge.lu, .badge.traite { background: #dbeafe; color: #1e40af; }
.badge.annule, .badge.rejete, .badge.refuse, .badge.spam { background: #fee2e2; color: #991b1b; }
.badge.urgente { background: #fee2e2; color: #991b1b; }
.badge.planifiee { background: #e0e7ff; color: #3730a3; }
.badge.normale { background: #f1f5f9; color: #475569; }

.row-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.icon-btn { background: #f0f5f8; border: none; border-radius: 8px; padding: .35rem .5rem; cursor: pointer; font-size: .9rem; }
.icon-btn:hover { background: var(--ocean); color: #fff; }

.filters { display: flex; gap: .6rem; margin-bottom: 1rem; flex-wrap: wrap; align-items: center; }
.filters select { padding: .5rem .8rem; border: 1.5px solid var(--line); border-radius: 10px; font: inherit; background: #fff; }

/* Calendar */
.cal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-dow { text-align: center; font-weight: 600; color: var(--ink-soft); font-size: .82rem; padding: .3rem; }
.cal-day { background: var(--card); border: 1px solid var(--line); border-radius: 10px; min-height: 96px; padding: .4rem; font-size: .8rem; min-width: 0; }
.cal-day.other { opacity: .4; }
.cal-day.today { border-color: var(--coral); border-width: 2px; }
.cal-daynum { font-weight: 600; margin-bottom: .2rem; }
.cal-ev { background: var(--ocean-light, #e6f3f9); color: var(--ocean); border-radius: 6px; padding: .15rem .35rem; margin-bottom: 3px; font-size: .72rem; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-ev.externe { background: #ede9fe; color: #6d28d9; }
.cal-ev.urgente { background: #fee2e2; color: #991b1b; }

/* Conversations */
.conv { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.3rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.conv-head { display: flex; justify-content: space-between; margin-bottom: .6rem; }
.conv-transcript { display: grid; gap: .4rem; margin-top: .8rem; }
.msg { padding: .5rem .8rem; border-radius: 10px; font-size: .88rem; max-width: 80%; }
.msg.assistant { background: #f0f5f8; }
.msg.user { background: var(--ocean); color: #fff; margin-left: auto; }

/* Drawer */
.drawer { position: fixed; inset: 0; background: rgba(21,48,59,.4); display: none; justify-content: flex-end; z-index: 100; }
.drawer.open { display: flex; }
.drawer-box { background: #fff; width: 440px; max-width: 100%; height: 100%; padding: 2rem; overflow-y: auto; box-shadow: -10px 0 40px -20px rgba(0,0,0,.4); }
.drawer-box h2 { margin-bottom: 1rem; }
.field { display: grid; gap: .3rem; margin-bottom: 1rem; }
.field label { font-size: .85rem; font-weight: 600; color: var(--ink-soft); }
.field input, .field select, .field textarea { padding: .6rem .8rem; border: 1.5px solid var(--line); border-radius: 10px; font: inherit; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: .8rem 1.3rem; border-radius: 999px; z-index: 200; opacity: 0; transition: all .3s; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }

.empty { text-align: center; color: var(--ink-soft); padding: 3rem; }
.mono { font-family: ui-monospace, monospace; font-size: .85rem; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; }
  .menu { grid-auto-flow: column; overflow-x: auto; }
  .kpis { grid-template-columns: repeat(2,1fr); }
}
