/* ==========================================================
   FEMS — Supplementary Styles
   Metronic styles.css provides the core Tailwind/theme utilities.
   This file adds FEMS-specific components and any missing utilities.
   ========================================================== */

/* ── Layout Scroll Fix ── */
@media (min-width: 1024px) {
    #scrollable_content {
        overflow-y: auto;
        max-height: 100vh;
    }
}

/* ── FEMS Alert Components ── */
.fems-alert {
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    border-width: 1px;
    border-style: solid;
    font-size: 0.875rem;
}
.fems-alert-success {
    background-color: #dcfce7;
    border-color: #86efac;
    color: #15803d;
}
.fems-alert-error {
    background-color: #fee2e2;
    border-color: #fca5a5;
    color: #b91c1c;
}

/* ── FEMS Dashboard Cards ── */
.fems-card {
    background-color: #fff;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px 0 rgba(0,0,0,.06);
}
.fems-card-title {
    font-size: 0.875rem;
    color: var(--muted-foreground, #6b7280);
}
.fems-card-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--foreground, #1f2937);
}
.fems-card-value.positive { color: #16a34a; }
.fems-card-value.negative { color: #dc2626; }
.fems-card-caption {
    font-size: 0.75rem;
    color: var(--muted-foreground, #9ca3af);
}

/* ── Modern Stat Cards ── */
.fems-stat-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: #fff;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 0.875rem;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,.05), 0 1px 2px rgba(0,0,0,.03);
    transition: box-shadow 0.2s, transform 0.2s;
}
.fems-stat-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,.08);
    transform: translateY(-1px);
}
.fems-stat-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    border-radius: 0.75rem;
    font-size: 1.125rem;
    flex-shrink: 0;
}
.fems-stat-icon-fuel     { background: #eff6ff; color: #2563eb; }
.fems-stat-icon-vehicle  { background: #f0fdf4; color: #16a34a; }
.fems-stat-icon-trip     { background: #fefce8; color: #ca8a04; }
.fems-stat-icon-efficiency { background: #faf5ff; color: #7c3aed; }
.fems-stat-body {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    min-width: 0;
}
.fems-stat-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--muted-foreground, #6b7280);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}
.fems-stat-number {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--foreground, #111827);
    line-height: 1.2;
}
.fems-stat-sub {
    font-size: 0.75rem;
    color: var(--muted-foreground, #9ca3af);
}
.fems-stat-sub.text-emerald { color: #059669; }
.fems-stat-sub.text-rose    { color: #e11d48; }

/* ── Dashboard Card (shared container) ── */
.fems-dash-card {
    background: #fff;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 0.875rem;
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.fems-dash-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border, #f3f4f6);
}
.fems-dash-card-header h3 {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--foreground, #1f2937);
    margin: 0;
    display: flex;
    align-items: center;
}
.fems-dash-badge {
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    background: #f0f4f8;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.fems-dash-badge-ai {
    background: linear-gradient(135deg, #ede9fe, #e0e7ff);
    color: #6d28d9;
}

/* ── Module Summary Cards ── */
.fems-module-card {
    padding: 0.75rem;
    border-radius: 0.5rem;
    background: var(--bg-muted, #f9fafb);
    transition: background 0.15s;
}
.fems-module-card:hover {
    background: #f0f4f8;
}
.fems-module-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 0.375rem;
    font-size: 0.8125rem;
    flex-shrink: 0;
}
.fems-progress-track {
    height: 0.375rem;
    background: #e5e7eb;
    border-radius: 9999px;
    overflow: hidden;
    margin-top: 0.375rem;
}
.fems-progress-fill {
    height: 100%;
    border-radius: 9999px;
    transition: width 0.6s ease;
}

/* ── Quick Action Items ── */
.fems-quick-action {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    border-radius: 0.5rem;
    text-decoration: none;
    color: var(--foreground, #1f2937);
    transition: background 0.15s;
}
.fems-quick-action:hover {
    background: #f0f4f8;
}
.fems-quick-label {
    flex: 1;
    font-size: 0.875rem;
    font-weight: 500;
}
.fems-quick-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    flex-shrink: 0;
}
.fems-quick-icon-puv     { background: #eff6ff; color: #2563eb; }
.fems-quick-icon-gov     { background: #f0fdf4; color: #16a34a; }
.fems-quick-icon-private { background: #fefce8; color: #ca8a04; }
.fems-quick-icon-tnvs    { background: #faf5ff; color: #8b5cf6; }
.fems-quick-icon-inspect { background: #fff7ed; color: #ea580c; }
.fems-quick-icon-vehicle { background: #fdf2f8; color: #db2777; }

/* ── Fuel Trend Chart ── */
.fems-chart-container {
    position: relative;
    height: 280px;
}

/* ── Vehicle Efficiency ── */
.fems-efficiency-label {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.5rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
}
.fems-efficiency-top {
    color: #059669;
    background: #ecfdf5;
}
.fems-efficiency-bottom {
    color: #dc2626;
    background: #fef2f2;
}
.fems-efficiency-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.625rem;
    border-radius: 0.375rem;
}
.fems-efficiency-row:hover {
    background: #f9fafb;
}
.fems-efficiency-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
}
.fems-efficiency-good {
    color: #059669;
    background: #ecfdf5;
}
.fems-efficiency-poor {
    color: #dc2626;
    background: #fef2f2;
}

/* ── FEMS Quick Action Cards ── */
.fems-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    border-radius: 0.5rem;
    text-align: center;
    font-size: 0.875rem;
    transition: background-color 0.15s;
    text-decoration: none;
    color: inherit;
}
.fems-action-puv      { background: #eff6ff; }
.fems-action-puv:hover { background: #dbeafe; }
.fems-action-gov      { background: #f0fdf4; }
.fems-action-gov:hover { background: #dcfce7; }
.fems-action-inspect      { background: #fff7ed; }
.fems-action-inspect:hover { background: #ffedd5; }
.fems-action-vehicle      { background: #faf5ff; }
.fems-action-vehicle:hover { background: #f3e8ff; }
.fems-action i {
    font-size: 1.25rem;
}
.fems-action-puv i      { color: #2563eb; }
.fems-action-gov i      { color: #16a34a; }
.fems-action-inspect i  { color: #ea580c; }
.fems-action-vehicle i  { color: #9333ea; }

/* ── Module Summary Row (legacy) ── */
.fems-module-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    border-radius: 0.375rem;
    background: var(--bg-muted, #f9fafb);
}
.fems-module-row:nth-child(even) { background: #f0f4f8; }

/* ── AI Dashboard Card Override ── */
.fems-ai-dashboard-card {
    background: linear-gradient(135deg, #fafbff 0%, #f8f5ff 100%);
    border: 1px solid #c7d2fe;
}

/* ── AI Chat Widget ── */
.fems-chat-toggle {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 9999px;
    border: none;
    background: #2563eb;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 50;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,.15);
    transition: transform 0.15s, background-color 0.15s;
}
.fems-chat-toggle:hover {
    background: #1d4ed8;
    transform: scale(1.1);
}
.fems-chat-panel {
    position: fixed;
    bottom: 6rem;
    right: 1.5rem;
    width: 24rem;
    height: 500px;
    background: #fff;
    border-radius: 0.75rem;
    border: 1px solid var(--border, #e5e7eb);
    box-shadow: 0 25px 50px -12px rgba(0,0,0,.2);
    z-index: 50;
    display: none;
    flex-direction: column;
}
.fems-chat-panel.open {
    display: flex;
}
.fems-chat-header {
    background: #2563eb;
    color: #fff;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem 0.75rem 0 0;
}
.fems-chat-header h3 {
    font-weight: 600;
    font-size: 0.875rem;
}
.fems-chat-header p {
    font-size: 0.75rem;
    opacity: 0.8;
}
.fems-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 380px;
}
.fems-chat-bubble {
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    max-width: 80%;
}
.fems-chat-bubble.bot {
    background: #f3f4f6;
    color: #1f2937;
    align-self: flex-start;
}
.fems-chat-bubble.user {
    background: #2563eb;
    color: #fff;
    align-self: flex-end;
}
.fems-chat-bubble.typing {
    background: #f3f4f6;
    color: #6b7280;
    font-style: italic;
    align-self: flex-start;
}
.fems-chat-input-area {
    border-top: 1px solid var(--border, #e5e7eb);
    padding: 0.75rem 1rem;
    display: flex;
    gap: 0.5rem;
}
.fems-chat-input {
    flex: 1;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    outline: none;
}
.fems-chat-input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37,99,235,.2);
}
.fems-chat-send {
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background-color 0.15s;
}
.fems-chat-send:hover {
    background: #1d4ed8;
}

/* ── Sidebar Dark Theme (explicit — bypasses Metronic .dark variable chain) ── */
#sidebar {
    background-color: oklch(14.1% 0.005 285.823); /* zinc-950 */
}

#sidebar .text-foreground,
#sidebar .kt-menu-title {
    color: oklch(98.5% 0 0); /* zinc-50 */
}

#sidebar .text-muted-foreground {
    color: oklch(55.2% 0.016 285.938); /* zinc-500 */
}

#sidebar .text-secondary-foreground,
#sidebar .kt-menu-icon {
    color: oklch(70.5% 0.015 286.067); /* zinc-400 */
}

#sidebar .text-mono {
    color: oklch(98.5% 0 0); /* zinc-50 — mono-foreground in dark */
}

#sidebar .kt-menu-link:hover {
    background-color: rgba(255,255,255,.08);
}

#sidebar .kt-menu-link.active,
#sidebar .kt-menu-item.active > .kt-menu-link {
    background-color: rgba(255,255,255,.1);
}

/* Sidebar footer elements */
#sidebar .text-destructive {
    color: oklch(57.7% 0.245 27.325); /* red-600 */
}

/* Mobile drawer gets same dark background */
.kt-drawer#sidebar {
    background-color: oklch(14.1% 0.005 285.823); /* zinc-950 */
}

/* ── Sidebar scrollbar ── */
#sidebar ::-webkit-scrollbar { width: 4px; }
#sidebar ::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 2px; }
#sidebar ::-webkit-scrollbar-track { background: transparent; }

/* ── Kendo Grid — FEMS Overrides ── */
.fems-btn-add {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #fff;
    background-color: #2563eb;
    border-radius: 0.375rem;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: background-color 0.15s;
}
.fems-btn-add:hover { background-color: #1d4ed8; }

.fems-grid-link {
    color: #2563eb;
    text-decoration: none;
    margin-right: 0.5rem;
    font-size: 0.8125rem;
    cursor: pointer;
}
.fems-grid-link:hover { text-decoration: underline; }

.fems-grid-link-edit  { color: #d97706; }
.fems-grid-link-delete {
    color: #dc2626;
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    cursor: pointer;
}
.fems-grid-link-delete:hover { text-decoration: underline; }

.fems-grid-link-resolve {
    color: #16a34a;
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    font-size: 0.8125rem;
    cursor: pointer;
}
.fems-grid-link-resolve:hover { text-decoration: underline; }

/* ── Responsive grid supplements (not in Metronic styles.css) ── */
@media (min-width: 1024px) {
    .lg\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ══════════════════════════════════════════════════
   FEMS List — Card/Grid Toggle Components
   ══════════════════════════════════════════════════ */

/* ── Page header bar ── */
.fems-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}
.fems-list-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1f2937;
    margin: 0;
}
.fems-list-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ── Toolbar (search + toggle) ── */
.fems-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.fems-search-wrap {
    flex: 1;
    max-width: 360px;
    position: relative;
}
.fems-search-wrap i {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    font-size: 0.8125rem;
    pointer-events: none;
}
.fems-search {
    width: 100%;
    padding: 0.5rem 0.75rem 0.5rem 2.25rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    background: #fff;
}
.fems-search:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.fems-toggle-group {
    display: flex;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    overflow: hidden;
}
.fems-toggle-card,
.fems-toggle-grid {
    padding: 0.45rem 0.75rem;
    border: none;
    background: #fff;
    cursor: pointer;
    color: #6b7280;
    font-size: 0.8125rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    transition: background-color 0.15s, color 0.15s;
}
.fems-toggle-card:hover,
.fems-toggle-grid:hover {
    background: #f3f4f6;
}
.fems-toggle-card.active,
.fems-toggle-grid.active {
    background: #2563eb;
    color: #fff;
}

/* ── Card grid container ── */
.fems-card-view {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 0.875rem;
}

/* ── Individual card ── */
.fems-item-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    padding: 1.25rem;
    transition: box-shadow 0.2s, border-color 0.2s;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    position: relative;
}
.fems-item-card:hover {
    box-shadow: 0 4px 20px rgba(0,0,0,.08);
    border-color: #bfdbfe;
}
.fems-item-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
}
.fems-item-card-title {
    font-weight: 600;
    font-size: 0.9375rem;
    color: #1f2937;
    margin: 0;
    line-height: 1.3;
}
.fems-item-card-subtitle {
    font-size: 0.8125rem;
    color: #6b7280;
}
.fems-item-card-icon {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.875rem;
}
.fems-item-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
}
.fems-item-card-field {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    font-size: 0.8125rem;
    line-height: 1.5;
}
.fems-item-card-field .label {
    color: #9ca3af;
    white-space: nowrap;
    min-width: 4.5rem;
}
.fems-item-card-field .value {
    color: #374151;
    font-weight: 500;
}
.fems-item-card-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-top: 0.625rem;
    border-top: 1px solid #f3f4f6;
    margin-top: auto;
}
.fems-card-action {
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.3rem 0.625rem;
    border-radius: 0.375rem;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: background-color 0.15s;
}
.fems-card-action-view {
    color: #2563eb;
    background: #eff6ff;
}
.fems-card-action-view:hover { background: #dbeafe; }
.fems-card-action-edit {
    color: #d97706;
    background: #fffbeb;
}
.fems-card-action-edit:hover { background: #fef3c7; }
.fems-card-action-delete {
    color: #dc2626;
    background: #fef2f2;
    font: inherit;
    font-size: 0.75rem;
    font-weight: 500;
}
.fems-card-action-delete:hover { background: #fee2e2; }
.fems-card-action-resolve {
    color: #16a34a;
    background: #f0fdf4;
    font: inherit;
    font-size: 0.75rem;
    font-weight: 500;
}
.fems-card-action-resolve:hover { background: #dcfce7; }

/* ── Badge ── */
.fems-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
}
.fems-badge-green  { background: #dcfce7; color: #166534; }
.fems-badge-red    { background: #fee2e2; color: #991b1b; }
.fems-badge-yellow { background: #fef9c3; color: #854d0e; }
.fems-badge-blue   { background: #dbeafe; color: #1e40af; }
.fems-badge-orange { background: #ffedd5; color: #9a3412; }
.fems-badge-purple { background: #f3e8ff; color: #6b21a8; }
.fems-badge-gray   { background: #f3f4f6; color: #4b5563; }

/* ── Pagination ── */
.fems-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.fems-count {
    font-size: 0.8125rem;
    color: #6b7280;
}
.fems-pager {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}
.fems-page-btn {
    min-width: 2rem;
    height: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    background: #fff;
    color: #374151;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: background-color 0.15s;
}
.fems-page-btn:hover:not([disabled]) { background: #f3f4f6; }
.fems-page-btn.active {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}
.fems-page-btn[disabled] {
    opacity: 0.4;
    cursor: default;
}

/* ── Empty state ── */
.fems-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem 1rem;
    color: #9ca3af;
}
.fems-empty i {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    display: block;
}

/* ── Grid view (Kendo wrapper) ── */
.fems-grid-view { display: none; }

/* ── Responsive adjustments ── */
@media (max-width: 640px) {
    .fems-card-view {
        grid-template-columns: 1fr;
    }
    .fems-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .fems-search-wrap { max-width: 100%; }
    .fems-list-header { flex-direction: column; align-items: flex-start; }
}

/* ══════════════════════════════════════════════════
   FEMS Form & Detail — Shared CRUD Page Components
   ══════════════════════════════════════════════════ */

/* ── Buttons ── */
.fems-btn-primary {
    display: inline-flex; align-items: center; gap: 0.35rem;
    padding: 0.5rem 1.25rem; font-size: 0.875rem; font-weight: 500;
    color: #fff; background: #2563eb; border: none; border-radius: 0.5rem;
    cursor: pointer; text-decoration: none;
    transition: background-color 0.15s, box-shadow 0.15s;
}
.fems-btn-primary:hover { background: #1d4ed8; box-shadow: 0 2px 8px rgba(37,99,235,.25); }

.fems-btn-secondary {
    display: inline-flex; align-items: center; gap: 0.35rem;
    padding: 0.5rem 1.25rem; font-size: 0.875rem; font-weight: 500;
    color: #374151; background: #f3f4f6; border: 1px solid #d1d5db; border-radius: 0.5rem;
    cursor: pointer; text-decoration: none;
    transition: background-color 0.15s;
}
.fems-btn-secondary:hover { background: #e5e7eb; }

.fems-btn-warning {
    display: inline-flex; align-items: center; gap: 0.35rem;
    padding: 0.5rem 1.25rem; font-size: 0.875rem; font-weight: 500;
    color: #fff; background: #d97706; border: none; border-radius: 0.5rem;
    cursor: pointer; text-decoration: none;
    transition: background-color 0.15s;
}
.fems-btn-warning:hover { background: #b45309; }

.fems-btn-danger {
    display: inline-flex; align-items: center; gap: 0.35rem;
    padding: 0.5rem 1.25rem; font-size: 0.875rem; font-weight: 500;
    color: #fff; background: #dc2626; border: none; border-radius: 0.5rem;
    cursor: pointer; text-decoration: none;
    transition: background-color 0.15s;
}
.fems-btn-danger:hover { background: #b91c1c; }

.fems-btn-success {
    display: inline-flex; align-items: center; gap: 0.35rem;
    padding: 0.5rem 1.25rem; font-size: 0.875rem; font-weight: 500;
    color: #fff; background: #16a34a; border: none; border-radius: 0.5rem;
    cursor: pointer; text-decoration: none;
    transition: background-color 0.15s;
}
.fems-btn-success:hover { background: #15803d; }

/* ── Form Card ── */
.fems-form-card {
    max-width: 48rem;
}
.fems-form-header {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1.25rem;
}
.fems-form-header h2 {
    font-size: 1.25rem; font-weight: 600; color: #1f2937; margin: 0;
}
.fems-form-header-subtitle {
    font-size: 0.8125rem; color: #6b7280; margin-top: 0.15rem;
}
.fems-form-body {
    background: #fff; border: 1px solid #e5e7eb; border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    padding: 1.5rem;
    display: flex; flex-direction: column; gap: 1.25rem;
}
.fems-form-section {
    display: flex; flex-direction: column; gap: 1rem;
}
.fems-form-section-title {
    font-size: 0.8125rem; font-weight: 600; color: #6b7280;
    text-transform: uppercase; letter-spacing: 0.04em;
    padding-bottom: 0.5rem; border-bottom: 1px solid #f3f4f6;
    margin: 0;
}
.fems-form-group {
    display: flex; flex-direction: column; gap: 0.25rem;
}
.fems-form-label {
    font-size: 0.8125rem; font-weight: 500; color: #374151;
}
.fems-form-input,
.fems-form-select,
.fems-form-textarea {
    width: 100%; padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db; border-radius: 0.5rem;
    font-size: 0.875rem; color: #1f2937; background: #fff;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.fems-form-input:focus,
.fems-form-select:focus,
.fems-form-textarea:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.fems-form-validation {
    font-size: 0.75rem; color: #dc2626;
}
.fems-form-actions {
    display: flex; align-items: center; gap: 0.5rem;
    padding-top: 1rem; border-top: 1px solid #f3f4f6;
}
.fems-form-row {
    display: grid; gap: 1rem;
}
.fems-form-row-2 { grid-template-columns: repeat(2, 1fr); }
.fems-form-row-3 { grid-template-columns: repeat(3, 1fr); }

/* ── Detail Card ── */
.fems-detail-card {
    max-width: 48rem;
}
.fems-detail-header {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1.25rem;
}
.fems-detail-header h2 {
    font-size: 1.25rem; font-weight: 600; color: #1f2937; margin: 0;
}
.fems-detail-header-subtitle {
    font-size: 0.8125rem; color: #6b7280; margin-top: 0.15rem;
}
.fems-detail-header-actions {
    display: flex; align-items: center; gap: 0.5rem;
}
.fems-detail-body {
    background: #fff; border: 1px solid #e5e7eb; border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    padding: 1.5rem;
    display: flex; flex-direction: column; gap: 1.25rem;
}
.fems-detail-section {
    display: flex; flex-direction: column; gap: 0.75rem;
}
.fems-detail-section-title {
    font-size: 0.8125rem; font-weight: 600; color: #6b7280;
    text-transform: uppercase; letter-spacing: 0.04em;
    padding-bottom: 0.5rem; border-bottom: 1px solid #f3f4f6;
    margin: 0;
}
.fems-detail-field {
    display: flex; flex-direction: column; gap: 0.15rem;
}
.fems-detail-label {
    font-size: 0.75rem; font-weight: 500; color: #9ca3af;
    text-transform: uppercase; letter-spacing: 0.03em;
}
.fems-detail-value {
    font-size: 0.9375rem; font-weight: 500; color: #1f2937;
}
.fems-detail-actions {
    display: flex; align-items: center; gap: 0.5rem;
    padding-top: 1rem; border-top: 1px solid #f3f4f6;
}

/* ── Checklist (Inspection) ── */
.fems-checklist {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.5rem;
}
.fems-checklist-item {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.375rem 0.625rem; border-radius: 0.375rem;
    background: #f9fafb; font-size: 0.8125rem;
}
.fems-checklist-item input[type="checkbox"] {
    width: 1rem; height: 1rem; border-radius: 0.25rem;
    border: 1px solid #d1d5db; accent-color: #2563eb;
}
.fems-checklist-pass {
    background: #f0fdf4; color: #166534;
}
.fems-checklist-fail {
    background: #fef2f2; color: #991b1b;
}
.fems-checklist-icon {
    width: 1.25rem; height: 1.25rem; border-radius: 9999px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 0.625rem; font-weight: 700; flex-shrink: 0;
}

/* ── Map info box ── */
.fems-map-info {
    background: #fffbeb; border: 1px solid #fde68a; color: #92400e;
    padding: 0.5rem 0.75rem; border-radius: 0.5rem; font-size: 0.8125rem;
}

/* ── Form responsive ── */
@media (max-width: 640px) {
    .fems-form-row-2,
    .fems-form-row-3 { grid-template-columns: 1fr; }
    .fems-form-header,
    .fems-detail-header { flex-direction: column; align-items: flex-start; }
    .fems-checklist { grid-template-columns: 1fr; }
}

/* ── Standalone Pages (Login / Error) ── */
.fems-standalone {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #eff6ff 0%, #f8fafc 50%, #f0f9ff 100%);
    padding: 1rem;
}
.fems-standalone-card {
    background: #fff; border-radius: 0.75rem; border: 1px solid #e5e7eb;
    box-shadow: 0 4px 24px rgba(0,0,0,.08);
    padding: 2.5rem; width: 100%; max-width: 28rem;
}
.fems-standalone-icon {
    width: 3.5rem; height: 3.5rem; border-radius: 0.75rem;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem; margin: 0 auto 1rem;
}
.fems-standalone h1 {
    font-size: 1.5rem; font-weight: 700; color: #1f2937;
    text-align: center; margin: 0 0 0.25rem;
}
.fems-standalone .subtitle {
    font-size: 0.875rem; color: #6b7280; text-align: center; margin-bottom: 1.5rem;
}
.fems-standalone .subtext {
    font-size: 0.75rem; color: #9ca3af; text-align: center;
}

/* ── OCR Receipt Scanner ── */
.fems-ocr-section {
    border: 1px dashed #93c5fd;
    border-radius: 0.75rem;
    background: #eff6ff;
    margin-bottom: 1.5rem;
}
.fems-ocr-header {
    background: #2563eb;
    color: #fff;
    padding: 0.5rem 1rem;
    border-radius: 0.75rem 0.75rem 0 0;
    font-weight: 600;
    font-size: 0.875rem;
}
.fems-ocr-body {
    padding: 1rem;
}
.fems-ocr-hint {
    font-size: 0.8125rem;
    color: #4b5563;
    margin-bottom: 0.75rem;
}
.fems-ocr-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.fems-ocr-file {
    display: none;
}
.fems-ocr-choose {
    cursor: pointer;
}
.fems-ocr-preview {
    margin-top: 0.75rem;
}
.fems-ocr-preview img {
    max-height: 10rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border, #e5e7eb);
}
.fems-ocr-status {
    margin-top: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.8125rem;
}
.fems-ocr-status-info {
    background: #dbeafe;
    color: #1e40af;
}
.fems-ocr-status-success {
    background: #dcfce7;
    color: #166534;
}
.fems-ocr-status-error {
    background: #fef2f2;
    color: #991b1b;
}
.fems-ocr-result {
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 0.5rem;
    font-size: 0.8125rem;
    color: #166534;
}

/* ── AI Insight Panel ── */
.fems-ai-panel {
    border: 1px solid #93c5fd;
    border-radius: 0.75rem;
    background: #eff6ff;
    margin-top: 1rem;
}
.fems-ai-panel-header {
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    color: #fff;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem 0.75rem 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.fems-ai-panel-header h3 {
    font-weight: 600;
    font-size: 0.9375rem;
    margin: 0;
}
.fems-ai-panel-body {
    padding: 1rem;
}
.fems-ai-response {
    background: #fff;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    font-size: 0.8125rem;
    color: #1f2937;
    line-height: 1.6;
    white-space: pre-wrap;
    min-height: 3rem;
}
.fems-ai-response.loading {
    color: #6b7280;
    font-style: italic;
}
.fems-ai-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}
.fems-ai-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.375rem 0.75rem;
    border: 1px solid #93c5fd;
    border-radius: 9999px;
    background: #fff;
    color: #2563eb;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.fems-ai-chip:hover {
    background: #2563eb;
    color: #fff;
}

/* (Dashboard AI card styles merged into dashboard section above) */

/* ══════════════════════════════════════════════════
   FEMS — Mobile Responsiveness Fixes
   ══════════════════════════════════════════════════ */

/* ── Mobile sidebar drawer: full-height scrollable ── */
@media (max-width: 1023px) {
    .kt-drawer#sidebar,
    #sidebar.kt-drawer-start {
        width: 280px !important;
        max-width: 85vw;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Ensure the sidebar menu section scrolls on mobile */
    #sidebar #sidebar_menu {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        flex: 1;
        min-height: 0;
    }

    /* Sidebar footer stays pinned at bottom */
    #sidebar #sidebar_footer {
        flex-shrink: 0;
    }

    /* Body no-scroll when drawer is open */
    body.kt-drawer-on {
        overflow: hidden;
    }
}

/* ── Main content area: prevent horizontal overflow on mobile ── */
@media (max-width: 1023px) {
    body {
        overflow-x: hidden;
    }

    /* Remove lg:overflow-hidden effect on mobile — allow vertical scrolling */
    .flex.grow {
        min-height: 100vh;
    }

    /* Content wrapper needs proper padding below mobile header */
    .flex.flex-col.lg\:flex-row.grow {
        min-height: 100vh;
    }

    /* Main content column fills viewport */
    .flex.flex-col.grow.lg\:rounded-l-xl {
        border-radius: 0;
        border: none;
        margin-left: 0;
        min-width: 0;
        overflow-x: hidden;
    }

    /* Scrollable content on mobile */
    #scrollable_content {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        max-height: none;
        min-height: 0;
    }

    /* Container should not overflow */
    .kt-container-fixed {
        max-width: 100%;
        padding-left: 1rem;
        padding-right: 1rem;
        overflow-x: hidden;
    }
}

/* ── Kendo grid: horizontal scroll on small screens ── */
@media (max-width: 768px) {
    .fems-grid-view,
    .fems-kendo-grid,
    .k-grid {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .k-grid table {
        min-width: 600px;
    }
}

/* ── Dashboard stat cards: stack on small screens ── */
@media (max-width: 640px) {
    .fems-stat-card {
        padding: 1rem;
    }

    .fems-stat-number {
        font-size: 1.25rem;
    }

    /* Dashboard cards full width */
    .fems-dash-card {
        padding: 1rem;
    }
}

/* ── Form & detail cards: remove max-width on mobile ── */
@media (max-width: 640px) {
    .fems-form-card,
    .fems-detail-card {
        max-width: 100%;
    }

    .fems-form-body,
    .fems-detail-body {
        padding: 1rem;
    }

    .fems-standalone-card {
        padding: 1.5rem;
        margin: 0 0.5rem;
    }
}

/* ── Chat panel: full-width on mobile ── */
@media (max-width: 640px) {
    .fems-chat-panel {
        width: calc(100vw - 1.5rem);
        right: 0.75rem;
        bottom: 5rem;
        max-height: 70vh;
    }

    .fems-chat-messages {
        max-height: 50vh;
    }
}

/* ── OCR section: responsive controls ── */
@media (max-width: 640px) {
    .fems-ocr-controls {
        flex-direction: column;
        align-items: stretch;
    }
}

/* ── Mobile header: ensure proper z-index and background ── */
@media (max-width: 1023px) {
    #header {
        background-color: oklch(14.1% 0.005 285.823);
    }
}

/* ══════════════════════════════════════════════════
   FEMS — PDF Export / Print Styles
   ══════════════════════════════════════════════════ */

@media print {
    /* Hide non-report UI elements */
    .no-print,
    #sidebar,
    #header,
    footer,
    .fems-chat-panel,
    .fems-chat-fab,
    #exportPdfBtn,
    form:not(#reportContent form) {
        display: none !important;
    }

    /* Reset layout so content flows freely (no scroll container, no sidebar margin) */
    body {
        background: #fff !important;
        overflow: visible !important;
        height: auto !important;
    }

    body > div,
    .flex.h-full,
    .flex.flex-col.grow,
    .flex.flex-col.lg\\:flex-row,
    #scrollable_content,
    main[role="content"],
    .kt-container-fixed {
        overflow: visible !important;
        height: auto !important;
        max-height: none !important;
        margin-left: 0 !important;
        padding: 0 !important;
        display: block !important;
        position: static !important;
    }

    /* Page title for the printed header */
    .pb-3 .kt-container-fixed h1 {
        font-size: 18pt !important;
        font-weight: 700 !important;
        margin-bottom: 8pt !important;
        color: #000 !important;
    }

    /* Hide username in print toolbar */
    .pb-3 .kt-container-fixed .text-secondary-foreground {
        display: none !important;
    }

    /* Report content fills the page */
    #reportContent {
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Stat cards print cleanly */
    .fems-stat-card {
        border: 1px solid #e5e7eb !important;
        break-inside: avoid;
    }

    /* Dashboard cards print cleanly */
    .fems-dash-card {
        border: 1px solid #e5e7eb !important;
        box-shadow: none !important;
        break-inside: avoid;
    }

    /* Charts: keep visible, avoid page break in middle */
    canvas {
        max-width: 100% !important;
        break-inside: avoid;
    }

    /* Tables: clean borders */
    table {
        border-collapse: collapse !important;
        width: 100% !important;
        font-size: 9pt !important;
    }

    table th, table td {
        border: 1px solid #d1d5db !important;
        padding: 4pt 6pt !important;
    }

    /* Keep grid layouts for print */
    .grid {
        break-inside: avoid;
    }

    /* Landscape orientation */
    @page {
        size: A4 landscape;
        margin: 10mm;
    }
}
