:root {
    --accent: #c41e3a;
    --accent-dark: #9a1830;
    --accent-soft: #fff0f2;
    --sidebar-bg: #141414;
    --sidebar-text: #e8e8e8;
    --sidebar-muted: #d4d4d4;
    --content-bg: #ffffff;
    --page-bg: #f4f5f7;
    --card-border: #e8e8ec;
    --text-primary: #141414;
    --text-secondary: #5c5c66;
    --alert-bg: #fff4f6;
    --alert-border: #f5c2cb;
    --shadow: 0 2px 14px rgba(20, 20, 20, 0.06);
    --shadow-lg: 0 12px 40px rgba(20, 20, 20, 0.12);
    --radius: 12px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    font-family: var(--font);
    color: var(--text-primary);
    background: var(--page-bg);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.82rem;
    background: #f0f0f4;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
}

.muted {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.82rem;
}

/* ── Login page ── */

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

.login-brand {
    flex: 1.1;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 3rem 4rem;
    border-right: 1px solid var(--card-border);
}

.login-brand-logo {
    font-size: 2.25rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin-bottom: 0.15rem;
}

.login-brand-logo span {
    color: var(--accent);
}

.login-brand-sub {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.login-brand-tagline {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 2rem;
}

.login-features {
    list-style: none;
    padding: 0;
    margin: 0;
    max-width: 420px;
}

.login-features li {
    position: relative;
    padding-left: 1.6rem;
    margin-bottom: 1rem;
    color: var(--text-secondary);
    line-height: 1.55;
    font-size: 0.95rem;
}

.login-features li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.55em;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
}

.login-panel {
    flex: 1;
    background: linear-gradient(155deg, #121212 0%, #2a2a2a 55%, #1e1e1e 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 2rem;
}

.login-card-light {
    width: 100%;
    max-width: 420px;
    background: #ffffff;
    border-radius: var(--radius);
    padding: 2.5rem 2.25rem;
    box-shadow: var(--shadow-lg);
}

.login-card-light h1 {
    margin: 0 0 0.35rem;
    font-size: 1.65rem;
    font-weight: 700;
    color: var(--text-primary);
}

.login-card-light .subtitle {
    color: var(--text-secondary);
    font-size: 0.925rem;
    margin: 0 0 1.75rem;
}

.form-group-light label {
    display: block;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 0.45rem;
}

.input-wrap {
    position: relative;
}

.input-icon {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    opacity: 0.45;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.input-icon-user {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%235c5c66' viewBox='0 0 24 24'%3E%3Cpath d='M12 12a5 5 0 1 0-5-5 5 5 0 0 0 5 5zm0 2c-4.42 0-8 2.24-8 5v1h16v-1c0-2.76-3.58-5-8-5z'/%3E%3C/svg%3E");
}

.input-icon-lock {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%235c5c66' viewBox='0 0 24 24'%3E%3Cpath d='M17 8V7a5 5 0 0 0-10 0v1H5v14h14V8zm-8 0V7a3 3 0 0 1 6 0v1z'/%3E%3C/svg%3E");
}

.form-group-light input {
    width: 100%;
    padding: 0.8rem 0.9rem 0.8rem 2.6rem;
    border: 1px solid #d8d8de;
    border-radius: 8px;
    background: #fafafa;
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group-light input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(196, 30, 58, 0.12);
    background: #fff;
}

.form-group-light {
    margin-bottom: 1.2rem;
}

.btn-signin {
    width: 100%;
    padding: 0.9rem 1rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    color: #ffffff;
    cursor: pointer;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    transition: opacity 0.15s, transform 0.1s;
    margin-top: 0.35rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-signin:hover {
    opacity: 0.93;
    text-decoration: none;
}

.btn-signin:active {
    transform: scale(0.99);
}

.btn-signin-arrow {
    font-size: 1.1rem;
}

.login-error-light {
    background: var(--alert-bg);
    border: 1px solid var(--alert-border);
    color: #8b1c2e;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    margin-bottom: 1.25rem;
}

.login-footer-note {
    margin-top: 1.5rem;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.45);
    text-align: center;
}

/* ── Dashboard shell ── */

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

.sidebar {
    width: 252px;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    padding: 1.25rem 0 1rem;
}

.sidebar-brand {
    padding: 0 1.35rem 1.25rem;
    border-bottom: 1px solid #262626;
    margin-bottom: 0.75rem;
}

.sidebar-brand-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: -0.02em;
}

.sidebar-brand-title span {
    color: var(--accent);
}

.sidebar-brand-sub {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    color: var(--sidebar-muted);
    margin-top: 0.25rem;
}

.sidebar-version {
    font-size: 0.72rem;
    color: #666;
    margin-top: 0.6rem;
}

.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
    flex: 1;
}

.sidebar-nav li {
    margin: 0.1rem 0.65rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.72rem 0.85rem;
    color: #f5f5f5;
    text-decoration: none;
    font-size: 0.9rem;
    border-radius: 8px;
    transition: background 0.12s, color 0.12s;
}

.nav-link:hover {
    background: #222;
    color: #ffffff;
    text-decoration: none;
}

.nav-link.active {
    color: #ffffff;
    background: linear-gradient(90deg, rgba(196, 30, 58, 0.22) 0%, rgba(196, 30, 58, 0.08) 100%);
    border-left: 3px solid var(--accent);
    padding-left: calc(0.85rem - 3px);
}

.nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.75;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.nav-link.active .nav-icon {
    opacity: 1;
}

.nav-icon-dashboard {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23e8e8e8' viewBox='0 0 24 24'%3E%3Cpath d='M3 13h8V3H3zm0 8h8v-6H3zm10 0h8V11h-8zm0-18v6h8V3z'/%3E%3C/svg%3E");
}

.nav-icon-users {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23e8e8e8' viewBox='0 0 24 24'%3E%3Cpath d='M16 11c1.66 0 2.99-1.34 2.99-3S17.66 5 16 5s-3 1.34-3 3 1.34 3 3 3zm-8 0c1.66 0 2.99-1.34 2.99-3S9.66 5 8 5 5 6.34 5 8s1.34 3 3 3zm0 2c-2.33 0-7 1.17-7 3.5V19h14v-2.5C15 14.17 10.33 13 8 13zm8 0c-.29 0-.62.02-.97.05 1.16.84 1.97 1.97 1.97 3.45V19h6v-2.5c0-2.33-4.67-3.5-7-3.5z'/%3E%3C/svg%3E");
}

.nav-icon-entitlements,
.nav-icon-sync,
.nav-icon-ota,
.nav-icon-logs,
.nav-icon-devices,
.nav-icon-analytics,
.nav-icon-django {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23e8e8e8' viewBox='0 0 24 24'%3E%3Cpath d='M4 6h16v2H4zm0 5h16v2H4zm0 5h16v2H4z'/%3E%3C/svg%3E");
}

.sidebar-user {
    padding: 1rem 1.35rem 0;
    border-top: 1px solid #262626;
    margin-top: auto;
}

.sidebar-user-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #b8b8b8;
}

.sidebar-user-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: #fff;
    margin: 0.2rem 0 0.5rem;
    word-break: break-word;
}

.sidebar-logout {
    font-size: 0.82rem;
    color: #ffffff;
}

.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--page-bg);
}

.topbar {
    background: var(--content-bg);
    border-bottom: 1px solid var(--card-border);
    padding: 1.15rem 2rem;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.topbar h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.topbar-subtitle {
    margin: 0.25rem 0 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.time-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: #f0f0f4;
    border-radius: 999px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.time-pill-icon {
    width: 14px;
    height: 14px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%235c5c66' viewBox='0 0 24 24'%3E%3Cpath d='M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm.5-13H11v6l5.25 3.15.75-1.23-4.5-2.67z'/%3E%3C/svg%3E");
    background-size: contain;
}

.content {
    padding: 1.5rem 2rem 2rem;
    flex: 1;
}

.page-footer {
    padding: 0.85rem 2rem 1.25rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    border-top: 1px solid var(--card-border);
    background: var(--content-bg);
}

/* ── Sections ── */

.section {
    margin-bottom: 1.5rem;
}

.section-header {
    margin-bottom: 1rem;
}

.section-header.row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.section-header h2 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
}

.section-desc {
    margin: 0.35rem 0 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
    max-width: 720px;
    line-height: 1.5;
}

.panel {
    background: var(--content-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 1.25rem 1.35rem;
    box-shadow: var(--shadow);
}

.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

/* ── Alert banner ── */

.alert-banner {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--alert-bg);
    border: 1px solid var(--alert-border);
    border-radius: var(--radius);
    padding: 0.95rem 1.25rem;
    margin-bottom: 1.5rem;
}

.alert-banner-icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23c41e3a' viewBox='0 0 24 24'%3E%3Cpath d='M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z'/%3E%3C/svg%3E");
    background-size: contain;
}

.alert-banner-text {
    flex: 1;
    font-size: 0.925rem;
    color: #7a1f2e;
}

.btn-alert {
    flex-shrink: 0;
    padding: 0.5rem 1.1rem;
    background: var(--accent);
    color: #ffffff !important;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

.btn-alert:hover {
    background: var(--accent-dark);
    text-decoration: none;
}

.btn-ghost {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
    white-space: nowrap;
}

.btn-ghost:hover {
    text-decoration: underline;
}

/* ── Info cards (administrator row) ── */

.info-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.info-card {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    background: var(--content-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 1.1rem 1.15rem;
    box-shadow: var(--shadow);
}

.info-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--accent-soft);
    flex-shrink: 0;
    background-size: 20px;
    background-repeat: no-repeat;
    background-position: center;
}

.info-icon-user {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23c41e3a' viewBox='0 0 24 24'%3E%3Cpath d='M12 12a5 5 0 1 0-5-5 5 5 0 0 0 5 5zm0 2c-4.42 0-8 2.24-8 5v1h16v-1c0-2.76-3.58-5-8-5z'/%3E%3C/svg%3E");
}

.info-icon-email {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23c41e3a' viewBox='0 0 24 24'%3E%3Cpath d='M20 4H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2zm0 4-8 5L4 8V6l8 5 8-5v2z'/%3E%3C/svg%3E");
}

.info-icon-clock {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23c41e3a' viewBox='0 0 24 24'%3E%3Cpath d='M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm.5-13H11v6l5.25 3.15.75-1.23-4.5-2.67z'/%3E%3C/svg%3E");
}

.info-icon-device {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23c41e3a' viewBox='0 0 24 24'%3E%3Cpath d='M17 1H7c-1.1 0-2 .9-2 2v18c0 1.1.9 2 2 2h10c1.1 0 2-.9 2-2V3c0-1.1-.9-2-2-2zm0 18H7V5h10v14z'/%3E%3C/svg%3E");
}

.info-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 0.2rem;
}

.info-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    word-break: break-word;
}

/* ── KPI cards ── */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.kpi-card {
    position: relative;
    border-radius: var(--radius);
    padding: 1.25rem 1.35rem;
    color: #ffffff;
    overflow: hidden;
    box-shadow: var(--shadow);
    min-height: 118px;
}

.kpi-card::after {
    content: "";
    position: absolute;
    right: -12px;
    bottom: -12px;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
}

.kpi-users {
    background: linear-gradient(135deg, #c41e3a 0%, #8f1529 100%);
}

.kpi-pending {
    background: linear-gradient(135deg, #e85d04 0%, #c44d00 100%);
}

.kpi-active {
    background: linear-gradient(135deg, #2d6a4f 0%, #1b4332 100%);
}

.kpi-plans {
    background: linear-gradient(135deg, #4361ee 0%, #3a0ca3 100%);
}

.kpi-icon {
    width: 28px;
    height: 28px;
    margin-bottom: 0.65rem;
    opacity: 0.9;
    background-size: contain;
    background-repeat: no-repeat;
}

.kpi-users .kpi-icon {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23ffffff' viewBox='0 0 24 24'%3E%3Cpath d='M16 11c1.66 0 2.99-1.34 2.99-3S17.66 5 16 5s-3 1.34-3 3 1.34 3 3 3zm-8 0c1.66 0 2.99-1.34 2.99-3S9.66 5 8 5 5 6.34 5 8s1.34 3 3 3zm0 2c-2.33 0-7 1.17-7 3.5V19h14v-2.5C15 14.17 10.33 13 8 13zm8 0c-.29 0-.62.02-.97.05 1.16.84 1.97 1.97 1.97 3.45V19h6v-2.5c0-2.33-4.67-3.5-7-3.5z'/%3E%3C/svg%3E");
}

.kpi-pending .kpi-icon,
.kpi-active .kpi-icon,
.kpi-plans .kpi-icon {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23ffffff' viewBox='0 0 24 24'%3E%3Cpath d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z'/%3E%3C/svg%3E");
}

.kpi-label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.9;
    margin-bottom: 0.35rem;
}

.kpi-value {
    font-size: 2.1rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.02em;
}

/* ── Sync tiles ── */

.sync-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.85rem;
}

.sync-tile {
    background: var(--content-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 1.1rem 1rem;
    text-align: center;
    box-shadow: var(--shadow);
}

.sync-tile-num {
    display: block;
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--accent);
    line-height: 1.1;
}

.sync-tile-label {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
}

/* ── Tables ── */

.table-wrap {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table th {
    text-align: left;
    padding: 0.55rem 0.65rem;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--card-border);
}

.data-table td {
    padding: 0.7rem 0.65rem;
    border-bottom: 1px solid #f0f0f4;
    vertical-align: middle;
}

.data-table tbody tr:hover td {
    background: #fafafa;
}

.changelog-row td {
    padding-top: 0;
    border-bottom: 1px solid #f0f0f4;
}

.changelog-cell {
    font-size: 0.8rem;
    color: var(--text-secondary);
    padding-bottom: 0.75rem !important;
    padding-left: 0.65rem !important;
}

.badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge-active {
    background: #d8f3dc;
    color: #1b4332;
}

.badge-inactive {
    background: #f0f0f4;
    color: #666;
}

.link-action {
    font-weight: 600;
    font-size: 0.82rem;
}

.empty-state {
    padding: 1.5rem 0.5rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
}

.empty-state p {
    margin: 0.35rem 0;
}

.badge-pending {
    background: #fff3cd;
    color: #856404;
}

.empty-cell {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem !important;
}

.col-check {
    width: 36px;
}

/* ── Toolbar & buttons ── */

.topbar-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.toolbar {
    margin-bottom: 1rem;
}

.toolbar-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.info-banner {
    margin-bottom: 1rem;
    padding: 1rem 1.15rem;
    background: #f8f9fc;
    border-left: 4px solid var(--accent);
}

.info-banner p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.55;
}

.kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.85rem;
    margin-bottom: 1rem;
}

.kpi-mini {
    background: var(--content-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 0.9rem 1rem;
    box-shadow: var(--shadow);
}

.kpi-mini-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.kpi-mini-value {
    font-size: 1.5rem;
    font-weight: 800;
    margin-top: 0.25rem;
}

.toolbar-form-wide {
    align-items: flex-end;
}

.filter-date {
    min-width: 150px;
}

.filter-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.search-input,
.filter-select,
.form-control {
    padding: 0.55rem 0.75rem;
    border: 1px solid #d8d8de;
    border-radius: 8px;
    font-size: 0.9rem;
    background: #fff;
    min-width: 180px;
}

.search-input {
    min-width: 240px;
}

.btn-primary,
.btn-secondary,
.btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.55rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border: none;
    cursor: pointer;
    text-decoration: none;
}

.btn-sm {
    padding: 0.45rem 0.8rem;
    font-size: 0.8rem;
}

.btn-caps {
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 700;
}

.col-actions {
    width: 88px;
    text-align: right;
}

.icon-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    justify-content: flex-end;
}

.icon-form {
    display: inline;
    margin: 0;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid #e0e0e6;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    padding: 0;
    background-repeat: no-repeat;
    background-position: center;
    background-size: 16px;
    transition: border-color 0.12s, background-color 0.12s;
}

.icon-btn:hover {
    border-color: var(--accent);
    background-color: var(--accent-soft);
    text-decoration: none;
}

.icon-btn-edit {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23c41e3a' viewBox='0 0 24 24'%3E%3Cpath d='M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04a1 1 0 0 0 0-1.41l-2.34-2.34a1 1 0 0 0-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z'/%3E%3C/svg%3E");
}

.icon-btn-delete {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%238b1c2e' viewBox='0 0 24 24'%3E%3Cpath d='M6 19a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z'/%3E%3C/svg%3E");
}

.icon-btn-view {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%235c5c66' viewBox='0 0 24 24'%3E%3Cpath d='M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5C21.27 7.61 17 4.5 12 4.5zm0 12.5a5 5 0 1 1 0-10 5 5 0 0 1 0 10zm0-8a3 3 0 1 0 .002 6.001A3 3 0 0 0 12 9z'/%3E%3C/svg%3E");
}

.analytics-charts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

.chart-panel h2 {
    margin: 0 0 1rem;
    font-size: 0.95rem;
    font-weight: 700;
}

.alerts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 0.85rem;
    margin-bottom: 1rem;
}

.alert-card {
    border-radius: var(--radius);
    padding: 0.9rem 1rem;
    border: 1px solid var(--card-border);
    background: #fff;
}

.alert-card-title {
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.35rem;
}

.alert-card p {
    margin: 0;
    font-size: 0.88rem;
    color: var(--text-secondary);
}

.alert-warning { border-left: 4px solid #e85d04; }
.alert-error { border-left: 4px solid #8b1c2e; }
.alert-info { border-left: 4px solid #4361ee; }
.alert-success { border-left: 4px solid #2d6a4f; }

.nav-icon-analytics {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23e8e8e8' viewBox='0 0 24 24'%3E%3Cpath d='M3.5 18.5l6-6 4 4L20.5 9.5 22 11l-8.5 8.5-4-4-6 6z'/%3E%3C/svg%3E");
}

.btn-primary {
    background: var(--accent);
    color: #fff !important;
}

.btn-primary:hover {
    background: var(--accent-dark);
    text-decoration: none;
}

.btn-secondary {
    background: #eef0f4;
    color: var(--text-primary) !important;
}

.btn-secondary:hover {
    background: #e2e5eb;
    text-decoration: none;
}

.btn-danger {
    background: #8b1c2e;
    color: #fff !important;
}

.bulk-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.bulk-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* ── Forms ── */

.admin-form {
    max-width: 640px;
}

.admin-form-wide {
    max-width: none;
}

.checkbox-grid-compact {
    margin: 1rem 0;
}

.form-row {
    margin-bottom: 1rem;
}

.form-row label {
    display: block;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
}

.form-row-check {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.75rem;
    background: #f8f9fc;
    border: 1px solid #ececf2;
    border-radius: 8px;
}

.form-row-check label {
    margin: 0;
    text-transform: uppercase;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    cursor: pointer;
}

.form-check-input {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    flex-shrink: 0;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.65rem;
}

.form-layout {
    max-width: 1100px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

.form-section-wide {
    grid-column: 1 / -1;
}

.form-section h2 {
    margin: 0 0 0.35rem;
    font-size: 1rem;
    font-weight: 700;
}

.form-section .section-desc {
    margin-bottom: 1rem;
}

.form-row-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.85rem;
}

.form-section .form-actions {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #f0f0f4;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.25rem;
}

.field-error {
    color: #8b1c2e;
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

.form-errors {
    background: var(--alert-bg);
    border: 1px solid var(--alert-border);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    color: #7a1f2e;
}

/* ── Flash messages ── */

.flash-messages {
    margin-bottom: 1rem;
}

.flash {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.flash-success {
    background: #d8f3dc;
    color: #1b4332;
}

.flash-warning {
    background: #fff3cd;
    color: #856404;
}

.flash-error {
    background: var(--alert-bg);
    color: #7a1f2e;
}

/* ── Pagination ── */

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid #f0f0f4;
}

.page-link {
    font-weight: 600;
    font-size: 0.85rem;
}

.page-info {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

/* ── Detail views ── */

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}

.section-gap {
    margin-top: 1.25rem;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.panel-header h2,
.panel h2 {
    margin: 0 0 1rem;
    font-size: 1rem;
    font-weight: 700;
}

.quick-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.inline-form {
    display: inline;
}

.detail-list {
    margin: 0;
}

.detail-list > div {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 0.5rem 1rem;
    padding: 0.45rem 0;
    border-bottom: 1px solid #f0f0f4;
}

.detail-list dt {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.detail-list dd {
    margin: 0;
    font-size: 0.9rem;
    word-break: break-word;
}

.detail-list-stacked > div {
    grid-template-columns: 180px 1fr;
}

.meta-panel {
    margin-bottom: 1rem;
}

.inline-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

/* ── Sync hub ── */

.sync-hub-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}

.sync-hub-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem;
    background: var(--content-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s, transform 0.1s;
}

.sync-hub-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    text-decoration: none;
}

.sync-hub-count {
    font-size: 2rem;
    font-weight: 800;
    color: var(--accent);
    line-height: 1;
}

.sync-hub-label {
    margin-top: 0.5rem;
    font-size: 0.82rem;
    font-weight: 600;
    text-align: center;
    color: var(--text-secondary);
}

.nav-icon-devices,
.nav-icon-plans,
.nav-icon-usage {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23e8e8e8' viewBox='0 0 24 24'%3E%3Cpath d='M17 1H7c-1.1 0-2 .9-2 2v18c0 1.1.9 2 2 2h10c1.1 0 2-.9 2-2V3c0-1.1-.9-2-2-2zm0 18H7V5h10v14z'/%3E%3C/svg%3E");
}

.nav-icon-plans {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23e8e8e8' viewBox='0 0 24 24'%3E%3Cpath d='M19 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2zm0 16H5V5h14v14z'/%3E%3C/svg%3E");
}

.nav-icon-usage {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23e8e8e8' viewBox='0 0 24 24'%3E%3Cpath d='M11.8 10.9c-2.27-.59-3-1.2-3-2.15 0-1.09 1.01-1.85 2.7-1.85 1.78 0 2.44.85 2.5 2.1h2.21c-.07-1.72-1.12-3.3-3.21-3.81V3h-3v2.16c-1.94.42-3.5 1.68-3.5 3.61 0 2.31 1.91 3.46 4.7 4.13 2.5.6 3 1.48 3 2.41 0 .69-.49 1.79-2.7 1.79-2.06 0-2.87-.92-2.98-2.1h-2.2c.12 2.19 1.76 3.42 3.68 3.83V21h3v-2.15c1.95-.37 3.5-1.5 3.5-3.55 0-2.84-2.43-3.81-4.7-4.4z'/%3E%3C/svg%3E");
}

/* ── Responsive ── */

@media (max-width: 1100px) {
    .info-grid,
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .sync-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .two-col,
    .detail-grid,
    .form-grid,
    .form-row-grid,
    .analytics-charts {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .login-page {
        flex-direction: column;
    }

    .login-brand {
        padding: 2rem;
        border-right: none;
        border-bottom: 1px solid var(--card-border);
    }

    .app-shell {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
    }

    .sidebar-nav {
        display: flex;
        flex-wrap: wrap;
        padding: 0 0.5rem;
    }

    .sidebar-user {
        display: none;
    }

    .topbar {
        flex-direction: column;
        padding: 1rem;
    }

    .time-pill {
        white-space: normal;
    }

    .content {
        padding: 1rem;
    }

    .info-grid,
    .kpi-grid,
    .sync-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 480px) {
    .info-grid,
    .kpi-grid,
    .sync-grid {
        grid-template-columns: 1fr;
    }
}
