/* Funnel Metrics dashboard — design system (Figma reference: dark+blue). */
/* DM Sans bundled locally (no Google Fonts dependency). */
@font-face { font-family: 'DM Sans'; font-style: normal; font-weight: 400; font-display: swap; src: url('../fonts/dm-sans-400.woff2') format('woff2'); }
@font-face { font-family: 'DM Sans'; font-style: normal; font-weight: 500; font-display: swap; src: url('../fonts/dm-sans-500.woff2') format('woff2'); }
@font-face { font-family: 'DM Sans'; font-style: normal; font-weight: 600; font-display: swap; src: url('../fonts/dm-sans-600.woff2') format('woff2'); }
@font-face { font-family: 'DM Sans'; font-style: normal; font-weight: 700; font-display: swap; src: url('../fonts/dm-sans-700.woff2') format('woff2'); }
:root {
	--fm-bg: #0a0a0f;
	--fm-surface: #111119;
	--fm-surface-2: #22222e;
	--fm-surface-3: #2a2a36;
	--fm-accent: #3b82f6;
	--fm-text: #f4f4f5;
	--fm-muted: #8b8b99;
	--fm-muted-2: #c9c9d4;
	--fm-up: #22c55e;
	--fm-down: #f43f5e;
}

html, body { background: var(--fm-bg); }
body { font-family: "DM Sans", system-ui, sans-serif; letter-spacing: -0.04em; }
h1, h2, h3, .font-display { letter-spacing: -0.04em; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--fm-surface); }
::-webkit-scrollbar-thumb { background: var(--fm-surface-3); border-radius: 8px; }

body.fm-loading #fm-kpis { opacity: .6; transition: opacity .2s; }

/* icons */
.fm-ic { width: 16px; height: 16px; display: block; }
.fm-ic-sm { width: 14px; height: 14px; }
.fm-nav-ic { width: 18px; height: 18px; }

/* sidebar nav active */
.fm-nav-active { background: rgba(59,130,246,.14) !important; color: var(--fm-text) !important; border-left-color: var(--fm-accent) !important; }

/* cards */
.fm-card { background: var(--fm-surface); border: 1px solid var(--fm-surface-2); border-radius: 18px; }
.fm-card-pad { padding: 22px; }
.fm-card-title { font-weight: 600; color: var(--fm-text); }
.fm-row-between { display: flex; align-items: center; justify-content: space-between; }
.fm-accent { color: var(--fm-accent); }
.fm-muted { color: var(--fm-muted); }
.fm-muted-2 { color: var(--fm-muted-2); }
.fm-xs { font-size: 11px; }
.fm-strong { color: var(--fm-text); font-weight: 600; }
.fm-center { text-align: center; }
.fm-empty { color: var(--fm-muted); font-size: 14px; text-align: center; padding: 28px 0; }

/* dropdowns */
.fm-select { background: var(--fm-surface-2); border: 1px solid var(--fm-surface-3); color: var(--fm-muted-2); font-size: 13px; border-radius: 11px; padding: 8px 12px; outline: none; cursor: pointer; font-family: inherit; letter-spacing: -0.02em; }

/* segmented control (Year/Month/Week/Day) */
.fm-seg-wrap { display: inline-flex; background: var(--fm-surface-2); border: 1px solid var(--fm-surface-3); border-radius: 11px; padding: 3px; gap: 2px; }
.fm-seg { font-size: 13px; color: var(--fm-muted); padding: 6px 14px; border-radius: 8px; cursor: pointer; border: 0; background: transparent; transition: all .15s; font-family: inherit; }
.fm-seg:hover { color: var(--fm-text); }
.fm-seg-on { background: var(--fm-accent); color: #fff; }

/* KPI strip (one card, dividers between) */
.fm-kpi-strip { display: flex; flex-wrap: wrap; margin-top: 22px; }
.fm-kpi-item { flex: 1 1 150px; padding: 2px 24px; border-left: 1px solid var(--fm-surface-2); }
.fm-kpi-item:first-child { padding-left: 0; border-left: 0; }
.fm-kpi-row { display: flex; align-items: center; gap: 10px; }
.fm-kpi-num { font-size: 30px; font-weight: 600; color: var(--fm-text); font-variant-numeric: tabular-nums; }
.fm-kpi-meta { display: flex; align-items: center; gap: 7px; color: var(--fm-muted); font-size: 13px; margin-top: 7px; }
.fm-kpi-sub { margin-left: auto; color: var(--fm-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
@media (max-width: 767px) { .fm-kpi-item { flex: 1 1 44%; border-left: 0; padding: 10px 0; } .fm-kpi-num { font-size: 24px; } }

/* trend / ratio pills */
.fm-trend { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 999px; line-height: 1.3; }
.fm-trend-up { color: var(--fm-up); background: rgba(34,197,94,.13); }
.fm-trend-down { color: var(--fm-down); background: rgba(244,63,94,.13); }
.fm-trend-neutral { color: var(--fm-muted-2); background: var(--fm-surface-2); }

/* line-chart headline + inline legend */
.fm-headline { font-size: 30px; font-weight: 600; color: var(--fm-text); font-variant-numeric: tabular-nums; margin-top: 4px; }
.fm-leg-inline-wrap { display: flex; gap: 16px; margin-top: 8px; }
.fm-leg-inline { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--fm-muted); }

/* doughnut legend with big numbers (Users-by-software style) */
.fm-doughnut-legend { display: flex; justify-content: space-around; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.fm-leg-stack { text-align: left; }
.fm-leg-num { font-size: 18px; font-weight: 600; color: var(--fm-text); font-variant-numeric: tabular-nums; }
.fm-leg-row { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--fm-muted); margin-top: 3px; }

/* dots */
.fm-dot { display: inline-block; width: 9px; height: 9px; border-radius: 999px; flex: none; }

/* gauge labels */
.fm-gauge-label { color: var(--fm-muted-2); font-size: 13px; font-weight: 500; }
.fm-gauge-sub { color: var(--fm-muted); font-size: 12px; margin-top: 2px; }

/* status pill (Recent-orders style) */
.fm-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; padding: 4px 10px; border-radius: 999px; }

/* mini funnel cards */
.fm-tag { font-size: 10px; letter-spacing: .04em; text-transform: uppercase; color: var(--fm-muted); }
.fm-mini-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; text-align: center; margin-top: 18px; }
.fm-mini-num { font-size: 21px; font-weight: 600; color: var(--fm-text); font-variant-numeric: tabular-nums; }
.fm-mini-lbl { font-size: 11px; color: var(--fm-muted); margin-top: 2px; }
.fm-kpi-ic { width: 34px; height: 34px; border-radius: 11px; display: inline-flex; align-items: center; justify-content: center; }

/* tables */
.fm-table-scroll { overflow-x: auto; }
.fm-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 480px; }
.fm-table thead th { text-align: left; font-size: 10px; letter-spacing: .05em; text-transform: uppercase; color: var(--fm-muted); font-weight: 600; padding: 0 14px 12px; }
.fm-table tbody td { padding: 12px 14px; border-top: 1px solid var(--fm-surface-2); color: var(--fm-muted-2); }
.fm-table .fm-num { text-align: right; font-variant-numeric: tabular-nums; }
.fm-table .fm-center { text-align: center; }
.fm-td-name { color: var(--fm-text); font-weight: 500; }
.fm-tr-win td { background: rgba(59,130,246,.08); }
.fm-tr-win .fm-td-name { box-shadow: inset 3px 0 0 var(--fm-accent); }
.fm-badge-win { margin-left: 8px; font-size: 10px; font-weight: 600; color: var(--fm-up); background: rgba(34,197,94,.15); padding: 2px 8px; border-radius: 999px; }
.fm-sig { color: var(--fm-up); }
.fm-ab-block { margin-bottom: 26px; }
.fm-ab-block:last-child { margin-bottom: 0; }
.fm-ab-title { color: var(--fm-text); font-weight: 600; margin: 0 0 12px; font-size: 15px; }

/* custom chart tooltip (reference bubble) */
.fm-tip { position: absolute; z-index: 9999; pointer-events: none; transform: translate(-50%, -120%); background: #16161f; border: 1px solid var(--fm-surface-3); border-radius: 12px; padding: 10px 13px; box-shadow: 0 14px 34px -10px rgba(0,0,0,.7); opacity: 0; transition: opacity .12s ease; white-space: nowrap; }
.fm-tip-main { display: flex; align-items: center; gap: 9px; }
.fm-tip-big { font-size: 18px; font-weight: 600; color: #fff; font-variant-numeric: tabular-nums; }
.fm-tip-sub { font-size: 11px; color: var(--fm-muted); margin-top: 4px; }
.fm-tip-date { font-size: 11px; color: var(--fm-muted); margin-bottom: 7px; text-transform: capitalize; }
.fm-tip-row { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--fm-muted-2); margin-top: 4px; }
.fm-tip-row .fm-dot { width: 8px; height: 8px; flex: none; }
.fm-tip-lbl { color: var(--fm-muted); }
.fm-tip-val { color: #fff; font-weight: 600; margin-left: 14px; font-variant-numeric: tabular-nums; }
.fm-tip-pct { color: var(--fm-muted); font-weight: 600; font-size: 11px; margin-left: 4px; }
.fm-tip-row .fm-trend { margin-left: 6px; }

/* management: buttons, forms, links */
.fm-btn-primary { background: var(--fm-accent); color: #fff; border: 0; border-radius: 11px; padding: 9px 16px; font-weight: 600; font-size: 13px; cursor: pointer; font-family: inherit; letter-spacing: -0.02em; }
.fm-btn-primary:hover { filter: brightness(1.08); }
.fm-btn-ghost { background: var(--fm-surface-2); color: var(--fm-muted-2); border: 1px solid var(--fm-surface-3); border-radius: 11px; padding: 9px 14px; font-weight: 500; font-size: 13px; cursor: pointer; font-family: inherit; }
.fm-btn-ghost:hover { color: var(--fm-text); }
.fm-form-title { font-size: 16px; font-weight: 600; color: var(--fm-text); margin: 0 0 14px; }
.fm-label { display: block; font-size: 12px; color: var(--fm-muted); margin: 14px 0 6px; }
.fm-input { width: 100%; box-sizing: border-box; background: var(--fm-surface-2); border: 1px solid var(--fm-surface-3); color: #fff; border-radius: 10px; padding: 10px 12px; font-family: inherit; font-size: 14px; outline: none; letter-spacing: -0.02em; }
.fm-input:focus { border-color: var(--fm-accent); }
select.fm-input { cursor: pointer; }
.fm-frow { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.fm-frow .fm-input { margin: 0; }
.fm-x { background: var(--fm-surface-2); border: 1px solid var(--fm-surface-3); color: var(--fm-muted); width: 36px; height: 38px; border-radius: 10px; cursor: pointer; font-size: 18px; flex: none; line-height: 1; }
.fm-x:hover { color: var(--fm-down); border-color: var(--fm-down); }
.fm-form-actions { display: flex; align-items: center; gap: 10px; margin-top: 18px; }
.fm-form-msg { font-size: 13px; color: var(--fm-muted); }
.fm-flags { display: inline-flex; align-items: center; gap: 6px; }
.fm-flag { width: 30px; height: 21px; padding: 0; border: 1px solid var(--fm-surface-3); border-radius: 5px; overflow: hidden; background: transparent; cursor: pointer; opacity: 0.4; transition: opacity .15s ease, box-shadow .15s ease, border-color .15s ease; display: inline-flex; }
.fm-flag svg { width: 100%; height: 100%; display: block; }
.fm-flag:hover { opacity: 0.85; }
.fm-flag.fm-flag-on { opacity: 1; border-color: var(--fm-accent); box-shadow: 0 0 0 2px rgba(59,130,246,0.45); }
/* Circular country flags (analytics tables/legend). */
.fm-cc { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; overflow: hidden; flex: none; vertical-align: middle; background: var(--fm-surface-3); }
.fm-cc-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fm-cc-badge { font-size: 10px; font-weight: 600; color: var(--fm-muted-2); letter-spacing: 0; }
.fm-cc-leg { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.fm-cc-leg-num { margin-left: auto; font-weight: 600; color: var(--fm-text); font-size: 13px; }
.fm-qp-n { font-variant-numeric: tabular-nums; }
.fm-qp-p { color: var(--fm-muted); font-size: 11px; margin-left: 6px; }
/* Custom country filter dropdown (flags in a native select aren't possible). */
.fm-dd { position: relative; display: inline-block; }
.fm-dd-btn { display: inline-flex; align-items: center; gap: 8px; width: 100%; min-width: 160px; background: var(--fm-surface-2); border: 1px solid var(--fm-surface-3); color: var(--fm-muted-2); font-size: 13px; border-radius: 11px; padding: 7px 12px; cursor: pointer; font-family: inherit; letter-spacing: -0.02em; }
.fm-dd-cur { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.fm-dd-caret { margin-left: auto; opacity: 0.6; font-size: 11px; padding-left: 6px; }
.fm-dd-menu { position: absolute; z-index: 60; top: calc(100% + 6px); left: 0; min-width: 210px; max-height: 340px; overflow-y: auto; background: var(--fm-surface); border: 1px solid var(--fm-surface-3); border-radius: 12px; padding: 6px; box-shadow: 0 18px 44px rgba(0,0,0,0.55); }
.fm-dd-opt { display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; background: transparent; border: 0; color: var(--fm-muted-2); font-size: 13px; font-family: inherit; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.fm-dd-opt:hover { background: var(--fm-surface-2); color: var(--fm-text); }
.fm-dd-opt-on { background: var(--fm-accent); color: #fff; }
.fm-dd-txt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fm-dd-cur .fm-cc, .fm-dd-opt .fm-cc { width: 20px; height: 20px; }
.fm-check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--fm-muted-2); margin: 14px 0 4px; cursor: pointer; user-select: none; }
.fm-check input { width: 16px; height: 16px; accent-color: var(--fm-accent); cursor: pointer; flex: none; }
.fm-form-hint { font-size: 12px; color: var(--fm-muted); margin-top: 10px; line-height: 1.5; }
.fm-card-foot { display: flex; gap: 14px; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--fm-surface-2); }
.fm-ab-actions { display: inline-flex; gap: 12px; flex: none; }
.fm-link { background: none; border: 0; color: var(--fm-accent); font-size: 12px; font-weight: 600; cursor: pointer; padding: 0; font-family: inherit; }
.fm-link:hover { text-decoration: underline; }
.fm-link-danger { color: var(--fm-down); }

/* login overlay (client-side gate; auth via /wp-json) */
.fm-login-overlay { position: fixed; inset: 0; z-index: 100; background: rgba(6,9,16,.94); backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; }
.fm-login-box { background: #111119; border: 1px solid #22222e; border-radius: 20px; padding: 36px; max-width: 380px; width: 90%; box-shadow: 0 20px 50px -20px rgba(0,0,0,.85); }
.fm-login-ic { width: 46px; height: 46px; border-radius: 12px; background: rgba(59,130,246,.16); display: flex; align-items: center; justify-content: center; font-size: 22px; margin-bottom: 16px; overflow: hidden; }
.fm-login-ic img { width: 30px; height: 30px; object-fit: contain; }
.fm-login-box h1 { font-size: 20px; margin: 0 0 6px; font-weight: 600; color: #fff; }
.fm-login-box p { color: var(--fm-muted); font-size: 14px; margin: 0 0 18px; }
.fm-login-box input { width: 100%; box-sizing: border-box; background: #22222e; border: 1px solid #2a2a36; color: #fff; border-radius: 11px; padding: 13px; margin: 0 0 10px; font-family: inherit; font-size: 15px; outline: none; letter-spacing: -0.02em; }
.fm-login-box input:focus { border-color: var(--fm-accent); }
.fm-login-box button { background: var(--fm-accent); color: #fff; border: 0; border-radius: 11px; padding: 13px 18px; cursor: pointer; font-weight: 600; width: 100%; font-size: 15px; font-family: inherit; }
.fm-login-box button:disabled { opacity: .7; cursor: default; }
.fm-login-err { color: var(--fm-down); font-size: 13px; margin-top: 10px; min-height: 16px; }

#fm-activity-tbody tr, .fm-activity-body tr { animation: fm-fade .35s ease; }
@keyframes fm-fade { from { opacity: 0; transform: translateY(-2px); } to { opacity: 1; transform: none; } }
