/* ── Tokens ───────────────────────────────────────────────────────────────── */
:root {
  --primary:       #c8202c;
  --primary-dark:  #a81820;
  --primary-light: #fde8e8;
  --primary-dim:   rgba(200, 32, 44, 0.10);

  --bg:     #eef0f5;
  --card:   #ffffff;
  --border: #e1e5ec;
  --border-strong: #cdd2da;

  --text:   #111827;
  --muted:  #64748b;
  --subtle: #94a3b8;

  --ok:      #059669;
  --ok-light: #d1fae5;
  --danger:  #dc2626;
  --warning: #d97706;
  --info:    #2563eb;
  --info-light: #dbeafe;

  --sidebar-bg:     #0d0f14;
  --sidebar-text:   #9ba5b5;
  --sidebar-hover:  rgba(255,255,255,0.05);
  --sidebar-active-bg: rgba(200,32,44,0.13);
  --sidebar-width:  248px;

  --shadow-xs: 0 1px 2px rgba(0,0,0,.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow:    0 4px 10px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.04);
  --shadow-md: 0 8px 20px rgba(0,0,0,.09), 0 3px 8px rgba(0,0,0,.05);
  --shadow-lg: 0 16px 40px rgba(0,0,0,.12), 0 6px 14px rgba(0,0,0,.07);

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 14px;

  --transition: 140ms cubic-bezier(.4,0,.2,1);
}

/* ── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 13.5px;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  background: #f1f5f9; padding: 0.1em 0.4em;
  border-radius: 4px; font-size: 0.88em;
  font-family: "SF Mono", "Fira Code", ui-monospace, monospace;
  color: #374151;
}
h1 { font-size: 1.45rem; font-weight: 700; margin: 0 0 1rem; letter-spacing: -.02em; text-wrap: balance; }
h2 { font-size: 1.1rem;  font-weight: 700; margin: 0 0 .75rem; letter-spacing: -.01em; }
h3 { font-size: .95rem;  font-weight: 600; margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.sub   { color: var(--muted); font-size: .83em; }

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed; top: 0; left: 0; height: 100vh; width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex; flex-direction: column; z-index: 10;
  border-right: 1px solid rgba(255,255,255,0.04);
}

.brand {
  display: flex; align-items: center; gap: .75rem;
  padding: 1.2rem 1rem 1.1rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  margin-bottom: .35rem;
}
.brand-logo { flex-shrink: 0; }
.brand-logo img { width: 46px; height: 46px; object-fit: contain; display: block; border-radius: 8px; }
.brand-title { font-weight: 700; font-size: .88rem; color: #f0f1f3; line-height: 1.25; letter-spacing: -.01em; }
.brand-sub { color: #49556a; font-size: .7rem; margin-top: .1rem; }

.nav { display: flex; flex-direction: column; gap: 1px; flex: 1; padding: 0 .55rem; overflow-y: auto; }
.nav::-webkit-scrollbar { width: 3px; }
.nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); border-radius: 3px; }

.nav-section {
  font-size: .67rem; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: #3d4756;
  padding: .9rem .6rem .25rem;
}

.nav a {
  display: flex; align-items: center; gap: .6rem;
  color: var(--sidebar-text); padding: .52rem .65rem; border-radius: 7px;
  font-size: .855rem; font-weight: 500;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  position: relative;
}
.nav a:hover { background: var(--sidebar-hover); color: #e2e8f0; text-decoration: none; }
.nav a.active {
  background: var(--sidebar-active-bg);
  color: #fff;
  box-shadow: inset 2px 0 0 var(--primary);
  padding-left: .85rem;
}
.nav a.active .nav-icon { opacity: 1; color: var(--primary); }
.nav-icon { flex-shrink: 0; opacity: .5; transition: opacity var(--transition); }
.nav a:hover .nav-icon { opacity: .8; }

.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,0.05);
  padding: .7rem .75rem .85rem;
}
.profile-link {
  display: flex; align-items: center; gap: .6rem;
  color: var(--sidebar-text); padding: .5rem .55rem; border-radius: 7px;
  transition: background var(--transition), color var(--transition);
}
.profile-link:hover { background: var(--sidebar-hover); text-decoration: none; color: #e2e8f0; }
.profile-name { font-size: .84rem; font-weight: 600; color: #cbd5e1; line-height: 1.2; }
.profile-role { font-size: .7rem; color: #475569; margin-top: .05rem; }

.logout-btn {
  display: flex; align-items: center; gap: .6rem; width: 100%;
  background: none; border: none; color: #3d4756; cursor: pointer;
  padding: .42rem .55rem; border-radius: 7px; font-size: .84rem;
  margin-top: 1px; transition: background var(--transition), color var(--transition);
  text-align: left; font-family: inherit;
}
.logout-btn:hover { background: rgba(220,38,38,.12); color: #fca5a5; }

.lang-switcher {
  display: flex; gap: .3rem; padding: .5rem .75rem;
  border-top: 1px solid rgba(255,255,255,0.05);
}
.lang-btn {
  flex: 1; background: transparent; border: 1px solid rgba(255,255,255,0.08);
  color: #4a5568; border-radius: 6px; padding: .3rem .2rem;
  font-size: 1.1rem; cursor: pointer; font-family: inherit;
  transition: background var(--transition), border-color var(--transition);
  line-height: 1;
}
.lang-btn:hover   { background: rgba(255,255,255,0.06); color: #9ba5b5; border-color: rgba(255,255,255,0.15); }
.lang-btn.lang-active { background: rgba(200,32,44,0.2); color: #f87171; border-color: rgba(200,32,44,0.35); }

/* Hide Google Translate banner */
.goog-te-banner-frame, .skiptranslate { display: none !important; }
body { top: 0 !important; }

.sidebar-copy {
  text-align: center; font-size: .67rem; color: #252b36;
  padding: .5rem 1rem .7rem; border-top: 1px solid rgba(255,255,255,0.03);
}
.sidebar-copy a { color: #374151; text-decoration: none; }
.sidebar-copy a:hover { color: var(--primary); }

/* ── Main layout ──────────────────────────────────────────────────────────── */
.main { margin-left: var(--sidebar-width); min-height: 100vh; }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 1.75rem; height: 54px;
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.menu-toggle { display: none; background: none; border: none; color: var(--text); cursor: pointer; padding: .4rem; border-radius: 6px; }
.menu-toggle:hover { background: var(--bg); }
.topbar-right { display: flex; gap: .4rem; align-items: center; }

.notif-btn {
  display: flex; align-items: center; gap: .35rem;
  padding: .4rem .65rem; border-radius: 7px; color: var(--muted);
  font-size: .85rem; font-weight: 500;
  transition: background var(--transition), color var(--transition);
}
.notif-btn:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.notif-btn.has-notif { color: var(--primary); }

.badge {
  background: var(--primary); color: white; border-radius: 100px;
  padding: .05rem .42rem; font-size: .7rem; font-weight: 700;
  min-width: 17px; text-align: center; letter-spacing: 0;
}

.content { padding: 1.75rem; max-width: 1400px; margin: 0 auto; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .48rem .95rem;
  border: 1px solid var(--border);
  background: white; color: var(--text);
  border-radius: var(--radius-sm);
  cursor: pointer; font-size: .855rem; font-weight: 500;
  font-family: inherit;
  text-decoration: none;
  box-shadow: var(--shadow-xs);
  transition: background var(--transition), box-shadow var(--transition), border-color var(--transition), color var(--transition);
  white-space: nowrap;
}
.btn:hover { background: #f8f9fb; box-shadow: var(--shadow-sm); text-decoration: none; border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); box-shadow: none; }

.btn-primary {
  background: linear-gradient(160deg, #d42330 0%, #c8202c 55%, #b51c28 100%);
  color: white; border-color: #b51c28;
  box-shadow: 0 1px 3px rgba(200,32,44,.35), 0 1px 2px rgba(200,32,44,.2);
}
.btn-primary:hover {
  background: linear-gradient(160deg, #c82029 0%, #b51c28 100%);
  box-shadow: 0 4px 12px rgba(200,32,44,.4), 0 2px 4px rgba(200,32,44,.25);
  border-color: #a81820;
}

.btn-danger { background: var(--danger); color: white; border-color: var(--danger); box-shadow: none; }
.btn-danger:hover { background: #b91c1c; }

.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn-ghost:hover { background: rgba(0,0,0,.045); border-color: transparent; box-shadow: none; }

.btn-sm { padding: .24rem .55rem; font-size: .8rem; }
.btn-block { display: flex; justify-content: center; width: 100%; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
label { display: block; margin-bottom: .75rem; font-weight: 500; font-size: .875rem; }

input, select, textarea {
  width: 100%;
  padding: .48rem .7rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-family: inherit;
  margin-top: .25rem;
  background: white;
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(200,32,44,.12);
}
input::placeholder, textarea::placeholder { color: var(--subtle); }
textarea { resize: vertical; }

.form-card {
  background: white; padding: 1.5rem;
  border-radius: var(--radius); border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.form-inline { display: flex; gap: .5rem; align-items: flex-end; flex-wrap: wrap; }
.form-inline input, .form-inline select { flex: 1; min-width: 120px; margin: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.grid-2 .full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; }
.filters { display: flex; gap: .45rem; flex-wrap: wrap; margin-bottom: 1.1rem; align-items: center; }
.filters input, .filters select { max-width: 200px; margin: 0; }

.filter-pill {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .3rem .9rem;
  border: 1.5px solid var(--border);
  border-radius: 100px; font-size: .82rem; font-weight: 500;
  background: white; color: var(--muted); cursor: pointer;
  transition: border-color var(--transition), color var(--transition), background var(--transition);
  text-decoration: none; white-space: nowrap;
  box-shadow: var(--shadow-xs);
}
.filter-pill:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.filter-pill.active { background: var(--primary); color: white !important; border-color: var(--primary); box-shadow: 0 2px 8px rgba(200,32,44,.3); }
.filter-pill.active:hover { background: var(--primary-dark); text-decoration: none; }
.filter-pill-clear { color: var(--muted); font-size: .78rem; }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: white;
  padding: 1.25rem 1.35rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1rem;
}
.card-summary { display: flex; gap: 2rem; flex-wrap: wrap; }

/* ── Tables ───────────────────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th, .table td {
  padding: .65rem .75rem;
  border-bottom: 1px solid var(--border);
  text-align: left; vertical-align: middle;
}
.table th {
  background: #f8f9fb;
  font-weight: 600; font-size: .78rem; color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em;
}
.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: #fafbfc; }
.table tbody tr:last-child td { border-bottom: none; }
.cell-user { display: flex; align-items: center; gap: .5rem; }
.actions { text-align: right; }
.actions .btn { margin-left: .2rem; }

/* ── Avatars ──────────────────────────────────────────────────────────────── */
.avatar, .avatar-sm { border-radius: 50%; object-fit: cover; }
.avatar    { width: 40px; height: 40px; }
.avatar-sm { width: 28px; height: 28px; }
.avatar-placeholder {
  background: linear-gradient(135deg, var(--primary) 0%, #7f1217 100%);
  color: white; display: inline-flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700;
}

/* ── Page header ──────────────────────────────────────────────────────────── */
.page-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 1.5rem;
}

/* ── Tags ─────────────────────────────────────────────────────────────────── */
.tag {
  display: inline-block; padding: .18rem .6rem;
  border-radius: 5px; font-size: .74rem; font-weight: 600;
  background: #f1f5f9; color: #475569;
  letter-spacing: .01em;
}
.tag-admin      { background: #fce7f3; color: #be185d; }
.tag-supervisor { background: #ede9fe; color: #6d28d9; }
.tag-driver     { background: #d1fae5; color: #065f46; }
.tag-commercial { background: #fff7ed; color: #c2410c; }

.tag-planned     { background: var(--info-light);  color: #1e40af; }
.tag-in_progress { background: #fff7ed; color: #c2410c; }
.tag-completed   { background: var(--ok-light);    color: #065f46; }
.tag-incomplete  { background: #fee2e2; color: #991b1b; }
.tag-cancelled   { background: #f1f5f9; color: var(--muted); }
.tag-ok  { background: var(--ok-light); color: #065f46; }
.tag-ko  { background: #fee2e2; color: #991b1b; }
.tag-off { background: #f1f5f9; color: var(--muted); }

/* ── Alerts ───────────────────────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem; border-radius: var(--radius-sm);
  margin-bottom: 1rem; font-size: .875rem; font-weight: 500;
  display: flex; align-items: center; gap: .5rem;
}
.alert-error   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-ok      { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-info    { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

/* ── Login ────────────────────────────────────────────────────────────────── */
.auth-body {
  display: flex; justify-content: center; align-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0d0f14 0%, #1a1f2e 50%, #0f1520 100%);
}
.login-wrap { width: 100%; max-width: 400px; padding: 1.5rem; }
.login-card {
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(0,0,0,.45), 0 8px 20px rgba(0,0,0,.3);
  overflow: hidden;
}
.login-card-header {
  background: linear-gradient(145deg, #c8202c 0%, #7f1217 60%, #0d0f14 100%);
  padding: 1.75rem 0;
  text-align: center;
}
.login-logo-wrap { width: calc(100% - 3rem); margin: 0 auto; }
.login-logo-wrap img { width: 100%; height: auto; display: block; }
.login-card-title { color: #fff; font-weight: 700; font-size: 1.15rem; }
.login-card-sub   { color: rgba(255,255,255,.5); font-size: .78rem; margin-top: .2rem; }
.login-card-body  { background: #fff; padding: 2rem 2rem 2.25rem; }
.login-card-body h2 {
  margin: 0 0 1.25rem; font-size: .85rem; color: var(--muted);
  font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
}

/* ── Progress ─────────────────────────────────────────────────────────────── */
.progress {
  height: 5px; background: #eef0f5;
  border-radius: 100px; overflow: hidden; min-width: 80px;
}
.progress > div {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-dark), var(--primary));
  border-radius: 100px;
  transition: width .4s ease;
}

/* ── Delivery points ──────────────────────────────────────────────────────── */
.points { list-style: none; padding: 0; margin: 0; }
.point {
  background: white; border: 1.5px solid var(--border);
  border-radius: var(--radius); margin-bottom: .5rem;
  border-left: 4px solid var(--border);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--transition);
}
.point:hover { box-shadow: var(--shadow-sm); }
.point-delivered    { border-left-color: var(--ok); }
.point-not_delivered { border-left-color: var(--danger); }
.point-pending      { border-left-color: #94a3b8; }
.point-body   { padding: .8rem .9rem; }
.point-head   { display: flex; gap: .75rem; align-items: flex-start; }
.point-main   { flex: 1; }
.point-pos    { font-weight: 700; color: var(--subtle); min-width: 2.25rem; font-size: .82rem; }
.point-actions { display: flex; gap: .2rem; flex-wrap: wrap; }
.point-status { margin-top: .6rem; padding-top: .6rem; border-top: 1px solid var(--border); display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.proof-thumb  { width: 72px; height: 72px; border-radius: var(--radius-sm); object-fit: cover; }

/* Status form */
.point-form   { border-top: 1.5px solid var(--border); background: #f8f9fb; padding: .9rem; }
.status-toggle { display: flex; border: 1.5px solid var(--border); border-radius: 8px; overflow: hidden; margin-bottom: .85rem; }
.toggle-opt   { flex: 1; cursor: pointer; position: relative; }
.toggle-opt input[type="radio"] { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-opt span {
  display: flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .65rem .5rem; font-weight: 600; font-size: .875rem;
  background: white; transition: background var(--transition), color var(--transition);
  border-right: 1px solid var(--border);
}
.toggle-opt:last-child span { border-right: none; }
.toggle-opt:hover span { background: #f3f4f6; }
.toggle-opt.opt-delivered input:checked ~ span { background: var(--ok-light); color: #065f46; }
.toggle-opt.opt-failed    input:checked ~ span { background: #fee2e2; color: #991b1b; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.form-grid .full { grid-column: 1/-1; }
.form-grid label  { margin: 0; font-size: .84rem; font-weight: 500; }
.form-grid input, .form-grid select, .form-grid textarea { margin-top: .2rem; font-size: .84rem; }
.form-grid textarea { resize: none; }
.point-form-actions { display: flex; justify-content: flex-end; margin-top: .75rem; }
.btn-modifier { background: none; border: none; font-size: .79rem; color: var(--muted); cursor: pointer; padding: .25rem .5rem; border-radius: 4px; text-decoration: underline; font-family: inherit; }
.btn-modifier:hover { color: var(--text); }
.radio-group { display: flex; gap: 1rem; margin-bottom: .5rem; }
.radio-group label { display: inline-flex; align-items: center; gap: .25rem; margin: 0; font-weight: normal; }
.radio-group input { width: auto; margin: 0; }

/* ── Sortable ─────────────────────────────────────────────────────────────── */
.sortable { list-style: none; padding: 0; margin: 0; }
.sortable li {
  background: white; padding: .6rem .75rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  margin-bottom: .25rem; display: flex; align-items: center; gap: .5rem;
  cursor: move; box-shadow: var(--shadow-xs);
  transition: box-shadow var(--transition);
}
.sortable li:hover { box-shadow: var(--shadow-sm); }
.sortable li.dragging { opacity: .4; }
.handle { color: var(--subtle); cursor: grab; }
.pos { color: var(--muted); font-size: .84em; min-width: 2rem; }

/* ── Driver header ────────────────────────────────────────────────────────── */
.driver-header {
  display: flex; justify-content: space-between; align-items: center;
  background: white; padding: 1rem 1.25rem;
  border-radius: var(--radius); margin-bottom: 1rem;
  border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.driver-header h1 { margin: 0; }
.big-num { font-size: 2rem; font-weight: 700; color: var(--primary); letter-spacing: -.03em; }
.driver-progress { text-align: right; }

/* ── Driver nav pills ─────────────────────────────────────────────────────── */
.driver-nav {
  display: flex; align-items: center; gap: .5rem;
  margin-bottom: 1.1rem;
}
.driver-nav-pills {
  display: flex; gap: .35rem; flex-wrap: wrap; flex: 1; justify-content: center;
}

/* ── KPI cards ────────────────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1rem; margin-bottom: 1rem;
}
.kpi-card {
  background: white; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem 1.25rem;
  display: flex; align-items: flex-start; gap: .9rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
}
.kpi-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.kpi-icon {
  width: 42px; height: 42px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.kpi-icon-tours    { background: #fee2e2; color: var(--primary); }
.kpi-icon-delivery { background: var(--ok-light); color: var(--ok); }
.kpi-icon-rate     { background: var(--info-light); color: var(--info); }
.kpi-icon-stores   { background: #fef9c3; color: #b45309; }
.kpi-body  { flex: 1; min-width: 0; }
.kpi-value {
  font-size: 1.9rem; font-weight: 700; line-height: 1;
  letter-spacing: -.03em; font-variant-numeric: tabular-nums;
}
.kpi-denom { font-size: 1rem; font-weight: 400; color: var(--muted); }
.kpi-label { font-size: .8rem; color: var(--muted); margin: .2rem 0 .35rem; font-weight: 500; }
.kpi-sub   { font-size: .77rem; display: flex; gap: .35rem; flex-wrap: wrap; }
.kpi-rate  {
  font-size: 1.05rem; font-weight: 700; align-self: center;
  padding: .3rem .65rem; border-radius: 8px;
}
.rate-high { background: var(--ok-light); color: #065f46; }
.rate-mid  { background: #fff7ed; color: #c2410c; }
.rate-low  { background: #fee2e2; color: #991b1b; }

/* ── Stats ────────────────────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.stat-card {
  background: white; padding: 1rem 1.15rem;
  border-radius: var(--radius); border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.stat-card.accent {
  background: linear-gradient(135deg, #c8202c 0%, #7f1217 100%);
  color: white; border: none;
  box-shadow: 0 4px 14px rgba(200,32,44,.35), 0 2px 6px rgba(200,32,44,.2);
}
.stat-card.accent .stat-label, .stat-card.accent .sub { color: rgba(255,255,255,.65); }
.stat-label { font-size: .83rem; color: var(--muted); font-weight: 500; }
.stat-value { font-size: 1.9rem; font-weight: 700; line-height: 1.2; margin-top: .2rem; letter-spacing: -.03em; }

.rate-pill { padding: .15rem .6rem; border-radius: 100px; font-weight: 600; font-size: .79rem; }
.reason-list { list-style: none; padding: 0; }
.reason-list li { padding: .5rem 0; border-bottom: 1px solid var(--border); }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.chart-line { width: 100%; height: 150px; }

/* ── Danger zone ──────────────────────────────────────────────────────────── */
.danger-zone { border-color: #fecaca; background: #fef2f2; }
.danger-zone h3 { color: var(--danger); }

/* ── Notifications ────────────────────────────────────────────────────────── */
.notif-list { list-style: none; padding: 0; }
.notif {
  display: flex; justify-content: space-between; align-items: center;
  padding: .75rem 1rem; border: 1px solid var(--border);
  border-radius: var(--radius-sm); margin-bottom: .4rem;
  background: white; box-shadow: var(--shadow-xs);
}
.notif.read { opacity: .55; }
.notif-actions { display: flex; gap: .4rem; }

/* ── Messenger ────────────────────────────────────────────────────────────── */
.messenger {
  display: grid; grid-template-columns: 310px 1fr;
  height: calc(100vh - 100px); gap: 0;
  background: white; border-radius: var(--radius);
  overflow: hidden; border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.conv-list { border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }
.conv-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem; border-bottom: 1px solid var(--border); }
.conv-header h2 { margin: 0; }
.search-input { margin: .5rem 1rem; width: auto; }
.conv-list details { padding: 0 1rem .5rem; }
.user-picker { list-style: none; padding: 0; max-height: 200px; overflow-y: auto; }
.picker-btn { display: flex; gap: .5rem; align-items: center; width: 100%; background: none; border: none; padding: .4rem; cursor: pointer; text-align: left; border-radius: 5px; font-family: inherit; }
.picker-btn:hover { background: var(--bg); }
.conv-items { list-style: none; padding: 0; margin: 0; flex: 1; overflow-y: auto; }
.conv-items li a { display: flex; gap: .75rem; padding: .75rem 1rem; color: var(--text); border-bottom: 1px solid var(--border); transition: background var(--transition); }
.conv-items li a:hover { background: var(--bg); text-decoration: none; }
.conv-items li.active a { background: var(--primary-dim); border-left: 3px solid var(--primary); }
.conv-meta { flex: 1; min-width: 0; }
.conv-top  { display: flex; justify-content: space-between; align-items: center; }
.conv-last { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.conv-view        { display: flex; flex-direction: column; overflow: hidden; }
.conv-view-header { display: flex; justify-content: space-between; align-items: center; padding: .75rem 1rem; border-bottom: 1px solid var(--border); }
.conv-view-header h3 { margin: 0; }
.empty-conv       { flex: 1; display: flex; align-items: center; justify-content: center; padding: 2rem; text-align: center; }
.messages-list    { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .35rem; background: #f8f9fb; }

.msg {
  align-self: flex-start; max-width: 74%;
  background: white; padding: .5rem .75rem;
  border-radius: 10px; border: 1px solid var(--border);
  box-shadow: var(--shadow-xs); position: relative;
}
.msg.own {
  align-self: flex-end;
  background: var(--primary-light); border-color: rgba(200,32,44,.15);
}
.msg.pinned { border: 2px solid var(--warning); }
.msg-author { font-size: .74rem; color: var(--primary); font-weight: 700; margin-bottom: .1rem; }
.msg-reply  { background: #f1f5f9; border-left: 3px solid var(--primary); padding: .25rem .5rem; font-size: .84rem; border-radius: 4px; margin-bottom: .25rem; }
.msg-text   { white-space: pre-wrap; word-wrap: break-word; line-height: 1.55; }
.msg-image  { max-width: 240px; border-radius: 7px; display: block; }
.msg-file   { display: inline-block; padding: .4rem .6rem; background: rgba(0,0,0,.05); border-radius: 6px; }
.msg-meta   { display: flex; gap: .35rem; align-items: center; margin-top: .25rem; font-size: .69rem; color: var(--subtle); }
.reaction   { background: white; border: 1px solid var(--border); border-radius: 100px; padding: 0 .35rem; font-size: .74rem; cursor: pointer; }
.msg-tools  { position: absolute; top: -22px; right: 4px; display: none; gap: .15rem; background: white; border: 1px solid var(--border); padding: .15rem; border-radius: 7px; box-shadow: var(--shadow-sm); }
.msg:hover .msg-tools { display: flex; }
.mt-btn     { background: none; border: none; cursor: pointer; padding: .15rem .3rem; font-size: .9rem; }
.msg-system { text-align: center; font-size: .74rem; color: var(--subtle); padding: .5rem; font-style: italic; }
.typing-indicator { padding: 0 1rem; font-size: .84rem; color: var(--muted); min-height: 1.2rem; }

.msg-compose { border-top: 1px solid var(--border); padding: .75rem; background: white; }
.compose-row { display: flex; gap: .5rem; align-items: flex-end; }
.msg-compose textarea { flex: 1; resize: none; max-height: 120px; margin: 0; }
.reply-preview { background: #f1f5f9; padding: .4rem .5rem; border-left: 3px solid var(--primary); margin-bottom: .5rem; font-size: .84rem; display: flex; justify-content: space-between; align-items: center; border-radius: 4px; }

.attach-btn {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 7px; cursor: pointer; flex-shrink: 0;
  color: var(--muted); transition: color var(--transition), background var(--transition); border: 1px solid transparent;
}
.attach-btn:hover { color: var(--primary); background: var(--primary-light); }
.attach-btn.has-file { color: var(--primary); background: var(--primary-light); border-color: rgba(200,32,44,.25); }
.file-preview { display: flex; align-items: center; gap: .5rem; padding: .35rem .6rem; background: var(--primary-light); border-radius: 6px; margin-bottom: .4rem; font-size: .81rem; color: var(--primary); border: 1px solid rgba(200,32,44,.2); }
.file-preview-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.send-btn { flex-shrink: 0; padding: .42rem .8rem; }

.members-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .5rem; max-height: 300px; overflow-y: auto; padding: .5rem; border: 1px solid var(--border); border-radius: 7px; }
.member-check { display: flex; align-items: center; gap: .5rem; padding: .4rem; border-radius: 5px; margin: 0; font-weight: normal; cursor: pointer; }
.member-check:hover { background: var(--bg); }
.member-check input { width: auto; margin: 0; }

.dropdown      { position: relative; display: inline-block; }
.dropdown-body { position: absolute; right: 0; top: 100%; background: white; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1rem; width: 280px; box-shadow: var(--shadow-md); z-index: 10; }
.dropdown-body ul { list-style: none; padding: 0; max-height: 240px; overflow-y: auto; }
.dropdown-body li { padding: .35rem 0; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: .25rem; }

.history { list-style: none; padding: 0; }
.history li { padding: .4rem 0; border-bottom: 1px dashed var(--border); font-size: .88rem; color: var(--text); }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s cubic-bezier(.4,0,.2,1); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .main { margin-left: 0; }
  .menu-toggle { display: flex; }
  .messenger { grid-template-columns: 1fr; height: calc(100vh - 120px); }
  .conv-list { display: none; }
  .messenger.show-list .conv-list { display: flex; }
  .messenger.show-list .conv-view { display: none; }
}
