/* MySender Admin — self-contained. No build step, no CDN, no external fonts. */

:root {
    --violet: #5632B8;
    --violet-deep: #25184F;
    --violet-soft: #F0EBFF;
    --ink: #172033;
    --muted: #667086;
    --line: #E3E6EF;
    --bg: #F5F6FA;
    --card: #FFFFFF;
    --ok: #047857;
    --ok-bg: #ECFDF5;
    --bad: #B91C1C;
    --bad-bg: #FEF2F2;
    --warn: #92400E;
    --warn-bg: #FFFBEB;
    --radius: 12px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 14.5px/1.5 "Segoe UI Variable", Aptos, "Segoe UI", system-ui, sans-serif;
}

a { color: var(--violet); }

/* ------------------------------------------------------------------ sign-in */

.auth-screen {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: linear-gradient(160deg, var(--violet-deep), var(--violet) 60%, #7C3AED);
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--card);
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .28);
}

.auth-card h1 { margin: 0 0 4px; font-size: 22px; }
.auth-card p.sub { margin: 0 0 22px; color: var(--muted); font-size: 14px; }

.auth-mark {
    width: 44px; height: 44px;
    display: grid; place-items: center;
    border-radius: 12px;
    background: var(--violet);
    color: #fff; font-size: 20px;
    margin-bottom: 16px;
}

/* -------------------------------------------------------------------- shell */

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

.sidebar {
    width: 232px;
    flex: 0 0 232px;
    background: linear-gradient(165deg, #211642, #39216F 76%, #462795);
    color: #fff;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
}

.brand { display: flex; gap: 10px; align-items: center; color: #fff; text-decoration: none; margin-bottom: 26px; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: rgba(255,255,255,.16); display: grid; place-items: center; }
.brand-copy strong { display: block; font-size: 15px; }
.brand-copy small { color: rgba(255,255,255,.7); font-size: 12px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
    color: rgba(255,255,255,.82);
    text-decoration: none;
    padding: 9px 12px;
    border-radius: 9px;
    font-size: 14px;
}
.nav-link:hover { background: rgba(255,255,255,.10); color: #fff; }
.nav-link.is-active { background: rgba(255,255,255,.18); color: #fff; font-weight: 600; }

.sidebar-foot { margin-top: auto; padding-top: 20px; font-size: 11.5px; color: rgba(255,255,255,.65); }
.sidebar-foot strong { display: block; color: rgba(255,255,255,.9); margin-bottom: 4px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    display: flex; justify-content: space-between; align-items: center;
    gap: 12px; padding: 14px 24px;
    background: var(--card); border-bottom: 1px solid var(--line);
}
.topbar-title strong { display: block; font-size: 16px; }
.topbar-title small { color: var(--muted); font-size: 12px; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }

.chip { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }
.avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--violet-soft); color: var(--violet); display: grid; place-items: center; font-size: 12px; font-weight: 700; }

.content { padding: 24px; }

/* --------------------------------------------------------------- components */

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 18px;
}
.card h2 { margin: 0 0 4px; font-size: 16px; }
.card p.hint { margin: 0 0 16px; color: var(--muted); font-size: 13px; }

.stat-row { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 18px; }
.stat {
    flex: 1 1 160px;
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 16px;
}
.stat .n { font-size: 26px; font-weight: 700; color: var(--violet-deep); }
.stat .k { font-size: 12.5px; color: var(--muted); }

label { display: block; font-size: 13px; font-weight: 600; margin: 0 0 5px; }
input[type=text], input[type=search], input[type=password], input[type=email], select {
    width: 100%; padding: 10px 12px;
    border: 1px solid var(--line); border-radius: 9px;
    font: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus { outline: 2px solid var(--violet-soft); border-color: var(--violet); }
.field { margin-bottom: 14px; }
.err { color: var(--bad); font-size: 12.5px; margin-top: 5px; }

.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 16px; border-radius: 9px;
    border: 1px solid transparent; background: var(--violet); color: #fff;
    font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { background: #4C1D95; }
.btn[disabled] { opacity: .6; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: var(--bg); }
.btn.danger { background: var(--bad); }
.btn.danger:hover { background: #991B1B; }
.btn.small { padding: 6px 11px; font-size: 13px; }
.btn.link { background: none; border: none; color: var(--violet); padding: 0; font-weight: 600; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--line); }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tbody tr:hover { background: #FAFAFE; }
.table-wrap { overflow-x: auto; }

.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.bad { background: var(--bad-bg); color: var(--bad); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.mute { background: var(--bg); color: var(--muted); }

.flash { margin: 16px 24px -4px; padding: 11px 14px; border-radius: 9px; font-size: 14px; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.bad { background: var(--bad-bg); color: var(--bad); }

.empty { text-align: center; padding: 34px 16px; color: var(--muted); font-size: 14px; }

.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }

.modal-back {
    position: fixed; inset: 0; background: rgba(17, 12, 34, .55);
    display: grid; place-items: center; padding: 20px; z-index: 40;
}
.modal {
    background: var(--card); border-radius: 14px; padding: 24px;
    width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto;
}
.modal h3 { margin: 0 0 4px; font-size: 17px; }
.modal p.hint { color: var(--muted); font-size: 13px; margin: 0 0 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 14px 0; }
.codes code { background: var(--bg); border: 1px solid var(--line); border-radius: 7px; padding: 8px; text-align: center; font-size: 13px; }

.qr { display: grid; place-items: center; padding: 14px; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.qr svg { width: 200px; height: 200px; }
.secret { font-family: ui-monospace, Consolas, monospace; background: var(--bg); border: 1px solid var(--line); border-radius: 7px; padding: 9px; word-break: break-all; font-size: 12.5px; }

.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.section-head h2 { margin: 0; font-size: 18px; }

.search { max-width: 280px; }

/* ------------------------------------------------------------------ filters */
/* The status tabs and the page-size picker sit on one line above the table.
   `.per-page` wraps a <select> in a <label>, so it has to undo the global
   label/select rules — those are written for stacked form fields and would
   otherwise put "Show" on its own line above a full-width dropdown. */

.filters {
    display: flex; justify-content: space-between; align-items: center;
    gap: 12px; flex-wrap: wrap; margin-bottom: 14px;
}

.filter-tabs { display: flex; gap: 6px; flex-wrap: wrap; }

.filter-tab {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 7px 13px; border-radius: 999px;
    border: 1px solid var(--line); background: var(--card); color: var(--ink);
    font: inherit; font-size: 13.5px; cursor: pointer;
}
.filter-tab:hover:not(.is-active) { background: var(--violet-soft); border-color: var(--violet); color: var(--violet); }
.filter-tab.is-active { background: var(--violet); border-color: var(--violet); color: #fff; font-weight: 600; }

.filter-count {
    display: inline-block; min-width: 20px; padding: 1px 6px;
    border-radius: 999px; background: var(--bg); color: var(--muted);
    font-size: 11.5px; font-weight: 600; text-align: center;
}
.filter-tab.is-active .filter-count { background: rgba(255, 255, 255, .22); color: #fff; }

/* "Needs 2FA" with anyone in it is a to-do list, not a filter — those resellers
   cannot sign in at all until an operator enrols them. */
.filter-tab.is-warn:not(.is-active) { border-color: #FCD34D; }
.filter-tab.is-warn:not(.is-active) .filter-count { background: var(--warn-bg); color: var(--warn); }

.per-page {
    display: inline-flex; align-items: center; gap: 8px;
    margin: 0; font-size: 13px; font-weight: 400; color: var(--muted);
}
.per-page select { width: auto; padding: 7px 10px; font-size: 13.5px; }

.pager { margin-top: 14px; }

.pagination {
    display: flex; justify-content: space-between; align-items: center;
    gap: 12px; flex-wrap: wrap;
}
.pagination-count { font-size: 13px; color: var(--muted); }
.pagination-count strong { color: var(--ink); font-weight: 600; }
.pagination-pages { display: flex; gap: 4px; flex-wrap: wrap; }

.page {
    min-width: 34px; padding: 7px 11px;
    border: 1px solid var(--line); background: var(--card); color: var(--ink);
    border-radius: 8px; font: inherit; font-size: 13.5px; cursor: pointer;
}
.page:hover:not(.is-current):not(.is-disabled):not(.is-gap) { background: var(--violet-soft); border-color: var(--violet); color: var(--violet); }
.page.is-current { background: var(--violet); border-color: var(--violet); color: #fff; font-weight: 600; }
.page.is-disabled { color: #B6BAC3; cursor: not-allowed; }
.page.is-gap { border-color: transparent; background: none; cursor: default; }
.page[disabled] { opacity: .5; cursor: progress; }

/* --------------------------------------------------------- reseller workspace */

.reseller-page { max-width: 1720px; margin: 0 auto; }
.reseller-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin: 3px 0 22px; }
.eyebrow { color: #756895; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .12em; }
.eyebrow span { color: #A9A2BD; margin: 0 4px; }
.reseller-header h1 { margin: 4px 0 11px; color: #17112E; font-size: clamp(27px, 2.3vw, 37px); font-weight: 750; letter-spacing: -.045em; line-height: 1.12; }
.reseller-meta, .reseller-header-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.reseller-header-actions { justify-content: flex-end; padding-top: 3px; }
.meta-text { color: var(--muted); font-size: 13px; padding-left: 3px; }
.refresh-note, .device-refresh { color: var(--muted); font-size: 12px; white-space: nowrap; }
.refresh-note small, .device-refresh span:last-child { color: #8790A1; font-size: inherit; }
.refresh-dot { display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; background: #1EA976; box-shadow: 0 0 0 3px #E1F6EE; vertical-align: 1px; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; width: fit-content; border-radius: 100px; padding: 4px 9px; background: #F0F2F6; color: #687183; font-size: 11px; font-weight: 700; white-space: nowrap; }
.status-pill i { width: 6px; height: 6px; flex: 0 0 6px; border-radius: 50%; background: currentColor; }
.status-pill.is-good { background: #E8F7EF; color: #067451; }
.status-pill.is-bad { background: #FFF0EF; color: #B5473C; }
.status-pill.is-warn { background: #FFF5E4; color: #98651A; }

.reseller-kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 11px; margin-bottom: 18px; }
.reseller-kpi { min-width: 0; padding: 17px 18px 15px; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 3px 14px rgba(30, 29, 60, .025); }
.reseller-kpi-label { color: #586176; font-size: 12px; font-weight: 700; }
.reseller-kpi strong { display: block; margin: 3px 0 1px; color: #25184F; font-size: 30px; font-weight: 750; letter-spacing: -.045em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.reseller-kpi small { display: block; color: #8A92A1; font-size: 11px; }
.reseller-kpi.is-warn { border-color: #F2D9AE; background: #FFFCF7; }
.reseller-kpi.is-warn strong { color: #A96812; }
.reseller-content-card { overflow: hidden; padding: 0; border-radius: 16px; }
.reseller-tabs { display: flex; align-items: center; gap: 3px; min-height: 62px; padding: 10px 16px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.reseller-tab { display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto; padding: 9px 13px; border: none; border-radius: 8px; background: transparent; color: #626B7E; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.reseller-tab:hover { background: #F5F3FA; color: var(--violet); }
.reseller-tab.is-active { background: var(--violet-soft); color: #4F2CB3; }
.reseller-tab span { min-width: 19px; padding: 1px 5px; border-radius: 6px; background: #E0D7FA; color: #4F2CB3; font-size: 10px; text-align: center; }
.reseller-signout { margin-left: auto; white-space: nowrap; }

/* Device tab: KPIs, a narrow fleet rail, and an opinionated detail panel. */
.device-tab-body { padding: 22px; }
.device-tab-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 18px; margin-bottom: 16px; }
.device-tab-heading h2 { margin: 2px 0 3px; color: #1D1732; font-size: 22px; letter-spacing: -.03em; }
.device-tab-heading p { margin: 0; color: var(--muted); font-size: 13px; }
.device-refresh { padding-bottom: 4px; }
.device-kpi-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-bottom: 20px; }
.device-kpi { min-width: 0; padding: 14px 15px 13px; border: 1px solid #E9EAF0; border-radius: 11px; background: #FAFBFD; }
.device-kpi span { display: block; color: #5E6779; font-size: 11.5px; font-weight: 700; }
.device-kpi strong { display: block; margin: 2px 0; font-size: 27px; line-height: 1.2; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.device-kpi small { display: block; color: #8A92A1; font-size: 10.5px; }
.device-kpi.is-good strong { color: #087653; }
.device-kpi.is-warn strong { color: #A96812; }
.device-kpi.is-bad strong { color: #B5473C; }
.device-workspace { display: grid; grid-template-columns: minmax(260px, 320px) minmax(0, 1fr); gap: 15px; align-items: start; }
.device-roster, .device-detail { min-width: 0; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.device-roster { overflow: hidden; }
.device-roster-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 17px 16px 11px; }
.device-roster-head h3 { margin: 0; color: #1D1732; font-size: 14px; }
.device-roster-head span { color: #8A92A1; font-size: 11px; }
.device-roster-list { padding: 0 8px 9px; }
.device-choice { display: block; width: 100%; margin: 2px 0 7px; padding: 13px 12px; border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--ink); text-align: left; font: inherit; cursor: pointer; }
.device-choice:hover { background: #F8F6FD; }
.device-choice.is-selected { border-color: #D9CDF9; background: #F8F5FF; box-shadow: inset 3px 0 #6B49C9; }
.device-choice-top, .device-choice-bottom { display: flex; align-items: center; gap: 8px; }
.device-choice-name { overflow: hidden; color: #241B3D; font-size: 13px; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.device-app-icon { display: grid; place-items: center; width: 25px; height: 25px; flex: 0 0 25px; border-radius: 7px; background: #E8DFFF; color: #5531BA; font-size: 16px; font-weight: 700; }
.device-choice-app { display: block; overflow: hidden; margin: 4px 0 10px 33px; color: #798295; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.device-choice-bottom { justify-content: space-between; padding-left: 33px; color: #929AAA; font-size: 10.5px; }
.device-choice-bottom .status-pill { font-size: 10px; padding: 3px 7px; }
.device-roster-empty { padding: 18px 12px 26px; color: var(--muted); font-size: 12px; }
.device-roster-pager { padding: 10px; border-top: 1px solid var(--line); }
.device-fleet-events { padding: 15px 16px; border-top: 1px solid var(--line); background: #FCFCFE; }
.device-fleet-events h4 { margin: 0 0 13px; color: #514A62; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.device-fleet-events p { margin: 0; color: #8790A1; font-size: 11px; line-height: 1.5; }
.device-fleet-event { display: flex; gap: 9px; margin: 0 0 12px; }
.device-fleet-event:last-child { margin-bottom: 0; }
.device-fleet-event strong, .device-event strong { display: block; color: #2D3140; font-size: 11.5px; font-weight: 650; }
.device-fleet-event small, .device-event small { display: block; color: #8891A1; font-size: 10.5px; }
.event-dot { display: inline-block; width: 8px; height: 8px; flex: 0 0 8px; margin-top: 5px; border-radius: 50%; background: #E5A137; }
.event-dot.crash { background: #D85D53; }
.event-dot.lag { background: #E5A137; }
.event-dot.error { background: #9371D5; }
.device-detail { padding: 23px 25px; }
.device-detail-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; }
.device-detail-header h3 { margin: 2px 0 3px; color: #211735; font-size: 22px; letter-spacing: -.035em; line-height: 1.18; }
.device-detail-header p { margin: 0; color: #8A91A0; font-size: 11.5px; }
.device-detail-header p span { margin: 0 4px; }
.device-callout { display: flex; gap: 5px; flex-direction: column; margin: 19px 0 18px; padding: 12px 14px; border: 1px solid #F3DEB9; border-radius: 9px; background: #FFFAF1; color: #855A1B; font-size: 11.5px; }
.device-callout strong { font-size: 12px; }
.device-callout.is-bad { border-color: #F4CFCA; background: #FFF7F5; color: #9A3E36; }
.device-metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; margin: 20px 0 23px; }
.device-metric { min-width: 0; padding: 13px 13px 11px; border: 1px solid #EAEBF1; border-radius: 9px; background: #FAFBFD; }
.device-metric span, .device-reading span { display: block; color: #697284; font-size: 10.5px; font-weight: 700; }
.device-metric strong { display: block; overflow: hidden; margin: 5px 0 2px; color: #2B2350; font-size: 17px; font-weight: 750; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.device-metric small, .device-reading small { display: block; color: #929BAA; font-size: 10px; line-height: 1.35; }
.device-section { padding: 18px 0; border-top: 1px solid #EDF0F5; }
.device-section-title { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 5px 15px; margin-bottom: 12px; }
.device-section-title h4 { margin: 0; color: #252038; font-size: 13px; }
.device-section-title small { color: #9AA2B0; font-size: 10.5px; }
.device-reading-grid, .permission-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.device-reading { padding: 13px 14px; border: 1px solid #EAEBF1; border-radius: 9px; }
.device-reading strong { display: block; margin: 3px 0 1px; color: #2B2350; font-size: 17px; }
.permission-item { display: flex; justify-content: space-between; gap: 10px; padding: 10px 12px; border: 1px solid #EAEBF1; border-radius: 8px; font-size: 11.5px; }
.permission-item span { color: #60697A; }
.permission-item strong { white-space: nowrap; }
.text-good { color: #087653; }
.text-bad { color: #B5473C; }
.text-muted { color: #8790A1; }
.device-no-data { display: flex; flex-direction: column; gap: 3px; padding: 14px; border: 1px dashed #D8DDE8; border-radius: 9px; background: #FAFBFD; color: #667085; font-size: 11.5px; }
.device-no-data strong { color: #3F4A5D; font-size: 12px; }
.device-action-hint { margin-top: 8px; padding: 10px 12px; border-left: 3px solid #D85D53; border-radius: 5px; background: #FFF8F7; color: #803F38; font-size: 11px; }
.device-switches { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.device-switches span { padding: 5px 8px; border-radius: 6px; background: #F1F3F7; color: #6B7483; font-size: 10.5px; text-transform: capitalize; }
.device-switches strong { color: #343B4A; }
.device-event { display: flex; align-items: flex-start; gap: 9px; padding: 9px 1px; border-bottom: 1px solid #F0F1F5; }
.device-event:last-child { border-bottom: none; }
.device-event > div { flex: 1; }
.device-event > span:last-child { color: #788193; font-size: 11px; font-variant-numeric: tabular-nums; }
.device-install-id { overflow-wrap: anywhere; padding-top: 15px; border-top: 1px solid #EDF0F5; color: #9AA2B0; font-size: 10px; }
.device-install-id code { margin-left: 5px; color: #6A7383; }
.device-unselected { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 290px; color: #8790A1; font-size: 12px; text-align: center; }
.device-unselected strong { color: #3E4658; font-size: 18px; }

/* Fleet-wide Devices page */
.fleet-page { max-width: 1720px; margin: 0 auto; }
.fleet-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin: 3px 0 22px; }
.fleet-header h1 { margin: 4px 0 5px; color: #17112E; font-size: clamp(27px, 2.3vw, 37px); letter-spacing: -.045em; line-height: 1.12; }
.fleet-header p { margin: 0; color: var(--muted); font-size: 13px; }
.fleet-panel { overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.fleet-live-notice { display: flex; gap: 11px; align-items: flex-start; margin: -6px 0 17px; padding: 13px 16px; border: 1px solid #F1DEB9; border-radius: 10px; background: #FFFBF3; color: #76521A; }
.fleet-live-notice .event-dot { margin-top: 6px; }
.fleet-live-notice strong { display: block; font-size: 12.5px; }
.fleet-live-notice p { margin: 2px 0 0; font-size: 11.5px; line-height: 1.5; }
.fleet-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 19px 20px; border-bottom: 1px solid var(--line); }
.fleet-toolbar > div:first-child { flex: 1; min-width: 220px; }
.fleet-toolbar h2 { margin: 0 0 2px; color: #221B38; font-size: 17px; }
.fleet-toolbar p { margin: 0; color: #8A92A1; font-size: 11.5px; }
.fleet-controls { display: flex; flex: 0 1 560px; gap: 9px; align-items: center; }
.fleet-controls input[type=search] { width: auto; min-width: 175px; flex: 1; padding: 8px 11px; font-size: 12px; }
.fleet-filters { display: flex; gap: 3px; padding: 3px; border-radius: 8px; background: #F3F4F8; }
.fleet-filters button { padding: 6px 9px; border: 0; border-radius: 6px; background: transparent; color: #677185; font: inherit; font-size: 11px; font-weight: 650; white-space: nowrap; cursor: pointer; }
.fleet-filters button.is-active { background: #fff; color: #4F2CB3; box-shadow: 0 1px 5px rgba(25, 24, 50, .09); }
.fleet-item { display: grid; grid-template-columns: minmax(230px, 2fr) minmax(130px, 1.1fr) minmax(135px, 1.2fr) minmax(130px, 1fr) auto; align-items: center; gap: 18px; min-height: 96px; padding: 16px 20px; border-bottom: 1px solid #EDF0F5; }
.fleet-item:last-child { border-bottom: 0; }
.fleet-item:hover { background: #FDFBFF; }
.fleet-item-phone { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
.fleet-item-phone .device-app-icon { width: 32px; height: 32px; flex-basis: 32px; font-size: 17px; }
.fleet-item-phone div { min-width: 0; }
.fleet-item-phone strong, .fleet-item-owner strong, .fleet-item-seen strong { display: block; overflow: hidden; color: #293145; font-size: 12.5px; text-overflow: ellipsis; white-space: nowrap; }
.fleet-item-phone small, .fleet-item-owner small, .fleet-item-health small, .fleet-item-seen small { display: block; overflow: hidden; margin-top: 3px; color: #8B94A2; font-size: 10.5px; line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; }
.fleet-item-owner > span, .fleet-item-health > span:first-child, .fleet-item-seen > span { display: block; margin-bottom: 5px; color: #8992A1; font-size: 10px; font-weight: 700; letter-spacing: .035em; text-transform: uppercase; }
.fleet-item-health .status-pill { margin-bottom: 1px; }
.fleet-item-link .btn { white-space: nowrap; padding: 7px 10px; font-size: 11px; }
.fleet-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 190px; gap: 3px; color: #8A92A1; font-size: 12px; text-align: center; }
.fleet-empty strong { color: #353A4C; font-size: 16px; }
.fleet-pagination { padding: 12px 20px; border-top: 1px solid var(--line); }

@media (max-width: 1280px) {
    .fleet-item { grid-template-columns: minmax(200px, 2fr) minmax(120px, 1fr) minmax(130px, 1fr) auto; }
    .fleet-item-seen { display: none; }
}

@media (max-width: 960px) {
    .fleet-toolbar, .fleet-header { align-items: flex-start; flex-direction: column; }
    .fleet-controls { width: 100%; flex: none; flex-wrap: wrap; }
    .fleet-item { grid-template-columns: 1fr auto; gap: 12px; }
    .fleet-item-owner, .fleet-item-health { grid-column: 1; padding-left: 42px; }
    .fleet-item-link { grid-column: 2; grid-row: 1 / span 3; }
}

/* Readable operational text at desktop widths; muted data is still legible. */
.reseller-kpi-label, .device-kpi span { font-size: 12.5px; }
.reseller-kpi small, .device-kpi small, .fleet-toolbar p { font-size: 11.5px; }
.device-choice-app, .device-choice-bottom, .device-fleet-event small, .device-event small { font-size: 11.5px; }
.device-metric span, .device-reading span, .device-section-title small, .permission-item, .device-no-data, .device-action-hint { font-size: 12px; }
.device-metric small, .device-reading small, .fleet-item-phone small, .fleet-item-owner small, .fleet-item-health small, .fleet-item-seen small { font-size: 11.5px; }
.fleet-item-phone strong, .fleet-item-owner strong, .fleet-item-seen strong { font-size: 13.5px; }
.fleet-item-owner > span, .fleet-item-health > span:first-child, .fleet-item-seen > span { font-size: 11px; }

@media (max-width: 600px) {
    .fleet-item { padding: 14px; }
    .fleet-item-link { grid-column: 1 / -1; grid-row: auto; padding-left: 42px; }
    .fleet-item-health, .fleet-item-owner { padding-left: 42px; }
}

@media (max-width: 1320px) {
    .reseller-kpis, .device-kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .device-metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1050px) {
    .device-workspace { grid-template-columns: 1fr; }
    .device-roster-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
    .device-fleet-events { display: none; }
}

@media (max-width: 680px) {
    .reseller-header, .device-tab-heading { display: block; }
    .reseller-header-actions { justify-content: flex-start; margin-top: 15px; }
    .reseller-kpis, .device-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .reseller-kpi, .device-kpi { padding: 12px; }
    .reseller-kpi strong { font-size: 25px; }
    .device-tab-body { padding: 15px; }
    .device-refresh { margin-top: 12px; }
    .device-roster-list { grid-template-columns: 1fr; }
    .device-detail { padding: 17px; }
    .device-detail-header { display: block; }
    .device-detail-header .status-pill { margin-top: 12px; }
    .device-metric-grid, .device-reading-grid, .permission-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 430px) {
    .reseller-kpis, .device-kpi-grid, .device-metric-grid, .device-reading-grid, .permission-grid { grid-template-columns: 1fr; }
}

/* Reference-aligned reseller device diagnostics. Kept separate from the
   generic admin styles so the other account screens retain their layout. */
.diagnostics-shell { width: 100%; max-width: none; margin: 0; }
.diagnostics-page { color: #151E32; }
.diag-back { display: flex; align-items: center; gap: 8px; margin: -2px 0 10px; color: #8997AD; font-size: 11px; }
.diag-back button { padding: 0; border: 0; background: none; color: #667891; font: inherit; font-weight: 650; cursor: pointer; }
.diag-back button:hover { color: #4F46E5; }
.diag-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.diag-header h1 { margin: 0; font-size: 31px; font-weight: 750; letter-spacing: -.045em; line-height: 1.15; }
.diag-header-actions, .diag-device-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.diag-refresh-pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border: 1px solid #BBEFDA; border-radius: 100px; background: #E9FCF2; color: #075D48; font-size: 12px; font-weight: 600; white-space: nowrap; }
.diag-refresh-pill i { width: 8px; height: 8px; border-radius: 50%; background: #10B981; }
.diag-refresh-pill span { font-weight: 450; }
.diag-button, .diag-primary { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 31px; padding: 5px 12px; border: 1px solid #CDD8E7; border-radius: 7px; background: #fff; color: #344258; font: inherit; font-size: 12px; font-weight: 650; text-decoration: none; white-space: nowrap; cursor: pointer; }
.diag-button:hover:not(:disabled) { border-color: #949FC0; background: #F8FAFD; }
.diag-button:disabled { opacity: .55; cursor: not-allowed; }
.diag-primary { border-color: #5046E5; background: #5046E5; color: #fff; }
.diag-primary:hover { background: #4136D6; color: #fff; }

.diag-kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 23px; }
.diag-kpi { min-width: 0; min-height: 132px; padding: 16px; border: 1px solid #DBE4EF; border-radius: 12px; background: #fff; box-shadow: 0 2px 3px rgba(28, 48, 82, .05); }
.diag-kpi.is-attention { border: 2px solid #FBBF24; padding: 15px; }
.diag-kpi-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 7px; min-height: 31px; }
.diag-kpi-top > span { color: #6B7F9B; font-size: 12px; font-weight: 800; line-height: 1.3; text-transform: uppercase; letter-spacing: .035em; }
.diag-kpi-top em { padding: 2px 8px; border: 1px solid #DBE3EE; border-radius: 100px; background: #F2F5F9; color: #52627A; font-size: 10.5px; font-style: normal; font-weight: 650; white-space: nowrap; }
.diag-kpi-top em.is-green { border-color: #BEF1D8; background: #E8FCF2; color: #07845C; }
.diag-kpi-top em.is-amber { border-color: #FDE19D; background: #FFF5D8; color: #A45C07; }
.diag-kpi strong { display: block; margin-top: 11px; color: #151E32; font-size: 30px; font-weight: 760; line-height: 1; font-variant-numeric: tabular-nums; }
.diag-kpi strong.is-green-text { color: #07976A; }
.diag-kpi strong.is-amber-text { color: #D37509; }
.diag-kpi small { display: block; margin-top: 8px; color: #7186A4; font-size: 11.5px; line-height: 1.35; }

.diag-workspace { display: grid; grid-template-columns: minmax(300px, 390px) minmax(0, 1fr); align-items: start; gap: 24px; }
.diag-left { min-width: 0; }
.diag-phone-panel, .diag-fleet-signals, .diag-detail { border: 1px solid #DAE3EE; border-radius: 17px; background: #fff; box-shadow: 0 2px 3px rgba(28, 48, 82, .04); }
.diag-phone-panel { padding: 17px 16px 16px; }
.diag-phone-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 21px; }
.diag-phone-heading h2 { margin: 0; font-size: 14px; letter-spacing: -.015em; }
.diag-phone-heading > span { padding: 2px 8px; border: 1px solid #DBE3EE; border-radius: 100px; background: #F2F5F9; color: #52637D; font-size: 11px; font-weight: 700; }
.diag-search { display: flex; align-items: center; gap: 9px; height: 32px; margin: 0 0 16px; padding: 0 10px; border: 1px solid #DAE3EE; border-radius: 7px; }
.diag-search svg { width: 15px; height: 15px; flex: 0 0 15px; fill: none; stroke: #90A2BD; stroke-width: 1.7; }
.diag-search input[type=search] { width: 100%; min-width: 0; padding: 0; border: none; outline: none; box-shadow: none; font-size: 12px; }
.diag-phone-list { display: grid; gap: 10px; }
.diag-phone-choice { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; align-items: start; gap: 10px; width: 100%; min-height: 105px; padding: 16px 14px; border: 1px solid #DAE3EE; border-radius: 12px; background: #fff; color: #243249; text-align: left; font: inherit; cursor: pointer; }
.diag-phone-choice:hover { border-color: #AEB6FF; background: #FBFBFF; }
.diag-phone-choice.is-selected { border: 2px solid #5D56FF; padding: 15px 13px; box-shadow: inset 3px 0 #514BFB; background: #F8F9FF; }
.diag-phone-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: #EEF1F6; color: #4D607D; }
.diag-phone-choice.is-selected .diag-phone-icon { background: #E7E7FF; color: #514BFB; }
.diag-phone-icon svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.diag-phone-main { display: flex; flex-direction: column; min-width: 0; }
.diag-phone-main strong { color: #233148; font-size: 14px; font-weight: 730; line-height: 1.2; }
.diag-phone-main small { margin-top: 3px; color: #7285A2; font-size: 12px; }
.diag-phone-status, .diag-state-pill { display: inline-flex; align-items: center; gap: 5px; width: fit-content; margin-top: 13px; padding: 3px 8px; border: 1px solid #F7D774; border-radius: 100px; background: #FFFAE9; color: #C36808; font-size: 11px; font-weight: 650; white-space: nowrap; }
.diag-phone-status.is-recent, .diag-state-pill.is-recent { border-color: #BBEFDA; background: #E9FCF2; color: #08765A; }
.diag-phone-status i, .diag-state-pill i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.diag-phone-side { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; color: #90A2BD; font-size: 11px; white-space: nowrap; }
.diag-phone-side code { padding: 1px 5px; border-radius: 4px; background: #F1F4F8; color: #768AA6; font-size: 10px; }
.diag-phone-side small { color: #8B9AB2; font-size: 11px; }
.diag-phone-empty { padding: 18px 4px; color: #7186A4; font-size: 12px; }
.diag-phone-pages { margin-top: 12px; }
.diag-fleet-signals { margin-top: 16px; padding: 17px 16px; }
.diag-signals-heading { color: #6F82A0; font-size: 11px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.diag-signals-heading span { margin-right: 6px; color: #91A4C1; font-size: 14px; }
.diag-fleet-signals p { margin: 10px 0 0; color: #6C819F; font-size: 12px; line-height: 1.55; }
.diag-fleet-signals p strong { color: #32425B; }

.diag-detail { min-width: 0; padding: 23px 24px; }
.diag-device-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding-bottom: 24px; border-bottom: 1px solid #DAE3EE; }
.diag-device-heading { min-width: 0; }
.diag-device-kind { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; color: #554BFF; font-size: 12px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.diag-device-kind > span:first-child { color: #B8C3D5; }
.diag-state-pill { margin-top: 0; text-transform: none; letter-spacing: 0; }
.diag-device-header h2 { margin: 5px 0 7px; color: #182239; font-size: 25px; letter-spacing: -.035em; line-height: 1.2; }
.diag-device-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; color: #778AA7; font-size: 12px; }
.diag-device-meta code { margin-right: 2px; padding: 2px 6px; border: 1px solid #DBE4EF; border-radius: 4px; background: #F2F5F9; color: #617591; font-size: 11px; }
.diag-device-meta strong { color: #43536C; font-weight: 650; }
.diag-device-meta b { color: #A6B6CC; font-size: 10px; }
.diag-device-actions { justify-content: flex-end; max-width: 325px; }
.diag-warning { display: flex; align-items: flex-start; gap: 12px; margin: 24px 0; padding: 17px; border: 1px solid #F7D774; border-radius: 11px; background: #FFFBED; }
.diag-warning-icon { display: grid; place-items: center; width: 24px; height: 24px; flex: 0 0 24px; border-radius: 50%; background: #FEF0C2; color: #C46C0A; font-size: 15px; }
.diag-warning > div { flex: 1; min-width: 0; }
.diag-warning strong { color: #28344B; font-size: 13px; }
.diag-warning p { margin: 3px 0 0; color: #586D8B; font-size: 12px; line-height: 1.5; }
.diag-warning a { margin-left: auto; color: #514BFB; font-size: 11px; font-weight: 650; white-space: nowrap; }
.diag-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 32px; }
.diag-metrics > div { min-width: 0; min-height: 119px; padding: 15px 14px; border: 1px solid #DFE7F1; border-radius: 11px; background: #F8FAFD; }
.diag-metrics span, .diag-readings span { display: block; color: #7185A2; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .025em; }
.diag-metrics strong { display: block; margin-top: 12px; color: #26354E; font-size: 16px; font-weight: 750; line-height: 1.2; }
.diag-metrics small, .diag-readings small { display: block; margin-top: 5px; color: #90A3BE; font-size: 11px; line-height: 1.4; }
.diag-section { margin-top: 28px; scroll-margin-top: 18px; }
.diag-section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.diag-section-head h3 { margin: 0; color: #202B41; font-size: 14px; }
.diag-section-head p { margin: 1px 0 0; color: #91A3BE; font-size: 12px; }
.diag-section-head > span { color: #91A3BE; font-size: 11px; }
.diag-readings { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 11px; }
.diag-readings > div { min-width: 0; min-height: 101px; padding: 15px 13px; border: 1px solid #DAE3EE; border-radius: 12px; }
.diag-readings span { font-size: 11px; letter-spacing: 0; text-transform: none; }
.diag-readings strong { display: block; margin-top: 7px; color: #33445F; font-size: 16px; line-height: 1.25; }
.diag-battery { height: 5px; margin-top: 9px; border-radius: 100px; background: #E6EDF5; }
.diag-battery i { display: block; height: 100%; border-radius: inherit; background: #10B981; }
.diag-permission-notice { padding: 15px 17px; border: 1px dashed #F4C75B; border-radius: 11px 11px 0 0; background: #FFFCF2; color: #A45C07; }
.diag-permission-notice strong { font-size: 12px; }
.diag-permission-notice p { margin: 3px 0 0; color: #627690; font-size: 12px; }
.diag-permission-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; padding: 12px; border: 1px dashed #F4C75B; border-radius: 11px; background: #FFFCF2; }
.diag-permission-notice + .diag-permission-grid { border-top: 0; border-radius: 0 0 11px 11px; }
.diag-permission-chip { display: flex; align-items: center; justify-content: space-between; gap: 5px; min-width: 0; padding: 8px; border: 1px solid #DCE5EF; border-radius: 7px; background: #fff; color: #495B75; font-size: 11px; }
.diag-permission-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.diag-permission-chip em { padding: 2px 5px; border-radius: 5px; background: #EDF2F8; color: #8DA1BC; font-size: 10px; font-style: normal; font-weight: 700; }
.diag-permission-chip em.is-on { background: #E8FCF2; color: #07845C; }
.diag-permission-chip em.is-off { background: #FFF0ED; color: #BA5142; }
.diag-permission-help { margin-top: 7px; padding: 8px 11px; border-left: 3px solid #E89921; background: #FFF9EC; color: #76521A; font-size: 11.5px; }
.diag-switches { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 11px; }
.diag-switches span { padding: 5px 8px; border: 1px solid #DAE3EE; border-radius: 6px; color: #667B97; font-size: 11px; text-transform: capitalize; }
.diag-switches strong { color: #293B57; }
.diag-event-filters { display: flex; gap: 5px; }
.diag-event-filters button { padding: 5px 8px; border: 1px solid transparent; border-radius: 5px; background: none; color: #687D9A; font: inherit; font-size: 11px; cursor: pointer; }
.diag-event-filters button.is-active { border-color: #DAE3EE; background: #F1F5F9; color: #3D4D65; }
.diag-event-list { overflow: hidden; min-height: 166px; border: 1px solid #DAE3EE; border-radius: 11px; background: #FAFBFD; }
.diag-event-row { display: flex; align-items: flex-start; gap: 11px; padding: 12px 15px; border-bottom: 1px solid #E5EAF1; }
.diag-event-row:last-child { border-bottom: 0; }
.diag-event-row > div { flex: 1; }
.diag-event-row strong { display: block; color: #33445F; font-size: 12px; }
.diag-event-row small, .diag-event-row > span:last-child { color: #8DA1BC; font-size: 11px; }
.diag-events-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 164px; padding: 25px; text-align: center; }
.diag-events-empty > span { display: grid; place-items: center; width: 37px; height: 37px; margin-bottom: 7px; border-radius: 50%; background: #EFF3F8; color: #92A5C0; font-size: 19px; }
.diag-events-empty strong { color: #33445F; font-size: 12px; }
.diag-events-empty p { max-width: 460px; margin: 5px 0 0; color: #7085A3; font-size: 12px; line-height: 1.45; }
.diag-no-phone { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 400px; color: #7186A4; font-size: 13px; text-align: center; }
.diag-no-phone strong { color: #26354E; font-size: 17px; }

@media (max-width: 1380px) {
    .diag-header { align-items: flex-start; }
    .diag-header-actions { justify-content: flex-end; }
    .diag-workspace { grid-template-columns: minmax(280px, 350px) minmax(0, 1fr); gap: 18px; }
    .diag-device-header { flex-direction: column; }
    .diag-device-actions { max-width: none; justify-content: flex-start; }
}
@media (max-width: 1120px) {
    .diag-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .diag-workspace { grid-template-columns: 1fr; }
    .diag-phone-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 800px) {
    .diag-header { display: block; }
    .diag-header-actions { justify-content: flex-start; margin-top: 15px; }
    .diag-metrics, .diag-readings, .diag-permission-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .diag-warning { flex-wrap: wrap; }
    .diag-warning a { margin-left: 36px; }
}
@media (max-width: 570px) {
    .diag-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .diag-phone-list { grid-template-columns: 1fr; }
    .diag-detail { padding: 17px; }
    .diag-refresh-pill span { display: none; }
    .diag-device-actions { width: 100%; }
}
@media (max-width: 390px) {
    .diag-kpis, .diag-metrics, .diag-readings, .diag-permission-grid { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
    .shell { flex-direction: column; }
    .sidebar { width: 100%; flex: none; flex-direction: row; align-items: center; gap: 14px; padding: 12px 16px; overflow-x: auto; }
    .brand { margin-bottom: 0; }
    .nav { flex-direction: row; }
    .sidebar-foot { display: none; }
    .content { padding: 16px; }
}
