/* ==============================================================================
   REPLAY — Professional Dark Admin Interface
   Mobile-First Responsive System (320px - 1440px+)
   Main Background: #0B1020 | Sidebar: #10192B | Card: #111A2E | Surface: #202C43
   Primary Accent: #24B8F0 | Secondary Accent: #A78BFA | Text: #F3F6FC
   ============================================================================== */

:root {
    --bg-main: #0B1020;
    --bg-sidebar: #10192B;
    --bg-card: #111A2E;
    --bg-surface: #202C43;
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-active: rgba(36, 184, 240, 0.4);
    --accent-primary: #24B8F0;
    --accent-secondary: #A78BFA;
    --text-primary: #F3F6FC;
    --text-muted: #94A3B8;
    --color-success: #22C55E;
    --color-warning: #F59E0B;
    --color-danger: #EF4444;
    --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --header-height: 64px;
    --sidebar-width: 270px;
}

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

html,
body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

img,
svg,
canvas {
    max-width: 100%;
    height: auto;
    vertical-align: middle;
}

/* ==============================================================================
   Layout Architecture
   ============================================================================== */
.app-container {
    display: flex;
    min-height: 100vh;
    width: 100%;
    position: relative;
    max-width: 100%;
    overflow-x: hidden;
}

/* Sidebar (Desktop fixed, Mobile overlay drawer) */
.app-sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.sidebar-header {
    height: var(--header-height);
    padding: 0 20px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand-title {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.brand-icon-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: rgba(36, 184, 240, 0.12);
    border: 1px solid rgba(36, 184, 240, 0.35);
    border-radius: 8px;
    color: var(--accent-primary);
    box-shadow: 0 0 12px rgba(36, 184, 240, 0.25);
}

.brand-icon-wrap svg,
.brand-icon-wrap i {
    width: 18px;
    height: 18px;
}

.brand-text-wrap {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.brand-name {
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.02em;
    color: #FFFFFF;
}

.brand-tag {
    font-size: 8.5px;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--accent-primary);
}

/* Quick Status Pill in Sidebar */
.sidebar-quick-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 12px 12px 4px;
    padding: 7px 10px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
}

.quick-status-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.quick-status-time {
    font-family: var(--font-mono);
    color: var(--accent-primary);
    font-size: 11px;
    font-weight: 600;
}

.sidebar-nav {
    padding: 10px 10px 24px;
    flex: 1;
}

/* Distinct Section Groups */
.nav-section-group {
    margin-bottom: 8px;
    padding-top: 10px;
}

.nav-section-group:not(:first-child) {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    margin-top: 10px;
}

.nav-group-header {
    padding: 4px 6px 6px;
}

.nav-group-badge {
    display: inline-block;
    font-size: 9.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #718096;
    padding: 2px 7px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.nav-group-links {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border-radius: 6px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.16s ease;
    white-space: nowrap;
    position: relative;
}

.nav-icon-box {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: #94A3B8;
    transition: color 0.16s ease, transform 0.16s ease;
}

.nav-icon-box svg,
.nav-icon-box i {
    width: 15px;
    height: 15px;
    stroke-width: 2;
}

.nav-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-link:hover {
    color: #FFFFFF;
    background-color: rgba(255, 255, 255, 0.05);
}

.nav-link:hover .nav-icon-box {
    color: var(--accent-primary);
    transform: translateX(1px);
}

.nav-link.active {
    color: #FFFFFF;
    background-color: rgba(36, 184, 240, 0.12);
    border-left: 3px solid var(--accent-primary);
    font-weight: 600;
}

.nav-link.active .nav-icon-box {
    color: var(--accent-primary);
}

.nav-active-indicator {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background-color: var(--accent-primary);
    box-shadow: 0 0 6px var(--accent-primary);
    margin-left: auto;
}

/* Sidebar Footer Telemetry Widget */
.sidebar-footer-widget {
    margin: 10px 10px 14px;
    padding: 10px 12px;
    background: rgba(17, 26, 46, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.subsystem-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
}

.subsystem-info {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 11px;
}

.subsystem-name {
    font-weight: 500;
}

.subsystem-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.subsystem-badge.success {
    background: rgba(34, 197, 94, 0.15);
    color: #22C55E;
    border: 1px solid rgba(34, 197, 94, 0.35);
}

.subsystem-badge.ai {
    background: rgba(36, 184, 240, 0.15);
    color: #24B8F0;
    border: 1px solid rgba(36, 184, 240, 0.35);
}

/* Mobile Sidebar Drawer Backdrop */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    z-index: 95;
    transition: opacity 0.25s ease;
}

/* Main Content Area */
.app-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
    width: calc(100% - var(--sidebar-width));
    max-width: 100%;
}

/* Top Navigation Bar */
.app-header {
    height: var(--header-height);
    background-color: var(--bg-main);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
    width: 100%;
    min-width: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.breadcrumbs {
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.breadcrumbs span.current {
    color: var(--text-primary);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-sidebar-toggle {
    display: none;
    background: transparent;
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    color: var(--text-primary);
    cursor: pointer;
    padding: 7px;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 36px;
    touch-action: manipulation;
}

.btn-sidebar-toggle:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

/* Content Body */
.app-content {
    padding: 24px;
    flex: 1;
    width: 100%;
    min-width: 0;
    max-width: 100%;
}

/* Page Header */
.page-header {
    margin-bottom: 24px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.01em;
}

.page-subtitle {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 2px;
}

/* ==============================================================================
   Responsive Grid System (Mobile-First)
   ============================================================================== */
.grid {
    display: grid;
    gap: 20px;
    width: 100%;
    min-width: 0;
}

.grid-1 {
    grid-template-columns: minmax(0, 1fr);
}

.grid-2 {
    grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 768px) {
    .grid-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.grid-3 {
    grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 640px) {
    .grid-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1024px) {
    .grid-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.grid-4 {
    grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 480px) {
    .grid-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1024px) {
    .grid-4 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* Split Sidebar / Master-Detail layout for Docs and Conversations */
.grid-sidebar {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
    width: 100%;
    min-width: 0;
}

@media (min-width: 900px) {
    .grid-sidebar {
        grid-template-columns: 280px minmax(0, 1fr);
    }
}

.grid-sidebar-wide {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
    width: 100%;
    min-width: 0;
}

@media (min-width: 960px) {
    .grid-sidebar-wide {
        grid-template-columns: 320px minmax(0, 1fr);
    }
}

/* Flexible Cards Grid that adapts automatically without overflowing */
.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
    gap: 20px;
    width: 100%;
    min-width: 0;
}

/* ==============================================================================
   Cards & Surfaces
   ============================================================================== */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    width: 100%;
    min-width: 0;
}

.card-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding-bottom: 14px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--border-subtle);
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    letter-spacing: -0.01em;
}

/* Metric / Stat Cards */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
    gap: 16px;
    margin-bottom: 24px;
    width: 100%;
    min-width: 0;
}

.metric-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-width: 0;
}

.metric-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.metric-value {
    font-size: 22px;
    font-weight: 700;
    color: #fff;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    word-break: break-all;
}

.metric-subtext {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
}

/* ==============================================================================
   Form Controls & Stacked Inputs
   ============================================================================== */
.form-group {
    margin-bottom: 18px;
    width: 100%;
    min-width: 0;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
    line-height: 1.4;
}

.form-control {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 10px 12px;
    color: #fff;
    font-size: 13px;
    font-family: inherit;
    transition: border-color 0.15s ease;
    box-sizing: border-box;
    min-height: 40px;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-primary);
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

select.form-control {
    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 24 24' fill='none' stroke='%2394A3B8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
    width: 100%;
}

.form-check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    margin-bottom: 14px;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-primary);
    cursor: pointer;
    flex-shrink: 0;
    margin-top: 1px;
}

.form-check label {
    font-size: 13px;
    cursor: pointer;
    color: var(--text-primary);
    line-height: 1.4;
}

/* ==============================================================================
   Buttons & Interactive Affordances
   ============================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    text-decoration: none;
    white-space: nowrap;
    min-height: 40px;
    touch-action: manipulation;
}

.btn-primary {
    background-color: var(--accent-primary);
    color: #0B1020;
    font-weight: 600;
}

.btn-primary:hover {
    background-color: #36c5fc;
}

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

.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

.btn-danger {
    background-color: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--color-danger);
}

.btn-danger:hover {
    background-color: rgba(239, 68, 68, 0.25);
}

.btn-sm {
    padding: 6px 10px;
    font-size: 12px;
    min-height: 34px;
}

.btn-icon {
    padding: 8px;
    min-width: 38px;
    min-height: 38px;
}

/* ==============================================================================
   Data Tables & Local Scrolling Containers
   ============================================================================== */
.table-responsive {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    margin-bottom: 20px;
    position: relative;
}

.data-table {
    width: 100%;
    min-width: 580px;
    border-collapse: collapse;
    font-size: 13px;
    text-align: left;
}

.data-table th {
    background-color: var(--bg-surface);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
}

.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
}

.data-table tr:hover td {
    background-color: rgba(255, 255, 255, 0.02);
}

.data-table .font-mono {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

/* Mobile-Friendly Data Cards (When tabular row transformation is desired) */
.data-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 14px;
    margin-bottom: 10px;
}

.data-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 13px;
}

.data-card-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    padding: 4px 0;
    color: var(--text-muted);
}

.data-card-row span:last-child {
    color: var(--text-primary);
    text-align: right;
}

/* ==============================================================================
   Status Badges & Chips
   ============================================================================== */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    padding: 3px 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.04);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.active { background-color: var(--color-success); }
.status-dot.inactive { background-color: var(--text-muted); }
.status-dot.warning { background-color: var(--color-warning); }
.status-dot.danger { background-color: var(--color-danger); }

/* Animated Real-Time Pulse Bulbs */
.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    position: relative;
    flex-shrink: 0;
}

.pulse-dot.active {
    background-color: #22C55E;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.7);
}

.pulse-dot.active::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    border: 1.5px solid #22C55E;
    animation: pulse-ring 2.2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}

.pulse-dot.inactive {
    background-color: #64748B;
}

.pulse-dot.warning {
    background-color: #F59E0B;
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.7);
}

.pulse-dot.danger {
    background-color: #EF4444;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.7);
}

@keyframes pulse-ring {
    0% { transform: scale(0.6); opacity: 1; }
    100% { transform: scale(2.4); opacity: 0; }
}

/* 1-Click Eye Toggle for Password & API Key Inputs */
.password-toggle-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.password-toggle-wrapper input {
    width: 100%;
    padding-right: 42px !important;
}

.password-toggle-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: #94A3B8;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    border-radius: 4px;
    transition: color 0.15s ease, background 0.15s ease;
    z-index: 2;
}

.password-toggle-btn:hover {
    color: #FFFFFF;
    background: rgba(255, 255, 255, 0.08);
}

.password-toggle-btn svg,
.password-toggle-btn i {
    width: 16px;
    height: 16px;
}

/* Modern Messenger Chat Thread */
.chat-thread-box {
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow-y: auto;
    padding: 16px;
    background: #080D1A;
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    flex: 1;
    min-height: 380px;
}

.chat-bubble-row {
    display: flex;
    flex-direction: column;
    max-width: 78%;
}

.chat-bubble-row.incoming {
    align-self: flex-start;
}

.chat-bubble-row.outgoing {
    align-self: flex-end;
}

.chat-bubble-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 4px;
    padding: 0 4px;
}

.chat-bubble-body {
    border-radius: 10px;
    padding: 12px 16px;
    color: #FFFFFF;
    font-size: 13.5px;
    line-height: 1.55;
    word-break: break-word;
    white-space: pre-wrap;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.chat-bubble-row.incoming .chat-bubble-body {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-bottom-left-radius: 2px;
}

.chat-bubble-row.outgoing.is-ai .chat-bubble-body {
    background-color: #0F2744;
    border: 1px solid rgba(36, 184, 240, 0.4);
    border-bottom-right-radius: 2px;
}

.chat-bubble-row.outgoing.is-owner .chat-bubble-body {
    background-color: #271C44;
    border: 1px solid rgba(167, 139, 250, 0.4);
    border-bottom-right-radius: 2px;
}

.chat-bubble-footer {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    padding: 0 4px;
}


/* ==============================================================================
   Command Box & Code Snippets
   ============================================================================== */
.command-box {
    background-color: #070B16;
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 12px 14px;
    font-family: var(--font-mono);
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 10px 0;
    word-break: break-all;
    width: 100%;
    min-width: 0;
}

/* ==============================================================================
   Alert Banners
   ============================================================================== */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 20px;
    line-height: 1.4;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.alert-success {
    background-color: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: #22C55E;
}

.alert-danger {
    background-color: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #EF4444;
}

.alert-warning {
    background-color: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: #F59E0B;
}

/* ==============================================================================
   Toast Notifications
   ============================================================================== */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 9999;
    pointer-events: none;
}

@media (min-width: 640px) {
    .toast-container {
        left: auto;
        max-width: 380px;
    }
}

.toast {
    background-color: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 12px 16px;
    font-size: 13px;
    color: #fff;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    gap: 10px;
    pointer-events: auto;
}

/* ==============================================================================
   Mobile & Responsive Breakpoints
   ============================================================================== */

/* Tablet & Smaller (<= 1024px) */
@media (max-width: 1024px) {
    .app-sidebar {
        transform: translateX(-100%);
    }

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

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

    .app-main {
        margin-left: 0;
        width: 100%;
    }

    .btn-sidebar-toggle {
        display: inline-flex;
    }
}

/* Standard Mobile & Phablet (<= 768px) */
@media (max-width: 768px) {
    :root {
        --header-height: 56px;
    }

    .app-header {
        padding: 0 16px;
    }

    .app-content {
        padding: 16px;
    }

    .page-header {
        margin-bottom: 18px;
    }

    .page-title {
        font-size: 18px;
    }

    .card {
        padding: 16px;
        margin-bottom: 16px;
    }

    .metrics-grid {
        gap: 12px;
        margin-bottom: 18px;
    }

    .metric-card {
        padding: 14px;
    }

    .metric-value {
        font-size: 20px;
    }

    /* Filters bar stack */
    .filter-bar {
        flex-direction: column;
        align-items: stretch !important;
    }

    .filter-bar > * {
        width: 100% !important;
        min-width: 0 !important;
    }

    .command-box {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .command-box .btn {
        width: 100%;
    }
}

/* Small Mobile (320px - 480px) */
@media (max-width: 480px) {
    .app-header {
        padding: 0 12px;
    }

    .app-content {
        padding: 12px;
    }

    .card {
        padding: 14px 12px;
        margin-bottom: 14px;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .breadcrumbs {
        font-size: 12px;
    }

    /* Hide long status text in header on narrow mobile to prevent overlap */
    .header-right .status-pill span:not(.status-dot) {
        display: none;
    }

    .header-right span[style*="text-muted"] {
        display: none;
    }

    /* Full-width primary action buttons */
    .form-actions {
        flex-direction: column;
        width: 100%;
    }

    .form-actions .btn {
        width: 100%;
        min-height: 44px;
    }

    /* Native touch-friendly controls */
    .btn {
        min-height: 44px;
        padding: 10px 14px;
    }

    .btn-sm {
        min-height: 38px;
    }

    .form-control {
        min-height: 44px;
        font-size: 14px; /* Prevents auto-zoom on iOS Safari */
    }

    /* Subtle full-bleed touch tables on small mobile */
    .table-responsive {
        margin-left: -12px;
        margin-right: -12px;
        width: calc(100% + 24px);
        max-width: calc(100% + 24px);
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .data-table th,
    .data-table td {
        padding: 10px 10px;
        font-size: 12px;
    }
}
