@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap');

:root {
    /* DHL Brand */
    --dhl-red: #d40511;
    --dhl-yellow: #ffcc00;
    --dhl-dark: #1a1a1a;

    --primary: var(--dhl-red);
    --primary-light: #ff1a2e;
    --primary-bg: #fef2f2;
    --accent: var(--dhl-yellow);
    --accent-bg: #fff9e0;
    --bg: #f7f7f5;
    --sidebar-bg: #2b2b2b;
    --sidebar-text: #b0b0b0;
    --sidebar-hover: #3a3a3a;
    --sidebar-active: rgba(255, 204, 0, 0.15);
    --card: #ffffff;
    --text: #1a1a1a;
    --text-secondary: #555555;
    --text-muted: #999999;
    --border: #e5e5e0;
    --border-light: #f2f2ef;
    --success: #10b981;
    --success-bg: #ecfdf5;
    --warning: #e6a800;
    --warning-bg: #fff9e0;
    --danger: #d40511;
    --danger-bg: #fef2f2;
    --info: #3b82f6;
    --info-bg: #eff6ff;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.05);
    --radius: 8px;
    --radius-lg: 12px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Roboto', 'Helvetica Neue', Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

/* ─── Layout ─── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ─── Sidebar ─── */
.sidebar {
    width: 240px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    height: 100dvh;
    z-index: 100;
    transition: transform var(--transition);
}

.sidebar-brand {
    padding: 16px 16px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand .logo-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}
.sidebar-brand .logo {
    background: var(--dhl-yellow);
    border-radius: 4px;
    padding: 4px 8px;
    font-weight: 900;
    font-size: 14px;
    color: var(--dhl-red);
    letter-spacing: -0.5px;
    font-family: 'Arial Black', Arial, sans-serif;
    line-height: 1;
}
.sidebar-brand .brand-text {
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.3px;
}
.sidebar-brand .brand-sub {
    font-size: 10px;
    color: var(--sidebar-text);
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding-left: 2px;
}

.sidebar-nav {
    flex: 1;
    padding: 8px 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
}
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    margin: 2px 8px;
    border-radius: 8px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s ease;
    border-left: 3px solid transparent;
}
.sidebar-nav a:hover {
    background: var(--sidebar-hover);
    color: #e0e0e0;
    transform: translateX(2px);
}
.sidebar-nav a.active {
    background: var(--sidebar-active);
    color: var(--dhl-yellow);
    border-left-color: var(--dhl-yellow);
    font-weight: 600;
}
.sidebar-nav .nav-icon {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    opacity: 0.7;
}
.sidebar-nav .nav-icon svg {
    width: 18px;
    height: 18px;
}
.sidebar-nav a:hover .nav-icon,
.sidebar-nav a.active .nav-icon { opacity: 1; }

.sidebar-section {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--sidebar-text);
    opacity: 0.5;
    padding: 16px 16px 4px;
    margin-top: 8px;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.06);
}
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 8px;
    transition: background var(--transition);
}
.sidebar-user:hover { background: var(--sidebar-hover); }
.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--dhl-yellow);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--dhl-dark);
    font-weight: 700;
    font-size: 13px;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; color: #e2e8f0; }
.user-role { font-size: 11px; color: var(--sidebar-text); }
.sidebar-logout {
    display: block;
    text-align: center;
    margin-top: 8px;
    padding: 6px;
    border-radius: 6px;
    font-size: 12px;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all var(--transition);
}
.sidebar-logout:hover { background: var(--sidebar-hover); color: #e2e8f0; }

/* ─── Main Content ─── */
.main-content {
    flex: 1;
    margin-left: 240px;
    min-height: 100vh;
}

.topbar {
    height: 60px;
    display: flex;
    align-items: center;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(8px);
    background: rgba(255,255,255,0.9);
    border-bottom: 3px solid var(--dhl-yellow);
}
.topbar h1 {
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.3px;
}
.topbar-actions {
    margin-left: auto;
    display: flex;
    gap: 8px;
    align-items: center;
}

.content-area {
    padding: 24px 28px;
    max-width: 1400px;
}

/* ─── Topbar Search ─── */
.topbar-search {
    position: relative;
    display: flex;
    align-items: center;
}
.topbar-search input {
    width: 240px;
    padding: 7px 32px 7px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    color: var(--text);
    background: var(--bg);
    outline: none;
    transition: all var(--transition);
}
.topbar-search input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(212, 5, 17, 0.1);
    background: #fff;
    width: 320px;
}
.topbar-search input::placeholder { color: var(--text-muted); }
.search-hint {
    position: absolute;
    right: 8px;
    font-size: 11px;
    font-family: inherit;
    color: var(--text-muted);
    background: var(--border-light);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 5px;
    pointer-events: none;
}
.topbar-search input:focus + .search-hint { display: none; }

/* ─── Cards ─── */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.06);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
    transform: translateY(-1px);
}
.card-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-header h2 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}
.card-body { padding: 16px; }

/* ─── Buttons ─── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card);
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s ease;
    white-space: nowrap;
}
.btn:hover {
    background: var(--bg);
    border-color: #cbd5e1;
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}
.btn:active {
    transform: translateY(0px);
}
.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 2px 4px rgba(212,5,17,0.2);
}
.btn-primary:hover {
    background: var(--primary-light);
    border-color: var(--primary-light);
    box-shadow: 0 4px 8px rgba(212,5,17,0.3);
}
.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: 6px; }
.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--bg); color: var(--text); border-color: transparent; }

/* ─── Login ─── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--dhl-dark) 0%, #2d2d2d 50%, var(--dhl-red) 100%);
    padding: 20px;
}
.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--card);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    padding: 40px 36px;
    animation: slideUp 0.3s ease-out;
}
.login-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 8px;
}
.login-logo .logo {
    width: 40px;
    height: 40px;
    background: var(--dhl-yellow);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    color: var(--dhl-red);
}
.login-logo .brand-text {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.5px;
}
.login-subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 32px;
}
.form-group {
    margin-bottom: 18px;
}
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 6px;
}
.form-group input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: var(--bg);
    transition: all var(--transition);
    outline: none;
}
.form-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(212, 5, 17, 0.1);
    background: #fff;
}
.login-card .btn-primary {
    width: 100%;
    padding: 11px;
    font-size: 14px;
    border-radius: 8px;
    margin-top: 6px;
}

/* ─── Alerts ─── */
.alert {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.alert-error {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid #fecaca;
}

/* ─── Badges ─── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
}
.badge-ok { background: var(--success-bg); color: #065f46; }
.badge-warn { background: var(--warning-bg); color: #92400e; }
.badge-danger { background: var(--danger-bg); color: #991b1b; }
.badge-info { background: var(--info-bg); color: #1e40af; }
.badge-neutral { background: var(--border-light); color: var(--text-secondary); }

/* ─── Stats Grid ─── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.stat-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}
.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.1;
    letter-spacing: -0.5px;
    transition: color 0.3s ease;
}
.stat-pct {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}
.stat-card.primary .stat-value { color: var(--primary); }
.stat-card.success .stat-value { color: var(--success); }
.stat-card.info .stat-value { color: var(--info); }
.stat-card.warning .stat-value { color: var(--warning); }

/* ─── Detail Grid ─── */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 16px;
}
.detail-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.detail-card h2 {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    padding: 12px 16px;
    background: var(--border-light);
    border-bottom: 1px solid var(--border);
}
.detail-card dl {
    display: grid;
    grid-template-columns: 150px 1fr;
    padding: 4px 16px;
    font-size: 13px;
}
.detail-card dt {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 13px;
    padding: 7px 0;
    border-bottom: 1px solid var(--border-light);
}
.detail-card dd {
    padding: 7px 0;
    border-bottom: 1px solid var(--border-light);
    word-break: break-all;
    color: var(--text);
    font-size: 13px;
}
.detail-card dd code {
    font-size: 12.5px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    color: var(--text-secondary);
}

/* ─── Query List ─── */
.query-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.query-item {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: all var(--transition);
}
.query-item:hover {
    border-color: #cbd5e1;
    box-shadow: var(--shadow);
}
.query-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    text-decoration: none;
    color: var(--text);
}
.query-link:hover { color: var(--primary); }
.query-link strong { font-size: 13.5px; font-weight: 600; }
.query-desc { color: var(--text-secondary); font-size: 13px; }

/* ─── Result count ─── */
.result-count {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 12px;
}

/* ─── Reports Table ─── */
.reports-table {
    width: 100%;
    border-collapse: collapse;
}
.reports-table thead th {
    text-align: left;
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 1;
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: 10px 12px;
}
.reports-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
}
.reports-table td {
    padding: 8px 12px;
    font-size: 13.5px;
    border-bottom: 1px solid var(--border-light);
}
.reports-table tbody tr {
    transition: background-color 0.15s ease;
}
.reports-table tbody tr:hover {
    background-color: var(--border-light);
}
.reports-table tbody tr:nth-child(even) {
    background-color: rgba(0,0,0,0.01);
}

/* ─── Back link ─── */
.back-link {
    text-decoration: none;
    color: var(--text-muted);
    margin-right: 8px;
    font-size: 18px;
    transition: color var(--transition);
}
.back-link:hover { color: var(--text); }

/* ─── Table wrapper ─── */
.table-wrapper { overflow-x: auto; }

/* ─── DataTables Overrides ─── */
table.dataTable {
    font-size: 13px;
    border-collapse: collapse !important;
}
table.dataTable thead th {
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-secondary);
    background: var(--border-light);
    border-bottom: 1px solid var(--border) !important;
    padding: 10px 14px !important;
}
table.dataTable tbody td {
    padding: 10px 14px !important;
    border-bottom: 1px solid var(--border-light) !important;
    color: var(--text);
}
table.dataTable tbody tr:hover td {
    background: #f8fafc !important;
}
table.dataTable a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}
table.dataTable a:hover { text-decoration: underline; }

/* DataTables wrapper elements */
.dt-container .dt-search input {
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: all var(--transition);
}
.dt-container .dt-search input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(212, 5, 17, 0.1);
}
.dt-container .dt-length select {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
}
.dt-container .dt-paging .dt-paging-button {
    border-radius: 6px !important;
    border: 1px solid var(--border) !important;
    font-size: 12px;
    padding: 4px 10px !important;
    margin: 0 2px;
}
.dt-container .dt-paging .dt-paging-button.current {
    background: var(--dhl-dark) !important;
    color: var(--dhl-yellow) !important;
    border-color: var(--dhl-dark) !important;
}
.dt-container .dt-info {
    font-size: 12px;
    color: var(--text-muted);
}

/* ─── Map ─── */
#map {
    border-radius: 8px;
    margin: 12px 20px 16px;
    border: 1px solid var(--border);
}

/* ─── Empty state ─── */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ─── Pipeline ─── */
.pipeline-layout { display: flex; gap: 16px; }
.pipeline-main { flex: 1; min-width: 0; }
.pipeline-sidebar { width: 280px; flex-shrink: 0; }

.section-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    margin: 24px 0 12px;
}

.ops-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
    margin-bottom: 8px;
}
.op-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: all var(--transition);
}
.op-card:hover { box-shadow: var(--shadow); }
.op-card-disabled { opacity: 0.5; pointer-events: none; }
.op-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.op-title { font-size: 13.5px; font-weight: 600; }
.op-meta { font-size: 11.5px; color: var(--text-muted); }
.op-run-btn { align-self: flex-start; margin-top: 4px; }

/* Running jobs */
.running-job {
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light);
}
.running-job:last-child { border-bottom: none; }
.running-job-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}
.running-job-log {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--border-light);
    padding: 6px 10px;
    border-radius: 6px;
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.empty-state-sm {
    text-align: center;
    padding: 16px;
    color: var(--text-muted);
    font-size: 13px;
}

/* Pulse animation for running badge */
.pulse { animation: pulse 2s infinite; }
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Settings */
.setting-group { margin-bottom: 14px; }
.setting-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.setting-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    background: var(--bg);
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.setting-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(212,5,17,0.1);
    outline: none;
}
.setting-help { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.setting-divider { height: 1px; background: var(--border); margin: 16px 0; }
.setting-toggle {
    display: flex !important;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px !important;
    color: var(--text) !important;
}
.setting-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}
.text-muted { color: var(--text-muted); font-size: 12px; }

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}
.modal-content {
    background: var(--card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 15px; font-weight: 600; }
.log-output {
    flex: 1;
    overflow: auto;
    padding: 16px 20px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text);
    background: #0f172a;
    color: #e2e8f0;
    margin: 0;
    min-height: 300px;
    white-space: pre-wrap;
    word-break: break-all;
}

/* ─── Dashboard ─── */
.dashboard-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}
.dashboard-card { overflow: hidden; }
.dashboard-card .card-body { padding: 16px; }
.dashboard-card canvas { max-height: 280px; }

/* ─── Mobile Menu Button ─── */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    padding: 4px 8px;
    margin-right: 8px;
    color: var(--text);
    border-radius: 6px;
}
.mobile-menu-btn:hover { background: var(--border-light); }

.mobile-logout-btn {
    display: none;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 18px;
    padding: 4px 8px;
    border-radius: 6px;
    margin-left: auto;
}
.mobile-logout-btn:hover { background: var(--border-light); color: var(--text); }

.mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 99;
    backdrop-filter: blur(2px);
}
.mobile-overlay.open { display: block; }

/* ─── City Dropdown ─── */
#city-dropdown div:hover { background: var(--border-light); }

/* ─── Two-Column Detail Layout ─── */
.detail-layout {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 16px;
    align-items: start;
}
@media (max-width: 1024px) {
    .detail-layout { grid-template-columns: 1fr; }
}

/* ─── Activity Timeline ─── */
.activity-entry {
    position: relative;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: background var(--transition);
}
.activity-entry:hover { background: var(--border-light); }
.activity-entry.expanded { background: var(--bg); cursor: default; }
.activity-entry .entry-header {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.activity-entry .entry-title {
    font-weight: 600;
    font-size: 13.5px;
    color: var(--text);
    flex: 1;
}
.activity-entry .entry-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}
.activity-entry .entry-body {
    display: none;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border-light);
}
.activity-entry.expanded .entry-body { display: block; }
.activity-entry .entry-body-text {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: pre-wrap;
    margin-bottom: 10px;
}
.activity-updates {
    padding-left: 14px;
    border-left: 2px solid var(--border);
    margin: 10px 0;
}
.activity-update {
    padding: 6px 0;
    font-size: 12px;
}
.activity-update-author {
    font-weight: 500;
    color: var(--text);
}
.activity-update-time {
    color: var(--text-muted);
    font-size: 11px;
}
.activity-update-text {
    color: var(--text-secondary);
    margin-top: 2px;
    white-space: pre-wrap;
}
.add-update-form {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}
.add-update-form input {
    flex: 1;
}
.entry-actions {
    display: flex;
    gap: 4px;
    margin-top: 8px;
    flex-wrap: wrap;
}
.time-ago {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ─── Compact Tabs (sidebar) ─── */
.tab-pills {
    display: flex;
    gap: 4px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.tab-pills a {
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 20px;
    background: var(--border-light);
    transition: all var(--transition);
}
.tab-pills a:hover { background: var(--border); color: var(--text); }
.tab-pills a.active { background: var(--dhl-dark); color: var(--dhl-yellow); }

/* ─── Tabs ─── */
.tab-nav {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 20px;
    overflow-x: auto;
}
.tab-nav a {
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    transition: all var(--transition);
}
.tab-nav a:hover { color: var(--text); }
.tab-nav a.active {
    color: var(--dhl-red);
    border-bottom-color: var(--dhl-yellow);
    font-weight: 600;
}
.tab-content { display: none; }
.tab-content.active {
    display: block;
    animation: fadeIn 0.15s ease-out;
}

/* Dynamic tab content fills remaining viewport */
.tab-content-dynamic {
    overflow-y: auto;
    overflow-x: hidden;
}
.tab-content-dynamic .hwapi-grid {
    display: grid;
    grid-template-columns: 220px 1fr;
}
.tab-content-dynamic .hwapi-schedule {
    border-right: 1px solid var(--border-light);
    overflow-y: auto;
}
.tab-content-dynamic .hwapi-events {
    overflow-y: auto;
}
@media (max-width: 768px) {
    .tab-content-dynamic .hwapi-grid {
        grid-template-columns: 1fr;
    }
    .tab-content-dynamic .hwapi-schedule {
        border-right: none;
        border-bottom: 1px solid var(--border-light);
        max-height: 200px;
    }
}

/* ─── System Tab ─── */
.system-stats-row {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 12px;
    flex-wrap: wrap;
}
.time-range-btn {
    padding: 3px 10px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--card);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}
.time-range-btn:hover {
    background: var(--border-light);
    border-color: #cbd5e1;
}
.time-range-btn.active {
    background: var(--dhl-dark);
    color: var(--dhl-yellow);
    border-color: var(--dhl-dark);
}
.event-group-header {
    border-left: 3px solid var(--dhl-yellow);
}
.event-group-hidden {
    display: none;
}
.trend-up { color: var(--danger); font-size: 10px; font-weight: 700; }
.trend-down { color: var(--success); font-size: 10px; font-weight: 700; }

/* ─── Status Banner ─── */
.status-banner {
    background: linear-gradient(135deg, var(--card) 0%, rgba(247,247,245,1) 100%);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}
.status-banner-top {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.status-banner-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.3px;
}
.status-banner-sub {
    font-size: 14px;
    color: var(--text-secondary);
}
.status-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-left: auto;
}
.status-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

/* ─── Maintenance Mode Banner ─── */
.maintenance-banner {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #ffcc00 0%, #f5b800 100%);
    border-radius: 14px;
    padding: 24px 28px;
    margin-bottom: 20px;
    box-shadow: 0 4px 20px rgba(212, 5, 17, 0.08), 0 2px 8px rgba(255, 204, 0, 0.25);
}
.maintenance-banner::before {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 220px; height: 220px;
    background: radial-gradient(circle, rgba(255,255,255,0.18) 0%, transparent 70%);
    transform: translate(60px, -60px);
    pointer-events: none;
}
.maintenance-banner-inner {
    position: relative;
    display: flex;
    align-items: center;
    gap: 20px;
}
.maintenance-banner-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: rgba(0,0,0,0.12);
    flex-shrink: 0;
}
.maintenance-banner-icon svg {
    color: #1a1a1a;
}
.maintenance-banner-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.maintenance-banner-header {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.maintenance-banner-title {
    font-size: 18px;
    font-weight: 800;
    color: #1a1a1a;
    letter-spacing: -0.3px;
}
.maintenance-banner-badge {
    display: inline-flex;
    align-items: center;
    background: #1a1a1a;
    color: #ffcc00;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 12px;
    border-radius: 20px;
    letter-spacing: 1px;
    text-transform: uppercase;
}
.maintenance-banner-meta {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    font-size: 13px;
    color: rgba(0,0,0,0.55);
}
.maintenance-banner-meta strong {
    color: #1a1a1a;
    font-weight: 700;
}
.maintenance-banner-progress-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 320px;
}
.maintenance-banner-progress {
    flex: 1;
    height: 6px;
    background: rgba(0,0,0,0.12);
    border-radius: 6px;
    overflow: hidden;
}
.maintenance-banner-progress-fill {
    height: 100%;
    background: #1a1a1a;
    border-radius: 6px;
    transition: width 0.4s ease;
}
.maintenance-banner-pct {
    font-size: 12px;
    font-weight: 700;
    color: #1a1a1a;
    white-space: nowrap;
}
.maintenance-banner-note {
    font-size: 11px;
    color: rgba(0,0,0,0.4);
    line-height: 1.3;
}
.maintenance-banner-right {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
    padding: 8px 4px;
}
.maintenance-banner-days {
    font-size: 32px;
    font-weight: 800;
    color: #1a1a1a;
    line-height: 1;
}
.maintenance-banner-days-label {
    font-size: 11px;
    font-weight: 600;
    color: rgba(0,0,0,0.45);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ─── Staleness Badges ─── */
.stale-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 7px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
}
.stale-warning { background: rgba(217,119,6,0.1); color: #d97706; }
.stale-danger { background: rgba(212,5,17,0.08); color: #d40511; }

/* ─── Signal Bar ─── */
.signal-bar {
    width: 80px;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}
.signal-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s;
}
.signal-excellent { background: #10b981; }
.signal-good { background: #3b82f6; }
.signal-fair { background: #f59e0b; }
.signal-poor { background: #ef4444; }

/* ─── Signal dot (fleet table) ─── */
.signal-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
    .mobile-menu-btn { display: block; }
    .sidebar {
        transform: translateX(-100%);
        z-index: 200;
    }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .content-area { padding: 14px; }
    .detail-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .pipeline-layout { flex-direction: column; }
    .pipeline-sidebar { width: 100%; }
    .ops-grid { grid-template-columns: 1fr; }
    .topbar { padding: 0 14px; }
    .topbar h1 { font-size: 15px; }
    .mobile-logout-btn { display: block; }
    .topbar-search input { width: 160px; }
    .topbar-search input:focus { width: 200px; }
    .search-hint { display: none; }
    .overview-grid { grid-template-columns: 1fr !important; }
    .overview-top { flex-direction: column !important; }
    .overview-top > div:first-child { flex: 0 0 auto !important; width: 100% !important; }
}

/* ─── Keyframe Animations ─── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ─── Custom Scrollbar ─── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ─── Badge Danger Positioning ─── */
.badge-danger {
    position: relative;
}

/* ─── Accessibility: Reduced Motion ─── */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .card:hover,
    .stat-card:hover,
    .btn:hover,
    .sidebar-nav a:hover {
        transform: none !important;
    }
}

/* ─── Anomaly Rules Editor ─── */
.ar-rule-card { transition: box-shadow var(--transition), border-color var(--transition); }
.ar-rule-card:hover { box-shadow: var(--shadow-md); border-color: var(--primary); }
.ar-card-disabled { opacity: 0.55; }
.ar-card-disabled:hover { opacity: 0.8; }

.ar-match-count {
    display:inline-flex; align-items:center; justify-content:center;
    min-width:28px; height:28px; padding:0 8px;
    border-radius:14px; font-size:12px; font-weight:700;
    background:var(--border-light); color:var(--text-muted);
}
.ar-match-count.has-matches { background:var(--danger-bg); color:var(--danger); }

.ar-tab {
    padding:10px 18px; font-size:13px; font-weight:500;
    border:none; background:none; cursor:pointer;
    color:var(--text-muted); border-bottom:2px solid transparent;
    transition: color var(--transition), border-color var(--transition);
}
.ar-tab:hover { color:var(--text); }
.ar-tab.active { color:var(--primary); border-bottom-color:var(--primary); }

.ar-tab-content { display:none; }
.ar-tab-content.active { display:block; }

.ar-field label {
    display:block; font-size:11px; font-weight:600;
    color:var(--text-muted); text-transform:uppercase;
    letter-spacing:0.5px; margin-bottom:4px;
}
.ar-field input, .ar-field select, .ar-field textarea {
    width:100%; padding:8px 10px;
    border:1px solid var(--border); border-radius:6px;
    font-size:13px; font-family:inherit;
    background:var(--card); color:var(--text);
    transition: border-color var(--transition);
}
.ar-field input:focus, .ar-field select:focus, .ar-field textarea:focus {
    border-color:var(--primary); outline:none;
    box-shadow:0 0 0 3px rgba(212,5,17,0.08);
}
.ar-field input[readonly] { background:var(--border-light); color:var(--text-muted); }

.ar-toggle {
    display:inline-flex; align-items:center; gap:6px;
    font-size:13px; cursor:pointer; user-select:none;
}
.ar-toggle input[type="checkbox"] {
    width:16px; height:16px; accent-color:var(--primary); cursor:pointer;
}

.ar-stat-card {
    padding:16px 20px; background:var(--border-light);
    border-radius:8px; text-align:center; min-width:120px;
}
.ar-stat-value { font-size:24px; font-weight:700; color:var(--text); }
.ar-stat-label { font-size:11px; color:var(--text-muted); margin-top:2px; text-transform:uppercase; letter-spacing:0.5px; }

/* Schema explorer */
.ar-schema-table { border-bottom:1px solid var(--border-light); }
.ar-schema-table-name {
    padding:6px 12px; font-weight:600; cursor:pointer;
    color:var(--text); font-size:12px;
    display:flex; align-items:center; justify-content:space-between;
}
.ar-schema-table-name:hover { background:var(--border-light); }
.ar-schema-cols { display:none; padding:0 8px 6px; }
.ar-schema-table.open .ar-schema-cols { display:block; }
.ar-schema-col {
    padding:3px 8px; display:flex; justify-content:space-between;
    cursor:pointer; border-radius:4px; font-size:11px;
}
.ar-schema-col:hover { background:var(--info-bg); }

#ed-sql_query::placeholder { color:#4a5568; }
#ed-sql_query::-webkit-scrollbar { width:8px; }
#ed-sql_query::-webkit-scrollbar-track { background:#0f172a; }
#ed-sql_query::-webkit-scrollbar-thumb { background:#334155; border-radius:4px; }
#ed-sql_query::-webkit-scrollbar-thumb:hover { background:#475569; }
