 
:root {
    --dash-bg: #f4f7fb;
    --dash-surface: #ffffff;
    --dash-surface-2: #f9fbff;
    --dash-border: rgba(15, 23, 42, 0.08);
    --dash-text: #0f172a;
    --dash-muted: #64748b;
    --dash-primary: #2563eb;
    --dash-primary-soft: rgba(37, 99, 235, 0.12);
    --dash-success: #16a34a;
    --dash-warning: #d97706;
    --dash-danger: #dc2626;
    --dash-info: #0284c7;
    --dash-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
    --dash-radius: 22px;
    --sidebar-width: 280px;
    --sidebar-collapsed-width: 92px;
    --topbar-height: 84px;
}

body.dashboard-dark {
    --dash-bg: #0b1220;
    --dash-surface: #111827;
    --dash-surface-2: #172033;
    --dash-border: rgba(255, 255, 255, 0.08);
    --dash-text: #f8fafc;
    --dash-muted: #94a3b8;
    --dash-primary: #60a5fa;
    --dash-primary-soft: rgba(96, 165, 250, 0.14);
    --dash-success: #22c55e;
    --dash-warning: #f59e0b;
    --dash-danger: #ef4444;
    --dash-info: #38bdf8;
    --dash-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

.saas-dashboard {
    min-height: 100vh;
    background: var(--dash-bg);
    color: var(--dash-text);
    display: flex;
}

/* SIDEBAR */
.dashboard-sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--dash-surface), var(--dash-surface-2));
    border-right: 1px solid var(--dash-border);
    padding: 22px 16px;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    transition: width 0.28s ease, transform 0.28s ease;
    z-index: 1040;
}

.sidebar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 12px;
}

.brand-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.brand-mark {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--dash-primary), #7c3aed);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}

.brand-title {
    font-weight: 700;
    line-height: 1.1;
}

.brand-subtitle {
    font-size: 12px;
    color: var(--dash-muted);
}

.sidebar-toggle,
.mobile-menu-btn,
.topbar-btn {
    border: 1px solid var(--dash-border);
    background: var(--dash-surface);
    color: var(--dash-text);
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--dash-text);
    text-decoration: none;
    border-radius: 14px;
    padding: 12px 14px;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

    .nav-link:hover {
        background: var(--dash-primary-soft);
        color: var(--dash-text);
        border-color: var(--dash-border);
    }

    .nav-link.active {
        background: var(--dash-primary-soft);
        border-color: rgba(37, 99, 235, 0.15);
        font-weight: 600;
    }

.nav-icon {
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 18px;
}

.sidebar-mini-card {
    background: var(--dash-surface);
    border: 1px solid var(--dash-border);
    border-radius: 18px;
    padding: 16px;
    box-shadow: var(--dash-shadow);
}

.mini-title {
    font-size: 12px;
    color: var(--dash-muted);
}

.mini-value {
    font-size: 28px;
    font-weight: 800;
    margin-top: 6px;
}

.mini-meta {
    font-size: 13px;
    color: var(--dash-muted);
}

/* MAIN */
.dashboard-main-area {
    flex: 1;
    min-width: 0;
    padding: 24px;
}

.dashboard-topbar {
    min-height: var(--topbar-height);
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(14px);
    border: 1px solid var(--dash-border);
    box-shadow: var(--dash-shadow);
    border-radius: 24px;
    padding: 18px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    margin-bottom: 22px;
    position: sticky;
    top: 16px;
    z-index: 20;
}

body.dashboard-dark .dashboard-topbar {
    background: rgba(17, 24, 39, 0.72);
}

.topbar-left,
.topbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.page-title {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.page-subtitle {
    color: var(--dash-muted);
    font-size: 14px;
}

.search-wrap {
    min-width: 300px;
}

.dashboard-search {
    width: 100%;
    border: 1px solid var(--dash-border);
    background: var(--dash-surface);
    color: var(--dash-text);
    border-radius: 14px;
    padding: 12px 14px;
    outline: none;
}

.topbar-action-btn {
    border-radius: 14px;
    padding: 11px 16px;
    font-weight: 600;
}

/* SECTION + GRID */
.dashboard-section {
    margin-bottom: 22px;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
}

.dashboard-grid-v2 {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
    gap: 20px;
}

.dashboard-col-main,
.dashboard-col-side {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* WIDGETS */
.widget-card {
    background: linear-gradient(180deg, var(--dash-surface), var(--dash-surface-2));
    border: 1px solid var(--dash-border);
    border-radius: var(--dash-radius);
    box-shadow: var(--dash-shadow);
    padding: 20px;
}

.widget-large {
    padding: 22px;
}

.widget-header,
.widget-toolbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}

.widget-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
}

.widget-subtitle {
    color: var(--dash-muted);
    font-size: 13px;
    margin-top: 3px;
}

.widget-value {
    font-size: 34px;
    font-weight: 800;
    margin-top: 14px;
    line-height: 1;
}

.widget-meta {
    color: var(--dash-muted);
    margin-top: 8px;
    font-size: 13px;
}

.widget-badge {
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 999px;
    font-weight: 700;
    white-space: nowrap;
}

    .widget-badge.up {
        background: rgba(22, 163, 74, 0.12);
        color: var(--dash-success);
    }

    .widget-badge.down {
        background: rgba(220, 38, 38, 0.12);
        color: var(--dash-danger);
    }

    .widget-badge.neutral {
        background: var(--dash-primary-soft);
        color: var(--dash-primary);
    }

.chart-wrap {
    margin-top: 20px;
    height: 320px;
}

.widget-toolbar-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* SNAPSHOT */
.snapshot-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-top: 18px;
}

.snapshot-item {
    border: 1px solid var(--dash-border);
    background: var(--dash-surface);
    border-radius: 18px;
    padding: 16px;
}

.snapshot-label {
    color: var(--dash-muted);
    font-size: 13px;
}

.snapshot-value {
    font-size: 20px;
    font-weight: 700;
    margin-top: 6px;
}

/* ACTIVITY */
.activity-feed {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 18px;
}

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--dash-border);
}

    .activity-item:last-child {
        border-bottom: none;
        padding-bottom: 0;
    }

.activity-dot {
    width: 12px;
    height: 12px;
    border-radius: 999px;
    margin-top: 6px;
    flex-shrink: 0;
}

    .activity-dot.success {
        background: var(--dash-success);
    }

    .activity-dot.warning {
        background: var(--dash-warning);
    }

    .activity-dot.info {
        background: var(--dash-info);
    }

.activity-title {
    font-weight: 600;
}

.activity-meta {
    color: var(--dash-muted);
    font-size: 13px;
    margin-top: 3px;
}

/* QUICK ACTIONS */
.quick-actions-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 18px;
}

.quick-action-tile {
    text-decoration: none;
    color: var(--dash-text);
    border: 1px solid var(--dash-border);
    border-radius: 18px;
    background: var(--dash-surface);
    min-height: 98px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

    .quick-action-tile:hover {
        transform: translateY(-2px);
        color: var(--dash-text);
        border-color: rgba(37, 99, 235, 0.3);
        background: var(--dash-primary-soft);
    }

.tile-icon {
    font-size: 22px;
}

/* ALERTS */
.alert-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 18px;
}

.alert-tile {
    border-radius: 18px;
    padding: 14px 16px;
    border: 1px solid var(--dash-border);
    background: var(--dash-surface);
}

    .alert-tile.danger {
        border-left: 4px solid var(--dash-danger);
    }

    .alert-tile.warning {
        border-left: 4px solid var(--dash-warning);
    }

    .alert-tile.info {
        border-left: 4px solid var(--dash-info);
    }

.alert-title {
    font-weight: 700;
}

.alert-meta {
    color: var(--dash-muted);
    font-size: 13px;
    margin-top: 4px;
}

/* PROGRESS */
.progress-widget {
    margin-top: 18px;
}

.progress-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.progress-label,
.progress-value {
    font-size: 14px;
    font-weight: 600;
}

.custom-progress {
    height: 12px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.18);
    overflow: hidden;
}

    .custom-progress .progress-bar {
        background: linear-gradient(90deg, var(--dash-primary), #7c3aed);
        border-radius: 999px;
    }

/* COLLAPSED SIDEBAR */
.saas-dashboard.sidebar-collapsed .dashboard-sidebar {
    width: var(--sidebar-collapsed-width);
}

.saas-dashboard.sidebar-collapsed .brand-text,
.saas-dashboard.sidebar-collapsed .nav-text,
.saas-dashboard.sidebar-collapsed .sidebar-footer {
    display: none;
}

.saas-dashboard.sidebar-collapsed .nav-link {
    justify-content: center;
}

/* MOBILE */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s ease;
    z-index: 1030;
}

@@media (max-width: 1199.98px) {
    .kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dashboard-grid-v2 {
        grid-template-columns: 1fr;
    }
}

@@media (max-width: 991.98px) {
    .dashboard-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
        width: min(86vw, 320px);
        box-shadow: var(--dash-shadow);
    }

    body.sidebar-mobile-open .dashboard-sidebar {
        transform: translateX(0);
    }

    body.sidebar-mobile-open .sidebar-backdrop {
        opacity: 1;
        visibility: visible;
    }

    .dashboard-main-area {
        padding: 16px;
    }

    .dashboard-topbar {
        top: 10px;
        border-radius: 20px;
        padding: 14px 16px;
    }

    .topbar-right {
        gap: 10px;
    }

    .search-wrap {
        min-width: 0;
    }
}

@@media (max-width: 767.98px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-topbar {
        flex-direction: column;
        align-items: stretch;
    }

    .topbar-left,
    .topbar-right {
        width: 100%;
        justify-content: space-between;
    }

    .topbar-right {
        flex-wrap: wrap;
    }

    .search-wrap {
        order: 3;
        width: 100%;
    }

    .dashboard-search {
        width: 100%;
    }

    .quick-actions-grid,
    .snapshot-grid {
        grid-template-columns: 1fr;
    }

    .widget-card,
    .widget-large {
        padding: 16px;
        border-radius: 18px;
    }

    .page-title {
        font-size: 24px;
    }

    .widget-value {
        font-size: 28px;
    }

    .chart-wrap {
        height: 260px;
    }
}

.farm-dashboard-card {
    background: linear-gradient(180deg, var(--dash-surface), var(--dash-surface-2));
    border: 1px solid var(--dash-border);
    border-radius: 22px;
    overflow: hidden;
    box-shadow: var(--dash-shadow);
}

    .farm-dashboard-card .card-body {
        color: var(--dash-text);
    }

    .farm-dashboard-card .text-muted,
    .farm-dashboard-card .small {
        color: var(--dash-muted) !important;
    }

.farm-map {
    background: rgba(148,163,184,.08);
}

.climate-container {
    border: 1px solid var(--dash-border);
    border-radius: 16px;
    background: var(--dash-surface);
    padding: 12px;
}

html {
    scroll-behavior: smooth;
}
 
