:root {
    /* Colors inspired by the NEXA screenshot */
    --bg-app: #f4f7fb;
    --bg-panel: #ffffff;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --border-light: #e5e7eb;
    
    --primary-purple: #6d28d9;
    --primary-purple-hover: #5b21b6;
    --alert-bg: #f5f3ff;
    --alert-border: #ede9fe;
    
    --status-red: #ef4444;
    --status-green: #10b981;
    --status-yellow: #f59e0b;
    
    --shadow-panel: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --radius-panel: 12px;
    --radius-input: 8px;
    
    --font-main: 'Outfit', sans-serif;
    --transition: all 0.2s ease-in-out;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-main);
}

body {
    background-color: var(--bg-app);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

/* App Layout */
.app-layout {
    display: flex;
    min-height: 100vh;
    padding: 1rem;
    gap: 1.5rem;
}

/* Sidebar */
.sidebar {
    width: 320px;
    background: var(--bg-panel);
    border-radius: var(--radius-panel);
    padding: 1.5rem;
    box-shadow: var(--shadow-panel);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    height: calc(100vh - 2rem);
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.brand-icon {
    font-size: 1.5rem;
    background: var(--alert-bg);
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    color: var(--primary-purple);
}

.brand h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text-main);
}

.sidebar-section {
    margin-bottom: 1.5rem;
}

.section-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

.form-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.form-group input {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-input);
    font-size: 0.95rem;
    color: var(--text-main);
    transition: var(--transition);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-purple);
}

/* Contact Inputs Styling */
details.contact-inputs {
    background: #f9fafb;
    padding: 1rem;
    border-radius: var(--radius-input);
    border: 1px solid var(--border-light);
    margin-bottom: 1rem;
}

details.contact-inputs summary {
    cursor: pointer;
    list-style: none; /* Hide default arrow */
    display: flex;
    justify-content: space-between;
    align-items: center;
}

details.contact-inputs summary::-webkit-details-marker {
    display: none;
}

details.contact-inputs[open] summary .arrow {
    transform: rotate(180deg);
}

.arrow {
    font-size: 0.75rem;
    color: var(--text-muted);
    transition: var(--transition);
}

.group-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0;
}

.inputs-wrapper {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group-small {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.form-group-small label {
    font-size: 0.85rem;
    color: var(--text-muted);
    width: 40%;
}

.form-group-small input {
    width: 60%;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    font-size: 0.85rem;
}

.primary-btn {
    width: 100%;
    background: var(--primary-purple);
    color: white;
    border: none;
    padding: 0.75rem;
    border-radius: var(--radius-input);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 0.5rem;
}

.primary-btn:hover {
    background: var(--primary-purple-hover);
}

/* Status Indicator */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--status-red);
}

.status-dot.connected {
    background: var(--status-green);
    box-shadow: 0 0 8px var(--status-green);
}

.status-text {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
}

/* Alerts */
.alert-section {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.alert-box {
    background: var(--alert-bg);
    border-left: 3px solid var(--primary-purple);
    border-radius: 0 var(--radius-input) var(--radius-input) 0;
    padding: 0.75rem;
    flex-grow: 1;
    overflow-y: auto;
    max-height: 200px;
}

.alert-item {
    display: flex;
    flex-direction: column;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
}

.alert-item:last-child {
    margin-bottom: 0;
}

.alert-source {
    font-weight: 600;
    color: var(--primary-purple);
    margin-bottom: 0.2rem;
}

.alert-msg {
    color: var(--text-main);
}

/* Main Content Area */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 2rem);
    overflow-y: auto;
}

.grid-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.panel {
    background: var(--bg-panel);
    border-radius: var(--radius-panel);
    padding: 1.5rem;
    box-shadow: var(--shadow-panel);
}

.panel-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 1.5rem;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1.25rem;
}

.contacts-layout, .needs-layout {
    grid-template-columns: repeat(4, 1fr);
}

.card {
    background: var(--bg-app);
    border: 2px solid transparent;
    border-radius: var(--radius-panel);
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    transition: var(--transition);
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.card-icon {
    font-size: 2.5rem;
}

.card-title {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-muted);
}

/* Active states */
.card.active {
    background: white;
    border-color: var(--primary-purple);
    box-shadow: 0 4px 12px rgba(109, 40, 217, 0.2);
    transform: translateY(-2px);
}

.card.active .card-title {
    color: var(--primary-purple);
    font-weight: 600;
}

.card.emergency.active {
    border-color: var(--status-red);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

.card.emergency.active .card-title {
    color: var(--status-red);
}

/* Responsive */
@media (max-width: 900px) {
    .app-layout {
        flex-direction: column;
        height: auto;
        padding: 0.5rem;
        gap: 1rem;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        padding: 1rem;
    }
    
    .main-content {
        height: auto;
        overflow-y: visible;
    }

    .panel {
        padding: 1rem;
    }

    .card {
        padding: 1rem 0.5rem;
        gap: 0.75rem;
    }

    .card-icon {
        font-size: 2rem;
    }

    .card-title {
        font-size: 0.85rem;
        text-align: center;
    }

    .contacts-layout, .needs-layout {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
}
