@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Manrope:wght@600;700;800&display=swap');

:root {
  color-scheme: light;
  --page: #f5f6fc;
  --surface: #fff;
  --ink: #18233f;
  --muted: #63718c;
  --line: #e7eaf4;
  --primary: #6147f5;
  --primary-hover: #2340d8;
  --primary-soft: #eef1ff;
  --danger: #c6394e;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Manrope', var(--font);
  --radius: 20px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); font: 400 14px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; }
button, a, input, select, summary { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; border: 0; }
button:disabled { cursor: wait; opacity: .5; }
button, summary { touch-action: manipulation; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
h1 { font: 800 30px/1.2 var(--display); letter-spacing: -1px; }
h2 { font: 800 17px/1.4 var(--display); letter-spacing: -.35px; }
h3 { font-size: 14px; font-weight: 650; }
p { font-size: 14px; color: var(--muted); }
strong { font-weight: 650; }
.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; flex-shrink: 0; }
[data-icon] { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.hidden, [hidden] { display: none !important; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.skip-link { position: fixed; left: 20px; top: -70px; z-index: 1000; padding: 12px 20px; background: var(--surface); border: 2px solid var(--primary); border-radius: 9px; }
.skip-link:focus { top: 16px; }
.primary, .secondary, .text-button, .icon-btn, .danger-button, .danger-link { display: inline-flex; align-items: center; justify-content: center; gap: 9px; white-space: nowrap; transition: background .18s, box-shadow .18s, transform .18s; }
.primary { background: var(--primary); color: var(--on-primary); min-height: 46px; padding: 12px 20px; border-radius: 12px; font-weight: 650; box-shadow: 0 5px 12px #3454f51c; }
.primary:hover { background: var(--primary-hover); box-shadow: 0 6px 18px #3454f52e; }
.primary:active, .danger-button:active { transform: translateY(1px); }
.primary .icon { width: 18px; height: 18px; stroke-width: 2; }
.secondary { background: var(--surface); border: 1px solid var(--line); padding: 11px 17px; border-radius: 11px; min-height: 44px; color: var(--muted); font-weight: 550; }
.secondary:hover, .icon-btn:hover { background: var(--soft); }
.text-button { background: transparent; color: var(--primary); font-weight: 600; padding: 8px 0; font-size: 14px; }
.text-button:hover { color: var(--primary-hover); }
.icon-btn { background: transparent; color: var(--muted); width: 40px; height: 40px; border-radius: 11px; flex-shrink: 0; }
.full { width: 100%; }
.danger-button { background: var(--danger); color: var(--on-primary); padding: 11px 20px; border-radius: 11px; min-height: 44px; font-weight: 650; }
.danger-button:hover { background: #bf3c4d; }
.danger-link { background: transparent; color: var(--danger); font-weight: 600; padding: 14px; border-radius: 11px; }
.danger-link:hover { background: var(--danger-soft); }
input, select { min-width: 0; min-height: 46px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); color: var(--ink); padding: 12px 14px; outline: 0; }
input:focus, select:focus { border-color: var(--focus); box-shadow: 0 0 0 3px #3454f50a; }
input::placeholder { color: var(--muted); }
input[readonly] { background: var(--soft); }
label { display: flex; flex-direction: column; gap: 9px; font-weight: 550; color: var(--muted); }
label small { font-size: 12px; font-weight: 400; color: var(--muted); line-height: 1.65; }

.source-logo { display: inline-flex; width: 42px; height: 42px; border-radius: 12px; overflow: hidden; flex-shrink: 0; background: var(--soft); box-shadow: 0 0 0 1px #14244006; }
.source-logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.source-name { display: flex; flex-direction: column; gap: 2px; line-height: 1.3; min-width: 0; }
.source-name strong { font-size: 14px; font-weight: 650; letter-spacing: .1px; }
.source-name small { color: var(--muted); font-size: 12px; font-weight: 400; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.filter-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 26px; }
.quick-periods { display: flex; padding: 4px; border-radius: 11px; background: var(--soft); gap: 2px; }
.quick-chip { min-height: 33px; padding: 6px 15px; border-radius: 8px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 500; }
.quick-chip.active { background: var(--surface); color: var(--muted); box-shadow: 0 2px 5px #1827440a; }
.date-picker { position: relative; }
.date-picker summary { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); color: var(--muted); min-height: 42px; padding: 10px 13px; list-style: none; cursor: pointer; font-size: 13px; }
.date-picker summary::-webkit-details-marker { display: none; }
.date-picker summary .icon { width: 16px; height: 16px; color: var(--muted); }
.date-popover { position: absolute; top: calc(100% + 9px); left: 0; z-index: 30; min-width: 280px; display: grid; gap: 13px; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 16px 50px #2137761c; }
.date-popover small { color: var(--muted); font-size: 12px; }
.filter-spacer { flex: 1; }
.refresh-button { background: var(--surface); border: 1px solid var(--line); width: 42px; height: 42px; }
.active-brand { display: flex; align-items: center; gap: 9px; min-height: 42px; padding: 5px 11px 5px 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; color: var(--primary); }
.active-brand .source-logo { width: 28px; height: 28px; border-radius: 8px; }
.active-brand .source-name { flex-direction: row; gap: 4px; align-items: baseline; }
.active-brand .source-name strong, .active-brand .source-name small { font-size: 12px; }
.active-brand .icon { width: 14px; height: 14px; }
.error-banner { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border: 1px solid var(--line); background: var(--danger-soft); border-radius: 13px; color: var(--danger); margin-bottom: 24px; }
.error-banner #dataErrorMessage { flex: 1; }
.error-banner .text-button { color: inherit; }
.workspace-content { display: grid; gap: 23px; }

/* Shared dashboard and per-link analytics components. */
.kpi-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 18px; }
.kpi { padding: 23px 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); position: relative; min-height: 155px; overflow: hidden; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.kpi .label { color: var(--muted); font-size: 14px; font-weight: 500; }
.kpi-icon { display: grid; place-items: center; height: 32px; width: 32px; background: var(--soft); color: var(--muted); border-radius: 10px; }
.kpi-icon .icon { width: 18px; height: 18px; }
.kpi .value { font: 800 40px/1.2 var(--display); letter-spacing: -1.6px; margin-top: 16px; font-variant-numeric: tabular-nums; position: relative; z-index: 1; }
.kpi .hint { color: var(--muted); font-size: 12px; margin-top: 5px; }
.panel-grid { display: grid; gap: 23px; }
.traffic-grid { grid-template-columns: minmax(0,2.05fr) minmax(285px,1fr); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: 0 3px 8px #182b5b02; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 24px 25px 0; }
.panel-head > .muted .icon { width: 18px; height: 18px; }
.legend { display: flex; gap: 17px; align-items: center; font-size: 12px; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 7px; }
.legend i { width: 7px; height: 7px; border-radius: 50%; }
.legend-hit { background: var(--chart-hit); }
.legend-unique { background: var(--chart-unique); }
.chart-summary { display: flex; align-items: baseline; gap: 10px; padding: 22px 25px 0; }
.chart-summary strong { font: 800 32px/1.2 var(--display); letter-spacing: -1px; }
.chart-summary span { color: var(--muted); font-size: 12px; }
.line-chart-wrap { height: 255px; padding: 19px 20px 18px; }
.line-chart-wrap svg { display: block; width: 100%; height: 100%; overflow: visible; }
.grid-line { stroke: var(--line); stroke-dasharray: 3 5; }
.axis { fill: var(--muted); font: 12px var(--font); }
.line-hit { fill: none; stroke: var(--chart-hit); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.line-unique { fill: none; stroke: var(--chart-unique); stroke-width: 2; stroke-dasharray: 5 5; stroke-linecap: round; }
.area-hit { fill: url(#areaGradient); }
.chart-point { fill: transparent; stroke: none; }
.chart-point:focus { fill: var(--chart-hit); outline: 0; }
.donut-layout { padding: 23px 26px 26px; }
.donut-wrap { width: 155px; height: 155px; position: relative; margin: 0 auto 24px; }
.donut { width: 100%; height: 100%; border-radius: 50%; background: var(--soft); transform: rotate(-90deg); }
.donut:after { content: ''; position: absolute; inset: 17px; background: var(--surface); border-radius: 50%; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut-center strong { font: 800 29px/1.3 var(--display); letter-spacing: -1px; }
.donut-center span { color: var(--muted); font-size: 12px; }
.device-legend { display: grid; gap: 10px; }
.device-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.device-row > i { width: 7px; height: 7px; border-radius: 50%; }
.device-row > span { flex: 1; color: var(--muted); }
.device-row strong { font-size: 13px; font-weight: 600; }
.device-row small { color: var(--muted); font-size: 12px; min-width: 30px; text-align: right; }
.dashboard-insights { display: grid; grid-template-columns: minmax(0,1.62fr) minmax(300px,1fr); gap: 23px; }
.map-note { color: var(--muted); font-size: 12px; }
.world-map { height: 310px; min-height: 310px; margin: 20px 24px 0; border-radius: 14px; background: var(--soft); z-index: 0; }
.map-loading { height: 100%; min-height: 310px; display: grid; place-items: center; padding: 20px; text-align: center; color: var(--muted); font-size: 14px; }
.geo-rankings { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; padding: 24px; }
.mini-section { min-width: 0; }
.mini-section h3 { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.rank-list { max-height: 214px; overflow: auto; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.rank-row { display: flex; align-items: center; gap: 9px; padding: 11px 0; font-size: 13px; border-bottom: 1px solid var(--line); }
.rank-row .rank { width: 14px; font-size: 12px; color: var(--muted); flex-shrink: 0; }
.rank-row .name { flex: 1; overflow-wrap: anywhere; }
.rank-row strong { font-size: 13px; margin-right: 4px; }
.brand-overview { display: grid; gap: 0; padding: 12px 25px 18px; }
.brand-card { display: grid; grid-template-columns: 1fr auto; gap: 0 15px; background: transparent; padding: 18px 0; text-align: left; border-bottom: 1px solid var(--line); color: var(--ink); }
.brand-card:last-child { border: 0; }
.brand-card:hover .source-name strong, .brand-card.active .source-name strong { color: var(--primary); }
.brand-name { display: flex; align-items: center; gap: 12px; }
.brand-name .source-logo { width: 40px; height: 40px; border-radius: 11px; }
.brand-arrow { display: none; }
.brand-card-metrics { display: grid; grid-template-columns: auto auto; align-items: baseline; column-gap: 5px; text-align: right; }
.brand-card-metrics strong { font: 800 21px/1.3 var(--display); letter-spacing: -.5px; }
.brand-card-metrics > span { font-size: 12px; color: var(--muted); }
.brand-card-metrics small { font-size: 12px; color: var(--muted); grid-column: 1/-1; }
.brand-meter { grid-column: 1/-1; height: 3px; border-radius: 3px; margin-top: 13px; background: var(--soft); overflow: hidden; }
.brand-meter i { display: block; height: 100%; border-radius: 3px; }
.lower-grid { grid-template-columns: 1fr 1fr; }
.bar-list, .activity-list { padding: 15px 25px 24px; }
.bar-row { display: grid; grid-template-columns: 1fr 1fr 40px; align-items: center; gap: 15px; margin: 19px 0; font-size: 14px; }
.bar-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row strong { text-align: right; font-size: 13px; }
.bar-track { height: 6px; background: var(--soft); border-radius: 6px; }
.bar-fill { height: 100%; background: var(--chart-hit); border-radius: 6px; }
.activity-item { display: flex; align-items: flex-start; gap: 12px; padding: 13px 0; }
.activity-icon { display: grid; place-items: center; width: 33px; height: 33px; background: var(--primary-soft); color: var(--primary); border-radius: 10px; flex-shrink: 0; }
.activity-icon .icon { width: 16px; height: 16px; }
.activity-title { font-size: 13px; font-weight: 600; }
.activity-sub { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; margin-top: 3px; }
.activity-time { font-size: 12px; color: var(--muted); margin-left: auto; white-space: nowrap; }

/* Links are the primary work surface, with copy, edit and permitted delete actions. */
.links-head { padding-bottom: 21px; border-bottom: 1px solid var(--line); }
.count-badge { display: inline-flex; align-items: center; justify-content: center; background: var(--primary-soft); color: var(--primary); font-size: 12px; font-weight: 600; padding: 2px 7px; min-width: 24px; border-radius: 6px; vertical-align: middle; margin-left: 6px; }
.result-count { font-size: 12px; color: var(--muted); }
.link-toolbar { display: flex; align-items: center; gap: 12px; padding: 22px 25px; }
.search-field { display: flex; flex-direction: row; align-items: center; gap: 10px; flex: 1; max-width: 470px; padding: 0 13px; border: 1px solid var(--line); border-radius: 11px; background: var(--soft); }
.search-field .icon { width: 18px; height: 18px; color: var(--muted); }
.search-field input { width: 100%; border: 0; background: transparent; min-height: 43px; padding: 10px 0; font-size: 14px; box-shadow: none; }
.search-field:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3px #3454f508; }
.search-field kbd { font: 12px var(--font); color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; }
.link-toolbar select { font-size: 13px; min-height: 43px; color: var(--muted); padding: 9px 27px 9px 12px; }
.link-toolbar > #linkRefresh { margin-left: auto; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 14px; }
thead { background: var(--soft); color: var(--muted); }
th { font-size: 12px; font-weight: 500; padding: 13px 16px; white-space: nowrap; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { padding-left: 25px; }
th:last-child, td:last-child { padding-right: 25px; }
td { padding: 21px 16px; border-bottom: 1px solid var(--line); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--soft); }
.number-cell { text-align: right; font-variant-numeric: tabular-nums; }
.number-cell strong { font-weight: 650; }
.link-identity { display: flex; align-items: center; gap: 13px; min-width: 215px; }
.link-symbol { display: grid; place-items: center; height: 38px; width: 38px; border: 1px solid var(--line); color: var(--primary); background: var(--primary-soft); border-radius: 12px; flex-shrink: 0; }
.link-symbol .icon { width: 18px; height: 18px; }
.link-text { min-width: 0; max-width: 335px; }
.link-name { display: block; max-width: 100%; text-align: left; font-size: 14px; font-weight: 600; background: transparent; color: var(--ink); padding: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-name:hover { color: var(--primary); }
.short-url { display: block; font-size: 12px; color: var(--primary); margin-top: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.short-url:hover { color: var(--primary); text-decoration: underline; }
.destination { display: block; max-width: 335px; font-size: 12px; color: var(--muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.source-pill { display: flex; align-items: center; gap: 9px; white-space: nowrap; color: var(--muted); }
.source-pill .source-logo { width: 34px; height: 34px; border-radius: 10px; }
.source-pill .source-name strong { font-size: 12px; }
.status-pill { display: inline-flex; gap: 6px; align-items: center; padding: 5px 9px; font-size: 12px; font-weight: 500; border-radius: 7px; white-space: nowrap; }
.status-pill:before { content: ''; height: 5px; width: 5px; border-radius: 50%; background: currentColor; }
.status-pill.active { color: var(--success); background: var(--success-soft); }
.status-pill.disabled { color: var(--warning); background: var(--warning-soft); }
.status-pill.archived { color: var(--muted); background: var(--line); }
.row-actions { display: flex; justify-content: flex-end; gap: 2px; }
.row-actions .icon-btn { width: 34px; height: 37px; }
.row-actions .icon { width: 17px; height: 17px; }
.delete-link-button { color: var(--danger); }
.delete-link-button:hover { background: var(--danger-soft); color: var(--danger); }
.table-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); padding: 15px 25px; font-size: 12px; color: var(--muted); }
.table-footer > .muted { color: var(--muted); font-size: 11px; letter-spacing: 1.5px; font-weight: 600; }
.pagination { display: flex; gap: 10px; align-items: center; }
.pagination button { display: grid; place-items: center; min-height: 34px; min-width: 34px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); border-radius: 8px; }
.pagination button:disabled { cursor: default; opacity: .35; }
.pagination .icon { width: 14px; height: 14px; }
.empty { display: grid; place-items: center; padding: 28px 15px; color: var(--muted); font-size: 14px; text-align: center; }
.empty-state { display: flex; align-items: center; flex-direction: column; padding: 80px 20px 90px; text-align: center; }
.empty-state > .icon { box-sizing: content-box; width: 32px; height: 32px; padding: 20px; color: var(--primary); background: var(--primary-soft); border: 1px solid var(--line); border-radius: 23px; margin-bottom: 24px; box-shadow: 0 7px 0 var(--soft); transform: rotate(-5deg); }
.empty-state h3 { color: var(--muted); font: 700 18px var(--display); margin-bottom: 8px; }
.empty-state p { color: var(--muted); font-size: 14px; margin-bottom: 15px; }
.empty-state p:empty { display: none; }
.empty-state .primary, .empty-state .secondary { margin-top: 16px; }
.page-footer { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-top: 23px; color: var(--muted); font-size: 12px; }
.connection-status { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.connection-status i { width: 5px; height: 5px; border-radius: 50%; background: #aebbd1; }
.connection-status[data-state=online] i { background: var(--success); }
.connection-status[data-state=error], .connection-status[data-state=error] i { color: var(--danger); }
.connection-status[data-state=error] i { background: var(--danger); }

/* Creation, editing and deletion use a single visual system. */
dialog { color: var(--ink); background: var(--surface); border: 1px solid var(--line); padding: 0; max-height: calc(100dvh - 40px); overflow: auto; box-shadow: 0 25px 100px #15294d33; }
dialog::backdrop { background: #1724487a; backdrop-filter: blur(6px); }
body:has(dialog[open]) { overflow: hidden; }
.modal-card { width: min(510px,calc(100% - 32px)); padding: 30px; border-radius: 25px; }
.create-card { width: min(610px,calc(100% - 32px)); padding: 32px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; margin-bottom: 25px; }
.modal-head h2 { font-size: 25px; margin-top: 7px; }
.dialog-eyebrow { display: block; font-size: 11px; letter-spacing: 1.8px; font-weight: 650; color: var(--muted); }
.dialog-symbol { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 15px; background: var(--primary-soft); color: var(--primary); }
.success-symbol { background: var(--success-soft); color: var(--success); }
.danger-symbol { background: var(--danger-soft); color: var(--danger); }
.modal-card > h2, .drawer-card > h2 { font: 800 26px/1.3 var(--display); letter-spacing: -.8px; margin-bottom: 25px; overflow-wrap: anywhere; }
.form-stack { display: grid; gap: 21px; }
.form-stack input, .form-stack select { width: 100%; font-size: 16px; }
.source-fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.source-fieldset legend { font-size: 14px; font-weight: 550; color: var(--muted); padding: 0; margin-bottom: 10px; }
.source-picker { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; }
.source-option { cursor: pointer; position: relative; }
.source-option input { position: absolute; height: 1px; width: 1px !important; min-height: 0; opacity: 0; padding: 0; pointer-events: none; }
.source-option-content { display: flex; flex-direction: column; align-items: flex-start; gap: 11px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); position: relative; }
.source-option-content .source-logo { width: 37px; height: 37px; border-radius: 10px; }
.source-option-content .source-name { flex-direction: row; gap: 4px; flex-wrap: wrap; align-items: baseline; }
.source-option-content .source-name strong, .source-option-content .source-name small { font-size: 12px; }
.source-option:hover .source-option-content { background: #fbfcff; border-color: var(--focus); }
.source-option input:checked + .source-option-content { background: var(--primary-soft); border-color: var(--focus); box-shadow: 0 0 0 1px var(--focus); }
.source-option input:focus-visible + .source-option-content { outline: 3px solid var(--focus); outline-offset: 3px; }
.source-check { position: absolute; top: 15px; right: 12px; color: var(--primary); opacity: 0; }
.source-check .icon { height: 15px; width: 15px; }
.source-option input:checked + .source-option-content .source-check { opacity: 1; }
.short-preview { background: var(--soft); border: 1px dashed var(--line); padding: 15px 17px; border-radius: 12px; min-width: 0; }
.short-preview > span { font-size: 12px; color: var(--muted); }
.short-preview strong { display: block; margin-top: 6px; font-size: 14px; color: var(--muted); font-weight: 500; overflow-wrap: anywhere; }
.modal-actions { display: flex; align-items: center; justify-content: flex-end; gap: 11px; padding-top: 7px; }
.form-error { color: var(--danger); font-size: 14px; line-height: 1.6; }
.form-error:empty { display: none; }
.success-card > label { margin-bottom: 21px; }
.success-card > .text-button { margin-top: 14px; }
.drawer-card { position: fixed; inset: 12px 12px 12px auto; width: min(500px,calc(100% - 24px)); height: calc(100dvh - 24px); max-height: calc(100dvh - 24px); margin: 0; border-radius: 24px; padding: 30px; }
.drawer-card .modal-head { align-items: center; margin-bottom: 14px; }
.copy-field, .password-field { display: flex; align-items: center; position: relative; }
.copy-field input, .password-field input { width: 100%; padding-right: 48px; }
.copy-field .icon-btn, .password-field .icon-btn { position: absolute; right: 4px; top: 3px; }
.edit-url-label { background: var(--soft); padding: 14px; border: 1px solid var(--line); border-radius: 14px; color: var(--muted); font-size: 12px; }
.edit-url-label input { background: var(--surface); font-size: 13px; color: var(--primary); }
.drawer-block { padding-top: 27px; margin-top: 28px; border-top: 1px solid var(--line); }
.drawer-block h3 { font: 800 16px var(--display); }
.history-list { margin-top: 21px; }
.history-item { border-left: 1px solid var(--line); padding: 0 0 20px 18px; margin-left: 5px; position: relative; }
.history-item:before { content: ''; position: absolute; left: -4px; top: 7px; height: 7px; width: 7px; background: #a5b7e4; border: 2px solid var(--surface); border-radius: 50%; box-sizing: content-box; }
.history-item strong { display: block; font-size: 13px; font-weight: 500; overflow-wrap: anywhere; }
.history-item span { color: var(--muted); font-size: 12px; }
#deleteFromDrawer { margin-top: 25px; border: 1px solid var(--line); }
.delete-target { display: flex; flex-direction: column; gap: 5px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--soft); margin-bottom: 17px; overflow-wrap: anywhere; }
.delete-target strong { font-size: 15px; }
.delete-target span { font-size: 12px; color: var(--muted); }
.dialog-description { color: var(--muted); font-size: 14px; line-height: 1.7; margin-bottom: 23px; }
#deleteError { margin-bottom: 13px; }
.toast { position: fixed; bottom: 26px; left: 50%; transform: translate(-50%,20px); background: #263d72; color: var(--on-primary); box-shadow: 0 10px 35px #21365f26; border-radius: 13px; padding: 14px 22px; opacity: 0; pointer-events: none; z-index: 200; transition: opacity .2s,transform .2s; max-width: calc(100% - 32px); font-size: 14px; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%,0); }
.toast[popover] { inset: auto; margin: 0; border: 0; bottom: 26px; left: 50%; overflow: visible; }
.boot-layer { position: fixed; inset: 0; z-index: 90; display: flex; gap: 22px; align-items: center; justify-content: center; background: var(--page); }
.spinner { height: 18px; width: 18px; border: 2px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
.login-layer { position: fixed; inset: 0; z-index: 80; display: grid; grid-template-columns: 1fr 1fr; background: var(--surface); overflow: auto; }
.login-art { min-height: 100dvh; background: radial-gradient(ellipse at 75% 35%,#5e7bff,transparent 70%),var(--chart-hit); padding: 48px; display: flex; flex-direction: column; align-items: center; position: relative; overflow: hidden; }
.login-wordmark { align-self: flex-start; width: 226px; height: auto; position: relative; z-index: 1; }
.login-emblem { flex: 1; width: 100%; display: grid; place-items: center; position: relative; min-height: 330px; }
.login-emblem > img { width: clamp(150px,19vw,280px); height: auto; transform: rotate(-12deg); border-radius: 28%; box-shadow: 0 35px 80px #142baf60,0 0 0 1px #ffffff12; position: relative; z-index: 1; }
.emblem-orbit { position: absolute; width: 75%; aspect-ratio: 1; max-width: 420px; border: 1px solid #ffffff13; border-radius: 30%; transform: rotate(-12deg); }
.orbit-two { width: 110%; max-width: 610px; border-color: #ffffff0e; }
.login-sources { display: flex; gap: 15px; position: relative; z-index: 1; }
.login-sources img { width: 42px; height: 42px; border-radius: 12px; box-shadow: 0 5px 15px #1b33ad25; }
.login-form-wrap { display: flex; align-items: center; justify-content: center; padding: 55px; }
.login-card { width: min(385px,100%); }
.login-card h1 { font-size: 36px; margin-bottom: 37px; }
.login-card label { margin-bottom: 23px; font-size: 14px; }
.login-card input { font-size: 16px; min-height: 49px; }
.login-card > .primary { min-height: 50px; margin-top: 13px; justify-content: space-between; }
.login-card .form-error { margin-bottom: 12px; }
.login-mobile-logo { display: none; }
.skeleton { background: linear-gradient(100deg,var(--surface) 20%,var(--soft) 45%,var(--surface) 65%); background-size: 220% 100%; animation: shimmer 1.7s infinite; }
.refreshing .refresh-button .icon { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position: -200% 0; } }

@media(min-width:1600px) {
  .line-chart-wrap { height: 290px; }
  .donut-wrap { width: 170px; height: 170px; }
  .kpi { min-height: 165px; }
}
@media(max-width:1200px) {
  .traffic-grid { grid-template-columns: minmax(0,1.8fr) minmax(270px,1fr); }
  .kpi { padding: 21px; }
  .kpi .value { font-size: 36px; }
  .dashboard-insights { grid-template-columns: minmax(0,1.3fr) minmax(300px,1fr); }
  .brand-card-metrics > span { display: none; }
  .brand-card-metrics small { font-size: 12px; }
  .visitors-column { display: none; }
  table { min-width: 960px; }
  .link-text { max-width: 275px; }
}
@media(max-width:1000px) {
  .kpi-grid { gap: 13px; }
  .kpi { padding: 18px; min-height: 146px; }
  .kpi .value { font-size: 34px; }
  .kpi .label { font-size: 13px; }
  .panel-head { padding: 22px 21px 0; }
  .dashboard-insights { grid-template-columns: 1fr; }
  .brand-overview { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 0 24px; }
  .brand-card:nth-last-child(-n+2) { border: 0; }
  .world-map { height: 350px; min-height: 350px; }
  .login-art { padding: 38px; }
  .login-form-wrap { padding: 40px; }
  .login-sources { gap: 10px; }
  .login-sources img { width: 35px; height: 35px; border-radius: 10px; }
}
@media(max-width:800px) {
  .page-heading { margin-bottom: 21px; gap: 10px; }
  .page-heading h1 { font-size: 25px; letter-spacing: -.8px; }
  .page-heading > .primary { min-height: 42px; font-size: 13px; gap: 7px; padding: 11px 14px; }
  .filter-bar { gap: 9px; margin-bottom: 21px; }
  .quick-chip { padding: 6px 11px; font-size: 12px; }
  .date-picker summary { font-size: 12px; padding: 10px; gap: 7px; }
  .date-picker summary .icon { width: 14px; height: 14px; }
  .filter-spacer { display: none; }
  .refresh-button { margin-left: auto; }
  .active-brand { order: 2; }
  .workspace-content, .panel-grid, .dashboard-insights { gap: 18px; }
  .kpi-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
  .kpi { padding: 18px; min-height: 139px; border-radius: 17px; }
  .kpi .value { font-size: 34px; margin-top: 12px; }
  .kpi-icon { width: 28px; height: 28px; }
  .kpi-icon .icon { width: 16px; height: 16px; }
  .traffic-grid { grid-template-columns: 1fr; }
  .panel { border-radius: 18px; }
  .panel-head { padding: 20px 19px 0; }
  .panel-head h2 { font-size: 16px; }
  .legend { gap: 11px; }
  .chart-summary { padding: 18px 19px 0; }
  .line-chart-wrap { height: 224px; padding: 16px 8px 20px; }
  .device-panel .donut-layout { display: flex; align-items: center; justify-content: center; gap: 33px; padding: 26px 22px; }
  .donut-wrap { width: 126px; height: 126px; margin: 0; flex-shrink: 0; }
  .device-legend { min-width: 0; flex: 1; max-width: 250px; }
  .world-map { margin: 19px 18px 0; height: 280px; min-height: 280px; }
  .map-loading { min-height: 280px; }
  .geo-rankings { padding: 21px 18px; gap: 20px; }
  .rank-row { font-size: 12px; }
  .map-note { font-size: 12px; }
  .brand-overview { padding: 10px 20px 17px; gap: 0; grid-template-columns: 1fr; }
  .brand-card { padding: 17px 0; }
  .brand-card:nth-last-child(2) { border-bottom: 1px solid var(--line); }
  .brand-card-metrics > span { display: inline; }
  .lower-grid { grid-template-columns: 1fr; }
  .bar-list, .activity-list { padding: 14px 20px 22px; }
  .links-head { padding: 19px 17px; gap: 12px; }
  .links-head h2 { font-size: 15px; }
  .result-count { font-size: 12px; text-align: right; }
  .link-toolbar { padding: 17px; gap: 8px; flex-wrap: wrap; }
  .search-field { max-width: none; flex-basis: 100%; }
  .link-toolbar select { flex: 1; min-width: 0; padding: 10px 22px 10px 10px; font-size: 12px; }
  .link-toolbar > #linkRefresh { margin-left: 0; }
  .table-wrap { overflow: visible; padding: 0 17px; }
  table, tbody { display: block; min-width: 0; }
  thead { display: none; }
  tbody tr { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 13px 8px; padding: 20px 0; border-top: 1px solid var(--line); }
  tbody tr:hover { background: transparent; }
  td { display: block; padding: 0 !important; border: 0; min-width: 0; }
  td:first-child { grid-column: 1/-1; }
  td:nth-child(2) { grid-column: 1; grid-row: 2; }
  td:nth-child(3) { grid-column: 1; grid-row: 3; align-self: center; }
  td:nth-child(4) { grid-column: 1; grid-row: 4; display: flex; align-items: baseline; gap: 5px; font-size: 14px; }
  td:nth-child(4):after { content: 'кліків'; color: var(--muted); font-size: 12px; }
  td:nth-child(6) { grid-column: 2; grid-row: 2; align-self: center; text-align: right; }
  td:nth-child(7) { grid-column: 2; grid-row: 3/5; align-self: center; }
  .link-identity { min-width: 0; align-items: flex-start; gap: 11px; }
  .link-text { flex: 1; max-width: calc(100% - 49px); }
  .link-name { font-size: 15px; }
  .destination { max-width: 100%; }
  .source-pill .source-logo { width: 30px; height: 30px; border-radius: 8px; }
  .source-pill .source-name { flex-direction: row; gap: 5px; align-items: baseline; }
  .row-actions { gap: 5px; }
  .row-actions .icon-btn { width: 38px; height: 41px; background: var(--soft); border: 1px solid var(--primary-soft); }
  .row-actions .delete-link-button { background: var(--danger-soft); border-color: var(--line); }
  .empty-state { padding: 46px 12px 53px; }
  .table-footer { padding: 14px 18px; }
  .page-footer { margin-top: 18px; font-size: 12px; }
  .login-layer { grid-template-columns: 1fr; min-height: 100dvh; }
  .login-art { display: none; }
  .login-form-wrap { padding: 40px 29px; background: radial-gradient(ellipse at 20% 0%,#edf2ff,transparent 60%),var(--surface); }
  .login-card { max-width: 380px; }
  .login-mobile-logo { display: block; width: 223px; height: auto; margin-bottom: 55px; }
  .login-card h1 { font-size: 30px; margin-bottom: 30px; }
  .modal-card, .create-card { padding: 26px 23px; width: calc(100% - 24px); max-height: calc(100dvh - 24px); border-radius: 22px; }
  .modal-head h2 { font-size: 24px; }
  .source-picker { gap: 8px; }
  .source-option-content { padding: 11px; gap: 9px; }
  .source-option-content .source-logo { width: 31px; height: 31px; border-radius: 9px; }
  .source-option-content .source-name { flex-direction: column; align-items: flex-start; gap: 2px; }
  .source-option-content .source-name strong, .source-option-content .source-name small { font-size: 12px; }
  .source-check { top: 10px; right: 8px; }
  .source-check .icon { width: 12px; height: 12px; }
  .drawer-card { inset: 0; width: 100%; height: 100dvh; max-height: 100dvh; border-radius: 0; padding: 26px 24px; }
  .modal-actions { flex-wrap: wrap; }
  .modal-actions > .primary, .modal-actions > .danger-button { flex: 1; }
  .date-popover { left: auto; right: 0; min-width: min(280px,85vw); }
  .toast, .toast[popover] { bottom: 90px; }
}
@media(max-width:390px) {
  .page-heading h1 { font-size: 23px; }
  .page-heading > .primary { padding: 11px; font-size: 12px; }
  .date-picker summary > [data-icon]:first-child { display: none; }
  .quick-chip { padding: 6px 10px; }
  .kpi { padding: 15px; }
  .kpi .label { font-size: 12px; }
  .geo-rankings { grid-template-columns: 1fr; }
  .rank-list { max-height: 185px; }
  .device-panel .donut-layout { gap: 22px; padding: 24px 18px; }
  .donut-wrap { width: 112px; height: 112px; }
  .device-row { font-size: 12px; }
  .row-actions { gap: 3px; }
  .row-actions .icon-btn { width: 34px; }
  .source-option-content { padding: 10px 8px; }
  .source-option-content .source-name strong { font-size: 11px; }
}
@media(prefers-reduced-motion:reduce) {
  *, *:before, *:after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
