*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #ffffff;
  --surface:   #f6f8fa;
  --border:    #e6e8eb;
  --border-dk: #c8ccd2;
  --accent:    #635bff;
  --accent-dk: #4b44cc;
  --text:      #1a1f36;
  --text-2:    #697386;
  --text-3:    #9ba3b2;
  --green:     #1a9e6e;  --green-bg:  #e9f7f2;
  --yellow:    #b54708;  --yellow-bg: #fef3e2;
  --red:       #c0152d;  --red-bg:    #fde8eb;
  --blue:      #1264a3;  --blue-bg:   #e8f3fb;
  --r:         6px;
  --sidebar-w: 64px;
  --font:      -apple-system, 'Inter', BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body { background:var(--bg); color:var(--text); font-family:var(--font); font-size:14px; line-height:1.5; min-height:100vh; -webkit-font-smoothing:antialiased; }

/* ── Layout ──────────────────────────────────────────────── */
.layout, .app-layout { display:flex; min-height:100vh; }
.main   { flex:1; min-width:0; padding:32px 36px; overflow-y:auto; }

/* ── Col 1 — Services (icônes) ───────────────────────────── */
.services-col {
  width:64px; flex-shrink:0;
  border-right:1px solid var(--border);
  display:flex; flex-direction:column; align-items:center;
  position:sticky; top:0; height:100vh;
  background:var(--bg);
}
.services-logo {
  display:flex; align-items:center; justify-content:center;
  padding:16px 0 14px;
  border-bottom:1px solid var(--border);
  width:100%;
  text-decoration:none;
}
.services-logo img { width:28px; height:28px; border-radius:6px; object-fit:contain; }
.services-list {
  flex:1; display:flex; flex-direction:column; align-items:center;
  padding:10px 0; gap:2px;
}
.service-link {
  display:flex; align-items:center; justify-content:center;
  width:40px; height:40px; border-radius:8px;
  color:var(--text-3);
  text-decoration:none; cursor:pointer;
  transition:background .1s, color .1s;
  user-select:none;
}
.service-link svg { width:18px; height:18px; flex-shrink:0; }
.service-link:hover:not(.disabled) { background:var(--surface); color:var(--text-2); }
.service-link.active { background:var(--surface); color:var(--accent); }
.service-link.disabled { color:var(--border-dk); cursor:default; }
.services-footer {
  padding:12px 0;
  border-top:1px solid var(--border);
  width:100%; display:flex; justify-content:center;
}
.btn-logout {
  display:flex; align-items:center; justify-content:center;
  width:40px; height:40px; border-radius:8px;
  background:none; border:none; cursor:pointer;
  color:var(--text-3); font-family:var(--font);
  transition:background .12s, color .12s;
}
.btn-logout:hover { background:var(--red-bg); color:var(--red); }
.btn-logout svg { width:17px; height:17px; }

/* ── Col 2 — Sous-services ───────────────────────────────── */
.subservices-col {
  width:180px; flex-shrink:0;
  border-right:1px solid var(--border);
  display:flex; flex-direction:column;
  position:sticky; top:0; height:100vh;
  background:var(--bg); overflow-y:auto;
  padding:16px 0;
}
.subservices-header {
  font-size:10px; font-weight:700; text-transform:uppercase;
  letter-spacing:.7px; color:var(--text-3);
  padding:0 14px 10px;
}
.subservice-link {
  display:block; padding:7px 14px;
  font-size:13px; color:var(--text-2);
  text-decoration:none;
  transition:color .1s, background .1s;
  border-radius:0;
}
.subservice-link:hover  { color:var(--text); background:var(--surface); }
.subservice-link.active { color:var(--accent); font-weight:600; background:#f5f4ff; }

/* ── Shared ──────────────────────────────────────────────── */
.soon-badge {
  margin-left:auto; font-size:9px; font-weight:600;
  text-transform:uppercase; letter-spacing:.4px;
  background:var(--surface); color:var(--text-3);
  border:1px solid var(--border); border-radius:4px;
  padding:1px 5px; flex-shrink:0;
}

/* ── Section header bar ──────────────────────────────────── */
.section-header-bar {
  display:flex; align-items:center; justify-content:space-between;
  margin-bottom:20px; padding-bottom:18px; border-bottom:1px solid var(--border);
}
.section-header-info { display:flex; align-items:center; gap:12px; }
.section-icon {
  width:36px; height:36px; border-radius:8px;
  background:var(--surface); border:1px solid var(--border);
  display:flex; align-items:center; justify-content:center;
  color:var(--text-2); flex-shrink:0;
}
.section-title { font-size:17px; font-weight:600; letter-spacing:-.2px; }
.section-sub   { font-size:12px; color:var(--text-2); margin-top:1px; }

/* ── Stat chips ──────────────────────────────────────────── */
.stat-chips {
  display:flex; gap:1px; background:var(--border);
  border:1px solid var(--border); border-radius:var(--r);
  overflow:hidden; margin-bottom:20px;
}
.stat-chip {
  flex:1; background:var(--bg); padding:14px 16px;
  display:flex; flex-direction:column; gap:5px; min-width:0;
}
.chip-label { font-size:10px; color:var(--text-2); text-transform:uppercase; letter-spacing:.5px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.chip-num   { font-size:22px; font-weight:700; letter-spacing:-.4px; line-height:1; }

/* ── Component grid ──────────────────────────────────────── */
.component-grid {
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:16px;
}
.component-card {
  background:var(--bg);
  border-radius:10px;
  box-shadow:0 1px 4px rgba(0,0,0,.06), 0 0 0 1px rgba(0,0,0,.05);
  overflow:hidden;
  display:flex; flex-direction:column;
}
.component-card.span-2 { grid-column:1 / -1; }

.comp-header {
  display:flex; align-items:center; justify-content:space-between;
  padding:13px 16px 11px;
  border-bottom:1px solid var(--border);
  background:var(--surface);
  flex-shrink:0;
}
.comp-title { font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.6px; color:var(--text-2); }
.comp-link  { font-size:12px; color:var(--accent); text-decoration:none; }
.comp-link:hover { text-decoration:underline; }
.comp-body  { padding:16px; flex:1; }

/* ── Queue counts grid ───────────────────────────────────── */
.queue-counts-grid {
  display:grid; grid-template-columns:repeat(5,1fr); gap:8px; margin-bottom:14px;
}
.q-count-box { display:flex; flex-direction:column; align-items:center; gap:3px; }
.q-count-num { font-size:20px; font-weight:700; letter-spacing:-.3px; line-height:1; }
.q-count-label { font-size:10px; color:var(--text-3); text-transform:uppercase; letter-spacing:.4px; }
.queue-status-line { display:flex; align-items:center; gap:7px; margin-bottom:12px; }
.queue-quick-actions { display:flex; gap:8px; flex-wrap:wrap; }

/* ── Inbox preview ───────────────────────────────────────── */
.comp-inbox-list { display:flex; flex-direction:column; flex:1; }
.inbox-preview-item {
  display:block; padding:10px 16px; border-bottom:1px solid var(--border);
  text-decoration:none; transition:background .1s; cursor:pointer;
}
.inbox-preview-item:last-child { border-bottom:none; }
.inbox-preview-item:hover { background:var(--surface); }
.inbox-preview-item.unread .inbox-item-from,
.inbox-preview-item.unread .inbox-item-subject { font-weight:600; color:var(--text); }
.inbox-item-row { display:flex; justify-content:space-between; align-items:baseline; margin-bottom:2px; }
.inbox-item-from { font-size:13px; color:var(--text); font-weight:400; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:200px; }
.inbox-item-date { font-size:11px; color:var(--text-3); flex-shrink:0; }
.inbox-item-subject { font-size:12px; color:var(--text-2); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

/* ── Analytics layout ────────────────────────────────────── */
.comp-analytics-body { display:flex; gap:0; flex:1; }
.analytics-chart-wrap { flex:1; padding:16px 20px; min-width:0; position:relative; height:240px; }
.analytics-side {
  width:220px; flex-shrink:0;
  border-left:1px solid var(--border);
  padding:16px;
  overflow-y:auto;
}
.analytics-side-label {
  font-size:10px; font-weight:700; text-transform:uppercase;
  letter-spacing:.5px; color:var(--text-3); margin-bottom:8px;
}

/* ── Login ───────────────────────────────────────────────── */

/* ── Login ───────────────────────────────────────────────── */
.login-wrapper { display:flex; align-items:center; justify-content:center; min-height:100vh; background:var(--surface); }
.login-card { background:var(--bg); border:1px solid var(--border); border-radius:10px; padding:40px; width:380px; }
.login-logo { display:flex; justify-content:center; margin-bottom:24px; }
.login-logo img { width:44px; height:44px; object-fit:contain; border-radius:10px; }
.login-title { font-size:17px; font-weight:600; text-align:center; margin-bottom:24px; }

/* ── Page header ─────────────────────────────────────────── */
.page-header {
  display:flex; align-items:flex-start; justify-content:space-between;
  margin-bottom:24px; padding-bottom:20px; border-bottom:1px solid var(--border);
}
.page-header h1 { font-size:18px; font-weight:600; letter-spacing:-.2px; }
.page-sub { font-size:12px; color:var(--text-2); margin-top:2px; }

/* ── Global status badge ─────────────────────────────────── */
.global-badge { display:inline-flex; align-items:center; gap:6px; padding:6px 14px; border-radius:20px; font-size:12px; font-weight:600; letter-spacing:.3px; }
.global-badge.loading    { background:var(--surface); color:var(--text-2); }
.global-badge.badge-healthy  { background:var(--green-bg); color:var(--green); }
.global-badge.badge-degraded { background:var(--yellow-bg); color:var(--yellow); }
.global-badge.badge-critical { background:var(--red-bg); color:var(--red); }

/* ── Stat grid ───────────────────────────────────────────── */
.stat-grid {
  display:grid; grid-template-columns:repeat(auto-fill, minmax(140px,1fr));
  gap:1px; background:var(--border); border:1px solid var(--border);
  border-radius:var(--r); overflow:hidden; margin-bottom:20px;
}
.stat-card { background:var(--bg); padding:18px 20px; }
.stat-label { font-size:11px; color:var(--text-2); text-transform:uppercase; letter-spacing:.5px; margin-bottom:6px; }
.stat-num { font-size:26px; font-weight:700; letter-spacing:-.5px; line-height:1; }
.c-red    { color:var(--red); }
.c-green  { color:var(--green); }
.c-yellow { color:var(--yellow); }
.c-blue   { color:var(--blue); }

/* ── Dash two-col grid ───────────────────────────────────── */
.dash-grid { display:grid; grid-template-columns:280px 1fr; gap:16px; }
.dash-col-left { display:flex; flex-direction:column; }
.dash-col-right { display:flex; flex-direction:column; gap:16px; }

/* ── Card ────────────────────────────────────────────────── */
.card { border:1px solid var(--border); border-radius:var(--r); background:var(--bg); overflow:hidden; }
.card-header {
  display:flex; align-items:center; justify-content:space-between;
  padding:12px 16px; border-bottom:1px solid var(--border); background:var(--surface);
}
.card-title { font-size:12px; font-weight:600; text-transform:uppercase; letter-spacing:.5px; color:var(--text-2); }

/* ── Health panel ────────────────────────────────────────── */
.health-list { padding:8px 0; }
.health-loading { padding:16px 16px; color:var(--text-2); font-size:13px; }
.health-item { display:flex; align-items:center; gap:10px; padding:9px 16px; border-bottom:1px solid var(--border); }
.health-item:last-child { border-bottom:none; }
.dot { width:8px; height:8px; border-radius:50%; flex-shrink:0; }
.dot-green  { background:var(--green); }
.dot-yellow { background:#f59e0b; }
.dot-red    { background:var(--red); }
.health-label   { flex:1; font-size:13px; font-weight:500; }
.health-latency { font-size:11px; color:var(--text-3); background:var(--surface); padding:1px 6px; border-radius:10px; }
.health-extra   { font-size:11px; color:var(--text-2); }
.health-error   { font-size:11px; color:var(--red); }

/* ── Simple list (services, templates) ──────────────────── */
.simple-list { padding:4px 0; }
.simple-row  { display:flex; align-items:center; justify-content:space-between; padding:9px 16px; border-bottom:1px solid var(--border); }
.simple-row:last-child { border-bottom:none; }
.simple-count { font-size:13px; font-weight:600; color:var(--text); }
.empty-sm { padding:16px; color:var(--text-3); font-size:13px; text-align:center; }

/* ── Audit row ───────────────────────────────────────────── */
.audit-row { display:grid; grid-template-columns:1fr auto auto; gap:12px; }
.audit-action { font-size:12px; font-family:'Menlo','Consolas',monospace; color:var(--accent); }
.audit-ip, .audit-time { white-space:nowrap; }

/* ── Table ───────────────────────────────────────────────── */
.table-wrap { overflow-x:auto; }
table { width:100%; border-collapse:collapse; }
th {
  text-align:left; padding:9px 16px; font-size:11px; font-weight:600;
  text-transform:uppercase; letter-spacing:.5px; color:var(--text-2);
  background:var(--surface); border-bottom:1px solid var(--border); white-space:nowrap;
}
td { padding:11px 16px; border-bottom:1px solid var(--border); vertical-align:middle; }
tr:last-child td { border-bottom:none; }
tbody tr:hover td { background:#fafbfc; }
.empty { text-align:center; color:var(--text-3); padding:32px; font-size:13px; }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display:inline-flex; align-items:center; gap:5px;
  padding:2px 8px; border-radius:20px; font-size:11px; font-weight:500; white-space:nowrap;
}
.badge-dot { width:6px; height:6px; border-radius:50%; flex-shrink:0; }
.badge-sent       { background:var(--green-bg);  color:var(--green); }
.badge-sent .badge-dot       { background:var(--green); }
.badge-queued     { background:var(--yellow-bg); color:var(--yellow); }
.badge-queued .badge-dot     { background:#f59e0b; }
.badge-processing { background:var(--blue-bg);   color:var(--blue); }
.badge-processing .badge-dot { background:var(--blue); }
.badge-failed     { background:var(--red-bg);    color:var(--red); }
.badge-failed .badge-dot     { background:var(--red); }
.badge-service { background:var(--surface); color:var(--text-2); border:1px solid var(--border); font-size:11px; }

/* ── Queue pills ─────────────────────────────────────────── */
.queue-pills { display:flex; gap:6px; align-items:center; }
.pill { font-size:11px; padding:3px 10px; border-radius:20px; background:var(--surface); color:var(--text-2); border:1px solid var(--border); }
.pill-active { background:var(--green-bg); color:var(--green); border-color:transparent; }
.pill-fail   { background:var(--red-bg);   color:var(--red);   border-color:transparent; }

/* ── Tabs ────────────────────────────────────────────────── */
.tabs { display:flex; border-bottom:1px solid var(--border); margin-bottom:16px; }
.tab-btn {
  padding:10px 18px; font-size:13px; font-weight:500; color:var(--text-2);
  background:none; border:none; border-bottom:2px solid transparent;
  cursor:pointer; margin-bottom:-1px; transition:color .12s, border-color .12s;
  display:flex; align-items:center; gap:6px;
}
.tab-btn:hover { color:var(--text); }
.tab-btn.active { color:var(--accent); border-bottom-color:var(--accent); }
.tab-count { background:var(--surface); color:var(--text-2); border-radius:10px; font-size:11px; font-weight:500; padding:1px 7px; }
.tab-pane { display:none; }
.tab-pane.active { display:block; }

/* ── Filter bar ──────────────────────────────────────────── */
.filter-bar { display:flex; gap:8px; align-items:center; flex-wrap:wrap; margin-bottom:12px; }
.filter-input, .filter-select {
  background:var(--bg); border:1px solid var(--border-dk); border-radius:var(--r);
  color:var(--text); padding:7px 12px; font-size:13px; font-family:var(--font); outline:none;
  transition:border-color .12s;
}
.filter-input:focus, .filter-select:focus { border-color:var(--accent); box-shadow:0 0 0 3px rgba(99,91,255,.1); }
.filter-check { display:flex; align-items:center; gap:6px; font-size:13px; color:var(--text-2); cursor:pointer; }

/* ── Queue controls ──────────────────────────────────────── */
.queue-controls { display:flex; gap:10px; align-items:center; padding:16px; flex-wrap:wrap; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display:inline-flex; align-items:center; gap:6px;
  padding:8px 14px; border-radius:var(--r); font-size:13px; font-weight:500;
  cursor:pointer; border:none; text-decoration:none;
  transition:background .12s, border-color .12s; white-space:nowrap; font-family:var(--font);
}
.btn-primary      { background:var(--accent); color:#fff; }
.btn-primary:hover { background:var(--accent-dk); }
.btn-secondary    { background:var(--bg); color:var(--text); border:1px solid var(--border-dk); }
.btn-secondary:hover { background:var(--surface); }
.btn-ghost        { background:none; color:var(--text-2); border:1px solid var(--border); }
.btn-ghost:hover  { background:var(--surface); color:var(--text); }
.btn-danger-ghost { background:none; color:var(--red); border:1px solid var(--border); }
.btn-danger-ghost:hover { background:var(--red-bg); border-color:var(--red); }
.btn-xs  { padding:4px 10px; font-size:11px; border-radius:4px; }
.btn-full { width:100%; justify-content:center; }

/* ── Forms ───────────────────────────────────────────────── */
.form-group { display:flex; flex-direction:column; gap:6px; margin-bottom:14px; }
label { font-size:13px; font-weight:500; }
input[type="text"], input[type="email"], input[type="password"], select, textarea {
  background:var(--bg); border:1px solid var(--border-dk); border-radius:var(--r);
  color:var(--text); padding:9px 13px; font-size:14px; font-family:var(--font);
  outline:none; transition:border-color .12s, box-shadow .12s; width:100%;
}
input:focus, select:focus, textarea:focus {
  border-color:var(--accent); box-shadow:0 0 0 3px rgba(99,91,255,.1);
}
input::placeholder, textarea::placeholder { color:var(--text-3); }
textarea { resize:vertical; line-height:1.6; }

/* ── Send card ───────────────────────────────────────────── */
.send-card { padding:24px; max-width:560px; }
.send-footer { display:flex; align-items:center; gap:16px; }

/* ── Pagination ──────────────────────────────────────────── */
.pagination { display:flex; align-items:center; gap:8px; padding:12px 16px; border-top:1px solid var(--border); }
.page-info { color:var(--text-2); font-size:12px; margin-right:auto; }
.page-btn { padding:5px 12px; border:1px solid var(--border); border-radius:var(--r); color:var(--text-2); font-size:12px; text-decoration:none; background:var(--bg); transition:background .12s; }
.page-btn:hover { background:var(--surface); color:var(--text); }

/* ── Alerts ──────────────────────────────────────────────── */
.alert { border-radius:var(--r); padding:12px 16px; margin-bottom:16px; font-size:13px; }
.alert-error   { background:var(--red-bg);   border:1px solid #f5c2c7; color:var(--red); }
.alert-success { background:var(--green-bg); border:1px solid #a8d5c2; color:var(--green); }

/* ── Gmail two-column ────────────────────────────────────── */
.mail-split { display:flex; height:calc(100vh - 280px); min-height:500px; overflow:hidden; }

.mail-list-panel {
  width:320px; flex-shrink:0; border-right:1px solid var(--border);
  overflow-y:auto; display:flex; flex-direction:column;
}
.mail-list-item {
  padding:12px 16px; border-bottom:1px solid var(--border);
  cursor:pointer; transition:background .1s;
}
.mail-list-item:hover    { background:var(--surface); }
.mail-list-item.selected { background:#f0efff; }
.mail-list-item.unread .mail-item-from,
.mail-list-item.unread .mail-item-subject { font-weight:600; color:var(--text); }
.mail-item-row1 { display:flex; justify-content:space-between; align-items:baseline; margin-bottom:3px; }
.mail-item-from    { font-size:13px; color:var(--text); font-weight:400; }
.mail-item-date    { font-size:11px; color:var(--text-3); white-space:nowrap; }
.mail-item-subject { font-size:12px; color:var(--text-2); margin-bottom:3px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.mail-item-meta    { display:flex; justify-content:space-between; align-items:center; }
.mail-att-badge    { font-size:11px; color:var(--text-3); }

.mail-detail-panel {
  flex:1; min-width:0; overflow:hidden; display:flex; flex-direction:column;
}
.mail-detail-empty {
  flex:1; display:flex; flex-direction:column; align-items:center;
  justify-content:center; gap:12px; color:var(--text-3); font-size:13px;
}
.mail-detail-content {
  flex:1; display:flex; flex-direction:column; overflow:hidden;
}
.mail-detail-header {
  padding:16px 20px; border-bottom:1px solid var(--border); background:var(--surface);
  display:flex; flex-direction:column; gap:6px;
}
.mail-detail-subject { font-size:15px; font-weight:600; }
.mail-detail-meta { font-size:12px; color:var(--text-2); display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
.mail-detail-actions { display:flex; gap:8px; }
.mail-detail-body { flex:1; overflow:hidden; display:flex; flex-direction:column; }
.mail-iframe { flex:1; border:none; background:#fff; }
.mail-pre { flex:1; overflow-y:auto; padding:20px; white-space:pre-wrap; word-break:break-word; font-family:'Menlo','Consolas',monospace; font-size:12px; line-height:1.6; }

/* ── Misc ────────────────────────────────────────────────── */
.mono { font-family:'Menlo','Consolas',monospace; font-size:12px; }
.text-sm { font-size:12px; }
.text-2  { color:var(--text-2); }
.text-3  { color:var(--text-3); }
.link    { color:var(--accent); text-decoration:none; }
.link:hover { text-decoration:underline; }
.tooltip-icon { cursor:help; color:var(--yellow); font-size:13px; }
