/* =========================================
   1. VARIABLES & RESET
========================================= */
:root {
    /* Brand Colors */
    --primary: #2c3e50;
    --primary-dark: #1a252f;
    --accent: #e74c3c;
    --bg-light: #f4f6f9;
    --bg-white: #ffffff;
    --border: #dce1e6;

    /* Status Colors */
    --success: #27ae60;
    --warning: #f39c12;
    --danger: #c0392b;
    --info: #3498db;

    /* Priority Colors */
    --prio-critical: #8e44ad;
    --prio-high: #c0392b;
    --prio-medium: #e67e22;
    --prio-low: #27ae60;
    --prio-low-bg: #e8f8f5;
}

* {
    box-sizing: border-box;
}

body,
html {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-light);
    color: #333;
    height: 100%;
    width: 100%;
    overflow: hidden;
    /* Prevent global scrollbar */
}

/* =========================================
   2. APP SHELL (Header + Main)
========================================= */
#app-root {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

.ag-theme-alpine {
    --ag-header-background-color: #f8f9fb;
    --ag-odd-row-background-color: #fafafa;
    font-size: 13px;
}

.ag-theme-alpine .ag-row.incident-row-breached {
    background: #fff1f0;
}

.ag-theme-alpine .ag-row.incident-row-breached:hover {
    background: #ffe4e1 !important;
}

.ag-theme-alpine .ag-row.incident-row-healthy {
    background: #f6fbf7;
}

.ag-theme-alpine .ag-row.incident-row-healthy:hover {
    background: #ebf7ee !important;
}

.ag-theme-alpine .ag-cell.sla-status-breached {
    color: #c0392b;
    font-weight: 700;
}

.ag-theme-alpine .ag-cell.sla-status-healthy {
    color: #1f8f4e;
    font-weight: 700;
}

.app-header {
    flex: 0 0 60px;
    /* Fixed Header Height */
    background-color: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    padding: 0 20px;
    justify-content: space-between;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

.brand {
    font-size: 1.2rem;
    font-weight: bold;
}

#main-nav button {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    padding: 10px 15px;
    cursor: pointer;
    font-size: 0.95rem;
    transition: 0.2s;
}

#main-nav button:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.user-profile {
    font-size: 0.9rem;
}

.logout-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    margin-left: 10px;
    cursor: pointer;
}

/* MAIN CONTENT AREA */
#main-content {
    flex: 1;
    /* Grow to fill remaining height */
    position: relative;
    overflow: hidden;
    /* Prevent scrolling on the container itself */
    display: flex;
    flex-direction: column;
    background: var(--bg-light);
}

/* Base View Container */
.view-section {
    flex: 1;
    /* Fill #main-content */
    height: 100%;
    width: 100%;
    padding: 10px;
    /* display: flex;
    flex-direction: column;
    overflow: hidden; */
    /* Default hidden, specific views override */
}

.view-sections {
    flex: 1;
    /* Fill #main-content */
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Default hidden, specific views override */
}

/* =========================================
   3. VIEW-SPECIFIC LAYOUTS
========================================= */

/* DASHBOARD (Gridstack Scrollable Area) */
#view-dashboard {
    overflow-y: auto;
    /* Enable scroll for dashboard */
    padding: 20px;
    display: block;
}

/* Cap width so large laptops/monitors keep the same widget density as ~14" screens */
#dashboard-production-shell {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    box-sizing: border-box;
}

/* LISTS (Simple Scroll) */
#view-incident-list {
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

/* SPLIT VIEWS (CRM, Services, CMDB) */
#view-crm,
#view-services,
#view-cmdb {
    padding: 0;
    overflow: hidden;
    /* Layout manages internal scrolling */
}

/* INCIDENT CONSOLE (Flex Layout) */
#view-incident-console {
   padding:20px;
    height:100%;
    overflow-y:auto;
}

#view-service-request-console {
   padding:20px;
    height:100%;
    overflow-y:auto;
}

/* UTILITIES & CHANGE MGMT (Scrollable) */
#view-utilities,
#view-change-management {
    overflow-y: auto;
    padding: 0;
    /* Managed internally */
    display: flex;
    flex-direction: column;
}

/* =========================================
   4. DASHBOARD GRIDSTACK OVERRIDES
========================================= */
.grid-stack {
    background: transparent;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    box-sizing: border-box;
}

/* Locked layout — hide resize affordances if any remain */
#view-dashboard .ui-resizable-handle,
#view-dashboard .grid-stack-item > .ui-resizable-handle {
    display: none !important;
    pointer-events: none !important;
}

/* Incident attachment chips (multi-file pending uploads) */
.inc-attachment-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.inc-attachment-chip {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 260px;
    padding: 8px 28px 8px 10px;
    background: #fff;
    border: 1px solid #d5dde8;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    font-size: 0.82rem;
    color: #334155;
}

.inc-attachment-chip-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.inc-attachment-chip-remove {
    position: absolute;
    top: -7px;
    right: -7px;
    width: 20px;
    height: 20px;
    border: 1px solid #d1d5db;
    border-radius: 50%;
    background: #fff;
    color: #64748b;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.inc-attachment-chip-remove:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #b91c1c;
}

.grid-stack-item-content>div {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.grid-stack-item-content {
    background: white;
    border-radius: 6px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    padding: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
}

/* Fix for resize handle z-index */
.ui-resizable-handle {
    z-index: 100 !important;
}

/* Dashboard Widget Styles */
.stat-card-widget {
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
}

.stat-card-widget h3 {
    margin: 0;
    font-size: 1rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
}

.stat-card-widget .stat-number {
    font-size: 3rem;
    font-weight: bold;
    color: var(--primary);
    line-height: 1;
}

.stat-card-widget .stat-label {
    font-size: 0.85rem;
    color: #999;
    margin-top: 5px;
}

/* Queue List Styles */
.queue-widget-list .dash-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    font-size: 0.9rem;
}

.queue-widget-list .dash-item:hover {
    background: #f9f9f9;
    padding-left: 5px;
    transition: 0.2s;
}

/* Queue Header with Reset Button */
.queue-header {
    margin: 0;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    flex: 0 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.reset-btn {
    font-size: 0.75rem;
    padding: 3px 8px;
    background: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 3px;
    cursor: pointer;
    color: #555;
}

.reset-btn:hover {
    background: #e0e0e0;
    color: #333;
}

/* --- CSS BAR CHART STYLES (Vertical Columns) --- */
.chart-widget {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    margin-top: 10px;
}

.chart-container {
    flex: 1;
    display: flex;
    /* Center cluster, add gap for fixed width bars */
    justify-content: center;
    gap: 10px;
    align-items: flex-end;
    /* Align bars to bottom */
    padding-top: 20px;
    padding-bottom: 5px;
    border-bottom: 1px solid #eee;
}

.chart-bar-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    /* Fixed width to ensure uniformity */
    width: 50px;
    flex: 0 0 50px;
    margin: 0;
    height: 100%;
    justify-content: flex-end;
    cursor: pointer;
    /* Interactive */
}

.chart-value {
    font-size: 0.8rem;
    font-weight: bold;
    margin-bottom: 5px;
    color: #555;
}

.chart-bar {
    width: 100%;
    border-radius: 4px 4px 0 0;
    min-height: 4px;
    transition: height 0.3s ease, opacity 0.3s ease;
    opacity: 0.7;
}

/* Interaction States */
.chart-bar:hover {
    opacity: 0.9;
}

.chart-bar.active {
    opacity: 1;
    border: 2px solid #333;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
}

.chart-label {
    margin-top: 8px;
    font-size: 0.7rem;
    color: #666;
    text-align: center;

    /* Text Wrapping & Alignment */
    white-space: normal;
    overflow: visible;
    line-height: 1.1;
    width: 100%;

    /* Fixed height to align x-axis */
    height: 45px;
    display: flex;
    align-items: flex-start;
    /* Top align text */
    justify-content: center;
}

.chart-widget h3 {
    flex-shrink: 0;
}

/* --- CSS HORIZONTAL BAR CHART STYLES (For Customers) --- */
.chart-container-horizontal {
    flex: 1;
    display: flex;
    flex-direction: column;
    /* Stack rows vertically */
    justify-content: flex-start;
    padding: 10px 0;
    overflow-y: auto;
}

.chart-row-group {
    display: flex;
    align-items: center;
    width: 100%;
    margin-bottom: 8px;
    cursor: pointer;
}

.chart-row-label {
    width: 150px;
    /* Fixed width, increased for long labels */
    font-size: 0.75rem;
    color: #555;
    text-align: right;
    padding-right: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}

.chart-row-bar-area {
    flex: 1;
    /* Take remaining space */
    background: #f0f0f0;
    height: 12px;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

.chart-row-bar {
    height: 100%;
    border-radius: 6px;
    transition: width 0.5s ease;
    opacity: 0.8;
}

.chart-row-bar:hover {
    opacity: 1;
}

.chart-row-bar.active {
    opacity: 1;
    border-right: 3px solid #333;
    /* Visual indicator for selected */
}

.chart-row-value {
    width: 30px;
    font-size: 0.75rem;
    font-weight: bold;
    color: #666;
    padding-left: 8px;
    text-align: left;
}

/* =========================================
   5. INCIDENT & CHANGE CONSOLE STYLES
========================================= */
.workflow-container {
    flex: 0 0 auto;
    margin-bottom: 20px;
    overflow-x: auto;
    padding-bottom: 5px;
}

/* Workflow Bar Container */
#workflow-chevron {
    display: flex;
    width: 100%;
    gap: 5px;
}

/* Workflow Step (Arrow) */
.chevron {
    flex: 1;
    /* Expand equally */
    text-align: center;
    background: #e0e0e0;
    padding: 8px 15px 8px 25px;
    /* Precise arrow shape */
    clip-path: polygon(0% 0%, calc(100% - 15px) 0%, 100% 50%, calc(100% - 15px) 100%, 0% 100%, 15px 50%);
    font-size: 0.85rem;
    color: #555;
    white-space: nowrap;
    display: flex;
    justify-content: center;
    align-items: center;
}

.chevron:first-child {
    /* Flat left edge for first item */
    clip-path: polygon(0% 0%, calc(100% - 15px) 0%, 100% 50%, calc(100% - 15px) 100%, 0% 100%);
    padding-left: 10px;
}

.chevron.active {
    background: var(--info);
    color: white;
}

.chevron.completed {
    background: var(--success);
    color: white;
}

/* Change Management Workflow (Distinct) */
#change-workflow-steps {
    display: flex;
    gap: 2px;
    background: #f0f0f0;
    padding: 5px;
    border-radius: 4px;
}

#change-workflow-steps .chevron {
    font-size: 0.75rem;
    padding: 6px 15px 6px 10px;
    background: #ccc;
    color: #555;
    clip-path: polygon(0% 0%, 90% 0%, 100% 50%, 90% 100%, 0% 100%, 10% 50%);
}

#change-workflow-steps .chevron.active {
    background: var(--info);
    color: white;
    font-weight: bold;
}

#change-workflow-steps .chevron.completed {
    background: var(--success);
    color: white;
}

/* --------------------------------------
   NEW: WORKFLOW ENGINE STATES & ANIMATIONS
-------------------------------------- */
.chevron.warn {
    background: #f1c40f !important;
    /* Yellow for Pending */
    color: #333 !important;
    animation: pulse-border 2s infinite;
}

.chevron.error {
    background: #e74c3c !important;
    /* Red for Rejected */
    color: white !important;
}

@keyframes pulse-border {
    0% {
        box-shadow: 0 0 0 0 rgba(241, 196, 15, 0.7);
    }

    70% {
        box-shadow: 0 0 0 6px rgba(241, 196, 15, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(241, 196, 15, 0);
    }
}

.status-scheduled {
    background-color: var(--warning);
    color: white;
}

.status-implemented {
    background-color: var(--success);
    color: white;
}

.incident-console-grid, .service-request-console-grid {
    display: grid;
    grid-template-columns: 3fr 1fr;
    gap: 20px;
    flex: 1;
    /* Fill remaining height */
    min-height: 0;
    /* Important for flex shrinking */
}

.console-main {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: white;
    border-radius: 4px;
    border: 1px solid var(--border);
}

.console-header {
    padding: 15px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-direction: column;   
    flex: 0 0 auto;
    gap:10px;
}

.console-tabs {
    display: flex;
    background: #f8f9fa;
    border-bottom: 1px solid var(--border);
    flex: 0 0 auto;
    overflow-x: auto;
}

.tab-btn {
    flex: 1;
    border: none;
    background: none;
    padding: 12px;
    cursor: pointer;
    color: #666;
    font-weight: 600;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
}

.tab-btn:hover {
    background: #f0f0f0;
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--accent);
    background: white;
}
/* .console-panel {
    padding:30px;
    max-height:70vh;
    overflow-y:auto;
} */

.small-btn {
    padding:6px 10px;
    font-size:13px;
}

.console-sidebar {
    overflow-y: auto;
}

.sidebar-widget {
    background: white;
    padding: 15px;
    border-radius: 4px;
    border: 1px solid var(--border);
    margin-bottom: 20px;
}

.sidebar-widget h4 {
    margin-top: 0;
    margin-bottom: 10px;
    color: #555;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

/* =========================================
   6. SPLIT LAYOUT (CRM & SERVICES)
========================================= */
.split-layout {
    display: flex;
    height: 100%;
    width: 100%;
    background: white;
}

.list-sidebar {
    width: 300px;
    min-width: 250px;
    border-right: 1px solid var(--border);
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.detail-content {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    /* Reset padding, specific views use internal padding */
    background: white;
    display: flex;
    flex-direction: column;
    /* Allows Console Layout inside */
}

.clickable-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.clickable-list li {
    padding: 15px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: 0.1s;
}

.clickable-list li:hover {
    background: white;
    border-left: 4px solid var(--info);
}

.clickable-list li.active {
    background: white;
    border-left: 4px solid var(--accent);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

/* --- SERVICE SPECIFIC: SLA & ASSET GRIDS --- */
.sla-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    background: #fdfdfd;
    padding: 15px;
    border-top: 1px solid #eee;
    font-size: 0.9rem;
}

.sla-detail-grid label {
    font-size: 0.75rem;
    color: #888;
    text-transform: uppercase;
    display: block;
    margin-bottom: 3px;
}

.sla-card {
    border-left: 4px solid var(--info);
    transition: all 0.2s;
}

.sla-card:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* --- CRM SPECIFIC --- */
.crm-console-grid {
    display: flex;
    flex-direction: column;
}

.service-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    background: #fdfdfd;
    padding: 15px;
    border-top: 1px solid #eee;
    font-size: 0.9rem;
    margin-top: 5px;
}

.service-card {
    border-left: 4px solid var(--success);
    transition: all 0.2s;
}

.service-card:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Contract Link & List Styles */
.contract-list-item {
    display: flex;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid #eee;
    background: #fff;
    transition: background-color 0.2s;
}

.contract-list-item:hover {
    background-color: #fcfcfc;
}

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

.doc-icon {
    font-size: 1.5rem;
    color: #e74c3c;
    margin-right: 15px;
    width: 30px;
    text-align: center;
}

.doc-info {
    flex: 1;
}

.doc-link {
    font-weight: bold;
    font-size: 0.95rem;
    color: #333;
    text-decoration: none;
    cursor: pointer;
    display: inline-block;
    margin-bottom: 2px;
}

.doc-link:hover {
    color: var(--primary);
    text-decoration: underline;
}

.doc-desc {
    font-size: 0.85rem;
    color: #666;
    margin-top: 2px;
}

.doc-meta {
    font-size: 0.75rem;
    color: #999;
    margin-top: 2px;
}

.doc-actions {
    margin-left: 10px;
}

.upload-zone {
    background-color: #f0f8ff;
    border: 1px dashed #3498db;
}

/* =========================================
   7. CMDB LAYOUT
========================================= */
.cmdb-container {
    display: flex;
    height: 100%;
    width: 100%;
    overflow: hidden;
}

.cmdb-sidebar {
    width: 300px;
    background: white;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-search-box {
    padding: 10px;
    border-bottom: 1px solid var(--border);
    background: #f8f9fa;
}

.tree-view {
    flex: 1;
    overflow-y: auto;
    padding: 5px 0;
}

#cmdb-resizer {
    width: 5px;
    background: #f0f0f0;
    cursor: col-resize;
    flex-shrink: 0;
    border-left: 1px solid #ddd;
    transition: background 0.2s;
}

#cmdb-resizer:hover,
#cmdb-resizer.resizing {
    background: var(--info);
}

.cmdb-canvas-wrapper {
    flex: 1;
    position: relative;
    background: #f4f6f9;
    overflow: hidden;
    display: flex;
    /* Ensures canvas fills container */
}

canvas#cmdb-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* Floating Details Panel */
.floating-details {
    position: absolute;
    top: 60px;
    right: 20px;
    width: 340px;
    background: white;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.15);
    border-radius: 4px;
    padding: 15px;
    z-index: 50;
    max-height: calc(100% - 80px);
    overflow-y: auto;
    border: 1px solid #ddd;
}

/* Tree View Styles */
.tree-node-parent,
.tree-item {
    padding: 6px 10px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #444;
}

.tree-node-parent:hover,
.tree-item:hover {
    background-color: #eef2f7;
}

.tree-node-parent.active {
    color: var(--primary);
    font-weight: bold;
}

.tree-children {
    display: none;
}

.tree-children.expanded {
    display: block;
}

/* =========================================
   8. COMPONENTS & UTILS
========================================= */
.hidden {
    display: none !important;
}

.card {
    background: white;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
}

/* Badges */
.badge {
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: bold;
    color: white;
    display: inline-block;
    vertical-align: middle;
}

.badge.priority-1-Critical {
    background: var(--prio-critical);
}

.badge.priority-2-High {
    background: var(--prio-high);
}

.badge.priority-3-Medium {
    background: var(--prio-medium);
}

.badge.priority-4-Low {
    background: var(--prio-low);
    color: #333;
}

.badge.ok,
.badge.Active {
    background: var(--success);
}

.badge.warn,
.badge.Warning {
    background: var(--warning);
}

.badge.err {
    background: var(--danger);
}

.badge.prio-low {
    background: #e0e0e0;
    color: #555;
}

/* Status Dots */
.status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 5px;
    vertical-align: middle;
}

.status-dot.ok {
    background: var(--success);
}

.status-dot.warn {
    background: var(--warning);
}

.saving-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #dce1e6;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: saving-spin 0.8s linear infinite;
}

@keyframes saving-spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.status-dot.err {
    background: var(--danger);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.6;
        transform: scale(1.2);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Simple Tables */
.simple-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.simple-table th {
    text-align: left;
    padding: 10px;
    background: #f8f9fa;
    border-bottom: 2px solid var(--border);
    font-size: 0.85rem;
    color: #666;
    font-weight: bold;
    position: sticky;
    top: 0;
}

.simple-table td {
    padding: 10px;
    border-bottom: 1px solid #eee;
    font-size: 0.9rem;
    vertical-align: middle;
}

.simple-table tr:hover {
    background-color: #fcfcfc;
}

/* Activity Stream */
.activity-stream-box {
    border: 1px solid var(--border);
    background: #f9f9f9;
    height: 250px;
    overflow-y: auto;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 4px;
}

.activity-entry {
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.activity-header {
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 5px;
    display: flex;
    justify-content: space-between;
}

/* Forms */
.form-row {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: bold;
    color: #555;
    margin-bottom: 5px;
}

select,
input,
textarea {
    width: 100%;
    padding: 4px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.9rem;
}

select:focus,
input:focus,
textarea:focus {
    outline: none;
    border-color: var(--info);
    box-shadow: 0 0 3px rgba(52, 152, 219, 0.3);
}

/* Buttons */
button {
    font-family: inherit;
}

button.primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 0.9rem;
}

button.primary:hover {
    background: var(--primary-dark);
}

button.secondary {
    background: #95a5a6;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
}

button.secondary:hover {
    background: #7f8c8d;
}

button.small-btn {
    padding: 4px 10px;
    font-size: 0.8rem;
    border-radius: 3px;
    border: 1px solid #ccc;
    background: white;
    cursor: pointer;
    color: #555;
}

button.small-btn:hover {
    background: #f0f0f0;
    border-color: #bbb;
}

/* Modals */
#modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal {
    background: white;
    padding: 25px;
    border-radius: 6px;
    width: 450px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
    margin-bottom: 15px;
}

.modal-header h3 {
    margin: 0;
    color: var(--primary);
}

.modal-footer {
    margin-top: 20px;
    text-align: right;
}

/* =========================================
   9. UTILITIES & CONFIG EDITOR
========================================= */
.accordion-header {
    background-color: white;
    padding: 15px;
    border: 1px solid var(--border);
    margin-bottom: 5px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    color: var(--primary);
    transition: background 0.2s;
}

.accordion-header:hover {
    background-color: #f8f9fa;
}

.accordion-header.active {
    background-color: #e8f4fd;
    border-color: var(--info);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    margin-bottom: 0;
}

.accordion-content {
    display: none;
    padding: 15px;
    background: white;
    border: 1px solid var(--border);
    border-top: none;
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
    margin-bottom: 20px;
}

.accordion-content.active {
    display: block;
}

.list-editor-wrapper {
    margin-bottom: 20px;
    padding: 15px;
    border: 1px solid #eee;
    border-radius: 4px;
    background: #fcfcfc;
}

.list-editor-item {
    display: flex;
    gap: 10px;
    margin-bottom: 8px;
    align-items: center;
}

.list-editor-item input {
    flex: 1;
}

.list-editor-item .actions {
    display: flex;
    gap: 5px;
}

.action-btn {
    padding: 6px 10px;
    background: #e0e0e0;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    color: #555;
    font-size: 0.8rem;
}

.action-btn:hover {
    background: #d0d0d0;
}

.action-btn.delete {
    background: #fadbd8;
    color: var(--danger);
}

.action-btn.delete:hover {
    background: #f5b7b1;
}

/* --- CMDB DRAG & DROP STYLES --- */

/* Highlight drop zones */
.drop-zone.drag-over {
    background-color: #d4e6f1 !important;
    /* Light blue highlight */
    border: 2px dashed #3498db;
    font-weight: bold;
    color: var(--primary);
}

/* Ensure tree nodes act as visual containers */
.tree-node-parent {
    border: 1px solid transparent;
    /* Prevent jump on border add */
    transition: background-color 0.2s, border-color 0.2s;
}

/* Draggable items cursor */
.tree-item[draggable="true"] {
    cursor: grab;
}

.tree-item[draggable="true"]:active {
    cursor: grabbing;
}

/* =========================================
   10. WORKFLOW EDITOR STYLES (NEW)
========================================= */
.step-card {
    background: #fff;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s;
}

.step-card:hover {
    transform: translateX(2px);
    border-color: var(--primary);
}

.step-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.step-index {
    background: var(--primary);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.8rem;
    font-weight: bold;
    flex-shrink: 0;
}

.control-btn-group {
    display: flex;
    gap: 5px;
}

/* Dropdown Container for Approvers */
.approver-dropdown-container {
    animation: fadeIn 0.2s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* --- WORKFLOW EDITOR STYLES --- */
.step-card {
    background: #fff;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s;
}

.step-card:hover {
    transform: translateX(2px);
    border-color: var(--primary);
}

.step-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.step-index {
    background: var(--primary);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.8rem;
    font-weight: bold;
    flex-shrink: 0;
}

.control-btn-group {
    display: flex;
    gap: 5px;
}

/* Dropdown Container for Approvers */
.approver-dropdown-container {
    animation: fadeIn 0.2s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =========================================
   11. RESPONSIVE DESIGN
========================================= */

/* -------------------------
   TABLET (641px - 1024px)
------------------------- */

 .console-panel {
         padding: 10px;

    }

@media screen and (max-width: 1024px) {
    .app-header {
        padding: 0 15px;
    }

    .brand {
        font-size: 1rem;
    }

    #main-nav button {
        padding: 8px 10px;
        font-size: 0.85rem;
    }

    .incident-console-grid, .service-request-console-grid {
        grid-template-columns: 2fr 1fr;
        gap: 15px;
    }

    .list-sidebar {
        width: 250px;
        min-width: 200px;
    }

    .cmdb-sidebar {
        width: 250px;
    }

    .floating-details {
        width: 280px;
    }

    #view-incident-console, #view-service-request-console {
        padding: 15px;
    }

    .grid-stack-item-content {
        padding: 15px;
    }

    .stat-card-widget h3 {
        font-size: 0.9rem;
    }

    .chart-bar-group {
        width: 45px;
        flex: 0 0 45px;
    }
}

/* -------------------------
   MOBILE (≤640px)
------------------------- */
@media screen and (max-width: 640px) {

    #view-dashboard {
        padding: 10px;
        overflow-y: auto;
        display: block;
    }

    .grid-stack {
        display: flex !important;
        flex-direction: column !important;
        gap: 15px !important;
        height: auto !important;
    }

    .grid-stack-item {
        position: static !important;
        width: 100% !important;
        height: auto !important;
        min-height: auto !important;
        margin-bottom: 0 !important;
        transform: none !important;
    }

    .grid-stack-item-content {
        position: static !important;
        width: 100% !important;
        height: auto !important;
        min-height: 180px !important;
        padding: 15px !important;
        margin: 0 !important;
        transform: none !important;
    }

    /* Remove gridstack positioning */
    .grid-stack>.grid-stack-item {
        left: auto !important;
        top: auto !important;
    }

    /* Ensure charts are visible */
    .chart-widget {
        min-height: 200px;
    }

    .chart-container-horizontal {
        max-height: 300px;
    }

    /* Fix queue widget */
    .queue-widget-list {
        max-height: 300px;
        overflow-y: auto;
    }

    /* --- HEADER --- */
    .app-header {
        flex: 0 0 auto;
        min-height: 60px;
        height: auto;
        padding: 10px;
        flex-wrap: wrap;
        gap: 10px;
    }

    .brand {
        font-size: 0.95rem;
    }

    #main-nav {
        order: 3;
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 5px;
        justify-content: center;
        padding-top: 10px;
        border-top: 1px solid rgba(255, 255, 255, 0.2);
    }

    #main-nav button {
        padding: 6px 10px;
        font-size: 0.75rem;
        background: rgba(255, 255, 255, 0.1);
        border-radius: 4px;
    }

    .user-profile {
        font-size: 0.8rem;
        display: flex;
        align-items: center;
        gap: 5px;
    }

    .logout-btn {
        padding: 4px 8px;
        font-size: 0.75rem;
        margin-left: 5px;
    }

    /* --- MAIN CONTENT --- */
    #main-content {
        overflow-y: auto;
    }

    .view-section {
        overflow-y: auto;
    }

    /* --- DASHBOARD --- */
    #view-dashboard {
        padding: 10px;
    }

    .grid-stack {
        display: flex !important;
        flex-direction: column !important;
        gap: 15px !important;
    }

    .grid-stack-item {
        position: static !important;
        width: 100% !important;
        height: auto !important;
        min-height: 200px !important;
        margin-bottom: 0 !important;
    }

    .grid-stack-item-content {
        padding: 15px !important;
        position: static !important;
        left: auto !important;
        right: auto !important;
        width: 100% !important;
        height: auto !important;
        min-height: 180px !important;
    }

    .stat-card-widget {
        min-height: 120px;
        padding: 15px;
    }

    .stat-card-widget h3 {
        font-size: 0.85rem;
        margin-bottom: 8px;
    }

    .stat-card-widget .stat-number {
        font-size: 2rem;
    }

    .queue-widget-list {
        max-height: none;
        min-height: 150px;
    }

    .queue-widget-list .dash-item {
        padding: 12px 5px;
        font-size: 0.85rem;
    }

    .queue-header {
        margin-bottom: 10px;
        font-size: 0.9rem;
    }

    .chart-widget {
        min-height: 250px;
    }

    .chart-container {
        padding: 15px 5px 5px 5px;
        gap: 8px;
    }

    .chart-container-horizontal {
        padding: 15px 10px;
    }

    /* --- INCIDENT LIST --- */
    #view-incident-list {
        padding: 10px;
    }

    #view-incident-list>div:first-child {
        flex-direction: column;
        gap: 10px;
        align-items: stretch !important;
    }

    #view-incident-list h2 {
        font-size: 1.2rem;
        margin: 0 0 10px 0;
    }

    #incident-search-input {
        width: 100% !important;
    }

    #incident-table-container {
        overflow-x: auto;
    }

    /* #incident-table-container .simple-table th:nth-child(5),
    #incident-table-container .simple-table td:nth-child(5) {
        display: none;
    } */

    /* --- CONSOLE GRIDS --- */
    .incident-console-grid, .service-request-console-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    #view-incident-console, #view-service-request-console {
        padding: 10px;
    }

    .console-header {
        padding: 10px;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .console-header>div {
        /* width: 100%; */
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    #inc-title {
        width: 100% !important;
        font-size: 1.1rem !important;
    }

    .console-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .tab-btn {
        padding: 10px 12px;
        font-size: 0.8rem;
        min-width: 90px;
        /* flex-shrink: 0; */
        /* flex: 0 0 auto; */
        /* height: 500px */
    }

    .console-panel {
        padding: 10px;
          min-height:35vh;
    max-height:60vh;
        overflow-y: auto;
    }

    .console-main {
        order: 2;
    }

    .console-sidebar {
        order: 1;
        margin-bottom: 15px;
    }

    /* --- SPLIT LAYOUTS --- */
    .split-layout {
        flex-direction: column;
    }

    .list-sidebar {
        width: 100%;
        min-width: 100%;
        max-height: 200px;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .detail-content {
        padding: 10px;
    }

    /* --- CMDB --- */
    .cmdb-container {
        flex-direction: column;
    }

    .cmdb-sidebar {
        width: 100%;
        max-height: 150px;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    #cmdb-resizer {
        display: none;
    }

    .floating-details {
        width: calc(100% - 20px);
        left: 10px;
        right: 10px;
        top: 10px;
        max-height: 80vh;
    }

    /* --- TABLES --- */
    .simple-table {
        /* display: block; */
        overflow-x: auto;
    }

    .simple-table thead {
        display: table-header-group;
    }

    .simple-table th,
    .simple-table td {
        padding: 8px 6px;
        font-size: 0.75rem;
        white-space: nowrap;
    }

    /* --- FORMS --- */
    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .form-group label {
        font-size: 0.8rem;
    }

    select,
    input,
    textarea {
        font-size: 0.85rem;
        padding: 4px;
    }

    /* --- WORKFLOW --- */
    .workflow-container {
        margin-bottom: 10px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    #workflow-chevron {
        min-width: max-content;
    }

    .chevron {
        font-size: 0.65rem;
        padding: 6px 8px 6px 12px;
        min-width: 70px;
        flex-shrink: 0;
    }

    #change-workflow-steps .chevron {
        font-size: 0.6rem;
        padding: 5px 8px;
        min-width: 65px;
    }

    /* --- SIDEBAR WIDGETS --- */
    .sidebar-widget {
        padding: 10px;
        margin-bottom: 10px;
    }

    .sidebar-widget h4 {
        font-size: 0.9rem;
    }

    /* --- BUTTONS --- */
    button.primary,
    button.secondary {
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    button.small-btn {
        padding: 4px 8px;
        font-size: 0.75rem;
    }

    /* --- MODALS --- */
    .modal {
        width: calc(100% - 20px);
        max-width: 400px;
        padding: 15px;
    }

    /* --- CHARTS --- */
    .chart-bar-group {
        width: 40px;
        flex: 0 0 40px;
    }

    .chart-value {
        font-size: 0.7rem;
    }

    .chart-label {
        font-size: 0.65rem;
        height: 40px;
    }

    .chart-row-label {
        width: 80px;
        font-size: 0.7rem;
    }

    .chart-row-value {
        width: 25px;
        font-size: 0.7rem;
    }

    /* --- GRIDS --- */
    .sla-detail-grid,
    .service-detail-grid {
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 10px;
        font-size: 0.85rem;
    }

    /* --- CARDS --- */
    .card {
        padding: 10px;
        margin-bottom: 10px;
    }

    /* --- ACTIVITY STREAM --- */
    .activity-stream-box {
        height: 200px;
        padding: 10px;
    }

    #inc-note-input {
        height: 60px !important;
        font-size: 0.85rem;
    }

    #inc-file-upload {
        font-size: 0.75rem;
    }

    /* --- BADGES --- */
    .badge {
        font-size: 0.7rem;
        padding: 2px 6px;
    }

    /* --- CONTRACT LIST --- */
    .contract-list-item {
        flex-wrap: wrap;
        padding: 10px;
    }

    .doc-icon {
        font-size: 1.2rem;
        margin-right: 10px;
    }

    /* --- TREE VIEW --- */
    .tree-node-parent,
    .tree-item {
        padding: 8px;
        font-size: 0.85rem;
    }

    /* --- ACCORDION --- */
    .accordion-header {
        padding: 10px;
        font-size: 0.9rem;
    }

    .accordion-content {
        padding: 10px;
    }

    /* --- LIST EDITOR --- */
    .list-editor-item {
        flex-direction: column;
        align-items: stretch;
    }

    .list-editor-item .actions {
        justify-content: flex-end;
    }

    /* --- STEP CARDS --- */
    .step-card {
        padding: 10px;
    }

    .step-header {
        flex-wrap: wrap;
    }

    .control-btn-group {
        width: 100%;
        justify-content: flex-end;
    }


    #incident-table-container {
        overflow-x: auto;
        /* width: 100%; */
    }

    #incident-table-container .simple-table {
        min-width: 100%;
    }

}

/* -------------------------
   SMALL MOBILE (≤480px)
------------------------- */
@media screen and (max-width: 480px) {

    .chart-container {
        flex-wrap: wrap;
        justify-content: flex-start;
    }

    .chart-bar-group {
        width: 35px;
        flex: 0 0 35px;
    }

    .chart-row-label {
        width: 80px;
        font-size: 0.65rem;
    }

    .console-header {
        padding: 8px;
    }

    .console-panel {
         padding: 10px;
          min-height:35vh;
    max-height:60vh;
        overflow-y: auto;
    }

    .activity-stream-box {
        height: 180px;
        padding: 8px;
    }

    .form-group {
        margin-bottom: 12px;
    }

    .sidebar-widget {
        padding: 10px;
        margin-bottom: 12px;
    }

    #inc-title {
        font-size: 1.05rem !important;
        padding: 6px 10px;
    }

    .tab-btn {
        padding: 9px 10px;
        font-size: 0.75rem;
        min-width: 85px;
    }

     #incident-table-container {
        overflow-x: auto;
        /* width: 100%; */
    }

    #incident-table-container .simple-table {
         width:max-content;
    min-width:100%;
    }

}

/* -------------------------
   EXTRA SMALL MOBILE (≤375px)
------------------------- */
@media screen and (max-width: 375px) {
    .app-header {
        padding: 8px;
    }

    .brand {
        font-size: 0.85rem;
    }

    #main-nav button {
        padding: 5px 8px;
        font-size: 0.7rem;
    }

    .console-header {
        padding: 8px;
    }

    #inc-title {
        font-size: 1rem !important;
    }

    .tab-btn {
        padding: 8px 6px;
        font-size: 0.7rem;
        min-width: 70px;
    }

    .console-panel {
        padding: 10px;
          min-height:50vh;
    max-height:100vh;
        overflow-y: auto;
    }

    button.primary,
    button.secondary {
        padding: 2px 2px;
        font-size: 0.744rem;    
    }

    .chevron {
        font-size: 0.6rem;
        padding: 4px 6px 4px 10px;
        min-width: 65px;
    }

    .chart-bar-group {
        width: 35px;
        flex: 0 0 35px;
    }

    .chart-value {
        font-size: 0.65rem;
    }

    .chart-label {
        font-size: 0.6rem;
        height: 35px;
    }

    .queue-widget-list .dash-item {
        padding: 10px 5px;
        font-size: 0.8rem;
    }

    .sidebar-widget {
        padding: 8px;
    }

    .grid-stack-item-content {
        padding: 12px !important;
        min-height: 160px !important;
    }
}

/* -------------------------
   LANDSCAPE MOBILE
------------------------- */
@media screen and (max-width: 900px) and (orientation: landscape) {

    .grid-stack-item-content {
        min-height: 150px;
    }

    .chart-widget {
        min-height: 150px;
    }

    .app-header {
        padding: 8px 15px;
    }

    #main-nav button {
        padding: 6px 10px;
        font-size: 0.75rem;
    }

    .incident-console-grid, .service-request-console-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .console-header {
        padding: 10px;
    }

    .console-panel {
        padding: 12px;
        min-height: 40vh;
    max-height: 70vh;
    overflow-y: auto;
    }

    .sidebar-widget {
        padding: 10px;
        margin-bottom: 12px;
    }

    #view-incident-console, #view-service-request-console {
        padding: 10px;
    }
}

/* -------------------------
   UTILITY CLASSES
------------------------- */
.full-width {
    width: 100% !important;
}

@media screen and (max-width: 640px) {
    .hide-mobile {
        display: none !important;
    }

    .show-mobile-only {
        display: block !important;
    }

    #incident-table-container {
        overflow-x: auto;
    }

    #incident-table-container .simple-table {
        min-width: max-content;
    }

    .incident-console-grid, .service-request-console-grid{
    display:flex;
    flex-direction:column;
}

.console-sidebar{
    order:1;
}

.console-main{
    order:2;
    /* height:9000px */
}

}

@media screen and (min-width: 641px) {
    .show-mobile-only {
        display: none !important;
    }
}

/* ========================================
   INCIDENT CONSOLE MOBILE FIX
======================================== */

@media screen and (max-width:768px){

/* convert grid to vertical layout */
.incident-console-grid, .service-request-console-grid{
    display:flex;
    flex-direction:column;
}

/* main console first */
.console-main{
    order:1;
}

/* sidebar second */
.console-sidebar{
    order:2;
}

/* better spacing */
.sidebar-widget{
    margin-bottom:12px;
}

/* tabs scroll horizontally */
.console-tabs{
    overflow-x:auto;
}

.tab-btn{
    flex:0 0 auto;
}

/* title responsive */
#inc-title{
    width:100% !important;
}

/* header stack */
.console-header{
    flex-direction:column;
    align-items:flex-start;
    gap:10px;
}


.sidebar-widget{
    padding:12px;
}

.sidebar-widget h4{
    font-size:0.9rem;
}

.form-group label{
    font-size:0.75rem;
}

select,
input{
    font-size:0.85rem;
}

}
