/* =====================================================
   Alfred Smart Metrics — Standalone Product
   ===================================================== */

/* =====================================================
   CSS Variables - Alfred Smart Brand
   ===================================================== */
:root {
    /* Alfred Smart Primary Colors */
    --alfred-cobalto: #003D59;
    --alfred-indigo: #005898;
    --alfred-celeste: #DDE5ED;
    --alfred-white: #ffffff;
    --alfred-black: #000000;
    
    /* Alfred Smart Secondary Colors */
    --alfred-jade: rgb(0, 200, 160);
    --alfred-teal: rgb(0, 178, 169);
    --alfred-rubio: rgb(244, 201, 93);
    --alfred-cielo: rgb(110, 193, 228);
    --alfred-violeta: rgb(162, 94, 217);
    --alfred-lavanda: rgb(175, 166, 242);
    --alfred-manzana: rgb(219, 89, 78);
    --alfred-verde-bosque: rgb(56, 125, 87);
    --alfred-mango: rgb(255, 170, 51);
    --alfred-indigo-light: rgba(0, 88, 152, 0.7);
    
    /* Text Colors */
    --text-primary: #1F2937;
    --text-secondary: #6B7280;
    
    /* Background variations */
    --bg-primary: #ffffff;
    --bg-secondary: #F8FAFC;
    --bg-tertiary: #f0f4f8;
    
    /* Typography */
    --font-primary: 'Poppins', sans-serif;
    --font-secondary: 'Source Sans Pro', sans-serif;
    
    /* Layout */
    --header-height: 60px;
    
    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 61, 89, 0.08);
    --shadow-md: 0 4px 16px rgba(0, 61, 89, 0.12);
    --shadow-lg: 0 12px 32px rgba(0, 61, 89, 0.16);
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
}

/* =====================================================
   Lucide Icons - Global Styles
   ===================================================== */
.icon-inline {
    display: inline-flex;
    width: 1em;
    height: 1em;
    vertical-align: -0.125em;
    margin-right: 0.35em;
}
.icon-inline svg {
    width: 100%;
    height: 100%;
    stroke-width: 2;
}
.btn svg,
button svg {
    width: 16px;
    height: 16px;
    stroke-width: 2;
    vertical-align: middle;
}
.btn-primary svg {
    stroke: currentColor;
}
#logout-btn svg {
    width: 18px;
    height: 18px;
    margin-right: 6px;
    vertical-align: middle;
}
.card-title .icon-inline {
    width: 1.1em;
    height: 1.1em;
    vertical-align: -0.15em;
    color: var(--alfred-indigo);
}
.empty-icon svg,
.empty-state svg,
.placeholder-icon svg {
    width: 48px;
    height: 48px;
    stroke-width: 1.5;
    color: var(--alfred-celeste);
}
.summary-icon svg {
    width: 24px;
    height: 24px;
    stroke-width: 1.75;
}
.drawer-icon svg {
    width: 32px;
    height: 32px;
}
.kpi-icon svg {
    width: 20px;
    height: 20px;
}

/* =====================================================
   Base Styles
   ===================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-primary);
    background: var(--bg-secondary);
    color: var(--alfred-cobalto);
    min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-primary);
    font-weight: 600;
    color: var(--alfred-cobalto);
}

/* =====================================================
   App Layout — No Sidebar, Clean Header
   ===================================================== */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: #fff;
    border-bottom: 1px solid #E5E7EB;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 100;
}

.app-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.app-header-logo {
    height: 32px;
    width: auto;
}

.app-header-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--alfred-cobalto);
    letter-spacing: -0.3px;
}

.app-header-badge {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 3px 10px;
    border-radius: 20px;
    background: linear-gradient(135deg, var(--alfred-jade), var(--alfred-teal));
    color: #fff;
}

.app-header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-user-info {
    text-align: right;
}

.header-user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--alfred-cobalto);
}

.header-user-role {
    font-size: 11px;
    color: var(--text-secondary);
}

.app-main {
    margin-top: var(--header-height);
    min-height: calc(100vh - var(--header-height));
}

/* =====================================================
   Buttons
   ===================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 8px;
    font-family: var(--font-primary);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition-normal);
    border: none;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--alfred-cobalto) 0%, var(--alfred-indigo) 100%);
    color: var(--alfred-white);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 61, 89, 0.4);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--alfred-violeta) 0%, var(--alfred-lavanda) 100%);
    color: var(--alfred-white);
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(162, 94, 217, 0.4);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.btn-outline {
    background: #fff;
    border: 2px solid #005898;
    color: #005898;
}

.btn-outline:hover {
    background: #005898;
    color: #fff;
}

.btn-ghost {
    background: transparent;
    color: #005898;
    border: none;
    padding: 6px 12px;
    font-size: 13px;
}
.btn-ghost:hover {
    background: rgba(0, 88, 152, 0.08);
    color: #003D59;
}

/* =====================================================
   Form Elements
   ===================================================== */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #003D59;
    margin-bottom: 8px;
    letter-spacing: 0.01em;
}

.form-input,
.form-select {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid #E5E7EB;
    border-radius: 8px;
    font-family: var(--font-primary);
    font-size: 14px;
    color: #003D59;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    background: #fff;
}

.form-input::placeholder {
    color: #9CA3AF;
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: #005898;
    box-shadow: 0 0 0 3px rgba(0, 88, 152, 0.1);
}

.form-input:disabled,
.form-select:disabled {
    background: #F3F4F6;
    color: #9CA3AF;
    cursor: not-allowed;
}

.form-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B7280' d='M6 8L2 4h8z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* =====================================================
   Login Screen
   ===================================================== */
.login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--alfred-cobalto) 0%, var(--alfred-indigo) 50%, var(--alfred-cielo) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.login-container {
    background: var(--alfred-white);
    padding: 48px;
    border-radius: 20px;
    box-shadow: 0 24px 64px rgba(0, 61, 89, 0.2);
    max-width: 420px;
    width: 90%;
    border: 1px solid var(--alfred-celeste);
}

.login-logo {
    height: 60px;
    width: auto;
    display: block;
    margin: 0 auto 24px;
}

.login-title {
    font-size: 28px;
    text-align: center;
    margin-bottom: 8px;
}

.login-subtitle {
    text-align: center;
    color: var(--alfred-indigo);
    margin-bottom: 8px;
}

.login-hint {
    text-align: center;
    font-size: 13px;
    color: var(--alfred-indigo);
    opacity: 0.8;
    margin-bottom: 32px;
}

.login-error {
    background: rgba(219, 89, 78, 0.1);
    border: 1px solid var(--alfred-manzana);
    color: var(--alfred-manzana);
    padding: 12px 16px;
    border-radius: 8px;
    text-align: center;
    font-size: 14px;
    margin-top: 16px;
    display: none;
}

.login-footer {
    text-align: center;
    font-size: 12px;
    color: #999;
    margin-top: 24px;
}

/* =====================================================
   Animations
   ===================================================== */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    75% { transform: translateX(8px); }
}

.shake {
    animation: shake 0.5s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

@keyframes slideInRight {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

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

.spin {
    animation: spin 0.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

/* =====================================================
   Message Box (Toast)
   ===================================================== */
.message-box {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    display: none;
    opacity: 0;
    transition: var(--transition-normal);
    font-weight: 500;
    color: var(--alfred-white);
}

.message-box.show {
    display: block;
    opacity: 1;
}

.message-box.success {
    background: linear-gradient(135deg, var(--alfred-jade) 0%, var(--alfred-verde-bosque) 100%);
}

.message-box.error {
    background: linear-gradient(135deg, var(--alfred-manzana) 0%, #c0392b 100%);
}

/* =====================================================
   Loading Indicator
   ===================================================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 61, 89, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.loading-overlay.show {
    display: flex;
}

.loading-spinner {
    background: var(--alfred-white);
    padding: 32px 48px;
    border-radius: 16px;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.loading-spinner::before {
    content: '';
    display: block;
    width: 40px;
    height: 40px;
    margin: 0 auto 16px;
    border-radius: 50%;
    background: conic-gradient(from 0deg, transparent 0%, var(--alfred-indigo) 100%);
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 4px));
    mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 4px));
    animation: spin 0.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

/* =====================================================
   Metrics Module Styles — Clean & Minimal (Inicio style)
   ===================================================== */

/* Container — narrow, centered */
.metrics-module {
    max-width: 960px;
    margin: 0 auto;
    padding: 24px 32px;
}

/* Header — same as dash-header */
.metrics-module .m-header {
    margin-bottom: 32px;
}
.metrics-module .m-header h1 {
    font-size: 24px;
    font-weight: 600;
    color: #003D59;
    margin: 0 0 4px 0;
    letter-spacing: -0.5px;
}
.metrics-module .m-header p {
    font-size: 14px;
    color: #6B7280;
    margin: 0;
}
.metrics-module .m-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

/* Back link — subtle, no border */
.metrics-module .m-back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    font-weight: 500;
    color: #005898;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    margin-bottom: 12px;
    transition: color 0.15s;
}
.metrics-module .m-back:hover {
    color: #003D59;
}
.metrics-module .m-back svg {
    width: 16px;
    height: 16px;
}

/* Toolbar — sticky bar with back + actions */
.metrics-module .m-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    position: sticky;
    top: 0;
    z-index: 40;
    background: #F9FAFB;
    margin: -8px -4px 4px -4px;
    padding: 6px 4px;
    border-radius: 0 0 10px 10px;
    transition: box-shadow .2s;
}
.metrics-module .m-toolbar.m-toolbar-scrolled {
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.metrics-module .m-toolbar .m-back {
    margin-bottom: 0;
}
.metrics-module .m-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Section label — uppercase, small, like dash-label */
.metrics-module .m-label {
    font-size: 13px;
    font-weight: 500;
    color: #6B7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 28px 0 12px 0;
    display: flex;
    align-items: center;
    gap: 6px;
}
.metrics-module .m-label svg {
    width: 16px;
    height: 16px;
}

/* Collapsible details section */
.metrics-module .m-details-section summary::-webkit-details-marker { display: none; }
.metrics-module .m-details-section[open] .m-toggle-icon { transform: rotate(90deg); }

/* Card — clean, like dash-card */
.metrics-module .m-card {
    background: #fff;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    padding: 20px 24px;
    margin-bottom: 12px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.metrics-module .m-card-clickable {
    cursor: pointer;
}
.metrics-module .m-card-clickable:hover {
    border-color: #005898;
    box-shadow: 0 2px 8px rgba(0, 61, 89, 0.06);
}
.metrics-module .m-card-label {
    font-size: 13px;
    font-weight: 500;
    color: #6B7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.metrics-module .m-card-label svg {
    width: 15px;
    height: 15px;
}
.metrics-module .m-card-hint {
    color: #005898;
    font-size: 12px;
    float: right;
    text-transform: none;
    letter-spacing: 0;
    font-weight: 400;
}

/* Big number display */
.metrics-module .m-big-number {
    font-size: 42px;
    font-weight: 700;
    color: #003D59;
    line-height: 1;
    margin-bottom: 4px;
}
.metrics-module .m-big-unit {
    font-size: 18px;
    color: #9CA3AF;
    font-weight: 400;
}
.metrics-module .m-big-sub {
    font-size: 14px;
    color: #6B7280;
    margin: 0;
}

/* KPI row — single-line auto-fit */
.metrics-module .m-kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}
.metrics-module .m-kpi {
    background: #fff;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    padding: 10px 10px;
    text-align: center;
}
.metrics-module .m-kpi-value {
    font-size: 18px;
    font-weight: 700;
    color: #003D59;
    line-height: 1.2;
}
.metrics-module .m-kpi-label {
    font-size: 11px;
    color: #6B7280;
    margin-top: 2px;
}
.metrics-module .m-kpi-delta {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: 11px;
    font-weight: 600;
    margin-top: 3px;
    padding: 1px 6px;
    border-radius: 20px;
}
.metrics-module .m-kpi-delta svg {
    width: 12px;
    height: 12px;
}
.metrics-module .m-kpi-delta-up {
    color: #DC2626;
    background: #FEF2F2;
}
.metrics-module .m-kpi-delta-down {
    color: #16A34A;
    background: #F0FDF4;
}
.metrics-module .m-kpi-sub {
    font-size: 11px;
    color: #005898;
    font-weight: 500;
    margin-top: 2px;
}

/* Simple table — minimal */
.metrics-module .m-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.metrics-module .m-table th {
    padding: 8px 10px;
    text-align: left;
    font-weight: 500;
    color: #9CA3AF;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #E5E7EB;
}
.metrics-module .m-table th:last-child,
.metrics-module .m-table td:last-child {
    text-align: right;
}
.metrics-module .m-table td {
    padding: 10px 10px;
    border-bottom: 1px solid #F3F4F6;
    color: #374151;
}
.metrics-module .m-table td strong {
    color: #003D59;
}
.metrics-module .m-table tbody tr:last-child td {
    border-bottom: none;
}

/* Inline stat row */
.metrics-module .m-stat-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 14px;
    border-bottom: 1px solid #F3F4F6;
}
.metrics-module .m-stat-row:last-child {
    border-bottom: none;
}
.metrics-module .m-stat-key {
    color: #6B7280;
}
.metrics-module .m-stat-val {
    font-weight: 600;
    color: #003D59;
}

/* Button row — used in toolbar actions */
.metrics-module .m-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}
.metrics-module .m-btn {
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    background: #fff;
    color: #374151;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.metrics-module .m-btn:hover {
    border-color: #005898;
    color: #005898;
}
.metrics-module .m-btn svg {
    width: 16px;
    height: 16px;
}
.metrics-module .m-btn-icon {
    padding: 8px;
    line-height: 1;
}
.metrics-module .m-btn-sm {
    padding: 7px 14px;
    font-size: 13px;
    border-radius: 7px;
}
.metrics-module .m-btn-sm.m-btn-icon {
    padding: 6px;
}
.metrics-module .m-btn-primary {
    background: #005898;
    border-color: #005898;
    color: #fff;
}
.metrics-module .m-btn-primary:hover {
    background: #003D59;
    border-color: #003D59;
    color: #fff;
}

/* Context menu (kebab dropdown) */
.metrics-module .m-context-menu-wrapper {
    position: relative;
}
.metrics-module .m-context-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 220px;
    background: #fff;
    border: 1px solid #E5E7EB;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,.12), 0 2px 6px rgba(0,0,0,.06);
    z-index: 50;
    padding: 6px 0;
    animation: ctxFadeIn .12s ease;
}
.metrics-module .m-context-menu.open {
    display: block;
}
@keyframes ctxFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.metrics-module .m-context-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    background: none;
    border: none;
    cursor: pointer;
    transition: background .1s ease;
    text-align: left;
}
.metrics-module .m-context-item:hover {
    background: #F3F4F6;
    color: #005898;
}
.metrics-module .m-context-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}
.metrics-module .m-context-divider {
    height: 1px;
    background: #E5E7EB;
    margin: 4px 0;
}

/* Select inputs */
.metrics-module .m-select {
    padding: 6px 10px;
    border: 1px solid #E5E7EB;
    border-radius: 6px;
    background: #fff;
    color: #374151;
    font-size: 13px;
    cursor: pointer;
    transition: border-color 0.2s;
}
.metrics-module .m-select:hover { border-color: #005898; }
.metrics-module .m-select:focus { outline: none; border-color: #005898; box-shadow: 0 0 0 2px rgba(0, 88, 152, 0.1); }

.metrics-module .m-input {
    padding: 6px 10px;
    border: 1px solid #E5E7EB;
    border-radius: 6px;
    background: #fff;
    color: #374151;
    font-size: 13px;
    transition: border-color 0.2s;
}
.metrics-module .m-input:focus { outline: none; border-color: #005898; box-shadow: 0 0 0 2px rgba(0, 88, 152, 0.1); }

/* Config bar — inline, subtle */
.metrics-module .m-config {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 16px;
    margin-bottom: 20px;
}
.metrics-module .m-config-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.metrics-module .m-config-item label {
    font-size: 11px;
    font-weight: 600;
    color: #9CA3AF;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Report sections — clean cards */
.metrics-module .m-report-section {
    background: #fff;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 12px;
}
.metrics-module .m-report-title {
    font-size: 14px;
    font-weight: 600;
    color: #003D59;
    margin: 0 0 16px 0;
    display: flex;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.metrics-module .m-report-title svg {
    width: 18px;
    height: 18px;
}

/* Search box */
.metrics-module .m-search {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    color: #374151;
    transition: border-color 0.2s;
    margin-bottom: 16px;
}
.metrics-module .m-search:focus {
    outline: none;
    border-color: #005898;
    box-shadow: 0 0 0 2px rgba(0, 88, 152, 0.1);
}
.metrics-module .m-search::placeholder {
    color: #D1D5DB;
}

/* Project list items */
.metrics-module .m-project-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background: #fff;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.2s, transform 0.15s;
}
.metrics-module .m-project-item:hover {
    border-color: #005898;
    box-shadow: 0 4px 12px rgba(0, 61, 89, 0.08);
    transform: translateY(-1px);
}

/* Project thumbnail */
.metrics-module .m-project-thumb {
    width: 64px;
    height: 64px;
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
    background: linear-gradient(135deg, #E8F4FD, #D1E8F8);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #7CB8D9;
}
.metrics-module .m-project-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.metrics-module .m-project-thumb svg {
    width: 28px;
    height: 28px;
}

/* Project info (text) */
.metrics-module .m-project-info {
    flex: 1;
    min-width: 0;
}
.metrics-module .m-project-name {
    font-size: 15px;
    font-weight: 600;
    color: #003D59;
    margin: 0 0 3px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.metrics-module .m-project-meta {
    font-size: 13px;
    color: #6B7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.metrics-module .m-project-arrow {
    color: #D1D5DB;
    flex-shrink: 0;
    transition: color 0.15s, transform 0.15s;
}
.metrics-module .m-project-arrow svg {
    width: 20px;
    height: 20px;
}
.metrics-module .m-project-item:hover .m-project-arrow {
    color: #005898;
    transform: translateX(2px);
}

/* Project detail hero banner */
.metrics-module .m-project-hero {
    width: 100%;
    height: 100px;
    border-radius: 12px;
    background-size: cover;
    background-position: center;
    position: relative;
    overflow: hidden;
    margin-bottom: 12px;
}
/* Gradient fallback when no image */
.metrics-module .m-project-hero-gradient {
    background: linear-gradient(135deg, #003D59 0%, #005898 40%, #0078C8 100%);
}
.metrics-module .m-project-hero-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 61, 89, 0.85) 0%, rgba(0, 61, 89, 0.2) 60%, transparent 100%);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 16px 22px;
}
.metrics-module .m-project-hero-gradient .m-project-hero-overlay {
    background: none;
}
.metrics-module .m-project-hero-overlay h1 {
    color: #fff;
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 2px 0;
    text-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.metrics-module .m-project-hero-overlay p {
    color: rgba(255, 255, 255, 0.85);
    font-size: 13px;
    margin: 0;
}

/* Empty state */
.metrics-module .m-empty {
    text-align: center;
    padding: 60px 20px;
    color: #9CA3AF;
}
.metrics-module .m-empty svg {
    width: 40px;
    height: 40px;
    margin-bottom: 12px;
}
.metrics-module .m-empty h3 {
    font-size: 16px;
    font-weight: 600;
    color: #6B7280;
    margin: 0 0 4px 0;
}
.metrics-module .m-empty p {
    font-size: 14px;
    margin: 0;
}

/* Project card: no data state */
.metrics-module .m-project-no-data {
    opacity: 0.7;
    border-style: dashed;
}
.metrics-module .m-project-no-data:hover {
    opacity: 1;
}
.metrics-module .m-project-no-data .m-project-thumb {
    background: linear-gradient(135deg, #F3F4F6, #E5E7EB);
    color: #9CA3AF;
}
.metrics-module .m-project-meta-pending {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #9CA3AF;
    font-style: italic;
}

/* Empty project detail (no sensor data) */
.metrics-module .m-empty-project {
    text-align: center;
    padding: 60px 20px;
    border: 2px dashed #E5E7EB;
    border-radius: 16px;
    margin-top: 8px;
}
.metrics-module .m-empty-project-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    background: linear-gradient(135deg, #F0F7FF, #DBEAFE);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #7CB8D9;
}
.metrics-module .m-empty-project-icon svg {
    width: 32px;
    height: 32px;
}
.metrics-module .m-empty-project h3 {
    font-size: 18px;
    font-weight: 600;
    color: #374151;
    margin: 0 0 8px 0;
}
.metrics-module .m-empty-project p {
    font-size: 14px;
    color: #6B7280;
    margin: 0;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

/* Loading spinner (inline) */
.metrics-module .loading-spinner {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: conic-gradient(from 0deg, transparent 0%, #005898 100%);
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
    mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
    animation: spin 0.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    padding: 0;
    box-shadow: none;
}

/* Metadata Drawer */
.metadata-drawer { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 1100; }
.drawer-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.35); animation: fadeIn 0.2s ease; }
.drawer-panel { position: absolute; top: 0; right: 0; width: 440px; max-width: 90vw; height: 100%; background: #fff; box-shadow: -4px 0 24px rgba(0,0,0,0.1); display: flex; flex-direction: column; animation: slideInRight 0.3s ease; }
.drawer-header { display: flex; justify-content: space-between; align-items: center; padding: 20px 24px; border-bottom: 1px solid #E5E7EB; flex-shrink: 0; }
.drawer-header h2 { margin: 0; font-size: 17px; font-weight: 600; color: #003D59; }
.drawer-body { flex: 1; overflow-y: auto; padding: 24px; }
.drawer-section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: #005898; margin: 20px 0 10px 0; padding-bottom: 6px; border-bottom: 1px solid #F3F4F6; }
.drawer-section-title:first-child { margin-top: 0; }
.drawer-actions { padding: 16px 0 0; border-top: 1px solid #E5E7EB; margin-top: 20px; }
.metadata-drawer .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.metadata-drawer .form-group { margin-bottom: 12px; }
.metadata-drawer .form-group label { display: block; font-size: 12px; font-weight: 600; color: #6B7280; margin-bottom: 4px; }

/* Asset metadata list inside drawer */
.asset-meta-list::-webkit-scrollbar { width: 4px; }
.asset-meta-list::-webkit-scrollbar-thumb { background: #D1D5DB; border-radius: 4px; }
.asset-meta-row:hover { border-color: #3B82F6 !important; }
.asset-meta-row select, .asset-meta-row input { width: 100%; border: 1px solid #E5E7EB; border-radius: 4px; background: #fff; }
.asset-meta-row select:focus, .asset-meta-row input:focus { border-color: #3B82F6; outline: none; box-shadow: 0 0 0 2px rgba(59,130,246,0.15); }

/* Dwelling Detail Drawer */
.dwelling-drawer { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 1100; }

/* Dwelling header name */
.dd-header-dwelling {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 340px;
    padding: 3px 8px;
    background: #F3F4F6;
    border-radius: 6px;
    display: inline-block;
    margin-bottom: 4px;
}

/* Clickable min/max/avg cells */
.m-cell-drill {
    cursor: pointer;
    color: #005898;
    font-weight: 600;
    border-bottom: 1px dashed #005898;
    padding-bottom: 1px;
    transition: all 0.15s ease;
}
.m-cell-drill:hover {
    color: #003D59;
    border-bottom-color: #003D59;
    background: rgba(0, 88, 152, 0.06);
    border-radius: 3px;
    padding: 2px 4px;
    margin: -2px -4px;
}

/* Dwelling drawer KPIs */
.dd-kpi-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}
.dd-kpi-row.dd-kpi-row-2 {
    grid-template-columns: repeat(2, 1fr);
}
.dd-kpi {
    background: #F9FAFB;
    border: 1px solid #E5E7EB;
    border-radius: 10px;
    padding: 14px 12px;
    text-align: center;
}
.dd-kpi-value {
    font-size: 18px;
    font-weight: 700;
    color: #003D59;
    line-height: 1.3;
}
.dd-kpi-unit {
    font-size: 12px;
    font-weight: 400;
    color: #6B7280;
}
.dd-kpi-label {
    font-size: 11px;
    color: #9CA3AF;
    margin-top: 2px;
}

/* Sensor cards */
.dd-sensors {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.dd-sensor-card {
    background: #fff;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    overflow: hidden;
    transition: border-color 0.15s;
}
.dd-sensor-card:hover {
    border-color: #D1D5DB;
}
.dd-sensor-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    cursor: pointer;
    transition: background 0.1s;
}
.dd-sensor-header:hover {
    background: #F9FAFB;
}
.dd-sensor-info {
    flex: 1;
    min-width: 0;
}
.dd-sensor-name {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #003D59;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.dd-sensor-uuid {
    font-size: 11px;
    color: #9CA3AF;
    font-family: monospace;
}
.dd-sensor-stats {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.dd-sensor-consumption {
    font-size: 13px;
    color: #374151;
}
.dd-sensor-readings {
    font-size: 11px;
    color: #9CA3AF;
}
.dd-sensor-invalid {
    font-size: 11px;
    color: #D97706;
}
.dd-sensor-valid {
    font-size: 11px;
}
.dd-sensor-chevron {
    width: 16px;
    height: 16px;
    color: #9CA3AF;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}
.dd-sensor-detail {
    padding: 0 14px 14px;
    border-top: 1px solid #F3F4F6;
}
.dd-sensor-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    font-size: 12px;
    color: #6B7280;
    padding-top: 10px;
}
.dd-sensor-meta strong {
    color: #374151;
}

/* Chart toggles */
.metrics-module .m-chart-toggles {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.metrics-module .m-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #374151;
    cursor: pointer;
    user-select: none;
}
.metrics-module .m-toggle input[type="checkbox"] {
    display: none;
}
.metrics-module .m-toggle-dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    display: inline-block;
    transition: opacity 0.15s;
}
.metrics-module .m-toggle input:not(:checked) + .m-toggle-dot {
    opacity: 0.25;
}

/* Year Toggle */
.metrics-module .m-year-toggle {
    display: inline-flex;
    gap: 0;
    border: 1px solid var(--alfred-celeste);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 20px;
}
.metrics-module .m-year-btn {
    padding: 7px 18px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    background: var(--alfred-white);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    border-right: 1px solid var(--alfred-celeste);
}
.metrics-module .m-year-btn:last-child {
    border-right: none;
}
.metrics-module .m-year-btn:hover {
    background: #f0f4f8;
    color: var(--alfred-cobalto);
}
.metrics-module .m-year-btn-active {
    background: var(--alfred-indigo);
    color: var(--alfred-white);
}
.metrics-module .m-year-btn-active:hover {
    background: var(--alfred-cobalto);
    color: var(--alfred-white);
}

/* =====================================================
   Section header — Tab toggle: Mensual | Pivot
   ===================================================== */
.metrics-module .m-section-header {
    flex-wrap: wrap;
    gap: 8px;
}
.metrics-module .m-tab-toggle {
    display: flex;
    background: #F3F4F6;
    border-radius: 8px;
    padding: 2px;
    gap: 2px;
}
.metrics-module .m-tab-btn {
    border: none;
    background: transparent;
    padding: 5px 14px;
    font-size: 12px;
    font-weight: 500;
    color: #6B7280;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.15s;
}
.metrics-module .m-tab-btn:hover {
    color: #374151;
    background: #E5E7EB;
}
.metrics-module .m-tab-btn-active {
    background: #fff;
    color: #003D59;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    font-weight: 600;
}
.metrics-module .m-tab-btn-active:hover {
    background: #fff;
    color: #003D59;
}

/* =====================================================
   Consumos - Category selector
   ===================================================== */
.metrics-module .m-consumos-cats {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 16px;
    margin-bottom: 16px;
}
.metrics-module .m-consumos-cat-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 1.5px solid #E5E7EB;
    background: #fff;
    padding: 7px 16px;
    font-size: 13px;
    font-weight: 600;
    color: #6B7280;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
}
.metrics-module .m-consumos-cat-btn i,
.metrics-module .m-consumos-cat-btn svg {
    width: 14px;
    height: 14px;
}
.metrics-module .m-consumos-cat-btn:hover {
    border-color: var(--cat-color, #003D59);
    color: var(--cat-color, #003D59);
}
.metrics-module .m-consumos-cat-btn-active {
    background: var(--cat-color, #003D59);
    border-color: var(--cat-color, #003D59);
    color: #fff !important;
}
.metrics-module .m-consumos-cat-btn-active svg {
    stroke: #fff;
}

/* =====================================================
   Pivot table
   ===================================================== */
.metrics-module .m-pivot-wrapper {
    position: relative;
}
.metrics-module .m-pivot-table {
    min-width: 100%;
    white-space: nowrap;
}
.metrics-module .m-pivot-metric-th {
    position: sticky;
    left: 0;
    background: #fff;
    z-index: 2;
    min-width: 100px;
    border-right: 2px solid #E5E7EB;
}
.metrics-module .m-pivot-metric-td {
    position: sticky;
    left: 0;
    background: #fff;
    z-index: 1;
    font-weight: 500;
    color: #374151;
    border-right: 2px solid #E5E7EB;
    min-width: 100px;
}
.metrics-module .m-pivot-year-th {
    cursor: pointer;
    text-align: center !important;
    background: #F9FAFB;
    font-weight: 600;
    color: #003D59;
    transition: background 0.15s;
    min-width: 120px;
    user-select: none;
}
.metrics-module .m-pivot-year-th:hover {
    background: #EFF6FF;
}
.metrics-module .m-pivot-year-th svg {
    vertical-align: middle;
    margin-left: 2px;
    transition: transform 0.2s;
}
.metrics-module .m-pivot-year-th.m-pivot-expanded svg {
    transform: rotate(90deg);
}
.metrics-module .m-pivot-month-th {
    text-align: center !important;
    font-size: 11px;
    min-width: 90px;
    color: #6B7280;
    background: #FAFBFC;
}
.metrics-module .m-pivot-year-td {
    text-align: right !important;
    font-weight: 500;
    background: #F9FAFB;
}
.metrics-module .m-pivot-month-td {
    text-align: right !important;
}
.metrics-module .m-pivot-unit {
    font-size: 11px;
    color: #9CA3AF;
    font-weight: 400;
}
.metrics-module .m-pivot-pct {
    font-size: 10px;
    color: #9CA3AF;
    font-weight: 400;
}
.metrics-module .m-pivot-row-total td {
    font-weight: 600;
    color: #003D59;
}
.metrics-module .m-pivot-row-total .m-pivot-metric-td {
    font-weight: 700;
}
.metrics-module .m-pivot-collapse-btn {
    display: inline-block;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    color: #005898;
    margin-right: 6px;
    padding: 2px 6px;
    border-radius: 4px;
    background: #EFF6FF;
    user-select: none;
    white-space: nowrap;
}
.metrics-module .m-pivot-collapse-btn:hover {
    background: #DBEAFE;
}
.metrics-module .m-pivot-collapse-btn svg {
    vertical-align: middle;
    width: 12px;
    height: 12px;
}

/* Zebra striping for pivot body */
.metrics-module .m-pivot-table tbody tr:nth-child(even) td:not(.m-pivot-metric-td) {
    background: #FAFBFC;
}
.metrics-module .m-pivot-table tbody tr:nth-child(even) .m-pivot-year-td {
    background: #F3F4F6;
}

/* Responsive */
@media (max-width: 480px) {
    .metrics-module { padding: 24px 16px; }
    .metrics-module .m-kpi-row { grid-template-columns: repeat(2, 1fr); gap: 6px; }
    .metrics-module .m-kpi { display: flex; flex-direction: column; align-items: center; text-align: center; }
    .metrics-module .m-config { flex-direction: column; align-items: stretch; }
    .metrics-module .m-context-menu { right: 0; left: auto; }
    .drawer-panel { width: 100%; max-width: 100%; }
    .metrics-module .m-tab-toggle { width: 100%; justify-content: center; }
    .metrics-module .m-project-thumb { width: 48px; height: 48px; border-radius: 8px; }
    .metrics-module .m-project-thumb svg { width: 22px; height: 22px; }
    .metrics-module .m-project-item { gap: 12px; padding: 10px 12px; }
    .metrics-module .m-project-hero { height: 80px; border-radius: 10px; }
    .metrics-module .m-project-hero-overlay { padding: 12px 16px; }
    .metrics-module .m-project-hero-overlay h1 { font-size: 17px; }
    .metrics-module .m-toolbar { margin: -8px -16px 8px -16px; padding: 8px 16px; border-radius: 0; }
    .metrics-module .m-main-tab { padding: 10px 14px; font-size: 14px; }
}

/* =====================================================
   METRICS - Main Tabs (Consumos | Analítica)
   ===================================================== */
.metrics-module .m-main-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #E5E7EB;
    margin-bottom: 0;
}
.metrics-module .m-main-tab {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 20px;
    border: none;
    background: transparent;
    color: #6B7280;
    font-size: 15px;
    font-weight: 600;
    border-radius: 0;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: all .2s;
}
.metrics-module .m-main-tab:hover { color: #374151; border-bottom-color: #D1D5DB; background: transparent; }
.metrics-module .m-main-tab-active {
    color: #005898;
    border-bottom-color: #005898;
    background: transparent;
    box-shadow: none;
}
.metrics-module .m-main-tab svg { width: 18px; height: 18px; }

/* =====================================================
   METRICS - Analytics Heatmap
   ===================================================== */
.hm-controls {
    margin-top: 16px;
    margin-bottom: 16px;
}
.hm-cat-selector {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.hm-cat-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 14px;
    border: 1.5px solid #E5E7EB;
    background: #fff;
    color: #6B7280;
    font-size: 13px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all .2s;
}
.hm-cat-btn svg { width: 14px; height: 14px; }
.hm-cat-btn:hover { border-color: var(--cat-color, #005898); color: var(--cat-color, #005898); }
.hm-cat-btn-active {
    background: var(--cat-color, #005898);
    border-color: var(--cat-color, #005898);
    color: #fff !important;
}
.hm-cat-btn-active svg { stroke: #fff; }

/* KPIs row */
.hm-kpis {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}
.hm-kpi {
    background: #fff;
    border: 1px solid #E5E7EB;
    border-radius: 10px;
    padding: 14px 16px;
    text-align: center;
}
.hm-kpi-value {
    font-size: 22px;
    font-weight: 700;
    color: #1F2937;
    line-height: 1.2;
}
.hm-kpi-label {
    font-size: 11px;
    font-weight: 500;
    color: #9CA3AF;
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-top: 4px;
}

/* Heatmap table */
.hm-heatmap-wrapper { margin-bottom: 20px; }
.hm-scroll {
    overflow-x: auto;
    border: 1px solid #E5E7EB;
    border-radius: 10px;
}
.hm-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    min-width: 600px;
}
.hm-table th {
    background: #F9FAFB;
    font-weight: 600;
    color: #6B7280;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: .5px;
    padding: 8px 6px;
    text-align: center;
    border-bottom: 1px solid #E5E7EB;
    position: sticky;
    top: 0;
    z-index: 2;
}
.hm-th-hour {
    position: sticky;
    left: 0;
    z-index: 3 !important;
    background: #F9FAFB !important;
    min-width: 56px;
    text-align: left !important;
    padding-left: 10px !important;
}
.hm-th-avg { background: #F3F4F6 !important; }
.hm-td-hour {
    position: sticky;
    left: 0;
    z-index: 1;
    background: #fff;
    font-weight: 600;
    color: #374151;
    font-size: 11px;
    padding: 5px 6px 5px 10px;
    min-width: 56px;
    border-right: 1px solid #E5E7EB;
}
.hm-cell {
    text-align: center;
    padding: 5px 4px;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    min-width: 60px;
    transition: opacity .15s;
    cursor: default;
    border: 0.5px solid rgba(255,255,255,.3);
}
.hm-cell:hover { opacity: .8; outline: 2px solid #374151; outline-offset: -2px; border-radius: 2px; }
.hm-cell-avg {
    border-left: 2px solid #D1D5DB !important;
    font-weight: 600;
}
.hm-cell-total { font-weight: 700; background: #F9FAFB !important; color: #374151 !important; }
.hm-row-total td { border-top: 2px solid #D1D5DB; }

/* Color legend */
.hm-legend {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    font-size: 11px;
    color: #9CA3AF;
}
.hm-legend-bar {
    width: 160px;
    height: 10px;
    border-radius: 5px;
    border: 1px solid #E5E7EB;
}
.hm-legend-label { font-weight: 600; color: #6B7280; }
.hm-legend-range { margin-left: auto; font-variant-numeric: tabular-nums; }

@media (max-width: 768px) {
    .hm-kpis { grid-template-columns: repeat(2, 1fr); }
    .hm-cat-selector { flex-direction: column; }
    .hm-cat-btn { width: 100%; justify-content: center; }
}

/* =====================================================
   ENTITLEMENTS — Lock Screens & Premium Badges
   ===================================================== */

/* Lock screen: shown when project has no METRICS contract */
.m-lock-screen {
    text-align: center;
    padding: 48px 24px;
    border: 2px dashed #E5E7EB;
    border-radius: 16px;
    margin-top: 12px;
    background: linear-gradient(180deg, #FAFBFC 0%, #F3F4F6 100%);
}
.m-lock-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 20px;
    background: linear-gradient(135deg, #FEF3C7, #FDE68A);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #D97706;
}
.m-lock-icon svg {
    width: 28px;
    height: 28px;
}
.m-lock-screen h3 {
    font-size: 18px;
    font-weight: 700;
    color: #1F2937;
    margin: 0 0 8px 0;
}
.m-lock-screen p {
    font-size: 14px;
    color: #6B7280;
    margin: 0 0 4px 0;
    max-width: 440px;
    margin-left: auto;
    margin-right: auto;
}
.m-lock-kam {
    margin-top: 24px;
    padding: 16px 20px;
    background: #fff;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    gap: 14px;
    text-align: left;
}
.m-lock-kam-avatar {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--alfred-indigo), var(--alfred-cobalto));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    flex-shrink: 0;
}
.m-lock-kam-name {
    font-size: 14px;
    font-weight: 600;
    color: #1F2937;
}
.m-lock-kam-role {
    font-size: 12px;
    color: #6B7280;
}
.m-lock-kam-email {
    font-size: 13px;
    color: var(--alfred-indigo);
    text-decoration: none;
}
.m-lock-kam-email:hover {
    text-decoration: underline;
}
.m-lock-sales {
    margin-top: 24px;
    padding: 14px 20px;
    background: #fff;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: #374151;
}
.m-lock-sales svg {
    width: 18px;
    height: 18px;
    color: var(--alfred-indigo);
}

/* Premium badge: overlaid on locked features */
.m-premium-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 3px 8px;
    border-radius: 6px;
    background: linear-gradient(135deg, #F59E0B, #D97706);
    color: #fff;
    vertical-align: middle;
}
.m-premium-badge svg {
    width: 11px;
    height: 11px;
}

/* Premium overlay: blurs content and shows upgrade prompt */
.m-premium-overlay {
    position: relative;
}
.m-premium-overlay-blur {
    filter: blur(3px);
    opacity: 0.5;
    pointer-events: none;
    user-select: none;
}
.m-premium-overlay-prompt {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 5;
    padding: 20px 28px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
}
.m-premium-overlay-prompt h4 {
    font-size: 15px;
    font-weight: 700;
    color: #1F2937;
    margin: 0 0 6px 0;
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
}
.m-premium-overlay-prompt p {
    font-size: 13px;
    color: #6B7280;
    margin: 0;
}

/* =====================================================
   Backfill Progress (inside Sensor Detail Drawer)
   ===================================================== */
.m-backfill-section {
    background: #F9FAFB;
    border: 1px solid #E5E7EB;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 20px;
}
.m-backfill-status {
    font-size: 13px;
    font-weight: 600;
    color: #003D59;
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.m-backfill-bar-track {
    width: 100%;
    height: 8px;
    background: #E5E7EB;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 6px;
}
.m-backfill-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--alfred-indigo), var(--alfred-jade));
    border-radius: 4px;
    transition: width 0.3s ease;
}
.m-backfill-detail {
    font-size: 11px;
    color: #6B7280;
    margin-bottom: 2px;
}
.m-backfill-result-ok {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 14px;
    background: #fff;
    border: 1px solid #E5E7EB;
    border-radius: 10px;
}
.m-backfill-result-ok strong {
    display: block;
    font-size: 14px;
    color: #1F2937;
    margin-bottom: 2px;
}

/* =====================================================
   Alarms Tab
   ===================================================== */
.m-alarms-container {
    padding: 0;
    margin-top: 16px;
}
.m-alarm-empty {
    text-align: center;
    padding: 48px 20px;
    color: #9CA3AF;
}
.m-alarm-empty i {
    width: 40px;
    height: 40px;
    margin-bottom: 12px;
    color: #D1D5DB;
}
.m-alarm-empty h3 {
    color: #4B5563;
    font-size: 15px;
    font-weight: 600;
    margin: 0 0 6px 0;
}
.m-alarm-empty p {
    font-size: 13px;
    margin: 0;
}

.m-alarm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.m-alarm-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: #1F2937;
    margin: 0;
}

.m-alarm-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.m-alarm-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: #fff;
    border: 1px solid #E5E7EB;
    border-radius: 10px;
    transition: box-shadow 0.15s;
}
.m-alarm-card:hover {
    box-shadow: var(--shadow-sm);
}
.m-alarm-card-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.m-alarm-card-icon i {
    width: 18px;
    height: 18px;
    color: #fff;
}
.m-alarm-card-body {
    flex: 1;
    min-width: 0;
}
.m-alarm-card-title {
    font-size: 13px;
    font-weight: 600;
    color: #1F2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.m-alarm-card-desc {
    font-size: 12px;
    color: #6B7280;
    margin-top: 2px;
}
.m-alarm-card-emails {
    font-size: 11px;
    color: #9CA3AF;
    margin-top: 2px;
}
.m-alarm-card-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.m-alarm-toggle {
    position: relative;
    width: 38px;
    height: 22px;
    background: #D1D5DB;
    border-radius: 11px;
    cursor: pointer;
    transition: background 0.2s;
    border: none;
    padding: 0;
}
.m-alarm-toggle.active {
    background: var(--alfred-jade);
}
.m-alarm-toggle::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform 0.2s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.m-alarm-toggle.active::after {
    transform: translateX(16px);
}
.m-alarm-delete {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: #9CA3AF;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
}
.m-alarm-delete:hover {
    color: #EF4444;
    background: #FEF2F2;
}
.m-alarm-delete i {
    width: 16px;
    height: 16px;
}

/* Premium alarm prompt (modal overlay) */
.m-alarm-premium-prompt {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.m-alarm-premium-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.4);
}
.m-alarm-premium-dialog {
    position: relative;
    background: #fff;
    border-radius: 16px;
    padding: 32px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.m-alarm-premium-dialog h3 {
    font-size: 16px;
    font-weight: 700;
    color: #1F2937;
    margin: 12px 0 8px;
}
.m-alarm-premium-dialog p {
    font-size: 13px;
    color: #6B7280;
    margin: 0 0 4px;
    line-height: 1.5;
}

/* Alarm form (inline) */
.m-alarm-form {
    background: #F9FAFB;
    border: 1px solid #E5E7EB;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 16px;
}
.m-alarm-form-title {
    font-size: 14px;
    font-weight: 600;
    color: #1F2937;
    margin: 0 0 16px 0;
}
.m-alarm-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}
.m-alarm-form-row.full {
    grid-template-columns: 1fr;
}
.m-alarm-form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 4px;
}
.m-alarm-form-group select,
.m-alarm-form-group input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #D1D5DB;
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    background: #fff;
    color: #1F2937;
    outline: none;
    transition: border-color 0.15s;
    box-sizing: border-box;
}
.m-alarm-form-group select:focus,
.m-alarm-form-group input:focus {
    border-color: var(--alfred-indigo);
}
.m-alarm-form-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 16px;
}

/* =====================================================
   Events Dropdown (Header Bell)
   ===================================================== */
.m-events-wrapper {
    position: relative;
}
.m-events-btn {
    background: none;
    border: none;
    cursor: pointer;
    position: relative;
    padding: 6px;
    border-radius: 8px;
    color: #6B7280;
    transition: color 0.15s, background 0.15s;
}
.m-events-btn:hover {
    background: #F3F4F6;
    color: #1F2937;
}
.m-events-btn i {
    width: 20px;
    height: 20px;
}
.m-events-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    background: #EF4444;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
}
.m-events-badge:empty,
.m-events-badge[data-count="0"] {
    display: none;
}
.m-events-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    width: 360px;
    max-height: 420px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.12);
    z-index: 1001;
    display: none;
    margin-top: 6px;
}
.m-events-dropdown.open {
    display: block;
}
.m-events-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 10px;
    border-bottom: 1px solid #F3F4F6;
}
.m-events-dropdown-header h4 {
    font-size: 14px;
    font-weight: 600;
    color: #1F2937;
    margin: 0;
}
.m-events-dropdown-header button {
    font-size: 12px;
    color: var(--alfred-indigo);
    background: none;
    border: none;
    cursor: pointer;
    font-weight: 500;
    padding: 0;
}
.m-events-list {
    padding: 6px 0;
}
.m-event-item {
    display: flex;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid #F9FAFB;
}
.m-event-item:hover {
    background: #F9FAFB;
}
.m-event-item.unread {
    background: #F0F5FF;
}
.m-event-item.unread:hover {
    background: #E8EFFC;
}
.m-event-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: #FEF2F2;
}
.m-event-icon i {
    width: 16px;
    height: 16px;
    color: #EF4444;
}
.m-event-body {
    flex: 1;
    min-width: 0;
}
.m-event-title {
    font-size: 13px;
    font-weight: 500;
    color: #1F2937;
    line-height: 1.3;
}
.m-event-meta {
    font-size: 11px;
    color: #9CA3AF;
    margin-top: 2px;
}
.m-event-unread-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--alfred-indigo);
    flex-shrink: 0;
    margin-top: 4px;
}
.m-events-empty {
    text-align: center;
    padding: 32px 16px;
    color: #9CA3AF;
    font-size: 13px;
}
.m-events-empty i {
    width: 28px;
    height: 28px;
    margin-bottom: 8px;
    color: #D1D5DB;
}

@media (max-width: 480px) {
    .m-events-dropdown {
        width: calc(100vw - 24px);
        right: -60px;
    }
}

/* Tier badge on project cards */
.m-tier-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 6px;
}
.m-tier-none {
    background: #F3F4F6;
    color: #9CA3AF;
}
.m-tier-basic {
    background: #DBEAFE;
    color: #1D4ED8;
}
.m-tier-premium {
    background: linear-gradient(135deg, #FEF3C7, #FDE68A);
    color: #92400E;
}

