:root {
    --bg: #eef2f7;
    --card: rgba(255,255,255,.96);
    --card-strong: #ffffff;
    --line: #dbe3ee;
    --line-soft: #e7edf5;
    --text: #0f172a;
    --muted: #64748b;
    --primary: #2563eb;
    --primary-2: #0ea5e9;
    --danger: #dc2626;
    --danger-soft: rgba(220,38,38,.1);
    --success: #16a34a;
    --success-soft: rgba(34,197,94,.12);
    --shadow: 0 14px 32px rgba(15,23,42,.08);
    --radius-lg: 22px;
    --radius-md: 16px;
  }
  
  * { box-sizing: border-box; }
  html, body { margin: 0; padding: 0; }
  body, input, select, button { font-family: 'Inter', sans-serif; }
  body {
    color: var(--text);
    background:
      radial-gradient(circle at top left, rgba(37,99,235,0.09), transparent 28%),
      radial-gradient(circle at top right, rgba(14,165,233,0.07), transparent 22%),
      linear-gradient(180deg, #f8fafc 0%, var(--bg) 100%);
  }
  
  .cmp-container { width: min(1520px, calc(100vw - 32px)); margin: 0 auto; }
  .cmp-main { padding: 20px 0 34px; }
  .cmp-shell { display: grid; gap: 18px; }
  
  .cmp-header {
    position: sticky; top: 0; z-index: 80;
    background: linear-gradient(135deg, rgba(255,255,255,.96) 0%, rgba(241,245,249,.96) 100%);
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 8px 24px rgba(15,23,42,.06);
    backdrop-filter: blur(10px);
  }
  .cmp-header::before {
    content: ''; position: absolute; inset: 0;
    background:
      radial-gradient(circle at left top, rgba(37,99,235,.07), transparent 26%),
      radial-gradient(circle at right center, rgba(14,165,233,.05), transparent 24%);
    pointer-events: none;
  }
  .cmp-header-inner {
    position: relative; z-index: 1; min-height: 88px;
    display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap;
  }
  .cmp-brand { display:flex; align-items:center; gap:16px; min-width:0; }
  .cmp-brand-mark {
    width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center;
    color: #fff; font-weight: 900; letter-spacing: .02em;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 42%, #0f172a 100%);
    box-shadow: 0 18px 32px rgba(37,99,235,.22), inset 0 1px 0 rgba(255,255,255,.18);
  }
  .cmp-brand-title { font-size: 1.42rem; font-weight: 800; letter-spacing: -.03em; }
  .cmp-brand-subtitle { margin: 6px 0 0; color: var(--muted); font-weight: 600; }
  .cmp-header-actions { display:flex; gap:10px; flex-wrap: wrap; margin-left: auto; }
  .cmp-header-link,
  button.cmp-header-link {
    height: 44px; padding: 0 14px; border-radius: 12px; border: 1px solid #dbe3ee;
    background: rgba(255,255,255,.95); color: var(--text); text-decoration: none; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; gap: 9px; font-weight: 800;
    box-shadow: 0 8px 18px rgba(15,23,42,.05);
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
  }
  .cmp-header-link:hover { transform: translateY(-1px); box-shadow: 0 12px 22px rgba(15,23,42,.08); border-color: #cbd5e1; }
  .cmp-header-link--primary {
    color: #fff; border-color: transparent;
    background: linear-gradient(135deg, #2563eb 0%, #0ea5e9 100%);
  }
  
  .cmp-toolbar-card,
  .cmp-scope-card,
  .cmp-kpi-card,
  .cmp-panel-card,
  .cmp-dialog-card {
    background: linear-gradient(180deg, rgba(255,255,255,.98) 0%, rgba(248,250,252,.98) 100%);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
  }
  
  .cmp-toolbar-card { padding: 18px; display: grid; gap: 14px; }
  .cmp-toolbar-grid {
    display: grid; gap: 12px;
    grid-template-columns: 220px minmax(310px, 1fr) minmax(310px, 1fr) 280px;
    align-items: stretch;
  }
  .cmp-filter-card {
    border: 1px solid var(--line-soft); border-radius: 18px; background: #fff;
    padding: 12px 14px; display: grid; gap: 8px; min-width: 0;
  }
  .cmp-filter-label {
    color: var(--muted); font-size: .74rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase;
  }
  .cmp-filter-card select,
  .cmp-filter-card input {
    width: 100%; border: none; outline: none; background: transparent; color: var(--text);
    font-size: .96rem; font-weight: 800;
  }
  .cmp-filter-card--period { gap: 10px; }
  .cmp-filter-dates {
    display: grid; grid-template-columns: minmax(0,1fr) auto minmax(0,1fr); align-items: center; gap: 8px;
    border: 1px solid #edf2f7; border-radius: 14px; padding: 8px 10px; background: #f8fafc;
  }
  .cmp-filter-dates span { color: var(--muted); font-size: .82rem; font-weight: 800; }
  .cmp-filter-card--month { min-width: 220px; }
  
  .cmp-toolbar-actions { display:grid; gap:10px; grid-template-columns: 1fr; }
  .cmp-btn {
    height: 50px; border-radius: 14px; border: 1px solid transparent; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; gap: 10px; font-weight: 900; font-size: .95rem;
  }
  .cmp-btn--primary {
    background: linear-gradient(135deg, #2563eb 0%, #0ea5e9 100%); color: #fff;
    box-shadow: 0 18px 28px rgba(37,99,235,.22);
  }
  .cmp-btn--ghost { background: #fff; color: var(--text); border-color: var(--line); }
  .cmp-mini-btn {
    height: 38px; padding: 0 12px; border-radius: 12px; border: 1px solid #dbe3ee; background: #fff; color: var(--text);
    font-weight: 800; cursor: pointer;
  }
  .cmp-toggle-link {
    height: 40px; padding: 0 12px; border-radius: 12px; border: 1px solid #dbe3ee; background: #fff; color: var(--text);
    font-weight: 800; cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  }
  .cmp-toolbar-meta { display:flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
  .cmp-status-wrap { display:grid; gap: 4px; }
  .cmp-status { font-weight: 800; font-size: .92rem; }
  .cmp-status--neutral { color: #475569; }
  .cmp-status--loading { color: var(--primary); }
  .cmp-status--success { color: #166534; }
  .cmp-status--error { color: #991b1b; }
  .cmp-context-line { color: var(--muted); font-size: .92rem; font-weight: 700; }
  
  .cmp-scope-card { padding: 16px 18px; display: grid; gap: 14px; }
  .cmp-scope-head { display:flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
  .cmp-panel-kicker { color: var(--muted); font-size: .76rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
  .cmp-scope-head h2,
  .cmp-panel-head h2 { margin: 6px 0 4px; font-size: 1.12rem; line-height: 1.15; letter-spacing: -.03em; }
  .cmp-scope-head p { margin: 0; color: #475569; font-weight: 700; }
  .cmp-scope-actions { display:flex; gap:10px; flex-wrap: wrap; }
  .cmp-scope-body { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cmp-block-card {
    border: 1px solid var(--line-soft); border-radius: 18px; background: #fbfdff; padding: 14px;
  }
  .cmp-block-head { display:flex; align-items:center; justify-content:space-between; gap: 12px; margin-bottom: 12px; }
  .cmp-block-kicker { display:inline-flex; padding: 4px 9px; border-radius: 999px; background: rgba(37,99,235,.08); color: var(--primary); font-size: .7rem; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; }
  .cmp-block-head h3 { margin: 8px 0 0; font-size: .98rem; }
  .cmp-block-select { border: none; background: transparent; color: var(--primary); font-weight: 800; cursor: pointer; }
  .cmp-city-stack { display:grid; gap: 10px; }
  .cmp-city-card { border: 1px solid #e6edf6; border-radius: 14px; padding: 11px; background: #fff; }
  .cmp-city-card header { display:flex; justify-content:space-between; align-items:center; gap: 10px; margin-bottom: 8px; }
  .cmp-city-name { font-weight: 800; font-size: .9rem; }
  .cmp-city-count { color: var(--muted); font-size: .78rem; font-weight: 700; }
  .cmp-check-grid { display:grid; gap: 8px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .cmp-check-item {
    display:flex; gap:8px; align-items:center; border:1px solid #e6edf6; border-radius: 12px; padding: 7px 9px; background: #fff;
    font-size: .8rem; font-weight: 700; color: #334155;
  }
  .cmp-check-item input { accent-color: var(--primary); }
  
  .cmp-kpi-grid { display:grid; gap: 14px; grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .cmp-kpi-card { padding: 18px 18px 20px; position: relative; overflow: hidden; min-height: 162px; }
  .cmp-kpi-card::before {
    content:''; position: absolute; left: 0; right: 0; top: 0; height: 6px;
  }
  .cmp-kpi-card--blue::before { background: linear-gradient(90deg, #1d4ed8, #3b82f6); }
  .cmp-kpi-card--cyan::before { background: linear-gradient(90deg, #0284c7, #22d3ee); }
  .cmp-kpi-card--amber::before { background: linear-gradient(90deg, #d97706, #f59e0b); }
  .cmp-kpi-card--slate::before { background: linear-gradient(90deg, #334155, #0f172a); }
  .cmp-kpi-card--green::before { background: linear-gradient(90deg, #15803d, #22c55e); }
  .cmp-kpi-card--red::before { background: linear-gradient(90deg, #b91c1c, #ef4444); }
  .cmp-kpi-label { display:block; margin-top: 6px; color: var(--muted); font-size: .78rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
  .cmp-kpi-value { display:block; margin-top: 16px; font-size: clamp(1.85rem, 2.25vw, 2.35rem); line-height: 1; letter-spacing: -.05em; font-weight: 900; }
  .cmp-kpi-value--name { font-size: 1.22rem; line-height: 1.15; }
  .cmp-kpi-value--trend { font-size: 1.55rem; }
  .cmp-card-meta { display:block; margin-top: 12px; color: #475569; font-size: .9rem; font-weight: 700; line-height: 1.45; }
  .cmp-card-meta--better { color: #166534; }
  .cmp-card-meta--worse { color: #991b1b; }
  .cmp-card-meta--stable { color: #475569; }
  
  .cmp-panel-card { padding: 20px 22px; }
  .cmp-panel-card--chart { padding-bottom: 16px; }
  .cmp-panel-card--compact { min-height: 100%; }
  .cmp-panel-head { display:flex; justify-content:space-between; gap: 12px; align-items:flex-start; margin-bottom: 16px; }
  .cmp-chart-wrap { height: 440px; }
  .cmp-insights-grid { display:grid; gap: 16px; grid-template-columns: 1.15fr 1fr 1fr; align-items: stretch; }
  
  .cmp-insights-list { list-style:none; padding:0; margin:0; display:grid; gap:10px; }
  .cmp-insights-list li {
    border: 1px solid #e5edf5; border-radius: 16px; padding: 14px 16px;
    background: linear-gradient(180deg, #fff 0%, #f8fbff 100%);
    color: #334155; font-weight: 700; line-height: 1.55;
  }
  
  .cmp-rank-list { display:grid; gap: 10px; }
  .cmp-rank-item {
    display:grid; grid-template-columns: 42px minmax(0,1fr) auto; gap: 12px; align-items:center;
    border: 1px solid #e5edf5; border-radius: 16px; padding: 12px 14px; background: #fff;
  }
  .cmp-rank-index {
    width: 42px; height: 42px; border-radius: 14px; display:grid; place-items:center;
    background: #f8fafc; color: var(--text); font-weight: 900;
  }
  .cmp-rank-title { font-weight: 800; }
  .cmp-rank-sub { margin-top: 4px; color: var(--muted); font-size: .83rem; font-weight: 700; }
  .cmp-rank-badge {
    height: 38px; border-radius: 999px; display:inline-flex; align-items:center; gap:8px; padding: 0 12px; font-weight: 900; white-space: nowrap;
  }
  .cmp-rank-badge--better, .cmp-pill--better, .cmp-trend-text--better { color: #166534; }
  .cmp-rank-badge--worse, .cmp-pill--worse, .cmp-trend-text--worse { color: #991b1b; }
  .cmp-rank-badge--stable, .cmp-pill--stable, .cmp-trend-text--stable { color: #475569; }
  .cmp-rank-badge--better { background: var(--success-soft); }
  .cmp-rank-badge--worse { background: var(--danger-soft); }
  .cmp-rank-badge--stable { background: #eef2f7; }
  .cmp-empty-state {
    border: 1px dashed #cbd5e1; border-radius: 16px; padding: 16px; text-align:center;
    color: var(--muted); font-weight: 700; background: #f8fafc;
  }
  
  .cmp-table-wrap { overflow:auto; border-radius: 18px; border: 1px solid #e5edf5; }
  .cmp-table { width: 100%; border-collapse: collapse; min-width: 960px; background: #fff; }
  .cmp-table thead th {
    background: #f8fbff; color: #475569; font-size: .76rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 900;
    text-align: left; padding: 14px 16px; border-bottom: 1px solid #e5edf5;
  }
  .cmp-table tbody td { padding: 14px 16px; border-bottom: 1px solid #eef2f7; font-weight: 700; vertical-align: top; }
  .cmp-table-main { font-weight: 800; }
  .cmp-table-sub { margin-top: 5px; color: #64748b; font-size: .82rem; font-weight: 700; }
  .cmp-pill { display:inline-flex; align-items:center; justify-content:center; min-width: 82px; height: 34px; border-radius: 999px; font-weight: 900; }
  .cmp-pill--better { background: var(--success-soft); }
  .cmp-pill--worse { background: var(--danger-soft); }
  .cmp-pill--stable { background: #eef2f7; }
  .cmp-empty-row { text-align:center; color: var(--muted); background: #fbfdff; }
  
  .cmp-footer { padding: 20px 0 32px; color: var(--muted); }
  .cmp-footer-inner { display:flex; justify-content:space-between; gap: 16px; flex-wrap: wrap; font-weight: 700; }
  
  .cmp-dialog {
    border: none; border-radius: 24px; padding: 0; width: min(560px, calc(100vw - 24px));
    background: transparent;
  }
  .cmp-dialog::backdrop { background: rgba(15,23,42,.5); backdrop-filter: blur(4px); }
  .cmp-dialog-card { padding: 18px; }
  .cmp-dialog-head { display:flex; justify-content:space-between; align-items:flex-start; gap: 12px; margin-bottom: 14px; }
  .cmp-dialog-head h2 { margin: 6px 0 0; }
  .cmp-dialog-close {
    width: 40px; height: 40px; border-radius: 12px; border: 1px solid #dbe3ee; background: #fff; cursor: pointer;
  }
  .cmp-dialog-grid { display:grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cmp-dialog-actions { margin-top: 14px; display:flex; justify-content:flex-end; }
  
  @media (max-width: 1360px) {
    .cmp-toolbar-grid { grid-template-columns: 1fr 1fr; }
    .cmp-kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .cmp-insights-grid { grid-template-columns: 1fr; }
  }
  
  @media (max-width: 980px) {
    .cmp-container { width: min(100vw - 20px, 1520px); }
    .cmp-header-inner,
    .cmp-scope-head,
    .cmp-toolbar-meta { align-items:flex-start; }
    .cmp-scope-body { grid-template-columns: 1fr; }
    .cmp-check-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  }
  
  @media (max-width: 720px) {
    .cmp-main { padding-top: 14px; }
    .cmp-header-actions,
    .cmp-toolbar-grid,
    .cmp-dialog-grid,
    .cmp-kpi-grid,
    .cmp-check-grid { grid-template-columns: 1fr; }
    .cmp-toolbar-grid { display:grid; }
    .cmp-header-link, button.cmp-header-link { width: 100%; }
    .cmp-filter-dates { grid-template-columns: 1fr; }
    .cmp-chart-wrap { height: 340px; }
  }
  
  @media print {
    .no-print,
    .cmp-footer { display: none !important; }
    body { background: #fff; }
    .cmp-container { width: 100%; }
    .cmp-main { padding: 0; }
    .cmp-shell { gap: 12px; }
    .cmp-toolbar-card,
    .cmp-scope-card,
    .cmp-kpi-card,
    .cmp-panel-card { box-shadow: none; border: 1px solid #dbe4ef; }
  }
  

.cmp-block-card--partial {
  border-color: rgba(245, 158, 11, .32);
  box-shadow: 0 10px 24px rgba(245, 158, 11, .08);
}
.cmp-block-toggle {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
  cursor: pointer;
}
.cmp-block-toggle-main {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.cmp-block-toggle input {
  margin-top: 6px;
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}
.cmp-block-summary {
  margin: 8px 0 0;
  color: #64748b;
  font-size: .84rem;
  font-weight: 700;
}
.cmp-block-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  height: 34px;
  padding: 0 10px;
  border-radius: 999px;
  background: #eff6ff;
  color: #1d4ed8;
  font-weight: 900;
  font-size: .85rem;
}
.cmp-city-card--compact {
  padding: 10px 11px;
}
.cmp-city-alims {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.cmp-alim-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: #f8fafc;
  border: 1px solid #e6edf6;
  color: #475569;
  font-size: .78rem;
  font-weight: 800;
}
.cmp-alim-pill--selected {
  background: rgba(37, 99, 235, .10);
  border-color: rgba(37, 99, 235, .25);
  color: #1d4ed8;
}
@media (max-width: 980px) {
  .cmp-block-toggle {
    flex-direction: column;
  }
  .cmp-block-count {
    align-self: flex-start;
  }
}
