/* ==========================================================================
   AdviseRe Insurance Brokerage System — Design System v3
   Calm, low-saturation palette · light sidebar · collapsible navigation
   ========================================================================== */
:root {
  /* Brand (softened from logo navy #1E459C) */
  --brand-800: #123B73;
  --brand-700: #1757B8;
  --brand-600: #1F6FEB;
  --brand-500: #3B82F6;
  --brand-400: #72A7FF;
  --brand-100: #DCEBFF;
  --brand-50:  #EEF6FF;

  --accent:    #0F9F8A;
  --accent-2:  #19B6B8;
  --accent-bg: #E6FAF6;
  --gold:      #D78A08;
  --gold-bg:   #FFF4D8;

  /* Neutrals — warm gray, easy on the eyes */
  --bg:        #F4F7FB;
  --surface:   #FFFFFF;
  --sidebar:   #FBFCFF;
  --ink:       #1E293B;
  --ink-2:     #475569;
  --ink-3:     #94A3B8;
  --line:      #E6ECF5;
  --line-2:    #D5DFEC;

  /* Status — muted */
  --ok:        #087F5B;  --ok-bg:     #E6F7EF;
  --warn:      #B7791F;  --warn-bg:   #FFF3D6;
  --danger:    #C2413B;  --danger-bg: #FDECEC;
  --info:      #1F6FEB;  --info-bg:   #EAF3FF;

  --shadow-1: 0 1px 2px rgba(30, 41, 59, .05), 0 1px 3px rgba(30, 41, 59, .07);
  --shadow-2: 0 8px 24px rgba(30, 64, 120, .10), 0 2px 6px rgba(30, 41, 59, .06);
  --shadow-3: 0 24px 60px rgba(24, 54, 97, .22);

  --r-sm: 8px; --r-md: 12px; --r-lg: 14px;
  --sidebar-w: 250px;
  --sidebar-w-mini: 74px;
  --topbar-h: 58px;
  --font: "Segoe UI Variable Text", "Segoe UI", -apple-system, "Inter", Roboto, Tahoma, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font);
  background: linear-gradient(180deg, #F8FBFF 0%, var(--bg) 220px);
  color: var(--ink);
  font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
::selection { background: var(--brand-100); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--ink-3); }

/* ==========================================================================
   Login
   ========================================================================== */
#login-screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: linear-gradient(145deg, #F7FBFF 0%, #EAF4FF 42%, #D8F7F1 100%);
}
.login-card {
  background: rgba(255, 255, 255, .96); padding: 42px 40px 34px; border-radius: 18px;
  width: 100%; max-width: 400px; box-shadow: var(--shadow-3); text-align: center;
  border: 1px solid rgba(31, 111, 235, .10);
  animation: rise .4s cubic-bezier(.2, .9, .3, 1.15);
}
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.99); } to { opacity: 1; } }
.login-logo { width: 200px; max-width: 68%; margin-bottom: 4px; }
.login-card h1 { font-size: 14.5px; color: var(--ink-2); margin: 2px 0 26px; font-weight: 600; }
.login-card form { text-align: start; }
.login-card label { display: block; margin-bottom: 15px; font-weight: 600; color: var(--ink-2); font-size: 12.5px; }
.login-card input {
  width: 100%; padding: 11px 13px; margin-top: 6px; border: 1.5px solid var(--line-2);
  border-radius: var(--r-sm); font-size: 14.5px; font-family: inherit;
  background: var(--surface); color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.login-card input:focus { outline: none; border-color: var(--brand-500); box-shadow: 0 0 0 3px var(--brand-100); }
.login-card .btn.primary.full { margin-top: 6px; padding: 11px; font-size: 14.5px; border-radius: 10px; }

/* ==========================================================================
   Layout
   ========================================================================== */
#app { display: flex; min-height: 100vh; min-height: 100dvh; }

#sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: linear-gradient(180deg, var(--sidebar) 0%, #F6FAFF 100%);
  border-inline-end: 1px solid var(--line);
  color: var(--ink); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; height: 100dvh;
  z-index: 40;
}
.brand {
  padding: 15px 16px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; min-height: 72px;
  background: linear-gradient(180deg, #FFFFFF 0%, #F8FBFF 100%);
}
.brand img { width: 100%; max-height: 46px; }
.brand .brand-mini {
  display: none; font-weight: 800; font-size: 17px; color: var(--brand-600); letter-spacing: -.02em;
}
#nav { flex: 1; padding: 10px 10px 14px; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; }

.nav-section { margin-bottom: 4px; }
.nav-section + .nav-section { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.nav-section-title {
  padding: 4px 12px 6px; font-size: 10.5px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-item {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: start;
  background: none; border: 0; color: var(--ink-2); padding: 8px 12px;
  font-size: 13.5px; font-family: inherit; cursor: pointer; border-radius: 9px;
  margin-bottom: 1px; transition: background .12s, color .12s;
  -webkit-tap-highlight-color: transparent; white-space: nowrap;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .7; }
.nav-item span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.nav-item:hover { background: #F0F7FF; color: var(--ink); }
.nav-item.active {
  background: var(--brand-50); color: var(--brand-700); font-weight: 600;
  box-shadow: inset 3px 0 0 var(--brand-600);
}
.nav-item.active svg { opacity: 1; color: var(--brand-600); }

.sidebar-footer { padding: 13px 14px calc(13px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
#user-info { font-size: 12.5px; margin-bottom: 9px; color: var(--ink-3); line-height: 1.5; }
#user-info b { color: var(--ink); display: block; font-size: 13px; }

/* --- Collapsed sidebar (desktop) --- */
@media (min-width: 901px) {
  body.sidebar-collapsed #sidebar { width: var(--sidebar-w-mini); }
  body.sidebar-collapsed .brand { padding: 15px 8px; }
  body.sidebar-collapsed .brand img { display: none; }
  body.sidebar-collapsed .brand .brand-mini { display: block; }
  body.sidebar-collapsed .nav-section-title { display: none; }
  body.sidebar-collapsed .nav-section + .nav-section { margin-top: 6px; padding-top: 6px; }
  body.sidebar-collapsed .nav-item { justify-content: center; padding: 10px 0; gap: 0; }
  body.sidebar-collapsed .nav-item span { display: none; }
  body.sidebar-collapsed .nav-item svg { width: 19px; height: 19px; }
  body.sidebar-collapsed .sidebar-footer { display: none; }
}


/* Collapse chevron pinned to the sidebar edge (desktop only) */
#btn-collapse {
  position: absolute; top: 86px; inset-inline-end: -13px; z-index: 45;
  width: 26px; height: 26px; border-radius: 50%; padding: 0;
  background: var(--surface); border: 1px solid var(--line-2); color: var(--ink-3);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  box-shadow: var(--shadow-1);
}
#btn-collapse:hover { color: var(--brand-600); border-color: var(--brand-400); }
#btn-collapse svg { width: 14px; height: 14px; }
body.sidebar-collapsed #btn-collapse svg { transform: rotate(180deg); }
[dir="rtl"] #btn-collapse svg { transform: rotate(180deg); }
[dir="rtl"] body.sidebar-collapsed #btn-collapse svg { transform: rotate(0deg); }
@media (max-width: 900px) { #btn-collapse { display: none; } }

#sidebar-overlay {
  position: fixed; inset: 0; background: rgba(30, 38, 55, .42); z-index: 35;
  opacity: 0; pointer-events: none; transition: opacity .25s;
}
body.nav-open #sidebar-overlay { opacity: 1; pointer-events: auto; }

#main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

#topbar {
  display: flex; align-items: center; gap: 10px; height: var(--topbar-h);
  background: rgba(255, 255, 255, .92);
  border-bottom: 1px solid var(--line); padding: 0 20px;
  position: sticky; top: 0; z-index: 30;
}
#btn-menu {
  background: none; border: 0; padding: 8px; margin-inline-start: -8px;
  border-radius: 8px; cursor: pointer; color: var(--ink-2);
  -webkit-tap-highlight-color: transparent;
}
#btn-menu:hover { background: var(--brand-50); color: var(--brand-600); }
#btn-menu svg { width: 21px; height: 21px; display: block; }
#topbar h2 { margin: 0; font-size: 16.5px; font-weight: 700; color: var(--ink); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#notif-bell {
  cursor: pointer; display: flex; align-items: center; gap: 7px;
  background: var(--surface); border: 1px solid var(--line-2); color: var(--ink-2);
  padding: 7px 12px; border-radius: 999px; transition: all .15s;
  -webkit-tap-highlight-color: transparent; user-select: none;
}
#notif-bell:hover { border-color: var(--brand-400); color: var(--brand-600); }
#notif-bell svg { width: 15px; height: 15px; }
#notif-count {
  font-weight: 700; color: #fff; background: linear-gradient(135deg, var(--brand-500), var(--accent)); font-size: 11px;
  min-width: 18px; height: 18px; border-radius: 999px; display: inline-flex;
  align-items: center; justify-content: center; padding: 0 5px;
}
.top-btn {
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--line-2); color: var(--ink-2);
  padding: 7px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 700;
  font-family: inherit; transition: all .15s;
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.top-btn:hover { border-color: var(--brand-400); color: var(--brand-600); }
.top-btn svg { width: 15px; height: 15px; }
@media (max-width: 480px) { .top-btn span.txt { display: none; } }

#content { padding: 20px 22px 70px; max-width: 1380px; width: 100%; margin: 0 auto; }

/* ==========================================================================
   Cards
   ========================================================================== */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 18px 20px; margin-bottom: 16px; box-shadow: var(--shadow-1);
}
.card:hover { border-color: #D6E7FF; box-shadow: var(--shadow-2); }
.card h3 {
  margin: 0 0 13px; font-size: 14px; font-weight: 700; color: var(--ink);
  display: flex; align-items: center; gap: 8px;
}
.card h3::before { content: ""; width: 3px; height: 15px; border-radius: 3px; background: linear-gradient(180deg, var(--brand-500), var(--accent)); }

.toolbar { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; margin-bottom: 15px; }
.toolbar input[type="text"], .toolbar input[type="date"], .toolbar select {
  padding: 8px 11px; border: 1.5px solid var(--line-2); border-radius: 9px;
  font-size: 13.5px; font-family: inherit; background: var(--surface); color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.toolbar input:focus, .toolbar select:focus { outline: none; border-color: var(--brand-500); box-shadow: 0 0 0 3px var(--brand-100); }
.toolbar .spacer { flex: 1; }

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1.5px solid var(--line-2); background: var(--surface); color: var(--ink-2);
  padding: 8px 14px; border-radius: 9px; cursor: pointer; font-size: 13.5px;
  font-weight: 600; font-family: inherit; transition: all .14s;
  -webkit-tap-highlight-color: transparent; white-space: nowrap;
}
.btn:hover { border-color: var(--brand-400); color: var(--brand-600); background: var(--brand-50); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(135deg, var(--brand-600), var(--accent)); border-color: transparent; color: #fff; box-shadow: 0 8px 18px rgba(31, 111, 235, .22); }
.btn.primary:hover { background: linear-gradient(135deg, var(--brand-700), #0B8F7D); border-color: transparent; color: #fff; }
.btn.danger { color: var(--danger); border-color: #E8CCC9; background: var(--surface); }
.btn.danger:hover { background: var(--danger-bg); border-color: var(--danger); }
.btn.small { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn.ghost { background: transparent; color: var(--ink-2); border-color: var(--line-2); width: 100%; margin-top: 6px; }
.btn.ghost:hover { background: var(--brand-50); color: var(--brand-600); }
.btn.full { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

/* ==========================================================================
   Tables
   ========================================================================== */
.table-wrap {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line); border-radius: var(--r-md);
}
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 480px; }
table.grid th {
  text-align: start; background: #F7F8FA; color: var(--ink-2);
  padding: 10px 12px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  border-bottom: 1px solid var(--line-2); white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
table.grid th.sortable { cursor: pointer; user-select: none; }
table.grid th.sortable:hover { background: var(--brand-50); color: var(--brand-600); }
table.grid td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; color: var(--ink-2); }
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid tbody tr { transition: background .1s; }
table.grid tbody tr:hover td { background: #FAFBFD; }
table.grid td:first-child { color: var(--ink); font-weight: 500; }
table.grid td.actions { white-space: nowrap; text-align: end; }
table.grid td.actions .btn { margin-inline-start: 4px; }

.pager {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  border-top: 1px solid var(--line); font-size: 12.5px; color: var(--ink-3);
  background: var(--surface);
}
.pager .spacer { flex: 1; }

.empty { color: var(--ink-3); padding: 38px 20px; text-align: center; font-size: 13.5px; }

/* ==========================================================================
   Badges
   ========================================================================== */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px;
  border-radius: 999px; font-size: 11.5px; font-weight: 700; white-space: nowrap;
}
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.danger { background: var(--danger-bg); color: var(--danger); }
.badge.info { background: var(--info-bg); color: var(--info); }

/* ==========================================================================
   Dashboard
   ========================================================================== */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(212px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
  background: linear-gradient(180deg, #FFFFFF 0%, #FBFDFF 100%); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 15px; display: flex; align-items: center; gap: 13px; box-shadow: var(--shadow-1);
  transition: box-shadow .15s;
}
.stat:hover { box-shadow: var(--shadow-2); }
.stat .chip {
  width: 40px; height: 40px; border-radius: 11px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: #EAF3FF; color: var(--brand-600);
}
.stat .chip svg { width: 19px; height: 19px; }
.stat.warn .chip { background: var(--warn-bg); color: var(--warn); }
.stat.danger .chip { background: var(--danger-bg); color: var(--danger); }
.stat.ok .chip { background: var(--ok-bg); color: var(--ok); }
.stat .num { font-size: 20px; font-weight: 800; color: var(--ink); line-height: 1.15; letter-spacing: -.01em; }
.stat .lbl { font-size: 11.5px; color: var(--ink-3); margin-top: 1px; font-weight: 600; }

.meter-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.meter { flex: 1; min-width: 200px; height: 12px; background: var(--brand-50); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.meter > i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand-500), var(--accent)); border-radius: 999px; }
.meter-labels { display: flex; justify-content: space-between; width: 100%; font-size: 12px; color: var(--ink-2); margin-top: 6px; }
.meter-labels b { color: var(--ink); }

.charts { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; margin-bottom: 16px; }
.chart-svg { width: 100%; height: auto; display: block; }
.hbar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; font-size: 12.5px; }
.hbar-label { width: 130px; flex-shrink: 0; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: end; }
.hbar-track { flex: 1; height: 16px; background: var(--brand-50); border-radius: 5px; overflow: hidden; }
.hbar-fill { height: 100%; background: linear-gradient(90deg, var(--brand-400), var(--accent-2)); border-radius: 5px; min-width: 2px; }
.hbar-val { width: 74px; flex-shrink: 0; font-weight: 700; color: var(--ink); font-size: 12px; }

/* ==========================================================================
   Customer 360
   ========================================================================== */
.profile-head { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.avatar {
  width: 52px; height: 52px; border-radius: 15px; flex-shrink: 0;
  background: var(--brand-100); color: var(--brand-600);
  font-size: 20px; font-weight: 800; display: flex; align-items: center; justify-content: center;
}
.profile-head h2 { margin: 2px 0 4px; font-size: 18px; color: var(--ink); }
.profile-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--ink-2); }
.profile-meta b { color: var(--ink); }
.kv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(205px, 1fr)); gap: 10px 18px; margin-top: 14px; }
.kv-grid .kv { font-size: 12px; color: var(--ink-3); }
.kv-grid .kv b { display: block; font-size: 13.5px; color: var(--ink); font-weight: 600; margin-top: 1px; }

.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 16px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tab {
  background: none; border: 0; padding: 9px 15px; font-size: 13.5px; font-weight: 600;
  color: var(--ink-3); cursor: pointer; font-family: inherit; white-space: nowrap;
  border-bottom: 2.5px solid transparent; margin-bottom: -2px; border-radius: 8px 8px 0 0;
  -webkit-tap-highlight-color: transparent;
}
.tab:hover { color: var(--brand-600); background: var(--brand-50); }
.tab.active { color: var(--brand-600); border-bottom-color: var(--brand-500); }
.tab .badge { margin-inline-start: 5px; }

/* ==========================================================================
   Modal
   ========================================================================== */
#modal-backdrop {
  position: fixed; inset: 0; background: rgba(30, 38, 55, .45); z-index: 50;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto;
  animation: fade .16s;
}
@keyframes fade { from { opacity: 0; } }
#modal {
  background: var(--surface); border-radius: var(--r-lg); width: 100%; max-width: 700px;
  padding: 22px 25px; box-shadow: var(--shadow-3); border: 1px solid var(--line);
  animation: rise .28s cubic-bezier(.2, .9, .3, 1.08);
}
#modal h3 { margin: 0 0 17px; color: var(--ink); font-size: 15.5px; font-weight: 700; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px 17px; }
.form-grid label, #modal form > label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.form-grid label.wide { grid-column: 1 / -1; }
.form-grid input, .form-grid select, .form-grid textarea,
#modal input, #modal select, #modal textarea {
  width: 100%; padding: 8.5px 11px; margin-top: 5px; border: 1.5px solid var(--line-2);
  border-radius: 9px; font-size: 13.5px; background: var(--surface); font-family: inherit;
  color: var(--ink); transition: border-color .15s, box-shadow .15s;
}
#modal input:focus, #modal select:focus, #modal textarea:focus {
  outline: none; border-color: var(--brand-500); box-shadow: 0 0 0 3px var(--brand-100);
}
.form-grid input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--brand-600); margin-top: 8px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.error { color: var(--danger); font-size: 13px; margin: 8px 0; }

/* ==========================================================================
   Toast
   ========================================================================== */
#toast { position: fixed; bottom: 22px; inset-inline-end: 22px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast-msg {
  background: var(--ink); color: #fff; padding: 11px 17px; border-radius: 11px;
  box-shadow: var(--shadow-2); font-size: 13.5px; animation: rise .22s;
  border-inline-start: 4px solid var(--brand-400);
}
.toast-msg.error { background: #7E332D; border-inline-start-color: #E5A19C; }

/* ==========================================================================
   Reports
   ========================================================================== */
.report-group-title {
  font-size: 12px; letter-spacing: .1em; text-transform: uppercase; font-weight: 700;
  color: var(--ink-3); margin: 20px 2px 10px;
}
.report-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(265px, 1fr)); gap: 10px; }
.report-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 13px 15px; cursor: pointer; transition: all .14s; position: relative; overflow: hidden;
}
.report-card::before {
  content: ""; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 3px;
  background: var(--line-2); transition: background .14s;
}
.report-card:hover { border-color: #BFD8FF; box-shadow: var(--shadow-2); }
.report-card:hover::before { background: linear-gradient(180deg, var(--brand-500), var(--accent)); }
.report-card h4 { margin: 0 0 4px; font-size: 13px; color: var(--ink); font-weight: 700; }
.report-card p { margin: 0; font-size: 11.5px; color: var(--ink-3); line-height: 1.45; }

/* ==========================================================================
   Print
   ========================================================================== */
@media print {
  #sidebar, #topbar, .toolbar, .btn, #notif-bell, #sidebar-overlay { display: none !important; }
  #content { padding: 0; max-width: none; }
  .card { border: 0; box-shadow: none; }
  .table-wrap { border: 0; overflow: visible; }
  body { background: #fff; }
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); }
}

@media (max-width: 900px) {
  #sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    transform: translateX(-104%);
    box-shadow: var(--shadow-3);
    width: min(292px, 84vw);
    transition: transform .26s cubic-bezier(.2, .8, .2, 1);
  }
  body.nav-open #sidebar { transform: translateX(0); }
  body.nav-open { overflow: hidden; }
  [dir="rtl"] #sidebar { left: auto; right: 0; transform: translateX(104%); }
  [dir="rtl"] body.nav-open #sidebar, body.nav-open [dir="rtl"] #sidebar { transform: translateX(0); }

  #topbar { padding: 0 14px; }
  #content { padding: 15px 13px 78px; }

  .card { padding: 15px 14px; border-radius: var(--r-md); }
  .stats { grid-template-columns: repeat(2, 1fr); gap: 9px; }
  .stat { padding: 12px; gap: 10px; }
  .stat .chip { width: 36px; height: 36px; border-radius: 10px; }
  .stat .num { font-size: 17px; }
  .charts { grid-template-columns: 1fr; }
  .hbar-label { width: 92px; }

  .toolbar { gap: 8px; }
  .toolbar input[type="text"] { flex: 1 1 150px; min-width: 0; }
  .btn { padding: 10px 14px; }
  .btn.small { padding: 8px 11px; font-size: 12px; }

  #modal-backdrop { padding: 0; align-items: flex-end; }
  #modal {
    max-width: none; border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
    max-height: 92dvh; overflow-y: auto; animation: sheet .28s cubic-bezier(.2, .9, .3, 1);
  }
  @keyframes sheet { from { transform: translateY(55%); opacity: .4; } }
  #modal::before {
    content: ""; display: block; width: 40px; height: 4px; border-radius: 4px;
    background: var(--line-2); margin: -4px auto 13px;
  }
  .form-grid { grid-template-columns: 1fr; gap: 12px; }
  .modal-actions { position: sticky; bottom: 0; background: var(--surface); padding-top: 12px; margin-top: 16px; }
  .modal-actions .btn { flex: 1; padding: 12px; }

  #toast { left: 14px; right: 14px; bottom: 14px; max-width: none; }
  .report-list { grid-template-columns: 1fr; }
  table.grid th, table.grid td { padding: 9px 10px; }
}

@media (max-width: 420px) {
  .stats { grid-template-columns: 1fr 1fr; }
  #topbar h2 { font-size: 15px; }
  .brand img { max-height: 40px; }
}

/* ==========================================================================
   RTL specifics
   ========================================================================== */
[dir="rtl"] .nav-item.active { box-shadow: inset -3px 0 0 var(--accent); }

/* ==========================================================================
   Dark theme — neutral charcoal, low glare
   ========================================================================== */
:root[data-theme="dark"] {
  --brand-800: #BFD8FF;
  --brand-700: #9BC4FF;
  --brand-600: #78AAFF;
  --brand-500: #4F8EF7;
  --brand-400: #3574D6;
  --brand-100: #1B3556;
  --brand-50:  #13253C;

  --accent:    #43D6BF;
  --accent-2:  #36C9D3;
  --accent-bg: #123B36;
  --gold:      #F5BA4F;
  --gold-bg:   #3B2B12;

  --bg:        #10161F;
  --surface:   #18212E;
  --sidebar:   #141D29;
  --ink:       #E7EEF8;
  --ink-2:     #B7C4D6;
  --ink-3:     #7F8EA3;
  --line:      #263346;
  --line-2:    #33445A;

  --ok:        #62D394;  --ok-bg:     #143426;
  --warn:      #F0BE55;  --warn-bg:   #3A2B12;
  --danger:    #F08A84;  --danger-bg: #3A2022;
  --info:      #78AAFF;  --info-bg:   #142740;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .3), 0 1px 3px rgba(0, 0, 0, .25);
  --shadow-2: 0 4px 14px rgba(0, 0, 0, .4), 0 2px 4px rgba(0, 0, 0, .25);
  --shadow-3: 0 18px 50px rgba(0, 0, 0, .55);
}
:root[data-theme="dark"] body { background: linear-gradient(180deg, #121F2D 0%, var(--bg) 220px); }
:root[data-theme="dark"] #login-screen { background: linear-gradient(145deg, #111B28 0%, #102238 48%, #0D302D 100%); }
:root[data-theme="dark"] .login-card { background: rgba(24, 33, 46, .96); border-color: rgba(120, 170, 255, .16); }
:root[data-theme="dark"] #sidebar { background: linear-gradient(180deg, var(--sidebar) 0%, #101823 100%); }
:root[data-theme="dark"] #topbar { background: rgba(24, 33, 46, .92); }
:root[data-theme="dark"] .brand { background: linear-gradient(180deg, rgba(255,255,255,.96) 0%, rgba(236,244,255,.96) 100%); }
:root[data-theme="dark"] .nav-section + .nav-section { border-top-color: var(--line); }
:root[data-theme="dark"] .nav-item:hover { background: #1A2A3E; }
:root[data-theme="dark"] .nav-item.active { background: #16283F; color: var(--brand-700); box-shadow: inset 3px 0 0 var(--brand-600); }
:root[data-theme="dark"] table.grid th { background: #22252C; }
:root[data-theme="dark"] table.grid tbody tr:hover td { background: #20242B; }
:root[data-theme="dark"] .card,
:root[data-theme="dark"] .stat { background: linear-gradient(180deg, #18212E 0%, #151E2B 100%); }
:root[data-theme="dark"] .card:hover { border-color: #355A88; }
:root[data-theme="dark"] .btn.primary { background: linear-gradient(135deg, var(--brand-500), #21A995); border-color: transparent; color: #F2F7FF; box-shadow: none; }
:root[data-theme="dark"] .btn.primary:hover { background: linear-gradient(135deg, var(--brand-600), #2CC6AD); border-color: transparent; }
:root[data-theme="dark"] .login-card input, :root[data-theme="dark"] #modal input,
:root[data-theme="dark"] #modal select, :root[data-theme="dark"] #modal textarea,
:root[data-theme="dark"] .toolbar input[type="text"], :root[data-theme="dark"] .toolbar input[type="date"],
:root[data-theme="dark"] .toolbar select { background: #15181D; color: var(--ink); }
:root[data-theme="dark"] .toast-msg { background: #2A3242; }
:root[data-theme="dark"] .toast-msg.error { background: #4A2521; }
:root[data-theme="dark"] .avatar { background: var(--brand-100); color: var(--brand-600); }
:root[data-theme="dark"] ::-webkit-scrollbar-thumb { border-color: var(--bg); }

/* Kill transitions while resizing across breakpoints */
body.no-transitions *, body.no-transitions { transition: none !important; }

/* ==========================================================================
   Typeahead lookup (combobox)
   ========================================================================== */
.lookup { position: relative; }
.lookup .lookup-input { padding-inline-end: 30px; }
.lookup-clear {
  position: absolute; inset-inline-end: 5px; top: 50%; transform: translateY(-32%);
  border: 0; background: none; color: var(--ink-3); cursor: pointer;
  font-size: 16px; padding: 2px 6px; border-radius: 6px; line-height: 1;
}
.lookup-clear:hover { color: var(--danger); }
.lookup-menu {
  position: absolute; top: calc(100% + 4px); inset-inline: 0;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px;
  box-shadow: var(--shadow-2); z-index: 70; max-height: 240px; overflow-y: auto;
}
.lookup-item { padding: 9px 12px; font-size: 13px; cursor: pointer; color: var(--ink-2); }
.lookup-item:hover, .lookup-item.hi { background: var(--brand-50); color: var(--brand-600); }
.lookup-empty { padding: 12px; color: var(--ink-3); font-size: 12.5px; text-align: center; }

.pager select {
  padding: 4px 8px; border: 1px solid var(--line-2); border-radius: 7px;
  font-size: 12px; background: var(--surface); color: var(--ink-2); font-family: inherit;
}
.toolbar select { max-width: 220px; }
:root[data-theme="dark"] .lookup-menu { background: var(--surface); }

/* ==========================================================================
   Reports v2 — catalog & rich viewer
   ========================================================================== */
.reports-head { display: flex; flex-direction: column; gap: 12px; }
.reports-search { position: relative; }
.reports-search .rs-icon { position: absolute; inset-inline-start: 13px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; line-height: 0; }
.reports-search .rs-icon svg { width: 17px; height: 17px; }
.reports-search input {
  width: 100%; padding: 11px 14px; padding-inline-start: 40px;
  border: 1.5px solid var(--line-2); border-radius: 10px; font-size: 14px;
  font-family: inherit; background: var(--surface); color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.reports-search input:focus { outline: none; border-color: var(--brand-500); box-shadow: 0 0 0 3px var(--brand-100); }

.chip-row { display: flex; flex-wrap: wrap; gap: 7px; }
.chip-btn {
  padding: 6px 13px; border: 1px solid var(--line-2); background: var(--surface);
  color: var(--ink-2); border-radius: 999px; font-size: 12.5px; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: all .13s; white-space: nowrap;
}
.chip-btn:hover { border-color: var(--brand-400); color: var(--brand-600); }
.chip-btn.active { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }

.report-card { padding: 15px 16px 16px; }
.report-card .rep-cat { display: flex; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 7px; }
.report-card .rep-cat svg { width: 13px; height: 13px; }
.report-card .rep-fav { position: absolute; top: 9px; inset-inline-end: 9px; border: 0; background: none; color: var(--ink-3); cursor: pointer; padding: 3px; border-radius: 6px; line-height: 0; }
.report-card .rep-fav svg { width: 17px; height: 17px; }
.report-card .rep-fav:hover, .report-card .rep-fav.on { color: var(--gold, #D78A08); }
.report-card h4 { padding-inline-end: 22px; }
.rep-tag { display: inline-flex; align-items: center; gap: 4px; margin-top: 9px; font-size: 10.5px; font-weight: 700; color: var(--brand-600); background: var(--brand-50); padding: 3px 9px; border-radius: 999px; }
.rep-tag svg { width: 12px; height: 12px; }

.report-toolbar .rep-preset { padding: 8px 10px; border: 1.5px solid var(--line-2); border-radius: 9px; font-size: 13px; background: var(--surface); color: var(--ink); font-family: inherit; }
.report-view-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.report-search input { padding: 8px 12px; border: 1.5px solid var(--line-2); border-radius: 9px; font-size: 13px; font-family: inherit; background: var(--surface); color: var(--ink); min-width: 210px; }
.report-search input:focus { outline: none; border-color: var(--brand-500); box-shadow: 0 0 0 3px var(--brand-100); }
.report-summary { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); margin-bottom: 16px; }

table.grid td.num, table.grid th.num { text-align: end; font-variant-numeric: tabular-nums; }
table.grid tfoot td { background: #F7F8FA; border-top: 2px solid var(--line-2); color: var(--ink); padding: 10px 12px; }
:root[data-theme="dark"] table.grid tfoot td { background: #22252C; }

/* ==========================================================================
   Customers page
   ========================================================================== */
.cust-cell { display: flex; align-items: center; gap: 10px; }
.cust-avatar {
  width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  background: var(--brand-100); color: var(--brand-700);
  font-size: 12.5px; font-weight: 800; display: flex; align-items: center; justify-content: center;
}
.cust-meta { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.cust-meta b { color: var(--ink); font-weight: 600; font-size: 13px; }
.cust-meta span { color: var(--ink-3); font-size: 11.5px; }
.cust-contact { display: flex; flex-direction: column; line-height: 1.4; }
.cust-contact span:last-child { color: var(--ink-3); font-size: 11.5px; }

.doc-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.doc-chip {
  display: inline-flex; align-items: center; padding: 2px 7px; border-radius: 6px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .02em; cursor: default;
}
.doc-chip.ok { background: var(--ok-bg); color: var(--ok); }
.doc-chip.warn { background: var(--warn-bg); color: var(--warn); }
.doc-chip.danger { background: var(--danger-bg); color: var(--danger); }
.doc-chip.none { background: var(--line); color: var(--ink-3); }

.pill-active {
  display: inline-block; margin-inline-start: 5px; padding: 1px 7px; border-radius: 999px;
  font-size: 10px; font-weight: 700; background: var(--ok-bg); color: var(--ok);
}
table.grid td.out-due { color: var(--danger); font-weight: 700; }
tr[data-id] { cursor: pointer; }

/* ==========================================================================
   Attachments uploader (drag & drop)
   ========================================================================== */
.att-cat-label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 12px; }
.att-cat-label select { display: block; width: 100%; max-width: 280px; margin-top: 5px; padding: 8.5px 11px; border: 1.5px solid var(--line-2); border-radius: 9px; font-size: 13.5px; background: var(--surface); color: var(--ink); font-family: inherit; }
.att-sep { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

.dropzone {
  border: 2px dashed var(--line-2); border-radius: 12px; padding: 26px 16px;
  display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
  cursor: pointer; color: var(--ink-3); background: var(--brand-50);
  transition: border-color .15s, background .15s, color .15s;
}
.dropzone:hover, .dropzone:focus { outline: none; border-color: var(--brand-400); color: var(--brand-600); }
.dropzone.over { border-color: var(--brand-600); background: var(--brand-100); color: var(--brand-700); }
.dz-icon { line-height: 0; }
.dz-icon svg { width: 34px; height: 34px; }
.dz-text b { display: block; font-size: 13.5px; color: var(--ink); }
.dz-text span { font-size: 12px; }

.staged-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.staged-file {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--surface); font-size: 13px;
}
.staged-file .sf-icon { line-height: 0; color: var(--brand-500); flex-shrink: 0; }
.staged-file .sf-icon svg { width: 16px; height: 16px; }
.staged-file .sf-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.staged-file .sf-size { color: var(--ink-3); font-size: 11.5px; flex-shrink: 0; }
.staged-file .sf-remove { border: 0; background: none; color: var(--ink-3); cursor: pointer; font-size: 14px; padding: 2px 6px; border-radius: 6px; flex-shrink: 0; }
.staged-file .sf-remove:hover { color: var(--danger); background: var(--danger-bg); }

.att-progress { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.att-progress .att-bar { flex: 1; height: 8px; background: var(--brand-50); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.att-progress .att-bar > i { display: block; height: 100%; width: 0; background: var(--brand-500); border-radius: 999px; transition: width .15s; }
.att-progress > span { font-size: 12px; font-weight: 700; color: var(--ink-2); min-width: 38px; text-align: end; }

/* ==========================================================================
   Customer profile — document sections
   ========================================================================== */
.doc-section { margin-bottom: 18px; }
.doc-section:last-child { margin-bottom: 0; }
.doc-section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.doc-section-head h4 { margin: 0; font-size: 13px; font-weight: 700; color: var(--brand-700); }


/* Regional settings — company logo */
.rg-logo-block { margin-top: 18px; }
.rg-logo-block > label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 8px; }
.rg-logo-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
#rg-logo-preview {
  height: 56px; max-width: 220px; object-fit: contain;
  background: #fff; border: 1px solid var(--line-2); border-radius: 10px; padding: 8px 14px;
}
.rg-logo-hint { font-size: 11.5px; color: var(--ink-3); }

/* Audit diff */
td.au-old { color: var(--danger); background: var(--danger-bg); }
td.au-new { color: var(--ok); background: var(--ok-bg); }
td.au-old, td.au-new { font-size: 12px; word-break: break-word; max-width: 260px; }

/* Google sign-in */
.login-divider { display: flex; align-items: center; gap: 12px; margin: 18px 0 14px; color: var(--ink-3); font-size: 12px; font-weight: 700; }
.login-divider::before, .login-divider::after { content: ''; flex: 1; border-top: 1px solid var(--line-2); }
#google-btn { display: flex; justify-content: center; }
.rg-google-block { margin-top: 18px; }
.rg-google-block > label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.rg-google-block input { width: 100%; max-width: 460px; margin-top: 5px; padding: 8.5px 11px; border: 1.5px solid var(--line-2); border-radius: 9px; font-size: 13px; font-family: inherit; background: var(--surface); color: var(--ink); }
.rg-guide { margin-top: 10px; max-width: 640px; }
.rg-guide summary { cursor: pointer; font-size: 12.5px; font-weight: 700; color: var(--brand-600); padding: 6px 0; }
.rg-guide ol { margin: 8px 0 4px; padding-inline-start: 22px; font-size: 12.5px; color: var(--ink-2); line-height: 1.9; }
.rg-guide code { background: var(--brand-50); border: 1px solid var(--line); border-radius: 5px; padding: 1px 7px; font-size: 12px; direction: ltr; unicode-bidi: embed; }

/* AI assistant */
.rg-ai-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; max-width: 720px; margin-top: 6px; }
.rg-ai-grid > label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.rg-ai-grid input, .rg-ai-grid select { width: 100%; margin-top: 5px; padding: 8.5px 11px; border: 1.5px solid var(--line-2); border-radius: 9px; font-size: 13px; font-family: inherit; background: var(--surface); color: var(--ink); }
.ai-summary { background: var(--brand-50); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; font-size: 13.5px; line-height: 2; color: var(--ink); max-height: 50vh; overflow-y: auto; white-space: pre-line; }
.ai-disclaimer { font-size: 11.5px; color: var(--ink-3); margin: 8px 2px 0; }

.ai-message { width: 100%; border: 1.5px solid var(--line-2); border-radius: 10px; padding: 12px 14px; font-size: 13.5px; line-height: 1.9; font-family: inherit; background: var(--surface); color: var(--ink); resize: vertical; }

/* AI Copilot chat */
.cp-card { display: flex; flex-direction: column; height: calc(100vh - 128px); min-height: 420px; padding: 0; overflow: hidden; }
.cp-log { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.cp-msg { max-width: 78%; padding: 11px 15px; border-radius: 14px; font-size: 13.5px; line-height: 1.9; white-space: pre-line; }
.cp-user { align-self: flex-end; background: var(--brand-600); color: #fff; border-end-end-radius: 4px; }
.cp-ai { align-self: flex-start; background: var(--brand-50); border: 1px solid var(--line); color: var(--ink); border-end-start-radius: 4px; }
.cp-typing { color: var(--ink-3); }
.cp-report { display: block; font-size: 11px; font-weight: 700; color: var(--brand-600); margin-bottom: 5px; }
.cp-welcome { margin: auto; text-align: center; color: var(--ink-2); padding: 20px; }
.cp-welcome h3 { margin: 8px 0 4px; color: var(--ink); }
.cp-welcome p { margin: 0 0 16px; font-size: 12.5px; color: var(--ink-3); }
.cp-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.cp-chip { border: 1.5px solid var(--line-2); background: var(--surface); color: var(--ink-2); border-radius: 999px; padding: 7px 14px; font-size: 12.5px; cursor: pointer; font-family: inherit; }
.cp-chip:hover { border-color: var(--brand-600); color: var(--brand-600); }
.cp-input-row { display: flex; gap: 10px; padding: 14px 16px; border-top: 1px solid var(--line); }
.cp-input-row textarea { flex: 1; padding: 10px 14px; border: 1.5px solid var(--line-2); border-radius: 10px; font-size: 13.5px; font-family: inherit; background: var(--surface); color: var(--ink); resize: none; max-height: 120px; overflow-y: auto; line-height: 1.6; }
.cp-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 9px; }
.cp-link { border: 1.5px solid var(--brand-600); background: var(--surface); color: var(--brand-600); border-radius: 8px; padding: 5px 11px; font-size: 12px; font-weight: 700; cursor: pointer; font-family: inherit; }
.cp-link:hover { background: var(--brand-600); color: #fff; }
@media (max-width: 900px) { .cp-card { height: calc(100dvh - 170px); } }

/* RTL typography: Arabic script must never be letter-spaced (it breaks letter
   joining) and labels wrap instead of being clipped mid-word. */
[dir="rtl"] body, [dir="rtl"] body * { letter-spacing: normal !important; }
[dir="rtl"] .nav-item { white-space: normal; }
[dir="rtl"] .nav-item span { overflow: visible; text-overflow: clip; line-height: 1.45; }
[dir="rtl"] .nav-section-title { white-space: normal; overflow: visible; }

/* Inline SVG icon sizing (buttons, modal titles, copilot hero) */
.btn svg { width: 15px; height: 15px; vertical-align: -3px; }
.ic-h3 { margin-inline-end: 7px; }
.ic-h3 svg { width: 19px; height: 19px; vertical-align: -4px; color: var(--brand-600); }


/* ---- Copilot v3: distinct AI identity ---- */
.cp-head { display: flex; align-items: center; gap: 12px; padding: 13px 18px; border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, var(--brand-50), var(--surface) 65%); }
.cp-head-mark { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
  background: var(--brand-600); color: #fff; box-shadow: 0 4px 12px color-mix(in srgb, var(--brand-600) 35%, transparent); }
.cp-head-mark svg { width: 21px; height: 21px; }
.cp-head-txt { display: flex; flex-direction: column; line-height: 1.35; }
.cp-head-txt b { font-size: 14px; color: var(--ink); }
.cp-status { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--ink-3); }
.cp-status i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); }

.cp-log { background:
  radial-gradient(600px 300px at 85% -80px, var(--brand-50), transparent 70%); }
.cp-row { display: flex; gap: 10px; align-items: flex-end; }
.cp-row-user { justify-content: flex-end; }
.cp-avatar { width: 28px; height: 28px; border-radius: 9px; flex-shrink: 0; display: grid; place-items: center;
  background: var(--brand-600); color: #fff; margin-bottom: 2px; }
.cp-avatar svg { width: 15px; height: 15px; }
.cp-msg { box-shadow: 0 1px 2px rgba(16, 42, 67, .06); }
.cp-user { background: linear-gradient(135deg, var(--brand-600), color-mix(in srgb, var(--brand-600) 75%, #1a6f8f)); }

.cp-hero-ic { width: 64px; height: 64px; margin: 0 auto 6px; border-radius: 20px; display: grid; place-items: center;
  background: var(--brand-600); color: #fff; box-shadow: 0 10px 28px color-mix(in srgb, var(--brand-600) 38%, transparent);
  }
.cp-hero-ic svg { width: 32px; height: 32px; color: #fff; }
@keyframes cp-float { 0%,100% { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(-6px) rotate(4deg); } }

.cp-dots { display: inline-flex; gap: 4px; margin-inline-end: 9px; vertical-align: middle; }
.cp-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--brand-600); opacity: .35;
  animation: cp-blink 1.2s infinite; }
.cp-dots i:nth-child(2) { animation-delay: .2s; }
.cp-dots i:nth-child(3) { animation-delay: .4s; }
@keyframes cp-blink { 0%,80%,100% { opacity: .25; transform: scale(.85); } 40% { opacity: 1; transform: scale(1.15); } }

.cp-input-row { background: var(--surface); }
.cp-input-row textarea { border-radius: 14px; }
.cp-input-row textarea:focus { outline: none; border-color: var(--brand-600);
  box-shadow: 0 0 0 3.5px color-mix(in srgb, var(--brand-600) 14%, transparent); }
.cp-send { width: 44px; height: 44px; border-radius: 50%; border: 0; flex-shrink: 0; cursor: pointer;
  display: grid; place-items: center; align-self: flex-end;
  background: var(--brand-600); color: #fff; transition: transform .12s, box-shadow .12s; }
.cp-send:hover { transform: translateY(-1px); box-shadow: 0 6px 14px color-mix(in srgb, var(--brand-600) 35%, transparent); }
.cp-send:disabled { opacity: .55; cursor: default; transform: none; }
.cp-send svg { width: 19px; height: 19px; }
[dir="rtl"] .cp-send svg { transform: scaleX(-1); }

.cp-chip { transition: all .15s; }
.cp-chip:hover { transform: translateY(-1px); box-shadow: 0 3px 10px rgba(16, 42, 67, .08); }

.cp-clear { margin-inline-start: auto; display: inline-flex; align-items: center; gap: 6px; color: var(--ink-3); }
.cp-clear:hover { color: var(--danger); border-color: var(--danger); }

/* Permissions editor */
.perm-ai { display: flex; align-items: center; gap: 10px; margin: 14px 0; font-size: 13.5px; color: var(--ink); }
.perm-ai input { width: 17px; height: 17px; accent-color: var(--brand-600); }
.perm-grid { width: 100%; margin-top: 4px; }
.perm-grid select { width: 100%; padding: 7px 10px; border: 1.5px solid var(--line-2); border-radius: 8px; font-size: 13px; font-family: inherit; background: var(--surface); color: var(--ink); }

/* Styled dialogs */
.ui-dialog-backdrop { position: fixed; inset: 0; background: rgba(15, 28, 45, .45); z-index: 300;
  display: grid; place-items: center; padding: 20px; }
.ui-dialog { background: var(--surface); border-radius: 16px; padding: 24px 24px 18px; width: 100%;
  max-width: 400px; text-align: center; box-shadow: 0 24px 60px rgba(10, 25, 45, .3); }
.ui-dialog-ic { width: 48px; height: 48px; margin: 0 auto 12px; border-radius: 14px; display: grid;
  place-items: center; background: var(--brand-50); color: var(--brand-600); }
.ui-dialog-ic.danger { background: var(--danger-bg); color: var(--danger); }
.ui-dialog-ic svg { width: 24px; height: 24px; }
.ui-dialog-msg { font-size: 14px; color: var(--ink); line-height: 1.7; white-space: pre-line; }
.ui-dialog-input { width: 100%; margin-top: 14px; padding: 9px 12px; border: 1.5px solid var(--line-2);
  border-radius: 10px; font-size: 13.5px; font-family: inherit; background: var(--surface); color: var(--ink); }
.ui-dialog-input:focus { outline: none; border-color: var(--brand-600); }
.ui-dialog-actions { display: flex; gap: 10px; justify-content: center; margin-top: 18px; }
.ui-dialog-actions .btn { min-width: 96px; justify-content: center; }
