:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e2e5e9;
  --text: #1f2937;
  --text-muted: #6b7280;
  --primary: #1e3a5f;
  --primary-hover: #16304f;
  --danger: #b91c1c;
  --success: #15803d;
  --radius: 6px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: "Segoe UI", system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }

.layout { display: flex; min-height: 100vh; }

/* ---------- Login ---------- */
.login-screen { position: fixed; inset: 0; background: linear-gradient(160deg, #1e3a5f 0%, #2c4f7c 60%, #3a6598 100%); display: flex; align-items: center; justify-content: center; z-index: 200; }
.login-card { background: var(--surface); border-radius: 10px; padding: 32px; width: 380px; max-width: calc(100vw - 32px); box-shadow: 0 24px 60px rgba(0,0,0,.35); }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.login-card h2 { font-size: 17px; margin-bottom: 18px; font-weight: 600; }
.login-error { background: #fdecec; color: var(--danger); border: 1px solid #f5c6c6; border-radius: var(--radius); padding: 9px 12px; font-size: 13px; margin-bottom: 14px; }
.btn-block { width: 100%; padding: 10px; font-size: 14px; }
.field input[type=password] { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px; }
.field input[type=password]:focus { outline: 2px solid #c7d6e8; border-color: var(--primary); }

/* ---------- Sidebar ---------- */
.sidebar { width: 250px; background: var(--surface); border-right: 1px solid var(--border); flex-shrink: 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; padding: 16px; border-bottom: 1px solid var(--border); }
.brand-mark { background: var(--primary); color: #fff; font-weight: 700; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius); font-size: 11px; letter-spacing: -0.3px; flex-shrink: 0; }
.brand-name { font-weight: 600; font-size: 15px; }
.brand-sub { font-size: 11px; color: var(--text-muted); }

#nav { padding: 8px 0 16px; flex: 1; }

/* Category level */
.nav-cat-head, .nav-sub-head { display: flex; align-items: center; justify-content: space-between; width: 100%; background: none; border: none; cursor: pointer; text-align: left; font-family: inherit; }
.nav-cat-head { padding: 12px 16px 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--primary); font-weight: 700; }
.nav-cat-head:hover { color: var(--primary-hover); }
.nav-cat .caret, .nav-sub .caret { transition: transform .15s; font-size: 10px; color: var(--text-muted); }
.nav-cat:not(.open) > .nav-cat-head .caret { transform: rotate(-90deg); }
.nav-cat:not(.open) > .nav-cat-body { display: none; }

/* Sub-category level */
.nav-sub-head { padding: 8px 16px 4px 22px; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 600; }
.nav-sub-head:hover { color: var(--text); }
.nav-sub:not(.open) > .nav-sub-head .caret { transform: rotate(-90deg); }
.nav-sub:not(.open) > .nav-sub-body { display: none; }

#nav a { display: block; padding: 7px 16px 7px 30px; color: var(--text); text-decoration: none; cursor: pointer; border-left: 3px solid transparent; font-size: 13.5px; }
#nav a:hover { background: #f0f2f5; }
#nav a.active { background: #eef2f7; border-left-color: var(--primary); font-weight: 600; color: var(--primary); }
#nav a.disabled { color: #b0b5bd; cursor: default; }
#nav a.disabled:hover { background: none; }
#nav a.disabled em { font-style: normal; font-size: 10px; background: #f3f4f6; border-radius: 99px; padding: 1px 7px; margin-left: 6px; color: var(--text-muted); }

/* Account avatar + menu (top-right) */
.user-wrap { position: relative; padding-left: 14px; margin-left: 4px; border-left: 1px solid var(--border); }
.user-avatar-btn { width: 36px; height: 36px; border-radius: 50%; background: var(--primary); color: #fff; border: none; cursor: pointer; font-weight: 700; font-size: 14px; font-family: inherit; display: flex; align-items: center; justify-content: center; transition: box-shadow .15s; }
.user-avatar-btn:hover { box-shadow: 0 0 0 3px #dbe3ee; }
.user-menu { position: absolute; right: 0; top: calc(100% + 8px); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 14px 40px rgba(0,0,0,.16); min-width: 230px; z-index: 60; overflow: hidden; padding-bottom: 4px; }
.user-menu-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; background: #fafbfc; border-bottom: 1px solid var(--border); }
.user-avatar-lg { width: 40px; height: 40px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; flex-shrink: 0; }
.user-menu-id { min-width: 0; }
.user-name { font-weight: 600; font-size: 13.5px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11.5px; color: var(--text-muted); line-height: 1.3; }
.user-menu a { display: block; padding: 10px 16px; font-size: 13.5px; color: var(--text); cursor: pointer; text-decoration: none; }
.user-menu a:hover { background: #f0f2f5; }
.user-menu a.menu-danger { color: var(--danger); }
.user-menu a.menu-danger:hover { background: #fdf1f1; }
.user-menu-sep { height: 1px; background: var(--border); margin: 4px 0; }

/* Profile modal */
.profile-list { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; font-size: 13.5px; margin-bottom: 4px; }
.profile-list dt { color: var(--text-muted); font-weight: 600; }
.profile-list dd { margin: 0; }

/* ---------- Main ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 24px; background: var(--surface); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.topbar h1 { font-size: 18px; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.chk { display: flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 13px; white-space: nowrap; }

.context-bar { padding: 10px 24px; background: #eef2f7; border-bottom: 1px solid var(--border); font-size: 13px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.context-bar a { color: var(--primary); cursor: pointer; text-decoration: none; font-weight: 600; }
.context-bar a:hover { text-decoration: underline; }
.context-bar select { padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }

.content { padding: 20px 24px; }

/* ---------- Table ---------- */
table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); }
th { background: #fafbfc; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); font-weight: 600; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfd; }
td.actions { text-align: right; white-space: nowrap; }

/* Drill-down links inside tables */
.drill { color: var(--primary); cursor: pointer; text-decoration: none; font-weight: 600; }
.drill:hover { text-decoration: underline; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.badge.active { background: #e7f4ec; color: var(--success); }
.badge.inactive { background: #f3f4f6; color: var(--text-muted); }
.badge.level { background: #eef2f7; color: var(--primary); }

.count-note { margin: 10px 2px; color: var(--text-muted); font-size: 13px; }
.empty { padding: 40px; text-align: center; color: var(--text-muted); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }

/* ---------- Buttons ---------- */
.btn { padding: 8px 16px; border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius); cursor: pointer; font-size: 13px; font-weight: 500; color: var(--text); font-family: inherit; }
.btn:hover { background: #f0f2f5; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }

/* Small action buttons in table rows */
.btn-sm { padding: 4px 12px; font-size: 12.5px; border-radius: 5px; margin-left: 6px; }
.btn-sm.btn-edit { border-color: #c7d6e8; color: var(--primary); }
.btn-sm.btn-edit:hover { background: #eef2f7; }
.btn-sm.btn-toggle { border-color: var(--border); color: var(--text-muted); }
.btn-sm.btn-toggle:hover { background: #f3f4f6; color: var(--text); }
.btn-sm.btn-danger { border-color: #f0c9c9; color: var(--danger); }
.btn-sm.btn-danger:hover { background: #fdf1f1; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: flex; align-items: flex-start; justify-content: center; padding-top: 10vh; z-index: 50; }
.modal { background: var(--surface); border-radius: 8px; width: 440px; max-width: calc(100vw - 32px); box-shadow: 0 20px 50px rgba(0,0,0,.2); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 16px; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text-muted); line-height: 1; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.field input[type=text], .field select { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px; }
.field input:focus, .field select:focus { outline: 2px solid #c7d6e8; border-color: var(--primary); }
.field .hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--text); color: #fff; padding: 12px 18px; border-radius: var(--radius); font-size: 13px; z-index: 100; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.toast.error { background: var(--danger); }

.hidden { display: none !important; }

/* ---------- Business form ---------- */
.biz-form { max-width: 1100px; }
.form-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.form-section h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--primary); margin-bottom: 14px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.contact-sub { font-size: 13px; margin: 14px 0 10px; color: var(--text-muted); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px 18px; }
.form-span2 { grid-column: 1 / -1; }
.field textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px; font-family: inherit; resize: vertical; }
.field input[type=number] { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px; }
.field input[type=file] { font-size: 13px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 6px 0 30px; }
.logo-row { display: flex; align-items: center; gap: 10px; }
.logo-preview { width: 42px; height: 42px; object-fit: contain; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.sub-note { font-size: 12px; color: var(--text-muted); }

/* ---------- Multi-select ---------- */
.ms { position: relative; }
.ms-btn { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; cursor: pointer; font-size: 14px; font-family: inherit; text-align: left; color: var(--text); }
.ms-btn-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-panel { position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; right: 0; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0,0,0,.12); }
.ms-search { width: 100%; padding: 8px 10px; border: none; border-bottom: 1px solid var(--border); font-size: 13px; outline: none; }
.ms-list { max-height: 220px; overflow-y: auto; padding: 4px 0; }
.ms-item { display: flex; align-items: center; gap: 8px; padding: 6px 12px; font-size: 13.5px; cursor: pointer; }
.ms-item:hover { background: #f0f2f5; }
.ms-empty { padding: 12px; color: var(--text-muted); font-size: 13px; text-align: center; }

/* ---------- Pager ---------- */
.pager { display: flex; align-items: center; gap: 12px; justify-content: flex-end; color: var(--text-muted); font-size: 13px; }
.pager-top { margin: 0 0 10px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.pager-bottom { margin-top: 12px; }

/* ---------- Import ---------- */
.import-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.import-help { font-size: 13.5px; line-height: 1.9; color: var(--text); margin-bottom: 14px; }
.import-upload { display: flex; align-items: center; gap: 12px; }
.import-summary { display: flex; align-items: center; gap: 10px; margin: 14px 0; }
.chip { padding: 5px 14px; border-radius: 99px; font-size: 13px; font-weight: 600; }
.chip-ok { background: #e7f4ec; color: #15803d; }
.chip-warn { background: #fdf3e3; color: #a16207; }
.chip-err { background: #fdecec; color: #b91c1c; }

/* ---------- Business filters ---------- */
.filter-panel { background: #fbfcfe; border-color: #d5deea; }
.filter-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.filter-panel select:disabled { background: #f3f4f6; color: #9ca3af; }
.filter-actions { display: flex; align-items: center; gap: 10px; margin-top: 12px; }

/* ---------- Permission matrix ---------- */
.perm-matrix { width: 100%; border-collapse: collapse; margin-top: 6px; }
.perm-matrix th, .perm-matrix td { border: 1px solid var(--border); padding: 7px 10px; font-size: 13px; text-align: center; }
.perm-matrix td:first-child, .perm-matrix th:first-child { text-align: left; font-weight: 600; }
.perm-matrix thead th { background: #fafbfc; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); }
.perm-matrix input[type=checkbox] { width: 15px; height: 15px; cursor: pointer; }

/* ---------- Dashboard ---------- */
.dash-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
.dash-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.dash-num { font-size: 30px; font-weight: 700; color: var(--primary); line-height: 1.1; }
.dash-cap { font-size: 13px; color: var(--text-muted); margin-top: 4px; font-weight: 600; }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; }
.dash-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.dash-panel h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--primary); margin-bottom: 12px; }
.bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.bar-label { width: 130px; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex-shrink: 0; }
.bar-track { flex: 1; background: #eef1f5; border-radius: 4px; height: 14px; overflow: hidden; }
.bar-fill { background: var(--primary); height: 100%; border-radius: 4px; min-width: 2px; }
.bar-value { width: 42px; text-align: right; font-size: 12.5px; font-weight: 600; flex-shrink: 0; }

/* ---------- Forecast month grid ---------- */
.month-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px 14px; }

/* ---------- Export dropdown (topbar) ---------- */
.export-wrap { position: relative; }
.export-menu { position: absolute; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0,0,0,.14); min-width: 170px; z-index: 40; overflow: hidden; }
.export-menu a { display: block; padding: 9px 14px; font-size: 13px; color: var(--text); cursor: pointer; text-decoration: none; }
.export-menu a:hover { background: #f0f2f5; }

/* ---------- Area picker (hierarchical tree) ---------- */
.area-picker .ms-btn-label.ap-empty { color: var(--text-muted); }
.ap-tree { max-height: 300px; overflow-y: auto; padding: 4px 0; }
.ap-country { padding: 7px 12px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 700; background: #fafbfc; border-bottom: 1px solid var(--border); }
.ap-row { display: flex; align-items: center; gap: 4px; padding: 3px 8px; }
.ap-row:hover { background: #f0f2f5; }
.ap-toggle { width: 16px; text-align: center; cursor: pointer; color: var(--text-muted); font-size: 10px; flex-shrink: 0; user-select: none; }
.ap-toggle.ap-leaf { cursor: default; }
.ap-item { display: flex; align-items: center; gap: 7px; font-size: 13.5px; cursor: pointer; flex: 1; min-width: 0; }
.ap-item span:not(.ap-level) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ap-level { font-size: 10.5px; color: var(--text-muted); background: #eef1f5; border-radius: 99px; padding: 1px 7px; flex-shrink: 0; }
.ap-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 12px; border-top: 1px solid var(--border); background: #fafbfc; }
.ap-hint { font-size: 11.5px; color: var(--text-muted); }
.link-clear { background: none; border: none; color: var(--primary); cursor: pointer; font-size: 12.5px; font-family: inherit; }
.link-clear:hover { text-decoration: underline; }

/* ---------- List bar (search / rows / add, sits above the list) ---------- */
.list-bar { display: flex; align-items: center; gap: 12px; padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.list-bar #search { padding: 7px 12px; border: 1px solid var(--border); border-radius: var(--radius); width: 260px; font-size: 13px; }
.list-bar #search:focus { outline: 2px solid #c7d6e8; border-color: var(--primary); }
.list-bar select { padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; font-size: 13px; }

/* sortable headers */
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { background: #eef2f7; color: var(--primary); }

/* ---------- Role matrix groups + compact tables ---------- */
.perm-scroll { max-height: 420px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.perm-matrix tr.perm-group td { background: #eef2f7; font-size: 12px; }
.perm-matrix td.perm-mod { padding-left: 22px; font-weight: 400; }
body.compact table th, body.compact table td { padding: 5px 10px; font-size: 13px; }
body.compact .btn-sm { padding: 2px 9px; font-size: 12px; }

/* ---------- Selected-value tags (always visible under multi-selects) ---------- */
.tag-box { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.tag { display: inline-flex; align-items: center; gap: 6px; background: #eef2f7; border: 1px solid #d5deea; color: var(--primary); border-radius: 99px; padding: 3px 6px 3px 11px; font-size: 12.5px; max-width: 100%; }
.tag-x { background: none; border: none; color: var(--primary); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 3px; border-radius: 50%; }
.tag-x:hover { background: #d5deea; color: var(--danger); }
.tag-clear { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 12px; text-decoration: underline; font-family: inherit; }
.tag-clear:hover { color: var(--danger); }

/* ---------- Icon-only buttons (e.g. Print in lists) ---------- */
.btn-icon { display: inline-flex; align-items: center; justify-content: center; padding: 4px 8px; line-height: 1; }
.btn-icon svg { display: block; }
.form-actions .btn svg { margin-right: 6px; vertical-align: -2px; }

/* ---------- Demand vs Offers ---------- */
.match-table td { vertical-align: middle; }
.match-table td.num, .match-table th.num { text-align: right; }
.match-row { cursor: pointer; }
.match-row:hover { background: #f3f6fa; }
.cmp-bars { display: flex; flex-direction: column; gap: 3px; }
.cmp-bar { background: #eef1f5; border-radius: 3px; height: 9px; overflow: hidden; }
.cmp-fill { height: 100%; border-radius: 3px; min-width: 2px; }
.cmp-demand { background: #b45309; }
.cmp-offer { background: #15803d; }
.cmp-demand-text { color: #b45309; }
.cmp-offer-text { color: #15803d; }
.num.neg { color: var(--danger); font-weight: 600; }
.num.pos { color: var(--success); font-weight: 600; }
.legend { display: inline-flex; align-items: center; gap: 6px; margin-left: 10px; font-size: 12px; color: var(--text-muted); }
.legend .dot, .donut-legend .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.legend .dot.cmp-demand { background: #b45309; }
.legend .dot.cmp-offer { background: #15803d; }
.match-detail { background: #fbfcfe; }
.match-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 6px 2px 10px; }
.match-side h4 { font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
.inner-table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--border); border-radius: 5px; }
.inner-table th { background: #fafbfc; font-size: 10.5px; text-transform: uppercase; color: var(--text-muted); padding: 5px 8px; }
.inner-table td { padding: 5px 8px; font-size: 12.5px; border-top: 1px solid var(--border); }
.inner-table td.num, .inner-table th.num { text-align: right; }

/* ---------- Dashboard extras ---------- */
.dash-card.clickable, .bar-row.clickable { cursor: pointer; }
.dash-card.clickable:hover { border-color: var(--primary); box-shadow: 0 2px 10px rgba(30,58,95,.10); }
.bar-row.clickable:hover .bar-label { color: var(--primary); font-weight: 600; }
.dash-panel.dash-wide { grid-column: 1 / -1; }
.paired-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.paired-bars { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.paired-row .bar-value { width: 78px; text-align: right; font-size: 12px; line-height: 1.35; }
.donut-wrap { display: flex; align-items: center; gap: 16px; }
.donut { width: 116px; height: 116px; border-radius: 50%; position: relative; flex-shrink: 0; }
.donut-hole { position: absolute; inset: 26px; background: var(--surface); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--primary); }
.donut-legend { font-size: 12.5px; display: flex; flex-direction: column; gap: 5px; }

/* ---------- Country dashboard (flags, drill-down, selection) ---------- */
.ctx-search { padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius); width: 220px; font-size: 13px; background: #fff; }
.ctx-search:focus { outline: 2px solid #c7d6e8; border-color: var(--primary); }
.crumbs { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.crumbs .crumb-sep { color: var(--text-muted); }
.crumbs strong { display: inline-flex; align-items: center; gap: 6px; }

.flag { width: 26px; height: 18px; object-fit: cover; border: 1px solid #dfe3e8; border-radius: 2px; vertical-align: -3px; background: #fff; }
.flag-chip { display: inline-block; min-width: 26px; padding: 1px 5px; border: 1px solid #dfe3e8; border-radius: 2px; background: #f3f4f6; color: var(--text-muted); font-size: 10.5px; font-weight: 700; text-align: center; letter-spacing: .04em; }

.country-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.country-tile { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; cursor: pointer; font-family: inherit; font-size: 14px; color: var(--text); transition: border-color .15s, box-shadow .15s; }
.country-tile:hover { border-color: var(--primary); box-shadow: 0 2px 12px rgba(30,58,95,.12); }
.country-tile .ct-flag { flex-shrink: 0; }
.country-tile .ct-flag .flag, .country-tile .ct-flag .flag-chip { width: 42px; height: 30px; min-width: 42px; font-size: 12px; line-height: 28px; }
.country-tile .ct-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.country-tile .ct-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.country-tile .ct-sub { font-size: 11.5px; color: var(--text-muted); }
.country-tile .ct-count { font-size: 22px; font-weight: 700; color: var(--primary); flex-shrink: 0; }

.group-grid { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); align-items: start; }
.group-panel .panel-note { margin: -6px 0 10px; }
.group-row { display: flex; align-items: center; gap: 8px; padding: 6px 4px; border-bottom: 1px solid #f0f2f5; }
.group-row:last-child { border-bottom: none; }
.group-row.act { padding-left: 26px; }
.group-name { flex: 1; min-width: 0; color: var(--primary); cursor: pointer; font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-name:hover { text-decoration: underline; }
.group-count { flex-shrink: 0; background: #eef2f7; color: var(--primary); border-radius: 99px; padding: 1px 10px; font-size: 12px; font-weight: 700; }
.group-toggle { width: 18px; flex-shrink: 0; background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 11px; font-family: inherit; }
.group-toggle.empty { cursor: default; color: #cbd2da; }
.act-list { background: #fbfcfe; border-left: 2px solid #e3e8ef; margin: 2px 0 8px 8px; padding: 2px 0; }

.sel-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px; font-size: 13px; }

/* ---------- Message composer / templates ---------- */
.static-val { padding: 8px 10px; background: #f7f9fb; border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px; display: flex; align-items: center; gap: 8px; }
.rte-toolbar { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; border: 1px solid var(--border); border-bottom: none; border-radius: var(--radius) var(--radius) 0 0; background: #fafbfc; padding: 6px 8px; }
.rte-btn { background: #fff; border: 1px solid var(--border); border-radius: 4px; cursor: pointer; font-family: inherit; font-size: 12px; padding: 3px 8px; color: var(--text); }
.rte-btn:hover { background: #eef2f7; border-color: #c7d6e8; color: var(--primary); }
.rte-btn.rte-field { color: var(--primary); border-color: #d5deea; background: #f4f7fb; font-size: 11.5px; }
.rte-sep { width: 1px; height: 18px; background: var(--border); margin: 0 4px; }
.rte { min-height: 190px; max-height: 420px; overflow-y: auto; border: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius); padding: 12px 14px; font-size: 14px; line-height: 1.6; background: #fff; }
.rte:focus { outline: 2px solid #c7d6e8; border-color: var(--primary); }
.rte p { margin: 0 0 8px; }
.rte ul, .rte ol { margin: 0 0 8px 20px; }
.merge-hint code, .count-note code, .hint code { background: #eef2f7; color: var(--primary); border-radius: 3px; padding: 1px 5px; font-size: 12px; }

.msg-img-preview { max-width: 180px; max-height: 70px; object-fit: contain; border: 1px solid var(--border); border-radius: 5px; background: #fff; }
.msg-img-thumb { width: 54px; height: 32px; object-fit: cover; border: 1px solid var(--border); border-radius: 4px; background: #fff; }
.mail-preview { border: 1px solid var(--border); border-radius: var(--radius); background: #f4f5f7; padding: 12px; max-height: 460px; overflow-y: auto; }
.mail-preview > img { display: block; width: 100%; border-radius: 4px 4px 0 0; }
.mail-preview .mail-body { background: #fff; border: 1px solid #e3e6ea; border-radius: 0 0 4px 4px; padding: 16px; font-size: 13.5px; line-height: 1.6; }
.result-box { border-color: #c7d6e8; background: #f7faff; }
