/* ===== Afrilen Finance Admin - Material Design Theme =====
   Matches the Blazor MudBlazor design exactly */

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

:root {
    --primary: #1565C0;
    --primary-light: rgba(21, 101, 192, 0.12);
    --primary-hover: #1254a1;
    --secondary: #00897B;
    --secondary-light: rgba(0, 137, 123, 0.12);
    --tertiary: #7B1FA2;
    --bg: #F5F5F5;
    --surface: #FFFFFF;
    --text-primary: #212121;
    --text-secondary: #757575;
    --nav-bg: #FFFFFF;
    --nav-text: #424242;
    --divider: #e0e0e0;
    --radius: 8px;
    --card-radius: 12px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 20px rgba(0,0,0,0.12);

    /* Status colors */
    --success: #4CAF50;
    --success-light: #E8F5E9;
    --warning: #FF9800;
    --warning-light: #FFF3E0;
    --error: #F44336;
    --error-light: #FFEBEE;
    --info: #2196F3;
    --info-light: #E3F2FD;
    --dark: #424242;
    --default: #9E9E9E;
    --default-light: #F5F5F5;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', Arial, sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ===== App Bar ===== */
.appbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: linear-gradient(135deg, #0D47A1 0%, #1565C0 50%, #1976D2 100%);
    color: #fff;
    display: flex;
    align-items: center;
    padding: 0 20px;
    z-index: 100;
    box-shadow: 0 2px 12px rgba(21,101,192,0.3), 0 1px 3px rgba(0,0,0,0.12);
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.appbar::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
}

.appbar .menu-btn {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.1);
    color: #fff;
    cursor: pointer;
    padding: 8px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.15s, border-color 0.2s;
}

.appbar .menu-btn:hover {
    background: rgba(255,255,255,0.18);
    border-color: rgba(255,255,255,0.2);
    transform: scale(1.05);
}

.appbar .menu-btn svg { width: 22px; height: 22px; }

.appbar .brand {
    font-size: 1.15rem;
    font-weight: 700;
    margin-left: 12px;
    letter-spacing: -0.01em;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

.appbar .spacer { flex: 1; }

.appbar .toolbar-btn {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.08);
    color: #fff;
    cursor: pointer;
    padding: 8px;
    border-radius: 10px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    text-decoration: none;
    margin-left: 6px;
    transition: background 0.2s, transform 0.15s, border-color 0.2s;
}

.appbar .toolbar-btn:hover {
    background: rgba(255,255,255,0.18);
    border-color: rgba(255,255,255,0.2);
    transform: scale(1.05);
}

.appbar .toolbar-btn svg {
    width: 22px;
    height: 22px;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.1));
}

.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 19px;
    height: 19px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--error);
    color: #fff;
    border: 2px solid #1565C0;
    font-size: 0.68rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.contract-device-empty {
    border: 1px dashed var(--divider);
    border-radius: 12px;
    padding: 14px;
    background: var(--default-light);
    color: var(--text-secondary);
    font-size: 0.88rem;
}

.contract-device-empty.contract-device-error {
    border-color: rgba(244,67,54,0.35);
    background: var(--error-light);
    color: var(--error);
}

.contract-device-cards {
    display: grid;
    gap: 10px;
    margin-top: 10px;
}

.contract-device-card {
    width: 100%;
    border: 1px solid var(--divider);
    border-radius: 14px;
    background: #fff;
    color: var(--text-primary);
    display: grid;
    grid-template-columns: 42px 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 12px;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}

.contract-device-card:hover,
.contract-device-card.active {
    border-color: var(--primary);
    box-shadow: 0 8px 22px rgba(21,101,192,0.14);
    transform: translateY(-1px);
}

.contract-device-card.active {
    background: linear-gradient(135deg, #fff 0%, rgba(21,101,192,0.06) 100%);
}

.contract-device-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.contract-device-icon svg {
    width: 24px;
    height: 24px;
}

.contract-device-info {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.contract-device-info strong,
.contract-device-info span,
.contract-device-info small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.contract-device-info span,
.contract-device-info small {
    color: var(--text-secondary);
}

.contract-device-info small {
    font-size: 0.75rem;
}

.contract-device-status {
    border-radius: 999px;
    padding: 4px 9px;
    font-size: 0.72rem;
    font-weight: 700;
    background: var(--default-light);
    color: var(--text-secondary);
}

.contract-device-status.online {
    background: var(--success-light);
    color: var(--success);
}

.contract-device-status.offline {
    background: var(--default-light);
    color: var(--default);
}

/* ===== Sidebar / Drawer ===== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(2px);
    z-index: 99;
}

.sidebar-overlay.open { display: block; }

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 272px;
    background: #0F1923;
    color: #CDD6E0;
    z-index: 110;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 24px rgba(0,0,0,0.35);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar.open { transform: translateX(0); }

.sidebar .drawer-header {
    padding: 22px 20px 14px;
    background: linear-gradient(180deg, rgba(21,101,192,0.25) 0%, rgba(21,101,192,0.05) 100%);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.sidebar .drawer-header::before {
    content: 'A';
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #1565C0, #42A5F5);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(21,101,192,0.4);
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.sidebar nav {
    padding: 8px 10px;
    flex: 1;
    overflow-y: auto;
}

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    margin: 1px 0;
    border-radius: 8px;
    color: #8899AA;
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    transition: all 0.18s ease;
    position: relative;
    border-left: 3px solid transparent;
}

.sidebar nav a:hover {
    background: rgba(255,255,255,0.05);
    color: #CDD6E0;
    border-left-color: rgba(255,255,255,0.15);
}

.sidebar nav a.active {
    background: rgba(21, 101, 192, 0.18);
    color: #64B5F6;
    font-weight: 600;
    border-left-color: #42A5F5;
    box-shadow: inset 0 0 0 1px rgba(21,101,192,0.15);
}

.sidebar nav a svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.7;
    transition: opacity 0.18s;
}

.sidebar nav a:hover svg { opacity: 0.9; }
.sidebar nav a.active svg { opacity: 1; color: #42A5F5; }

.sidebar .divider {
    border-top: 1px solid rgba(255,255,255,0.06);
    margin: 10px 14px;
}

.sidebar > form { flex-shrink: 0; }

.sidebar .logout-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    margin: 4px 10px 14px;
    border-radius: 8px;
    background: rgba(244,67,54,0.08);
    border: 1px solid rgba(244,67,54,0.12);
    color: #EF9A9A;
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 500;
    font-family: inherit;
    width: calc(100% - 20px);
    text-align: left;
    transition: all 0.18s ease;
}

.sidebar .logout-btn:hover {
    background: rgba(244,67,54,0.18);
    color: #EF5350;
    border-color: rgba(244,67,54,0.25);
}

.sidebar .logout-btn svg {
    width: 20px;
    height: 20px;
    opacity: 0.7;
    transition: opacity 0.18s;
}

.sidebar .logout-btn:hover svg { opacity: 1; }

/* ===== Main Content ===== */
.main-content {
    margin-top: 64px;
    min-height: calc(100vh - 64px);
    padding: 24px;
    max-width: 1400px;
    margin-left: 0;
    transition: margin-left 0.25s ease;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.page-subtitle {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

/* ===== Cards ===== */
.card {
    background: var(--surface);
    border-radius: var(--card-radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.card .card-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.card .card-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
    margin-top: 4px;
}

/* ===== Panel (white card with border) ===== */
.panel {
    background: var(--surface);
    border: 1px solid var(--divider);
    border-radius: var(--card-radius);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.panel h2, .panel h3, .panel .panel-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

/* ===== Stats Grid ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

/* ===== Grid ===== */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

/* ===== Profile Page ===== */
.profile-layout {
    display: grid;
    grid-template-columns: 290px 1fr;
    gap: 24px;
    align-items: start;
}

/* -- Sidebar -- */
.profile-sidebar { position: sticky; top: 88px; }

.profile-sidebar-card {
    background: var(--surface);
    border-radius: 16px;
    padding: 28px 24px 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.04);
    text-align: center;
    border: 1px solid var(--divider);
}

.ps-avatar-wrap {
    position: relative;
    display: inline-block;
    margin-bottom: 16px;
}

.ps-avatar {
    width: 88px;
    height: 88px;
    border-radius: 28px;
    background: linear-gradient(135deg, #1565C0 0%, #42A5F5 50%, #64B5F6 100%);
    color: #fff;
    font-size: 2rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(21,101,192,0.3), 0 0 0 4px rgba(21,101,192,0.08);
    transition: transform 0.2s ease;
}

.ps-avatar:hover { transform: scale(1.04); }

.ps-status-dot {
    position: absolute;
    bottom: 6px;
    right: 6px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #4CAF50;
    border: 3px solid #fff;
    box-shadow: 0 0 0 3px rgba(76,175,80,0.18);
    animation: statusPulse 2s infinite;
}

@keyframes statusPulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(76,175,80,0.18); }
    50% { box-shadow: 0 0 0 8px rgba(76,175,80,0.08); }
}

.ps-name {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.ps-role {
    display: inline-block;
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 12px;
}

.ps-email {
    font-size: 0.82rem;
    color: var(--text-secondary);
    word-break: break-word;
}

.ps-divider {
    border-top: 1px solid var(--divider);
    margin: 18px 0;
}

.ps-meta {
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-align: left;
}

.ps-meta-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.ps-meta-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--primary);
    opacity: 0.6;
}

.ps-logout-btn {
    width: 100%;
    margin-top: 18px;
    padding: 10px;
    border: 1px solid rgba(239,68,68,0.2);
    border-radius: 10px;
    background: rgba(239,68,68,0.04);
    color: #EF5350;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.18s, border-color 0.18s;
}

.ps-logout-btn:hover {
    background: rgba(239,68,68,0.1);
    border-color: rgba(239,68,68,0.35);
}

.ps-logout-btn svg { width: 18px; height: 18px; }

/* -- Main panels -- */
.profile-main { display: flex; flex-direction: column; gap: 20px; }

.profile-panel {
    padding: 0;
    overflow: hidden;
}

.profile-panel-head {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
    border-bottom: 1px solid var(--divider);
    background: linear-gradient(180deg, rgba(21,101,192,0.03), transparent);
}

.pph-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, #1565C0, #42A5F5);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(21,101,192,0.2);
}

.pph-icon svg { width: 22px; height: 22px; }

.pph-icon-lock {
    background: linear-gradient(135deg, #FF9800, #FFB74D);
    box-shadow: 0 4px 12px rgba(255,152,0,0.25);
}

.pph-icon-shield {
    background: linear-gradient(135deg, #43A047, #66BB6A);
    box-shadow: 0 4px 12px rgba(76,175,80,0.25);
}

.profile-panel-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 2px;
}

.profile-panel-sub {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* -- Form -- */
.profile-form { padding: 20px 24px 24px; }

.pf-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.pf-row-2 {
    grid-template-columns: 1fr 1fr;
}

.pf-field label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.pf-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.pf-input-icon {
    position: absolute;
    left: 14px;
    width: 18px;
    height: 18px;
    color: var(--text-secondary);
    opacity: 0.5;
    pointer-events: none;
    z-index: 1;
}

.pf-input-wrap input {
    width: 100%;
    padding: 11px 14px 11px 42px;
    border: 1px solid var(--divider);
    border-radius: 10px;
    font-size: 0.88rem;
    font-family: inherit;
    background: var(--surface);
    color: var(--text-primary);
    transition: border-color 0.18s, box-shadow 0.18s;
}

.pf-input-wrap input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(21,101,192,0.1);
}

.pf-input-wrap input::placeholder { color: var(--text-secondary); opacity: 0.5; }

.pf-actions {
    padding-top: 4px;
}

.pf-actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    font-size: 0.9rem;
}

/* -- Security status -- */
.profile-security {
    padding: 16px 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ps-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--divider);
}

.ps-item:last-child { border-bottom: none; }

.psi-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.psi-check {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: rgba(76,175,80,0.1);
    color: #4CAF50;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.psi-check svg { width: 18px; height: 18px; }

.psi-left strong {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 1px;
}

.psi-left span {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* ===== Responsive ===== */
@media (max-width: 899px) {
    .profile-layout { grid-template-columns: 1fr; }
    .profile-sidebar { position: static; }
    .pf-row-2 { grid-template-columns: 1fr; }
    .ps-item { flex-direction: column; align-items: flex-start; gap: 8px; }
}

.notification-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    margin-bottom: 16px;
}

.notification-head p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 2px;
}

tr.notification-unread {
    background: linear-gradient(90deg, rgba(21,101,192,0.08), rgba(21,101,192,0.02));
}

tr.notification-unread td:first-child {
    border-left: 4px solid var(--primary);
}

/* ===== Forms ===== */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

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

input:not([type]),
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="date"],
input[type="datetime-local"],
input[type="tel"],
input[type="url"],
textarea,
select {
    padding: 10px 14px;
    border: 1px solid #c4c4c4;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.9rem;
    background: var(--surface);
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
    width: 100%;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(21, 101, 192, 0.2);
}

input::placeholder {
    color: #9e9e9e;
}

textarea {
    min-height: 96px;
    resize: vertical;
    line-height: 1.45;
}

input[readonly],
textarea[readonly] {
    background: #f7f8fa;
    color: var(--text-secondary);
    cursor: default;
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='%23757575'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 36px;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    transition: background 0.2s, box-shadow 0.2s, opacity 0.2s;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--surface);
    color: var(--primary);
    border-color: var(--primary);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--primary-light);
}

.btn-success {
    background: var(--success);
    color: #fff;
    border-color: var(--success);
}

.btn-success:hover:not(:disabled) {
    background: #43A047;
}

.btn-error {
    background: var(--error);
    color: #fff;
    border-color: var(--error);
}

.btn-error:hover:not(:disabled) {
    background: #E53935;
}

.btn-warning {
    background: var(--warning);
    color: #fff;
    border-color: var(--warning);
}

.btn-warning:hover:not(:disabled) {
    background: #F57C00;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.8rem;
}

.btn-text {
    background: none;
    border: none;
    color: var(--primary);
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
    padding: 4px 8px;
    text-decoration: none;
}
.btn-text:hover {
    background: var(--primary-light);
    border-radius: 4px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: none;
    border: none;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-icon:hover {
    background: rgba(0,0,0,0.08);
}

.btn-icon svg {
    width: 20px;
    height: 20px;
}

/* ===== Tables ===== */
.table-wrap {
    overflow-x: auto;
    background: var(--surface);
    border-radius: var(--card-radius);
    box-shadow: var(--shadow-sm);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

thead th {
    background: #fafafa;
    color: var(--text-secondary);
    font-weight: 600;
    text-align: left;
    padding: 12px 16px;
    border-bottom: 2px solid var(--divider);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--divider);
    color: var(--text-primary);
}

tbody tr:hover {
    background: rgba(0,0,0,0.02);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* Table avatar */
.table-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.8rem;
    margin-right: 10px;
    vertical-align: middle;
    flex-shrink: 0;
}

td[data-label="Device"] > .table-avatar,
td[data-label="Name"] > .table-avatar {
    display: inline-flex;
}

td[data-label="Device"],
td[data-label="Name"] {
    display: flex;
    align-items: center;
}

.table-actions {
    display: flex;
    gap: 4px;
    justify-content: flex-end;
}

/* ===== Chips / Badges ===== */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 16px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}

.chip-success {
    background: var(--success-light);
    color: #2E7D32;
}

.chip-warning {
    background: var(--warning-light);
    color: #E65100;
}

.chip-error {
    background: var(--error-light);
    color: #C62828;
}

.chip-info {
    background: var(--info-light);
    color: #1565C0;
}

.chip-default {
    background: var(--default-light);
    color: #616161;
}

.chip-dark {
    background: #E0E0E0;
    color: #212121;
}

.chip-tertiary {
    background: #F3E5F5;
    color: #6A1B9A;
}

.chip-outlined {
    background: transparent;
    border: 1px solid currentColor;
}

.chip .chip-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

/* ===== Alerts / Flash Messages ===== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 0.9rem;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.alert-success {
    background: var(--success-light);
    color: #2E7D32;
    border-left: 4px solid var(--success);
}

.alert-error {
    background: var(--error-light);
    color: #C62828;
    border-left: 4px solid var(--error);
}

.alert-warning {
    background: var(--warning-light);
    color: #E65100;
    border-left: 4px solid var(--warning);
}

.alert-info {
    background: var(--info-light);
    color: #1565C0;
    border-left: 4px solid var(--info);
}

/* ===== Modal / Dialog ===== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
}

.modal-overlay.open {
    display: flex;
}

.modal {
    background: var(--surface);
    border-radius: var(--card-radius);
    padding: 24px;
    max-width: 520px;
    width: 90vw;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 24px 48px rgba(0,0,0,0.2);
}

.modal h3 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 12px;
}

.modal p {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.modal .modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

/* Modal form styles */
.modal .form-group,
.modal-form .form-group {
    margin-bottom: 14px;
}

.modal .form-group:last-of-type,
.modal-form .form-group:last-of-type {
    margin-bottom: 0;
}

.modal .grid-form,
.modal-form .grid-form {
    margin-bottom: 4px;
}

.modal .grid-form .form-group,
.modal-form .grid-form .form-group {
    margin-bottom: 0;
}

.modal input,
.modal select,
.modal textarea,
.modal-form input,
.modal-form select,
.modal-form textarea {
    width: 100%;
    box-sizing: border-box;
}

/* ===== Loading Modal ===== */
.loading-modal {
    background: var(--surface);
    border-radius: var(--card-radius);
    padding: 40px 32px;
    text-align: center;
    box-shadow: 0 24px 48px rgba(0,0,0,0.2);
    max-width: 360px;
    width: 80vw;
}

.spinner {
    width: 44px;
    height: 44px;
    border: 4px solid var(--divider);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#loadingText {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-top: 16px;
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%) translateY(120px);
    background: var(--dark);
    color: #fff;
    padding: 14px 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 300;
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    pointer-events: none;
    font-size: 0.9rem;
    font-weight: 500;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.toast.toast-success {
    background: var(--success);
}

.toast.toast-error {
    background: var(--error);
}

.toast.toast-info {
    background: var(--primary);
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ===== Progress Bar ===== */
.progress-linear {
    height: 4px;
    background: var(--divider);
    border-radius: 2px;
    overflow: hidden;
    margin: 12px 0;
}

.progress-linear .bar {
    height: 100%;
    background: var(--primary);
    animation: progress-indeterminate 1.5s ease-in-out infinite;
    width: 40%;
    border-radius: 2px;
}

@keyframes progress-indeterminate {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(350%); }
}

/* ===== Toolbar Row (search + buttons) ===== */
.toolbar-row {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.toolbar-row .search-field {
    flex: 1;
    min-width: 200px;
    max-width: 360px;
}

.toolbar-row .spacer {
    flex: 1;
}

/* ===== Search Input ===== */
.search-input-wrap {
    position: relative;
}

.search-input-wrap svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--text-secondary);
    pointer-events: none;
}

.search-input-wrap input {
    padding-left: 40px !important;
}

/* ===== Dialog Form ===== */
.dialog-form .form-group {
    margin-bottom: 12px;
}

/* ===== Device Console (two-panel) ===== */
.device-console {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 20px;
    min-height: 500px;
}

.device-list-panel {
    background: var(--surface);
    border-radius: var(--card-radius);
    padding: 16px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
}

.device-list-panel .search-wrap {
    margin-bottom: 12px;
}

.device-list-scroll {
    flex: 1;
    overflow-y: auto;
    max-height: 600px;
}

.device-console .device-card {
    background: var(--surface);
    border: 1px solid var(--divider);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.device-console .device-card:hover {
    border-color: #bdbdbd;
    box-shadow: var(--shadow-sm);
}

.device-console .device-card.selected {
    border: 2px solid var(--primary);
    box-shadow: 0 0 0 2px rgba(21, 101, 192, 0.15);
}

.device-console .device-card .device-info strong {
    display: block;
    font-size: 0.9rem;
}

.device-console .device-card .device-info small {
    color: var(--text-secondary);
    font-size: 0.78rem;
}

.device-console .device-card .device-meta {
    text-align: right;
}

.command-panel {
    background: var(--surface);
    border-radius: var(--card-radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
}

.command-panel .empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    color: var(--text-secondary);
    text-align: center;
}

.command-panel .empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.4;
}

.command-section {
    background: #fafafa;
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 12px;
}

.command-section h4 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.command-log {
    background: #1a1a2e;
    color: #a5d6a7;
    padding: 12px;
    border-radius: var(--radius);
    font-family: 'Cascadia Code', 'Fira Code', monospace;
    font-size: 0.75rem;
    min-height: 120px;
    max-height: 250px;
    overflow-y: auto;
    line-height: 1.6;
    flex: 1;
}

.command-log .log-info { color: #81C784; }
.command-log .log-success { color: #4CAF50; }
.command-log .log-warn { color: #FFB74D; }
.command-log .log-error { color: #EF5350; }

/* ===== Policies page ===== */
.policy-overview-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
    gap: 18px;
}

.policy-panel {
    margin-bottom: 0;
    overflow: hidden;
}

.policy-panel-head {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: flex-start;
    margin-bottom: 16px;
}

.policy-panel-head h3 {
    margin: 0 0 4px;
}

.policy-panel-head p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.86rem;
}

.policy-rule-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.policy-rule-item {
    display: grid;
    grid-template-columns: 120px 110px 1fr;
    gap: 12px;
    align-items: center;
    padding: 12px 14px;
    border: 1px solid var(--divider);
    border-radius: 12px;
    background: linear-gradient(180deg, #fff 0%, #fafafa 100%);
}

.policy-rule-delay {
    font-weight: 700;
    font-size: 0.84rem;
    color: var(--text-primary);
}

.policy-rule-action {
    font-size: 0.86rem;
    color: var(--text-secondary);
}

.policy-eval-grid {
    display: grid;
    gap: 10px;
}

.policy-eval .eval-stat {
    padding: 14px;
    border: 1px solid var(--divider);
    border-radius: 12px;
    background: #fafafa;
}

.policy-eval .eval-stat span {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.policy-eval .eval-stat strong {
    display: block;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.policy-note,
.policy-footnote {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.policy-note {
    margin-top: 14px;
}

.policy-footnote {
    margin-top: 14px;
}

.lock-screen-panel {
    border: 1px solid rgba(21, 101, 192, 0.16);
    background:
        radial-gradient(circle at top left, rgba(21, 101, 192, 0.08), transparent 34%),
        var(--surface);
}

.lock-screen-content {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 26px;
    align-items: start;
}

.lock-screen-form {
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid var(--divider);
    border-radius: 16px;
    padding: 18px;
}

.lock-screen-actions {
    margin-top: 18px;
}

.lock-preview-card {
    display: flex;
    justify-content: center;
}

.lock-preview-phone {
    width: 280px;
    min-height: 520px;
    border-radius: 34px;
    padding: 14px;
    background: #05070f;
    box-shadow: 0 24px 50px rgba(15, 23, 42, 0.24);
    border: 8px solid #151923;
    color: #f8fafc;
}

.lock-preview-status {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    color: #cbd5e1;
    padding: 4px 8px 12px;
}

.lock-preview-body {
    border-radius: 24px;
    min-height: 452px;
    padding: 28px 18px;
    background:
        radial-gradient(circle at top, rgba(239, 68, 68, 0.18), transparent 34%),
        linear-gradient(180deg, #101522 0%, #060811 100%);
    text-align: center;
}

.lock-preview-icon {
    width: 54px;
    height: 54px;
    border-radius: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    font-weight: 800;
    font-size: 1.4rem;
    border: 1px solid rgba(248, 113, 113, 0.25);
    margin-bottom: 16px;
}

.lock-preview-body h4 {
    margin: 0 0 8px;
    font-size: 1rem;
    letter-spacing: 0.08em;
}

.lock-preview-body p {
    margin: 0;
    color: #94a3b8;
    font-size: 0.78rem;
}

.lock-preview-payment {
    margin: 22px 0 14px;
    padding: 16px;
    border-radius: 18px;
    background: rgba(15, 23, 42, 0.72);
    border: 1px solid rgba(148, 163, 184, 0.12);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.lock-preview-payment strong {
    color: #fbbf24;
    font-size: 0.84rem;
}

.lock-preview-payment span {
    color: #fb923c;
    font-weight: 800;
    font-size: 1.15rem;
    letter-spacing: 0.04em;
    overflow-wrap: anywhere;
}

.lock-preview-payment small {
    color: #cbd5e1;
    font-size: 0.78rem;
    font-weight: 700;
}

.lock-preview-instructions {
    margin-top: 12px !important;
}

.lock-preview-footer {
    margin-top: 34px !important;
    color: #64748b !important;
}

/* ===== Android Management ===== */
.aem-setup-alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
}

.aem-setup-alert code {
    background: rgba(0,0,0,0.06);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85em;
}

.aem-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-top: 12px;
}

.aem-stat-card {
    background: var(--surface);
    border-radius: var(--card-radius);
    padding: 16px;
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.aem-stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
}

.aem-stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ===== Reports cards ===== */
.reports-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.report-card {
    background: var(--surface);
    border-radius: var(--card-radius);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.report-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.report-card svg {
    width: 40px;
    height: 40px;
    margin-bottom: 12px;
}

.report-card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.report-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ===== Settings ===== */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.settings-grid .panel {
    margin-bottom: 0;
}

/* ===== Login Page ===== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1565C0 0%, #00897B 100%);
    padding: 20px;
}

.login-card {
    background: var(--surface);
    border-radius: 14px;
    padding: 40px;
    width: min(440px, 100%);
    box-shadow: 0 16px 60px rgba(0,0,0,0.25);
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.login-card h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0;
    text-align: center;
}

.login-card .subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-align: center;
    margin-top: -12px;
}

.login-card .form-group {
    gap: 6px;
}

.login-card .form-group label {
    font-size: 0.85rem;
    color: var(--text-primary);
}

.login-card .btn-primary {
    padding: 12px;
    font-size: 0.95rem;
    justify-content: center;
}

/* ===== Tabs ===== */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--divider);
    margin-bottom: 16px;
}

.tab {
    padding: 10px 20px;
    border: none;
    background: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.2s, border-color 0.2s;
}

.tab:hover {
    color: var(--primary);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* ===== Divider ===== */
.divider {
    border-top: 1px solid var(--divider);
    margin: 16px 0;
}

/* ===== Settings Switch / Toggle ===== */
.toggle-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 12px 0;
}

.toggle {
    position: relative;
    width: 48px;
    height: 26px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle .slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #ccc;
    border-radius: 26px;
    transition: 0.3s;
}

.toggle .slider::before {
    content: '';
    position: absolute;
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
}

.toggle input:checked + .slider {
    background: var(--primary);
}

.toggle input:checked + .slider::before {
    transform: translateX(22px);
}

/* ===== DL (description list) ===== */
dl {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 0;
}

dt, dd {
    padding: 10px 12px;
    border-bottom: 1px solid var(--divider);
    font-size: 0.88rem;
}

dt {
    font-weight: 600;
    color: var(--text-secondary);
    background: #fafafa;
}

/* ===== Device Phone Mockup ===== */
.device-inspector {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 2.5rem;
    background: var(--surface);
    border-radius: var(--card-radius);
    padding: 2rem;
    box-shadow: var(--shadow-sm);
    align-items: start;
}

.device-phone-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: sticky;
    top: 1rem;
    padding-top: 0.5rem;
}

.device-phone {
    width: 270px;
    height: 540px;
    background: #000;
    border-radius: 48px;
    padding: 12px;
    box-sizing: border-box;
    box-shadow: 0 30px 60px -15px rgba(0,0,0,0.3), inset 0 0 3px 3px rgba(255,255,255,0.15);
    position: relative;
}

.device-phone .phone-screen {
    width: 100%;
    height: 100%;
    border-radius: 38px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
    text-align: center;
    position: relative;
    border: 1px solid rgba(255,255,255,0.04);
    transition: background 0.5s ease;
}

.device-phone .phone-notch {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    width: 85px;
    height: 24px;
    background: #000;
    border-radius: 20px;
    z-index: 10;
}

.device-phone .phone-home {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 90px;
    height: 4px;
    background: rgba(255,255,255,0.25);
    border-radius: 2px;
}

.device-phone .phone-glow {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 50%;
    background: linear-gradient(135deg, rgba(255,255,255,0.07) 0%, rgba(255,255,255,0) 60%);
    pointer-events: none;
    border-radius: 38px 38px 0 0;
}

.phone-screen-inner {
    z-index: 2;
    padding: 0 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
}

.phone-state-icon {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.4s ease;
}

.phone-state-icon svg {
    width: 28px;
    height: 28px;
}

.phone-state-label {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    letter-spacing: -0.01em;
    transition: color 0.4s ease;
}

.phone-state-sub {
    font-size: 13px;
    opacity: 0.85;
    margin: 8px 0 0;
    line-height: 1.6;
    font-weight: 400;
    transition: color 0.4s ease;
}

/* Phone screen states */
.phone-screen.state-normal {
    background: radial-gradient(circle at top, #0d2818 0%, #061208 100%);
}
.phone-screen.state-normal .phone-state-icon {
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.25);
    color: #4ade80;
    box-shadow: 0 0 24px rgba(34, 197, 94, 0.15);
}
.phone-screen.state-normal .phone-state-label { color: #4ade80; }

.phone-screen.state-locked {
    background: radial-gradient(circle at top, #2d1414 0%, #120607 100%);
}
.phone-screen.state-locked .phone-state-icon {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: #f87171;
    box-shadow: 0 0 24px rgba(239, 68, 68, 0.15);
}
.phone-screen.state-locked .phone-state-label { color: #f87171; }

.phone-screen.state-warning {
    background: radial-gradient(circle at top, #2d1f0d 0%, #120c06 100%);
}
.phone-screen.state-warning .phone-state-icon {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.25);
    color: #fbbf24;
    box-shadow: 0 0 24px rgba(245, 158, 11, 0.15);
}
.phone-screen.state-warning .phone-state-label { color: #fbbf24; }

.phone-screen.state-restricted {
    background: radial-gradient(circle at top, #0d1f2d 0%, #060d12 100%);
}
.phone-screen.state-restricted .phone-state-icon {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.25);
    color: #60a5fa;
    box-shadow: 0 0 24px rgba(59, 130, 246, 0.15);
}
.phone-screen.state-restricted .phone-state-label { color: #60a5fa; }

.phone-screen.state-released {
    background: radial-gradient(circle at top, #1a1a1a 0%, #0a0a0a 100%);
}
.phone-screen.state-released .phone-state-icon {
    background: rgba(156, 163, 175, 0.1);
    border: 1px solid rgba(156, 163, 175, 0.2);
    color: #9ca3af;
    box-shadow: 0 0 24px rgba(156, 163, 175, 0.08);
}
.phone-screen.state-released .phone-state-label { color: #9ca3af; }

/* Default / Offline */
.phone-screen.state-default {
    background: radial-gradient(circle at top, #1a1a2e 0%, #0e0e1a 100%);
}
.phone-screen.state-default .phone-state-icon {
    background: rgba(148, 163, 184, 0.1);
    border: 1px solid rgba(148, 163, 184, 0.15);
    color: #94a3b8;
    box-shadow: 0 0 16px rgba(148, 163, 184, 0.06);
}
.phone-screen.state-default .phone-state-label { color: #cbd5e1; }

/* Phone name under mockup */
.device-phone-name {
    font-size: 13px;
    font-weight: 600;
    margin: 12px 0 4px;
    color: var(--text-primary);
    max-width: 170px;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.device-phone-online {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 100px;
}
.device-phone-online .dot {
    width: 6px; height: 6px;
    background: #22c55e;
    border-radius: 50%;
    display: inline-block;
}
.device-phone-online.offline {
    background: rgba(156,163,175,0.1);
    color: #94a3b8;
}
.device-phone-online.offline .dot {
    background: #94a3b8;
}

/* === Inspector detail panel === */
.inspector-detail {
    flex: 1;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.inspector-header {
    border-bottom: 1px solid var(--divider);
    padding-bottom: 12px;
}

.inspector-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0 0 2px;
    letter-spacing: -0.02em;
}

.inspector-header .subtitle {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin: 0;
}

.inspector-header .device-id {
    font-size: 11px;
    color: var(--text-secondary);
    font-family: monospace;
    background: var(--default-light);
    padding: 3px 8px;
    border-radius: 6px;
    margin-top: 6px;
    display: inline-block;
}

.inspector-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px 16px;
    background: #fafafa;
    padding: 14px;
    border-radius: 12px;
    border: 1px solid var(--divider);
}

.inspector-grid .ig-item {}
.inspector-grid .ig-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 2px;
    font-weight: 600;
}
.inspector-grid .ig-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}
.ig-value.ig-success { color: #22c55e !important; }
.ig-value.ig-error { color: #ef4444 !important; }
.ig-value.ig-warning { color: #f59e0b !important; }
.ig-value.ig-default { color: var(--text-secondary) !important; }


.inspector-empty {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    border-top: 1px solid var(--divider);
    padding-top: 16px;
    margin-top: 4px;
}

.inspector-actions .aem-insp-btn {
    flex: 1;
    min-width: 90px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}
.inspector-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    flex-direction: column;
    gap: 8px;
}

/* === Device Cards (Devices page) === */
.device-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
    gap: 16px;
}

.device-card {
    background: var(--surface);
    border-radius: var(--card-radius);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    gap: 1rem;
    align-items: stretch;
    border: 1.5px solid var(--divider);
    transition: box-shadow 0.25s, border-color 0.25s, transform 0.2s;
}

.device-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
    transform: translateY(-1px);
}

.device-card-phone-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.device-card .mini-phone {
    width: 90px;
    height: 160px;
    background: #1a1a2e;
    border-radius: 22px;
    padding: 5px;
    box-sizing: border-box;
    flex-shrink: 0;
    box-shadow: 0 8px 24px rgba(0,0,0,0.18), inset 0 0 1px 1px rgba(255,255,255,0.06);
}

.device-card .mini-phone .mini-screen {
    width: 100%;
    height: 100%;
    border-radius: 18px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    position: relative;
    border: 1px solid rgba(255,255,255,0.04);
}

.device-card .mini-phone .mini-notch {
    position: absolute;
    top: 5px;
    left: 50%;
    transform: translateX(-50%);
    width: 28px;
    height: 8px;
    background: #1a1a2e;
    border-radius: 8px;
    z-index: 5;
}

.device-card .mini-screen-icon {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.device-card .mini-screen-icon svg {
    width: 15px;
    height: 15px;
}

.mini-state-label {
    font-size: 0.55rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.8;
    color: inherit;
}

.mini-online-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.65rem;
    font-weight: 600;
    color: #94a3b8;
    padding: 2px 8px;
    border-radius: 100px;
    background: rgba(156,163,175,0.08);
}

.mini-online-badge.online {
    color: #22c55e;
    background: rgba(34,197,94,0.1);
}

.mini-online-badge .dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
    display: inline-block;
}

/* Mini screen states - gradient backgrounds with matching accent */
.mini-screen.state-normal { background: radial-gradient(circle at top, #0d2818 0%, #061208 100%); color: #4ade80; }
.mini-screen.state-locked { background: radial-gradient(circle at top, #2d1414 0%, #120607 100%); color: #f87171; }
.mini-screen.state-warning { background: radial-gradient(circle at top, #2d1f0d 0%, #120c06 100%); color: #fbbf24; }
.mini-screen.state-restricted { background: radial-gradient(circle at top, #0d1f2d 0%, #060d12 100%); color: #60a5fa; }
.mini-screen.state-released { background: radial-gradient(circle at top, #1a1a1a 0%, #0a0a0a 100%); color: #9ca3af; }
.mini-screen.state-default { background: radial-gradient(circle at top, #1a1a2e 0%, #0e0e1a 100%); color: #94a3b8; }

.mini-screen.state-normal .mini-screen-icon { background: rgba(34,197,94,0.25); color: #4ade80; }
.mini-screen.state-locked .mini-screen-icon { background: rgba(239,68,68,0.25); color: #f87171; }
.mini-screen.state-warning .mini-screen-icon { background: rgba(245,158,11,0.25); color: #fbbf24; }
.mini-screen.state-restricted .mini-screen-icon { background: rgba(59,130,246,0.25); color: #60a5fa; }
.mini-screen.state-released .mini-screen-icon { background: rgba(156,163,175,0.18); color: #9ca3af; }
.mini-screen.state-default .mini-screen-icon { background: rgba(148,163,184,0.15); color: #94a3b8; }

.device-card .card-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.device-card .card-device-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.device-card .card-device-id {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-family: monospace;
}

.device-card .card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 2px;
}

.device-card .card-detail {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.device-card .card-actions {
    display: flex;
    gap: 4px;
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid var(--divider);
    flex-wrap: wrap;
}

/* ===== Device select cards (Android page row) ===== */
.device-select-cards {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.device-select-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1.5px solid var(--divider);
    background: var(--surface);
    cursor: pointer;
    transition: all 0.2s;
    flex: 1 1 auto;
    min-width: 180px;
    max-width: 260px;
}

.device-select-card:hover {
    border-color: var(--primary);
    background: var(--primary-light);
    box-shadow: var(--shadow-sm);
}

.device-select-card.active {
    border-color: var(--primary);
    background: var(--primary-light);
    box-shadow: 0 0 0 2px rgba(21,101,192,0.15);
}

.dsc-avatar {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.dsc-info {
    min-width: 0;
    flex: 1;
}

.dsc-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dsc-sub {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ===== Token device card row ===== */
.token-generate-row {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.token-left {
    flex: 1;
    min-width: 0;
}

.token-right {
    width: 220px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.token-qr-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 170px;
    height: 170px;
    border: 2px dashed var(--divider);
    border-radius: 12px;
    text-align: center;
    gap: 6px;
}

.token-device-cards {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.token-device-card {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 7px 12px;
    border-radius: 10px;
    border: 1.5px solid var(--divider);
    background: var(--surface);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-primary);
}

.token-device-card:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.token-device-card.active {
    border-color: var(--primary);
    background: var(--primary-light);
    box-shadow: 0 0 0 2px rgba(21,101,192,0.15);
}

.tdc-avatar {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.tdc-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Clickable device list item in Android page */
.device-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s;
    border: 1px solid transparent;
}

.device-list-item:hover {
    background: var(--default-light);
}

.device-list-item.active {
    background: var(--primary-light);
    border-color: var(--primary);
}

.device-list-item .dli-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #fff;
    font-weight: 700;
    font-size: 0.75rem;
}

.device-list-item .dli-info {
    flex: 1;
    min-width: 0;
}

.device-list-item .dli-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.device-list-item .dli-sub {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

/* ===== Utility ===== */
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.ml-1 { margin-left: 8px; }
.ml-2 { margin-left: 16px; }
.mr-1 { margin-right: 8px; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-end { display: flex; justify-content: flex-end; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.flex-1 { flex: 1; }
.font-bold { font-weight: 700; }
.text-secondary { color: var(--text-secondary); }
.text-primary { color: var(--primary); }
.hidden { display: none !important; }
.inline-form { display: inline; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== AEM Action Buttons ===== */
.aem-actions {
    display: flex;
    gap: 2px;
    flex-wrap: nowrap;
}
.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    background: transparent;
    color: var(--text-secondary);
    transition: all 0.15s;
    padding: 0;
}
.action-btn svg {
    width: 18px;
    height: 18px;
}
.action-btn:hover {
    background: var(--primary-light);
    color: var(--primary);
}
.action-btn.action-enroll:hover { background: #E8F5E9; color: var(--success); }
.action-btn.action-sync:hover { background: #E8F5E9; color: var(--secondary); }
.action-btn.action-lock:hover { background: #FFEBEE; color: var(--error); }
.action-btn.action-unlock:hover { background: #E8F5E9; color: var(--success); }
.action-btn.action-wipe:hover { background: #FFEBEE; color: var(--error); }
.action-btn.action-release:hover { background: #FFF3E0; color: var(--warning); }
.action-btn.action-delete:hover { background: #FFEBEE; color: var(--error); }

/* ===== Dashboard Cards ===== */
.dash-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}
.dash-card {
    background: var(--surface);
    border-radius: var(--card-radius);
    padding: 16px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
    transition: box-shadow 0.2s, transform 0.15s;
    cursor: pointer;
}
.dash-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.dash-card-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.dash-card-body {
    display: flex;
    flex-direction: column;
}
.dash-card-label {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.dash-card-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
}

/* ===== Financial Metrics ===== */
.fin-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.fin-metric {
    background: #fafafa;
    border-radius: var(--radius);
    padding: 14px;
}
.fin-metric-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.fin-metric-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
}
.fin-metric-sub {
    font-size: 0.75rem;
    color: var(--text-secondary);
}
.fin-outstanding .fin-metric-value { color: var(--warning); }
.fin-revenue .fin-metric-value { color: var(--success); }
.fin-completed .fin-metric-value { color: var(--secondary); }
.fin-total .fin-metric-value { color: var(--primary); }

/* ===== Device Health Bars ===== */
.device-health {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.health-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.health-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.health-label {
    width: 80px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-primary);
    flex-shrink: 0;
}
.health-count {
    width: 36px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
    text-align: right;
    flex-shrink: 0;
}
.health-bar {
    flex: 1;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}
.health-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s ease;
}

/* ===== Responsive ===== */
@media (min-width: 900px) {
    .sidebar {
        transform: translateX(0);
    }
    .sidebar-overlay {
        display: none !important;
    }
    .main-content {
        margin-left: 272px;
    }
    .appbar .menu-btn {
        display: none;
    }
}

/* ===== Help Page ===== */
.help-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 28px;
    align-items: start;
}

.help-toc {
    position: sticky;
    top: 88px;
    background: var(--surface);
    border-radius: 12px;
    padding: 18px 16px;
    border: 1px solid var(--divider);
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.help-toc-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.help-toc-link {
    display: block;
    padding: 7px 10px;
    border-radius: 6px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    margin-bottom: 2px;
}

.help-toc-link:hover {
    background: rgba(21,101,192,0.06);
    color: var(--primary);
}

.help-content { display: flex; flex-direction: column; gap: 0; }

.help-section {
    display: flex;
    gap: 20px;
    padding: 32px 0;
    border-bottom: 1px solid var(--divider);
}

.help-section:last-child { border-bottom: none; }

.help-section h2 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.help-section > div:last-child > p {
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.6;
}

.help-step-num {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: linear-gradient(135deg, #1565C0, #42A5F5);
    color: #fff;
    font-size: 1.15rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 14px rgba(21,101,192,0.25);
}

.help-card {
    background: var(--surface);
    border: 1px solid var(--divider);
    border-radius: 10px;
    margin-bottom: 14px;
    overflow: hidden;
}

.help-card-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg);
    border-bottom: 1px solid var(--divider);
    font-size: 0.92rem;
}

.help-card-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 6px;
    white-space: nowrap;
}

.help-card-body {
    padding: 16px;
    font-size: 0.88rem;
    line-height: 1.65;
    color: var(--text-primary);
}

.help-card-body p { margin-bottom: 10px; }

.help-card-body p:last-child { margin-bottom: 0; }

.help-card-body ul,
.help-card-body ol {
    margin: 8px 0 12px 18px;
}

.help-card-body li {
    margin-bottom: 6px;
    line-height: 1.55;
}

.help-card-body li:last-child { margin-bottom: 0; }

.help-code {
    background: #0F1923;
    color: #64B5F6;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    padding: 14px 18px;
    border-radius: 8px;
    margin: 10px 0;
    line-height: 1.7;
    overflow-x: auto;
}

.help-note {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 8px;
    font-size: 0.82rem;
    margin-top: 10px;
    line-height: 1.55;
}

.help-note svg { width: 20px; height: 20px; flex-shrink: 0; margin-top: 1px; }

.help-note-warn {
    background: rgba(255,152,0,0.08);
    border: 1px solid rgba(255,152,0,0.2);
    color: #e65100;
}

.help-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    margin-top: 10px;
}

.help-table th {
    text-align: left;
    padding: 8px 12px;
    background: var(--bg);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--divider);
}

.help-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--divider);
}

.help-table tr:last-child td { border-bottom: none; }

@media (max-width: 899px) {
    .help-layout { grid-template-columns: 1fr; }
    .help-toc { position: static; display: none; }
    .help-section { flex-direction: column; gap: 12px; }
    .help-step-num { width: 36px; height: 36px; border-radius: 10px; font-size: 1rem; }
}

@media (max-width: 899px) {
    .main-content {
        margin-left: 0;
    }
    .device-console {
        grid-template-columns: 1fr;
    }
    .settings-grid {
        grid-template-columns: 1fr;
    }
    .grid-2 {
        grid-template-columns: 1fr;
    }
    .grid-3 {
        grid-template-columns: 1fr;
    }
    .aem-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    .dash-cards {
        grid-template-columns: repeat(2, 1fr);
    }
    .fin-metrics {
        grid-template-columns: 1fr;
    }
    .policy-overview-grid,
    .lock-screen-content {
        grid-template-columns: 1fr;
    }
    .lock-preview-card {
        order: -1;
    }
    .device-inspector {
        grid-template-columns: 1fr;
    }
    .device-phone-wrap {
        position: static;
        padding-top: 0;
    }
    .device-cards {
        grid-template-columns: 1fr;
    }
    .inspector-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .inspector-actions {
        flex-direction: column;
    }
    .token-generate-row {
        flex-direction: column;
    }
    .token-right {
        width: 100%;
    }
}

@media (max-width: 640px) {
    .policy-rule-item {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .policy-panel-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .lock-screen-form {
        padding: 14px;
    }

    .lock-preview-phone {
        width: min(280px, 100%);
        min-height: 480px;
    }
}
