/** Phase 12 — Dashboard UI overhaul: mobile-first nav, toast, password toggle, polished cards. */
:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #182733;
  background: #f4f7f8;
  --navy: #102a3b;
  --navy-soft: #18394d;
  --teal: #138a7e;
  --teal-dark: #0c6c63;
  --blue: #3973e6;
  --amber: #e8a23a;
  --violet: #805ad5;
  --border: #dfe7ea;
  --muted: #6d7d88;
  --surface: #fff;
  --danger: #b42318;
  --radius: .85rem;
  --shadow-sm: 0 1px 3px rgba(16,42,59,.06);
  --shadow-md: 0 5px 22px rgba(16,42,59,.05);
  --shadow-lg: 0 24px 70px rgba(16,42,59,.12);
  --transition: .18s ease;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; background: #f4f7f8; }
body.is-loading .main-content { cursor: progress; }
body.is-loading .main-content::after { content: ""; position: fixed; inset: 0 0 auto; z-index: 20; height: 3px; background: linear-gradient(90deg, transparent, var(--teal), transparent); animation: loading-bar 1.2s ease-in-out infinite; }
@keyframes loading-bar { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
button, input, select { font: inherit; }
button { border: 0; border-radius: var(--radius); padding: .72rem 1rem; color: white; background: var(--teal); font-weight: 750; cursor: pointer; transition: background var(--transition), transform var(--transition), box-shadow var(--transition); }
button:not(.icon-button):not(.icon-btn):not(.password-toggle), .tracker-hint { display: inline-flex; align-items: center; justify-content: center; gap: .38rem; }
.button-icon, .inline-icon { width: 1rem; height: 1rem; flex: 0 0 auto; }
button:hover { background: var(--teal-dark); }
button:active { transform: scale(.97); }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid rgba(19,138,126,.25); outline-offset: 2px; }
button:disabled { cursor: not-allowed; opacity: .5; }
input, select { width: 100%; border: 1px solid var(--border); border-radius: var(--radius); padding: .72rem .82rem; color: inherit; background: white; transition: border-color var(--transition), box-shadow var(--transition); }
input:focus, select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(19,138,126,.12); }
label { display: block; margin: 1rem 0 .4rem; font-size: .88rem; font-weight: 750; }
h1, h2, p { margin-top: 0; }
h1 { letter-spacing: -.035em; }
h2 { margin-bottom: 0; font-size: 1.05rem; letter-spacing: -.015em; }
a { color: var(--teal); }
[hidden] { display: none !important; }
.centered { text-align: center; }
.muted { color: var(--muted); }
.eyebrow { margin-bottom: .38rem; color: var(--teal); text-transform: uppercase; letter-spacing: .13em; font-size: .68rem; font-weight: 850; }
.brand-mark { display: grid; place-items: center; width: 3.55rem; height: 3.55rem; margin: 0 auto 1rem; border: 1px solid rgba(255,255,255,.18); border-radius: 1.05rem; color: #fff; background: linear-gradient(145deg, #0f766e, #62b9ac); box-shadow: 0 10px 25px rgba(19,138,126,.2); font-weight: 900; }
.brand-mark.small { width: 2.6rem; height: 2.6rem; margin: 0; border-radius: .78rem; box-shadow: none; font-size: .8rem; }
.centered-view { min-height: 100vh; display: grid; place-content: center; padding: 1.25rem; text-align: center; }
.login-background { background: radial-gradient(circle at 20% 10%, rgba(74,180,166,.16), transparent 35%), radial-gradient(circle at 90% 90%, rgba(57,115,230,.1), transparent 35%), #f4f7f8; }
.auth-card { width: min(26rem, calc(100vw - 2rem)); padding: 2.35rem; border: 1px solid var(--border); border-radius: 1.3rem; background: var(--surface); box-shadow: var(--shadow-lg); text-align: left; }
.auth-card h1 { margin-bottom: .55rem; text-align: center; }
.auth-card button[type="submit"] { width: 100%; margin-top: 1rem; }
.challenge { min-height: 65px; margin-top: 1.1rem; }
.form-error { margin: .75rem 0 0; color: var(--danger); font-size: .86rem; }

/* Password field with toggle */
.password-field { position: relative; }
.password-field input { padding-right: 3rem; }
.password-toggle { position: absolute; right: .5rem; top: 50%; transform: translateY(-50%); display: grid; place-items: center; width: 2.2rem; height: 2.2rem; padding: 0; border-radius: .5rem; color: var(--muted); background: transparent; }
.password-toggle:hover { color: var(--navy); background: rgba(0,0,0,.04); }
.password-toggle svg { width: 1.15rem; height: 1.15rem; }

/* ─── App Shell ─── */
.app-shell { display: grid; grid-template-columns: 15.6rem minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; z-index: 10; height: 100vh; display: flex; flex-direction: column; padding: 1.35rem 1rem; color: #fff; background: var(--navy); }
.brand { display: flex; align-items: center; gap: .75rem; margin: .2rem .45rem 2.1rem; color: white; text-decoration: none; font-weight: 850; line-height: 1.05; }
.sidebar nav { display: grid; gap: .25rem; }
.sidebar nav a { display: flex; align-items: center; gap: .7rem; padding: .72rem .88rem; border-radius: var(--radius); color: #b9ccd7; text-decoration: none; font-weight: 680; transition: color var(--transition), background var(--transition); }
.sidebar nav a svg { width: 1.2rem; height: 1.2rem; flex-shrink: 0; opacity: .75; }
.sidebar nav a:hover, .sidebar nav a.active { color: #fff; background: var(--navy-soft); }
.sidebar nav a.active svg { opacity: 1; stroke: #75bdb5; }
.sidebar-foot { display: flex; flex-direction: column; gap: .35rem; margin: auto .6rem 1rem; font-size: .75rem; }
.sidebar-foot-row { display: flex; align-items: center; gap: .5rem; color: #a9bec9; }
.sidebar-version { color: #73818c; font-size: .7rem; }
.database-status > span:first-child { display: grid; place-items: center; width: 1rem; height: 1rem; border-radius: 50%; font-size: .64rem; font-weight: 900; }
.database-status > span:first-child svg { width: .75rem; height: .75rem; }
.database-status[data-connected="checking"] > span:first-child { color: #a9bec9; border: 1px solid #73818c; }
.database-status[data-connected="true"] > span:first-child { color: #062f2a; background: #44d19d; box-shadow: 0 0 0 3px rgba(68,209,157,.12); }
.database-status[data-connected="false"] > span:first-child { color: #fff; background: #f04438; box-shadow: 0 0 0 3px rgba(240,68,56,.12); }

/* Sidebar action buttons */
.sidebar-actions { display: flex; flex-direction: column; gap: .4rem; }
.sidebar-action-btn { display: flex; align-items: center; gap: .5rem; width: 100%; padding: .65rem .75rem; font-size: .82rem; font-weight: 680; color: #d5e1e7; background: transparent; border: 1px solid rgba(255,255,255,.12); border-radius: var(--radius); transition: color var(--transition), background var(--transition); }
.sidebar-action-btn:hover { color: white; background: rgba(255,255,255,.07); }
.sidebar-action-btn svg { flex-shrink: 0; }
.sidebar-action-btn.logout-btn { border-color: rgba(255,255,255,.16); }

/* Mobile header */
.mobile-header { display: none; }

/* Mobile bottom nav */
.mobile-nav { display: none; }

/* ─── Main content ─── */
.main-content { width: 100%; max-width: 105rem; padding: 2rem clamp(1rem, 3vw, 3rem) 4rem; overflow: hidden; }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.35rem; }
.page-header h1 { margin-bottom: 0; font-size: clamp(1.55rem, 3vw, 2.1rem); }
.header-actions { display: flex; gap: .65rem; }
.compact { padding: .58rem .78rem; }
.secondary { color: #344a58; background: white; border: 1px solid var(--border); }
.secondary:hover { background: #f5f8f9; }
.icon-btn { display: grid; place-items: center; width: 2.4rem; height: 2.4rem; padding: 0; border-radius: .65rem; color: var(--muted); background: transparent; border: 1px solid var(--border); }
.icon-btn:hover { color: var(--navy); background: #f5f8f9; }
.icon-btn svg { width: 1.15rem; height: 1.15rem; }

/* ─── Toast notifications ─── */
.toast-container { position: fixed; top: 1.2rem; right: 1.2rem; z-index: 100; display: flex; flex-direction: column; gap: .55rem; pointer-events: none; max-width: min(26rem, calc(100vw - 2rem)); }
.toast { pointer-events: auto; display: flex; align-items: center; gap: .75rem; padding: .85rem 1.1rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: 0 8px 32px rgba(16,42,59,.12); font-size: .86rem; font-weight: 600; animation: toast-in .3s ease; }
.toast.toast-success { border-left: 3px solid #44d19d; }
.toast.toast-error { border-left: 3px solid var(--danger); color: var(--danger); }
.toast.toast-out { animation: toast-out .25s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateX(1rem); } to { opacity: 1; transform: none; } }
@keyframes toast-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateX(1rem); } }

/* ─── Analytics toolbar ─── */
.analytics-toolbar { display: flex; align-items: flex-end; gap: .85rem; margin-bottom: 1.15rem; padding: .75rem; border: 1px solid var(--border); border-radius: var(--radius); background: rgba(255,255,255,.76); backdrop-filter: blur(8px); }
.field-inline { min-width: 13rem; margin: 0; }
.field-inline span, .custom-range label span { display: block; margin-bottom: .3rem; color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; }
.range-group { display: flex; gap: .35rem; margin-left: auto; }
.range-button { padding: .62rem .8rem; font-size: .82rem; }
.range-button.active { border-color: var(--teal); color: white; background: var(--teal); }
.custom-range { display: flex; align-items: flex-end; gap: .45rem; }
.custom-range label { margin: 0; }
.custom-range input { padding: .55rem .6rem; }

/* ─── KPI Grid ─── */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.kpi-card { display: flex; align-items: flex-start; gap: .9rem; min-width: 0; padding: 1.15rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); transition: transform var(--transition), box-shadow var(--transition); }
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.kpi-icon { flex: 0 0 auto; display: grid; place-items: center; width: 2.6rem; height: 2.6rem; border-radius: .82rem; }
.kpi-icon svg { width: 1.2rem; height: 1.2rem; }
.kpi-icon.teal { color: #087b70; background: #e5f7f4; }
.kpi-icon.blue { color: #2e64cf; background: #eaf0fd; }
.kpi-icon.amber { color: #b66c04; background: #fff4df; }
.kpi-icon.violet { color: #6842b9; background: #f1ebfb; }
.kpi-card p { margin-bottom: .35rem; color: var(--muted); font-size: .8rem; }
.kpi-card strong { display: block; margin-bottom: .3rem; font-size: clamp(1.35rem, 2.6vw, 1.85rem); letter-spacing: -.04em; white-space: nowrap; }
.kpi-card small { font-size: .7rem; white-space: nowrap; }
.positive { color: #067647; }
.negative { color: var(--danger); }

/* ─── Panels ─── */
.panel { overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); transition: box-shadow var(--transition); }
.panel:hover { box-shadow: var(--shadow-md); }
.chart-panel, .table-panel, .setting-card { margin-bottom: 1rem; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.05rem 1.15rem .5rem; }
.panel-heading a { font-size: .78rem; font-weight: 750; text-decoration: none; }
.panel-meta { color: var(--muted); font-size: .75rem; }
.tracker-hint { color: var(--teal); text-decoration: none; font-weight: 700; }
.tracker-hint:hover { text-decoration: underline; }
.allowlist-panel { margin-bottom: 1rem; }
.allowlist-form { padding: .25rem 1.15rem 1.15rem; }
.allowlist-form > label { margin-top: .55rem; }
.combobox-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .55rem; }
.allowlist-tags { display: flex; flex-wrap: wrap; gap: .45rem; min-height: 2.1rem; margin-top: .8rem; }
.allowlist-tag { display: inline-flex; align-items: center; gap: .35rem; max-width: 100%; padding: .38rem .45rem .38rem .62rem; border: 1px solid #b7ded9; border-radius: 999px; color: #0c6c63; background: #effaf8; font-size: .78rem; font-weight: 720; }
.allowlist-tag span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.allowlist-tag button { display: grid; place-items: center; width: 1.35rem; height: 1.35rem; padding: 0; border-radius: 50%; color: #52726f; background: transparent; font-size: 1rem; line-height: 1; }
.allowlist-tag button svg { width: .8rem; height: .8rem; }
.allowlist-tag button:hover { color: var(--danger); background: #fee4e2; }
.field-help { margin: .55rem 0 0; color: var(--muted); font-size: .76rem; line-height: 1.5; }
.allowlist-actions { display: flex; justify-content: flex-end; margin-top: .9rem; }

/* ─── Charts ─── */
.chart-height-main { height: 20rem; padding: .4rem 1rem 1rem; }
.chart-height-hours { height: 15rem; padding: .4rem 1rem 1rem; }
.chart-height-donut { width: 10.5rem; height: 10.5rem; }
.insight-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 1rem; margin-bottom: 1rem; }
.insight-card { min-height: 16rem; }
.donut-layout { display: flex; align-items: center; justify-content: center; gap: 1.5rem; padding: .7rem 1.1rem 1.2rem; }
.legend-list { min-width: 8.5rem; display: grid; gap: .7rem; }
.legend-list > div { display: flex; justify-content: space-between; gap: 1rem; font-size: .8rem; }
.legend-list span { display: flex; align-items: center; gap: .45rem; color: var(--muted); }
.legend-dot { width: .55rem; height: .55rem; border-radius: 50%; }
.color-0 { background: var(--teal); }.color-1 { background: var(--blue); }.color-2 { background: var(--amber); }.color-3 { background: #a7b1b8; }
.rank-list { display: grid; gap: .8rem; padding: .7rem 1.15rem 1.2rem; }
.rank-item { display: grid; grid-template-columns: 1.5rem minmax(0, 1fr) auto; align-items: center; gap: .7rem; }
.rank-number { color: #98a4ab; font-size: .75rem; font-weight: 750; }
.rank-item strong { display: block; margin-bottom: .28rem; font-size: .8rem; }
.rank-item b { font-size: .8rem; }
.rank-bar { display: block; width: 100%; height: .28rem; overflow: hidden; border-radius: 1rem; background: #eef2f3; }
.rank-bar i { display: block; height: 100%; border-radius: inherit; background: var(--teal); }
.bar-0 i { width: 2%; }.bar-1 i { width: 10%; }.bar-2 i { width: 20%; }.bar-3 i { width: 30%; }.bar-4 i { width: 40%; }.bar-5 i { width: 50%; }.bar-6 i { width: 60%; }.bar-7 i { width: 70%; }.bar-8 i { width: 80%; }.bar-9 i { width: 90%; }.bar-10 i { width: 100%; }

/* ─── Tables ─── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .92rem 1rem; border-bottom: 1px solid #edf1f3; text-align: left; vertical-align: middle; }
th { position: sticky; top: 0; z-index: 2; color: var(--muted); background: #f8fafb; text-transform: uppercase; letter-spacing: .055em; font-size: .68rem; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background var(--transition); }
tbody tr:hover { background: #f6f9fa; }
tbody tr:nth-child(even) { background: #fcfdfd; }
tbody tr:nth-child(even):hover { background: #f6f9fa; }
td { font-size: .84rem; }
td small { display: block; max-width: 22rem; margin-top: .25rem; overflow: hidden; color: var(--muted); text-overflow: ellipsis; }
code { font-size: .78rem; }
.sort-button { padding: 0; border-radius: 0; color: inherit; background: transparent; text-transform: inherit; letter-spacing: inherit; font-size: inherit; }
.sort-button:hover { color: var(--teal); background: transparent; }
.status { display: inline-flex; padding: .32rem .52rem; border-radius: 999px; font-size: .7rem; font-weight: 800; white-space: nowrap; }
.status.active { color: #067647; background: #ecfdf3; }
.status.waiting { color: #b54708; background: #fffaeb; }
.status.disabled { color: #475467; background: #f2f4f7; }
.status.duplicate { color: #b42318; background: #fee4e2; }
.duplicate-row { background: #fff8f7; }
.actions { white-space: nowrap; }
.link-button { padding: .32rem .5rem; color: var(--teal); background: transparent; font-size: .78rem; border-radius: .4rem; transition: background var(--transition); }
.link-button:hover { color: var(--teal-dark); background: #eff8f7; }
.link-button.danger { color: var(--danger); }
.link-button.danger:hover { background: #fef3f2; }
.empty-state { padding: 3rem 1rem; color: var(--muted); text-align: center; }
.traffic-grid, .settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.settings-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.setting-card { padding: 1.35rem; }
.setting-card p:last-child { margin: .8rem 0 0; color: var(--muted); line-height: 1.65; font-size: .86rem; }

/* ─── About page ─── */
.about-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 2rem; margin-bottom: 1.25rem; padding: clamp(1.4rem, 3vw, 2.2rem); overflow: hidden; border: 1px solid #b7e6df; border-radius: 1.15rem; background: radial-gradient(circle at 90% 15%, rgba(19,138,126,.16), transparent 30%), linear-gradient(135deg, #f7fcfb, #eaf7f5); }
.about-hero h2 { margin-bottom: .55rem; color: var(--navy); font-size: clamp(1.35rem, 2.5vw, 2rem); }
.about-hero p:not(.eyebrow) { max-width: 42rem; margin: 0; color: #49606d; line-height: 1.65; }
.about-feature-pills { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .45rem; max-width: 22rem; }
.about-feature-pills span, .about-badge { padding: .42rem .66rem; border: 1px solid rgba(19,138,126,.2); border-radius: 999px; color: #0c6c63; background: rgba(255,255,255,.75); font-size: .72rem; font-weight: 780; white-space: nowrap; }
.about-layout { display: grid; grid-template-columns: minmax(0, 1fr) 19rem; align-items: start; gap: 1.25rem; }
.about-main, .about-side { display: grid; gap: 1rem; }
.about-section { padding: 1.35rem; }
.about-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.about-section-heading h2 { font-size: 1.2rem; }
.about-intro { margin: .65rem 0 1rem; color: var(--muted); font-size: .88rem; line-height: 1.6; }
.install-option { padding: 1rem 0; border-top: 1px solid var(--border); }
.install-option:last-child { padding-bottom: 0; }
.install-option-copy { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: .55rem; font-size: .84rem; }
.install-option-copy span { color: var(--muted); font-size: .76rem; }
.code-copy-row { display: flex; align-items: center; gap: .5rem; }
.code-copy-row pre { flex: 1 1 auto; margin: 0; }
.code-copy-row button { flex: 0 0 auto; white-space: nowrap; }
.about-platform-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.about-platform-card { position: relative; min-width: 0; padding: 1.3rem; overflow: hidden; }
.about-platform-card h2 { margin-bottom: .65rem; }
.about-platform-card > p:last-of-type { margin-bottom: 0; color: var(--muted); font-size: .84rem; line-height: 1.6; }
.platform-number { position: absolute; top: .85rem; right: 1rem; color: #d7e5e8; font-size: 1.8rem; font-weight: 900; }
.compact-code-row { margin-top: 1rem; }
.compact-code-row pre { padding: .75rem; font-size: .7rem; }
.about-debug { display: grid; grid-template-columns: minmax(12rem, .7fr) minmax(0, 1.3fr); align-items: center; gap: 1.25rem; padding: 1.25rem; }
.about-debug-copy h2 { margin-bottom: .5rem; }
.about-debug-copy p:last-child { margin: 0; color: var(--muted); font-size: .84rem; line-height: 1.55; }
.about-side-card { padding: 1.25rem; }
.about-side-card h2 { margin-bottom: .7rem; }
.about-side-card > p:last-child { margin: 0; color: var(--muted); font-size: .84rem; line-height: 1.65; }
.about-check-list { display: grid; gap: .72rem; margin: 0; padding: 0; list-style: none; }
.about-check-list li { position: relative; padding-left: 1.35rem; color: #405561; font-size: .82rem; line-height: 1.4; }
.about-check-list li::before { content: ""; position: absolute; left: .15rem; top: .15rem; width: .35rem; height: .65rem; border: solid var(--teal); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.privacy-card { border-color: #c7e9e4; background: #f4fbfa; }
.about-version-card { display: grid; gap: .25rem; padding: 1.25rem; color: #d4e3e9; border-color: var(--navy); background: var(--navy); }
.about-version-card span { color: #8eb0bb; font-size: .7rem; text-transform: uppercase; letter-spacing: .09em; }
.about-version-card strong { color: #fff; font-size: 1.5rem; }
.about-version-card small { color: #9eb3bd; }
.visually-hidden { position: absolute; left: -9999px; top: -9999px; opacity: 0; pointer-events: none; }
button.copied { background: #0f6f65; }

/* ─── Checkbox site list (replaces select multiple) ─── */
.checkbox-site-list { max-height: 14rem; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); background: white; }
.checkbox-site-item { display: flex; align-items: center; gap: .6rem; padding: .62rem .85rem; border-bottom: 1px solid #f0f3f4; cursor: pointer; transition: background var(--transition); }
.checkbox-site-item:last-child { border-bottom: 0; }
.checkbox-site-item:hover { background: #f6f9fa; }
.checkbox-site-item input { width: auto; margin: 0; accent-color: var(--teal); }
.checkbox-site-item label { margin: 0; font-weight: 600; font-size: .84rem; cursor: pointer; }
.checkbox-empty { padding: .75rem; }
.db-ok { color: #44d19d; }
.db-err { color: #f04438; }

/* ─── Dialogs ─── */
dialog { width: min(34rem, calc(100vw - 2rem)); padding: 0; border: 0; border-radius: 1.05rem; box-shadow: var(--shadow-lg); }
dialog::backdrop { background: rgba(10,27,39,.62); backdrop-filter: blur(4px); }
dialog form, .snippet-dialog-body { padding: 1.5rem; }
.dialog-header, .dialog-actions, .toggle-row { display: flex; align-items: center; }
.dialog-header { justify-content: space-between; }
.dialog-header h2 { margin-bottom: 0; }
.icon-button { padding: .2rem .6rem; color: var(--muted); background: transparent; font-size: 1.8rem; }
.icon-button svg { width: 1rem; height: 1rem; }
.icon-button:hover { color: var(--navy); background: #f3f6f7; }
.dialog-actions { justify-content: flex-end; gap: .65rem; margin-top: 1.35rem; }
.toggle-row { gap: .6rem; }
.toggle-row input { width: auto; }
pre { overflow-x: auto; margin: 1rem 0; padding: 1rem; border-radius: var(--radius); color: #d6e7ed; background: #102a3b; font-size: .78rem; line-height: 1.6; white-space: pre-wrap; }

/* ─── Mobile user menu ─── */
.mobile-user-menu { position: absolute; top: 3.4rem; right: .75rem; z-index: 30; min-width: 14rem; padding: .75rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-lg); animation: menu-in .15s ease; }
@keyframes menu-in { from { opacity: 0; transform: translateY(-.5rem); } to { opacity: 1; transform: none; } }
.mobile-menu-info { padding: .35rem .25rem .65rem; }
.mobile-menu-info strong { display: block; font-size: .92rem; }
.mobile-menu-info span { font-size: .75rem; }
.mobile-menu-row { padding: .2rem .25rem; font-size: .76rem; }
.mobile-menu-row span { display: inline-grid; place-items: center; width: 1rem; height: 1rem; margin-right: .2rem; vertical-align: -.2rem; }
.mobile-menu-row span svg { width: .8rem; height: .8rem; }
.mobile-user-menu hr { margin: .55rem 0; border: 0; border-top: 1px solid var(--border); }
.mobile-menu-action { display: flex; align-items: center; gap: .55rem; width: 100%; padding: .6rem .5rem; color: var(--navy); background: transparent; font-size: .84rem; font-weight: 650; border-radius: .5rem; }
.mobile-menu-action:hover { background: #f5f8f9; }
.mobile-menu-action.danger { color: var(--danger); }
.mobile-menu-action.danger:hover { background: #fef3f2; }
.avatar-btn { border-radius: 50%; width: 2.4rem; height: 2.4rem; background: var(--navy-soft); color: #d5e1e7; border: 0; }
.avatar-btn:hover { background: var(--teal-dark); color: white; }

/* ═══════════════════════════════════════════════════════
   RESPONSIVE — Tablet
   ═══════════════════════════════════════════════════════ */
@media (max-width: 1120px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settings-grid { grid-template-columns: 1fr; }
  .about-layout { grid-template-columns: 1fr; }
  .about-side { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .analytics-toolbar { flex-wrap: wrap; }
  .range-group { margin-left: 0; }
}

/* ═══════════════════════════════════════════════════════
   RESPONSIVE — Mobile (bottom nav pattern)
   ═══════════════════════════════════════════════════════ */
@media (max-width: 790px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }

  /* Mobile header */
  .mobile-header { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 15; padding: .55rem .75rem; background: var(--navy); }
  .mobile-brand { display: flex; align-items: center; color: white; text-decoration: none; }

  /* Mobile bottom nav */
  .mobile-nav { display: flex; justify-content: space-around; position: fixed; bottom: 0; left: 0; right: 0; z-index: 15; padding: .25rem 0; padding-bottom: max(.25rem, env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -4px 20px rgba(16,42,59,.06); }
  .mobile-nav-item { display: flex; flex-direction: column; align-items: center; gap: .15rem; padding: .45rem .35rem .3rem; border-radius: .65rem; color: var(--muted); text-decoration: none; font-size: .62rem; font-weight: 700; transition: color var(--transition); min-width: 3.5rem; }
  .mobile-nav-item svg { width: 1.35rem; height: 1.35rem; }
  .mobile-nav-item.active { color: var(--teal); }
  .mobile-nav-item:active { background: rgba(19,138,126,.06); }

  /* Content adjustments for mobile bottom nav */
  .main-content { padding: 1rem .85rem; padding-bottom: 5.5rem; }
  .page-header h1 { font-size: 1.45rem; }

  .insight-grid, .traffic-grid, .about-platform-grid, .about-side { grid-template-columns: 1fr; }
  .about-hero { align-items: flex-start; flex-direction: column; gap: 1rem; }
  .about-feature-pills { justify-content: flex-start; max-width: none; }
  .about-debug { grid-template-columns: 1fr; }
  .custom-range { width: 100%; }

  /* Toast on mobile */
  .toast-container { top: auto; bottom: 5rem; right: .75rem; left: .75rem; max-width: none; }

  .mobile-header-actions { display: flex; gap: .45rem; }
}

/* ═══════════════════════════════════════════════════════
   RESPONSIVE — Small phone
   ═══════════════════════════════════════════════════════ */
@media (max-width: 540px) {
  .page-header { align-items: flex-start; flex-direction: column; gap: .5rem; }
  .header-actions { width: 100%; }
  .header-actions button { flex: 1; }

  /* KPI horizontal scroll on small phones */
  .kpi-grid { display: flex; overflow-x: auto; gap: .75rem; padding-bottom: .5rem; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; }
  .kpi-card { flex: 0 0 min(75vw, 16rem); scroll-snap-align: start; }

  .analytics-toolbar, .range-group { width: 100%; }
  .field-inline { width: 100%; }
  .range-group { display: grid; grid-template-columns: repeat(4, 1fr); }
  .range-button { padding: .55rem .3rem; font-size: .76rem; }
  .custom-range { display: grid; grid-template-columns: 1fr 1fr; }
  .custom-range button { grid-column: 1 / -1; }
  .donut-layout { flex-direction: column; }
  .auth-card { padding: 1.5rem; }
  .install-option-copy, .about-section-heading { align-items: flex-start; flex-direction: column; gap: .35rem; }
  .code-copy-row { align-items: stretch; flex-direction: column; }
  .code-copy-row button { width: 100%; }
  .combobox-row { grid-template-columns: 1fr; }

  /* Card layout for tables on small phones */
  .table-panel .table-wrap table thead { display: none; }
  .table-panel .table-wrap table,
  .table-panel .table-wrap table tbody,
  .table-panel .table-wrap table tr,
  .table-panel .table-wrap table td { display: block; width: 100%; }
  .table-panel .table-wrap table tr { padding: .85rem 1rem; border-bottom: 1px solid #edf1f3; }
  .table-panel .table-wrap table tr:last-child { border-bottom: 0; }
  .table-panel .table-wrap table td { padding: .2rem 0; border-bottom: 0; font-size: .82rem; }
  .table-panel .table-wrap table td:first-child { font-weight: 750; font-size: .9rem; margin-bottom: .25rem; }
  .table-panel .table-wrap table td::before { content: attr(data-label); display: inline-block; min-width: 5.5rem; color: var(--muted); font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
  .table-panel .table-wrap table td:first-child::before { display: none; }
  .table-panel .table-wrap table td .actions,
  .table-panel .table-wrap table td.actions { display: flex; gap: .35rem; margin-top: .4rem; }

  /* Bottom sheet dialogs on mobile */
  dialog { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 1.2rem 1.2rem 0 0; }
  dialog[open] { animation: sheet-up .25s ease; }
  @keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
}
