@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --ink: #17181C;
  --ink-soft: #6B7280;
  --ink-faint: #9CA3AF;
  --paper: #F4F5F7;
  --paper-raised: #FFFFFF;
  --line: #E7E8EC;
  --line-soft: #F0F1F4;
  --sidebar-bg: #17181C;
  --sidebar-bg-soft: #202127;
  --blue-600: #3D5AFE;
  --blue-700: #2F45D6;
  --blue-100: #E8ECFF;
  --teal-700: #1F7A5C;
  --teal-100: #DFF3EA;
  --amber-600: #B8721A;
  --amber-500: #E8A33D;
  --amber-100: #FBEBD2;
  --coral-600: #C0392B;
  --coral-100: #FBE3DF;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(23,24,28,0.04);
  --shadow: 0 1px 3px rgba(23,24,28,0.04), 0 6px 16px rgba(23,24,28,0.05);
  --shadow-lg: 0 8px 24px rgba(23,24,28,0.08), 0 20px 44px rgba(23,24,28,0.10);
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }
*:focus-visible { outline: 2px solid var(--blue-600); outline-offset: 2px; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
code { font-family: 'SF Mono', Consolas, monospace; background: var(--line-soft); padding: 1px 5px; border-radius: 4px; font-size: 0.9em; }

h1, h2, h3 { font-family: var(--font-body); font-weight: 800; letter-spacing: -0.015em; margin: 0; color: var(--ink); }
h1 { font-size: 24px; }
h2 { font-size: 16px; font-weight: 700; }
h3 { font-size: 14px; font-weight: 700; }

/* ---------- Layout ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: #D7D8DD;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .brand { font-size: 17px; font-weight: 800; letter-spacing: -0.01em; margin-bottom: 2px; color: #fff; padding: 0 8px; }
.sidebar .brand-sub { font-size: 11px; color: #7C7E88; margin-bottom: 26px; padding: 0 8px; letter-spacing: 0.03em; }
.sidebar nav { display: flex; flex-direction: column; gap: 1px; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; font-size: 13.5px; font-weight: 600; color: #B4B6C0; transition: background 0.12s ease, color 0.12s ease; }
.sidebar nav a:hover { background: var(--sidebar-bg-soft); color: #fff; }
.sidebar nav a.active { background: var(--sidebar-bg-soft); color: #fff; }
.sidebar .spacer { flex: 1; }
.sidebar .logout { font-size: 13px; color: #7C7E88; padding: 9px 10px; transition: color 0.12s ease; border-top: 1px solid #2A2B32; padding-top: 14px; margin-top: 6px; }
.sidebar .logout:hover { color: #fff; }

.main { flex: 1; padding: 32px 36px 60px; max-width: 1180px; width: 100%; }

.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 22px; flex-wrap: wrap; gap: 14px; }
.page-header p { color: var(--ink-soft); margin: 5px 0 0; font-size: 13.5px; }
.greeting { font-size: 13px; color: var(--ink-faint); font-weight: 600; margin-bottom: 3px; }

/* ---------- Cards ---------- */
.card { background: var(--paper-raised); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); }
.card + .card { margin-top: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-head h2 { font-size: 14.5px; }
.card-footer-link { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 700; color: var(--ink); margin-top: 12px; }
.card-footer-link:hover { color: var(--blue-600); }

.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid2 { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; }
@media (max-width: 980px) { .grid3 { grid-template-columns: 1fr 1fr; } .grid2 { grid-template-columns: 1fr; } }
@media (max-width: 680px) { .grid3 { grid-template-columns: 1fr; } }

.statrow { background: var(--paper-raised); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); display: flex; margin-bottom: 16px; overflow: hidden; }
.statrow .statcell { flex: 1; padding: 18px 22px; border-right: 1px solid var(--line-soft); }
.statrow .statcell:last-child { border-right: none; }
.statrow .sc-label { font-size: 11.5px; color: var(--ink-faint); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; display: flex; align-items: center; gap: 4px; }
.statrow .sc-value { font-size: 26px; font-weight: 800; margin-top: 6px; color: var(--ink); letter-spacing: -0.01em; }
@media (max-width: 780px) { .statrow { flex-wrap: wrap; } .statrow .statcell { flex: 1 1 50%; border-bottom: 1px solid var(--line-soft); } }

.grid-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card { background: var(--paper-raised); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.stat-card .label { font-size: 11px; color: var(--ink-faint); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-card .value { font-size: 23px; font-weight: 800; margin-top: 5px; color: var(--ink); }

.chart-card { background: var(--paper-raised); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 18px 8px; box-shadow: var(--shadow-sm); margin-bottom: 14px; }
.chart-card h3 { margin-bottom: 3px; }
.chart-card .chart-sub { font-size: 12px; color: var(--ink-faint); margin-bottom: 12px; }
.chart-wrap { position: relative; height: 190px; }
.charts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 14px; margin-bottom: 8px; }

/* ---------- Agent identity ---------- */
.agent-identity {
  background: var(--sidebar-bg);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  box-shadow: var(--shadow);
}
.agent-identity .avatar {
  width: 48px; height: 48px; border-radius: 12px; background: rgba(255,255,255,0.10);
  display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0;
}
.agent-identity .name { font-size: 20px; font-weight: 800; color: #fff; letter-spacing: -0.01em; }
.agent-identity .badges { display: flex; gap: 7px; margin-top: 5px; flex-wrap: wrap; }
.identity-badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; background: rgba(255,255,255,0.10); }
.identity-badge.on { color: #8FEAC0; }
.identity-badge.off { color: #F3ADA0; }
.identity-badge .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.agent-identity .quickstats { display: flex; gap: 24px; margin-left: auto; flex-wrap: wrap; }
.agent-identity .quickstat { text-align: right; }
.agent-identity .quickstat .qs-value { font-size: 19px; font-weight: 800; color: #fff; }
.agent-identity .quickstat .qs-label { font-size: 10.5px; color: rgba(255,255,255,0.55); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; }

.delta-pill { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; margin-left: 8px; }
.delta-up { background: var(--teal-100); color: var(--teal-700); }
.delta-down { background: var(--coral-100); color: var(--coral-600); }
.delta-flat { background: var(--line-soft); color: var(--ink-faint); }

.mini-list { display: flex; flex-direction: column; gap: 0; }
.mini-list-row { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.mini-list-row:last-child { border-bottom: none; }
.mini-list-row .ml-main { font-weight: 700; color: var(--ink); }
.mini-list-row .ml-sub { color: var(--ink-faint); font-size: 11.5px; }

/* ---------- Agent tiles (dashboard) ---------- */
.agent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.agent-tile {
  background: var(--paper-raised); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow-sm); transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
  position: relative; overflow: hidden; display: flex; gap: 12px; align-items: flex-start;
}
.agent-tile::before { content: ''; position: absolute; top: 0; left: 0; bottom: 0; width: 3px; background: var(--line-soft); }
.agent-tile:has(.status-on)::before { background: var(--teal-700); }
.agent-tile:has(.status-off)::before { background: var(--coral-600); }
.agent-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--blue-600); }
.agent-tile .tile-avatar { width: 38px; height: 38px; border-radius: 10px; background: var(--sidebar-bg); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 17px; flex-shrink: 0; }
.agent-tile .name { font-size: 15.5px; font-weight: 800; margin-bottom: 4px; color: var(--ink); }
.agent-tile .status { font-size: 11.5px; font-weight: 700; }
.status-on { color: var(--teal-700); }
.status-off { color: var(--coral-600); }

.tile-create {
  display: flex; align-items: center; justify-content: center; border: 1.5px dashed var(--line);
  border-radius: var(--radius); padding: 18px; color: var(--ink-faint); font-weight: 700; cursor: pointer;
  background: transparent; min-height: 76px; transition: border-color 0.12s ease, color 0.12s ease, background 0.12s ease;
}
.tile-create:hover { border-color: var(--blue-600); color: var(--blue-600); background: var(--blue-100); }

/* ---------- Forms ---------- */
label { display: block; font-size: 12.5px; font-weight: 700; color: var(--ink-soft); margin-bottom: 5px; }
input, textarea, select {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 13.5px; background: var(--paper-raised); color: var(--ink);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
input:focus, textarea:focus, select:focus { border-color: var(--blue-600); box-shadow: 0 0 0 3px var(--blue-100); outline: none; }
.field { margin-bottom: 14px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

button, .btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: var(--radius-sm);
  border: none; font-family: inherit; font-size: 13.5px; font-weight: 700; cursor: pointer;
  transition: background 0.12s ease, transform 0.08s ease, box-shadow 0.12s ease;
}
button:active { transform: scale(0.98); }
.btn-primary { background: var(--blue-600); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--blue-700); }
.btn-secondary { background: var(--paper-raised); color: var(--ink); border: 1px solid var(--line); }
.btn-secondary:hover { border-color: var(--ink-faint); background: var(--line-soft); }
.btn-danger { background: var(--coral-100); color: var(--coral-600); }
.btn-danger:hover { background: #F5CFC7; }
.btn-sm { padding: 6px 11px; font-size: 12px; }

.pwd-wrap { position: relative; }
.pwd-wrap input { padding-right: 38px; }
.pwd-wrap .pwd-toggle {
  position: absolute; right: 2px; top: 50%;
  transform: translateY(-50%) !important;
  background: none; border: none; padding: 4px; cursor: pointer; border-radius: 6px;
  display: flex; align-items: center; justify-content: center; color: var(--ink-faint);
  width: 28px !important; height: 28px; margin: 0 !important;
}
.pwd-wrap .pwd-toggle:hover { color: var(--blue-600); background: var(--line-soft); }
.pwd-wrap .pwd-toggle svg { width: 16px; height: 16px; pointer-events: none; }

.error-banner { background: var(--coral-100); color: var(--coral-600); padding: 11px 14px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; margin-bottom: 16px; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-faint); padding: 0 12px 10px; border-bottom: 1px solid var(--line); }
td { padding: 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--line-soft); }

.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge-attente { background: var(--amber-100); color: var(--amber-600); }
.badge-livre { background: var(--teal-100); color: var(--teal-700); }
.badge-echec { background: var(--coral-100); color: var(--coral-600); }

.filters { display: flex; gap: 7px; margin-bottom: 18px; flex-wrap: wrap; }
.filters a { padding: 7px 13px; border-radius: 999px; font-size: 12.5px; font-weight: 700; border: 1px solid var(--line); color: var(--ink-soft); transition: all 0.12s ease; }
.filters a.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.filters a:hover:not(.active) { border-color: var(--blue-600); color: var(--blue-600); }

.empty-state { text-align: center; padding: 44px 20px; color: var(--ink-faint); font-size: 13.5px; }

/* ---------- Auth pages ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--sidebar-bg); padding: 20px; }
.auth-card { background: var(--paper-raised); border-radius: 18px; padding: 40px 36px; width: 100%; max-width: 380px; box-shadow: 0 30px 80px rgba(0,0,0,0.35); }
.auth-brand { font-size: 21px; font-weight: 800; color: var(--ink); margin-bottom: 3px; }
.auth-sub { font-size: 13px; color: var(--ink-soft); margin-bottom: 24px; }
.auth-card button { width: 100%; justify-content: center; margin-top: 6px; padding: 11px; }
.auth-switch { text-align: center; font-size: 13px; color: var(--ink-soft); margin-top: 18px; }
.auth-switch a { color: var(--blue-600); font-weight: 700; }

.plan-badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 10.5px; font-weight: 700; background: var(--amber-100); color: var(--amber-600); margin-left: 8px; vertical-align: middle; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 22px; overflow-x: auto; }
.tabs a { padding: 10px 4px; margin-right: 20px; font-size: 13.5px; font-weight: 700; color: var(--ink-faint); border-bottom: 2px solid transparent; white-space: nowrap; transition: color 0.12s ease; }
.tabs a.active { color: var(--ink); border-bottom-color: var(--blue-600); }
.tabs a:hover:not(.active) { color: var(--ink); }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar { position: sticky; top: 0; z-index: 20; width: 100%; height: auto; flex-direction: row; align-items: center; padding: 12px 16px; gap: 12px; }
  .sidebar .brand-sub { display: none; }
  .sidebar nav { flex-direction: row; }
  .sidebar .spacer { display: none; }
  .sidebar .logout { margin-left: auto; border-top: none; padding-top: 9px; }
  .main { padding: 22px 16px; max-width: 100%; }
  .field-row { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; }
  h1 { font-size: 21px; }
  table { font-size: 12px; }
  th, td { padding: 9px 7px; }
}
