/* ================= ROOT VARIABLES ================= */

:root {
    --primary: #6b3129;
    --primary-dark: #4b1f19;
    --accent: #843c31;

    --bg: #f3f4f6;
    --card-bg: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
}

body.dark {
    --bg: #111827;
    --card-bg: #1f2937;
    --text: #f3f4f6;
    --muted: #9ca3af;
}

/* ================= RESET ================= */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', sans-serif;
}

body {
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    transition: background 0.3s ease, color 0.3s ease;
}

html {
    overflow-y: scroll;
}

/* ================= LAYOUT STRUCTURE ================= */

.dashboard {
    display: flex;
    min-height: 100vh;
}

/* ================= SIDEBAR ================= */

.sidebar {
    width: 260px;
    background: linear-gradient(180deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
}

.logo h2 {
    font-size: 1.3rem;
}

.logo span {
    font-size: 0.85rem;
    opacity: 0.8;
}

.sidebar-nav {
    margin-top: 40px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.sidebar-nav a {
    color: white;
    text-decoration: none;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 0.9;
    transition: 0.2s ease;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    opacity: 1;
}

/* ================= MAIN AREA ================= */

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* ================= TOPBAR ================= */

.topbar {
    background: var(--card-bg);
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.topbar h1 {
    font-size: 1.5rem;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.theme-toggle {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text);
}

/* ================= CONTENT WRAPPER ================= */

.content {
    padding: 40px;
    display: flex;                /* STACK SECTIONS VERTICALLY */
    flex-direction: column;
    gap: 40px;                    /* STRONG SECTION SEPARATION */
}

/* ================= CARD CONTAINER ================= */

.card {
    background: var(--card-bg);
    padding: 30px;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.05);
    border: 1px solid rgba(0,0,0,0.05); /* subtle separation */
    transition: background 0.3s ease;
}

.card h3 {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-grid-4x3 {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* 4 columns */
    grid-template-rows: repeat(3, auto);  /* 3 rows */
    gap: 20px;                             /* spacing between cards */
}

/* ================= GENERIC GRID (HOMEPAGE) ================= */

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 18px;
    margin-top: 10px;
}

/* ================= BUTTONS ================= */

.card-btn {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border: none;
    border-radius: 14px;
    padding: 16px;
    color: white;
    font-weight: 600;
    cursor: pointer;

    display: flex;
    align-items: center;
    gap: 10px;

    transition: all 0.25s ease;
}

.card-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 18px rgba(0,0,0,0.15);
}

.card-btn.secondary {
    background: linear-gradient(135deg, #374151, #1f2937);
}

/* ================= FIELDSETS (QUIZ PAGE) ================= */

fieldset {
    background: var(--card-bg);
    padding: 25px;
    border-radius: 16px;
    border: none;
    box-shadow: 0 6px 18px rgba(0,0,0,0.05);
    margin-bottom: 30px;
}

legend {
    font-weight: bold;
    color: var(--primary);
    padding: 0 10px;
}

/* ================= EMPLOYEE GRID ================= */

.employee-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
}

/* ================= FORM ELEMENTS ================= */

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
}

input[type="text"],
input[type="password"],
select {
    width: 100%;
    padding: 12px;
    margin-bottom: 16px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 1rem;
    background: var(--bg);
    color: var(--text);
}


input:focus,
select:focus {
    border-color: var(--primary);
    outline: none;
}

/* ================= QUIZ GRID ================= */

.quiz-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;

    max-height: 65vh;
    overflow-y: auto;

    padding-right: 8px;

    scroll-behavior: smooth;
}

/* Subtle scrollbar styling */
.quiz-grid::-webkit-scrollbar {
    width: 8px;
}

.quiz-grid::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.15);
    border-radius: 10px;
}

body.dark .quiz-grid::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
}

/* Quiz Question Card */
.quiz-question {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.05);
    transition: transform 0.2s ease;
}

.quiz-question:hover {
    transform: translateY(-3px);
}

.quiz-question h3 {
    margin-bottom: 10px;
    color: var(--primary);
}

.quiz-question p {
    margin-bottom: 12px;
    font-weight: 500;
}

.quiz-question label {
    font-weight: normal;
    margin-bottom: 6px;
    display: block;
    cursor: pointer;
}

/* ================= BUTTON ROW ================= */

.button-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin-top: 20px;
}

.action-button,
.secondary-button {
    border: none;
    border-radius: 14px;
    padding: 14px 20px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
}

.action-button {
    background: linear-gradient(135deg, var(--primary), var(--accent));
}

.secondary-button {
    background: linear-gradient(135deg, #374151, #1f2937);
}

.search-button {
    margin-left: auto;
}

.action-button:hover,
.secondary-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 18px rgba(0,0,0,0.15);
}

/* ================= RESULTS ================= */

.correct {
    border: 2px solid #16a34a;
    background-color: #dcfce7;
}

.incorrect {
    border: 2px solid #dc2626;
    background-color: #fee2e2;
}

.result-box {
    margin-top: 20px;
    padding: 15px;
    border-radius: 12px;
    font-weight: bold;
}

.result-box.pass {
    background-color: #dcfce7;
    color: #166534;
}

.result-box.fail {
    background-color: #fee2e2;
    color: #991b1b;
}

/* ================= RESPONSIVE ================= */

@media (max-width: 1100px) {
    .quiz-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 900px) {

    .sidebar {
        display: none;
    }

    .content {
        padding: 20px;
    }

    .quiz-grid {
        grid-template-columns: 1fr;
    }

    .employee-grid {
        grid-template-columns: 1fr;
    }

    .button-row {
        justify-content: center;
    }
}

.quiz-panel {
    position: relative;
}

.quiz-panel::after {
    content: "";
    position: absolute;
    bottom: 80px; /* above sticky bar */
    left: 0;
    right: 0;
    height: 40px;
    pointer-events: none;

    background: linear-gradient(
        to bottom,
        rgba(255,255,255,0),
        var(--card-bg)
    );
}

body.dark .quiz-panel::after {
    background: linear-gradient(
        to bottom,
        rgba(17,24,39,0),
        var(--card-bg)
    );
}

.quiz-panel {
    display: flex;
    flex-direction: column;
}

/* ================= STICKY QUIZ ACTION BAR ================= */

.quiz-panel form {
    display: flex;
    flex-direction: column;
}

.quiz-panel .button-row,
.quiz-panel .result-box,
.quiz-panel #postQuizActions {
    position: sticky;
    bottom: 0;

    background: var(--card-bg);
    padding-top: 15px;
    padding-bottom: 10px;

    z-index: 5;
}

.quiz-panel .button-row {
    border-top: 1px solid rgba(0,0,0,0.08);
    margin-top: 10px;
}

body.dark .quiz-panel .button-row {
    border-top: 1px solid rgba(255,255,255,0.1);
}

body.dark {
    --bg: #0f172a;          /* deeper navy */
    --card-bg: #1e293b;     /* stronger contrast */
    --text: #f8fafc;
    --muted: #94a3b8;
}

body.dark .quiz-question {
    box-shadow: 0 8px 20px rgba(0,0,0,0.4);
}

body.dark fieldset {
    box-shadow: 0 6px 18px rgba(0,0,0,0.35);
}

body.dark .correct {
    background-color: #064e3b;
    border-color: #10b981;
    color: #d1fae5;
}

body.dark .incorrect {
    background-color: #7f1d1d;
    border-color: #ef4444;
    color: #fee2e2;
}

body.dark .result-box.pass {
    background-color: #065f46;
    color: #d1fae5;
}

body.dark .result-box.fail {
    background-color: #7f1d1d;
    color: #fee2e2;
}


/* ================= QUIZ PROGRESS ================= */

.quiz-progress {
    margin-bottom: 20px;
}

.progress-text {
    font-weight: 600;
    margin-bottom: 8px;
}

.progress-bar {
    height: 8px;
    background: rgba(0,0,0,0.08);
    border-radius: 20px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    transition: width 0.3s ease;
}

body.dark .progress-bar {
    background: rgba(255,255,255,0.1);
}

.home-button {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background-color: #1e3a8a; /* adjust to match theme */
    color: #fff;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 500;
    transition: background 0.2s ease;
}

.home-button:hover {
    background-color: #162d6b;
}

.content .grid {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-auto-rows: 1fr;
    gap: 20px;
    margin-top: 10px;
}

@media (max-width: 1100px) {
    .content .grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 700px) {
    .content .grid {
        grid-template-columns: 1fr;
    }
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* ================= DATA TABLE (DASHBOARD) ================= */

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
    background: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
}

/* Header */
thead {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
}

th {
    padding: 12px;
    font-weight: 600;
    font-size: 0.9rem;
}

/* Body */
td {
    padding: 10px;
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

/* Row striping */
tbody tr:nth-child(even) {
    background: rgba(0,0,0,0.02);
}

/* Hover effect */
tbody tr:hover {
    background: rgba(0,0,0,0.05);
    transition: 0.2s ease;
}

/* Dark mode adjustments */
body.dark thead {
    background: linear-gradient(135deg, var(--primary-dark), var(--accent));
}

body.dark td {
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

body.dark tbody tr:nth-child(even) {
    background: rgba(255,255,255,0.03);
}

body.dark tbody tr:hover {
    background: rgba(255,255,255,0.06);
}

.status {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-block;
}

.status.pending {
    background: #fef3c7;
    color: #92400e;
}

.status.complete {
    background: #dcfce7;
    color: #166534;
}

.status.overdue {
    background: #fee2e2;
    color: #991b1b;
}

body.dark .status.pending {
    background: #78350f;
    color: #fde68a;
}

body.dark .status.complete {
    background: #064e3b;
    color: #a7f3d0;
}

body.dark .status.overdue {
    background: #7f1d1d;
    color: #fecaca;
}

.warning {
    background: #fef3c7 !important;
}

.overdue {
    background: #fee2e2 !important;
    font-weight: 600;
}

body.dark .warning {
    background: #78350f !important;
    color: #fde68a;
}

body.dark .overdue {
    background: #7f1d1d !important;
    color: #fecaca;
}

/* =========================
   KPI + CHART LAYOUT
========================= */

.kpi-chart-layout {
    display: grid;
    grid-template-columns: 1.35fr 1fr;
    gap: 25px;
    align-items: stretch;
}

/* =========================
   KPI 2 x 3 GRID
========================= */

.kpi-container {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(3, 1fr);
    gap: 22px;
    margin-bottom: 0;
}

/* =========================
   KPI CARD
========================= */

.kpi-card {
    background: var(--card-bg);
    border-radius: 18px;
    padding: 22px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.08);
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
    min-width: 0;
}

.kpi-card:hover {
    transform: translateY(-4px);
}

.kpi-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.kpi-icon {
    width: 58px;
    height: 58px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 22px;
}

.blue { background: #2563eb; }
.green { background: #10b981; }
.orange { background: #f59e0b; }
.red { background: #ef4444; }
.purple { background: #8b5cf6; }
.teal { background: #14b8a6; }

.kpi-content {
    margin-top: 20px;
}

.kpi-content h2 {
    margin: 0;
    font-size: 38px;
    font-weight: 700;
}

.kpi-content span {
    color: #888;
    font-size: 13px;
}

.kpi-content p {
    margin-top: 10px;
    font-size: 16px;
    font-weight: 600;
}

/* =========================
   CHART
========================= */

.chart-card {
    background: var(--card-bg);
    border-radius: 18px;
    padding: 25px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.08);
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
}

.chart-header h3 {
    margin: 0 0 25px 0;
}

.chart-placeholder {
    flex: 1;
    min-height: 320px;
    border: 2px dashed #cbd5e1;
    border-radius: 16px;

    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;

    color: #94a3b8;
}

.chart-placeholder i {
    font-size: 52px;
    margin-bottom: 15px;
}

/* =========================
   DARK MODE
========================= */

body.dark .kpi-card,
body.dark .chart-card {
    background: #1e293b;
    color: white;
}

body.dark .dashboard-filter select {
    background: #1e293b;
    color: white;
    border: 1px solid #334155;
}

body.dark .dashboard-header p,
body.dark .kpi-content span {
    color: #cbd5e1;
}

body.dark .progress-bar {
    background: #334155;
}

body.dark .chart-placeholder {
    border-color: #475569;
    color: #94a3b8;
}

/* =========================
   KPI RESPONSIVE LAYOUT
========================= */

@media (max-width: 1200px) {

    .kpi-chart-layout {
        grid-template-columns: 1fr;
    }

    .kpi-container {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .chart-card {
        min-height: 400px;
    }
}

@media (max-width: 700px) {

    .kpi-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }

    .kpi-chart-layout {
        grid-template-columns: 1fr;
    }
}

.dashboard-filter {
    display: flex;
    gap: 12px;
    align-items: center;
}

.dashboard-filter select {
    min-width: 160px;
}

.dashboard-filter {
    display: flex;
    gap: 8px;
    align-items: center;
}

.dashboard-filter select {
    width: 130px;
    padding: 6px 8px;
    font-size: 13px;
}

/* =========================================================
   PURCHASING DASHBOARD - FINAL LAYOUT
========================================================= */

.content {
    padding: 30px 40px 50px;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* Dashboard heading */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dashboard-header h2 {
    margin-bottom: 6px;
}

.dashboard-header p {
    color: var(--muted);
}

/* KPI filters */
.kpi-filter-row {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    margin-top: -10px;
}

.kpi-filter-row select {
    width: auto;
    min-width: 150px;
    margin-bottom: 0;
}

/* =========================================================
   KPI AREA
========================================================= */

.kpi-chart-layout {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    gap: 25px;
    align-items: stretch;
}

/* KPI cards */
.kpi-container {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    width: 100%;
}

/* KPI cards should fill their grid cells */
.kpi-card {
    width: 100%;
    min-width: 0;
}

/* Trends panel */
.chart-card {
    width: 100%;
    min-width: 0;
    margin: 0;
}

/* =========================================================
   FOLLOW-UP + REFERENCE SECTIONS
========================================================= */

.content > .card {
    width: 100%;
    margin: 0;
}

.content > .card h3 {
    margin-bottom: 20px;
}

/* Module buttons */
.content > .card .grid {
    width: 100%;
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
    margin-top: 0;
}

.content > .card .card-btn {
    width: 100%;
    min-height: 58px;
}

/* =========================================================
   RESPONSIVE
========================================================= */

@media (max-width: 1200px) {

    .kpi-chart-layout {
        grid-template-columns: 1fr;
    }

    .kpi-container {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .chart-card {
        min-height: auto;
    }

    .content > .card .grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 800px) {

    .content {
        padding: 20px;
        gap: 24px;
    }

    .kpi-container {
        grid-template-columns: 1fr;
    }

    .kpi-filter-row {
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .content > .card .grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 550px) {

    .content > .card .grid {
        grid-template-columns: 1fr;
    }

    .kpi-filter-row select {
        width: 100%;
    }
}

/* =========================================================
   KPI PERFORMANCE TRENDS CARD
========================================================= */

.chart-card {
    display: flex;
    flex-direction: column;
    min-height: 100%;
    padding: 25px;
}

/* Header containing title + filters */
.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 0;
}

.chart-title {
    flex: 1;
    min-width: 220px;
}

.chart-title h3 {
    margin: 0 0 6px 0;
}

.chart-title p {
    color: var(--muted);
    font-size: 0.85rem;
}

/* Filters now live inside the trend card */
.chart-header .kpi-filter-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin: 0;
    flex-shrink: 0;
}

.chart-header .kpi-filter-row select {
    width: auto;
    min-width: 145px;
    margin: 0;
    padding: 8px 10px;
    font-size: 13px;
}

/* Push the trend data slightly down */
.kpi-trend-table-wrapper {
    width: 100%;
    margin-top: 28px;
    flex: 1;
}

/* Keep table inside the card */
.kpi-trend-table {
    width: 100%;
    margin-top: 0;
}

/* Bottom-right export area */
.chart-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.export-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;

    background: linear-gradient(
        135deg,
        var(--primary),
        var(--accent)
    );

    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 10px 16px;

    font-size: 0.85rem;
    font-weight: 600;

    cursor: pointer;
    transition: all 0.25s ease;
}

.export-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.15);
}

.export-button i {
    font-size: 0.9rem;
}

/* Dark mode */
body.dark .chart-footer {
    border-top-color: rgba(255, 255, 255, 0.1);
}

/* =========================================================
   RESPONSIVE TREND CARD
========================================================= */

@media (max-width: 900px) {

    .chart-header {
        flex-direction: column;
        align-items: stretch;
    }

    .chart-header .kpi-filter-row {
        justify-content: flex-start;
        width: 100%;
    }

    .chart-header .kpi-filter-row select {
        flex: 1;
    }
}

@media (max-width: 550px) {

    .chart-header .kpi-filter-row {
        flex-direction: column;
        align-items: stretch;
    }

    .chart-header .kpi-filter-row select {
        width: 100%;
    }

    .export-button {
        width: 100%;
        justify-content: center;
    }
}

/* =========================================================
   KPI BAR CHART
========================================================= */

.kpi-bar-chart-section {
    width: 100%;
    margin-top: 30px;
    padding-top: 25px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.kpi-bar-chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.kpi-bar-chart-header h3 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 1rem;
}

.kpi-bar-chart-header span {
    color: var(--muted);
    font-size: 0.8rem;
}

.kpi-bar-chart-wrapper {
    position: relative;
    width: 100%;
    height: 320px;
}

body.dark .kpi-bar-chart-section {
    border-top-color: rgba(255, 255, 255, 0.1);
}

/* Responsive */
@media (max-width: 700px) {

    .kpi-bar-chart-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .kpi-bar-chart-wrapper {
        height: 280px;
    }
}

/* =========================================================
   ROBUST KPI CARD
========================================================= */

.kpi-card-robust {
    display: flex;
    flex-direction: column;

    padding: 22px;

    min-height: 225px;

    transition:
        transform 0.25s ease,
        box-shadow 0.25s ease;
}

.kpi-card-robust:hover {
    transform: translateY(-4px);
}


/* =========================================================
   KPI TOP
========================================================= */

.kpi-robust-top {
    display: flex;
    align-items: center;
    gap: 15px;
    width: 100%;
}

.kpi-card-robust .kpi-icon {
    flex-shrink: 0;

    width: 56px;
    height: 56px;

    border-radius: 15px;

    display: flex;
    align-items: center;
    justify-content: center;

    font-size: 21px;
}


/* =========================================================
   NUMBER
========================================================= */

.kpi-card-robust .kpi-number-block {
    flex: 1;
    min-width: 0;
}

.kpi-card-robust .kpi-number-row {
    display: flex;
    align-items: baseline;
    gap: 7px;
}

.kpi-card-robust .kpi-number-row h2 {
    margin: 0;

    font-size: 34px;
    line-height: 1;

    font-weight: 700;
}

.kpi-card-robust .kpi-unit {
    color: var(--muted);

    font-size: 13px;
    font-weight: 500;
}


/* =========================================================
   HISTORICAL AVERAGE
========================================================= */

.kpi-card-robust .historical-average {
    margin-top: 7px;

    color: var(--muted);

    font-size: 11px;
    font-weight: 500;

    white-space: nowrap;
}

.kpi-card-robust .historical-average strong {
    color: var(--text);
}


/* =========================================================
   PERFORMANCE INDICATOR
========================================================= */

.kpi-performance {
    flex-shrink: 0;

    min-width: 72px;

    text-align: right;
}

.kpi-performance-value {
    display: flex;
    align-items: center;
    justify-content: flex-end;

    gap: 4px;

    font-size: 13px;
    font-weight: 700;
}

.kpi-performance > span {
    display: block;

    margin-top: 3px;

    font-size: 10px;
    font-weight: 600;
}


/* Better */
.kpi-performance.positive {
    color: #16a34a;
}


/* Above historical */
.kpi-performance.negative {
    color: #dc2626;
}


/* No change */
.kpi-performance.neutral {
    color: #6b7280;
}


/* Dark mode */
body.dark .kpi-performance.positive {
    color: #34d399;
}

body.dark .kpi-performance.negative {
    color: #f87171;
}

body.dark .kpi-performance.neutral {
    color: #94a3b8;
}


/* =========================================================
   DESCRIPTION
========================================================= */

.kpi-card-robust .kpi-description {
    display: flex;
    flex-direction: column;

    gap: 5px;

    margin-top: 20px;
    padding-top: 15px;

    border-top: 1px solid rgba(0, 0, 0, 0.07);
}

.kpi-card-robust .kpi-description strong {
    color: var(--text);

    font-size: 14px;
}

.kpi-card-robust .kpi-description span {
    color: var(--muted);

    font-size: 12px;
    line-height: 1.45;
}


/* =========================================================
   CONTEXTUAL PERFORMANCE MESSAGE
========================================================= */

.kpi-context {
    display: flex;
    align-items: center;

    gap: 8px;

    margin-top: auto;
    padding-top: 15px;

    font-size: 11px;
    font-weight: 600;

    line-height: 1.4;
}

.kpi-context i {
    flex-shrink: 0;
}


/* Better */
.kpi-context.positive {
    color: #15803d;
}


/* Worse */
.kpi-context.negative {
    color: #b91c1c;
}


/* Neutral */
.kpi-context.neutral {
    color: #6b7280;
}


body.dark .kpi-context.positive {
    color: #4ade80;
}

body.dark .kpi-context.negative {
    color: #f87171;
}

body.dark .kpi-context.neutral {
    color: #94a3b8;
}


/* =========================================================
   RESPONSIVE
========================================================= */

@media (max-width: 550px) {

    .kpi-robust-top {
        gap: 10px;
    }

    .kpi-card-robust .kpi-number-row h2 {
        font-size: 28px;
    }

    .kpi-performance {
        min-width: 62px;
    }

    .kpi-performance-value {
        font-size: 11px;
    }
}

/* =========================================================
   KPI 7 — OUTSTANDING PURCHASE ORDERS
========================================================= */

.outstanding-po-kpi {
    background: var(--card-bg);

    border-radius: 18px;

    padding: 18px 20px;

    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);

    position: relative;

    overflow: hidden;

    transition:
        transform 0.25s ease,
        box-shadow 0.25s ease;
}

.outstanding-po-kpi:hover {
    transform: translateY(-3px);

    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.11);
}

.outstanding-po-kpi {
    width: 100%;
    grid-column: 1 / -1;
}


/* =========================================================
   MAIN KPI HEADER
========================================================= */

.outstanding-po-main {
    display: flex;

    align-items: center;

    gap: 14px;

    min-width: 0;
}


/* Icon */

.outstanding-po-main .kpi-icon {
    width: 50px;
    height: 50px;

    min-width: 50px;

    border-radius: 14px;

    display: flex;
    align-items: center;
    justify-content: center;

    color: #fff;

    font-size: 19px;
}


/* =========================================================
   NUMBER
========================================================= */

.outstanding-po-value {
    min-width: 0;
}

.outstanding-po-number {
    display: flex;

    align-items: baseline;

    gap: 6px;

    font-size: 30px;

    font-weight: 700;

    line-height: 1;
}

.outstanding-po-number span {
    color: var(--muted);

    font-size: 11px;

    font-weight: 500;
}

.outstanding-po-label {
    margin-top: 5px;

    color: var(--muted);

    font-size: 11px;

    font-weight: 500;
}


/* =========================================================
   STATUS
========================================================= */

.outstanding-po-status {
    margin-left: auto;

    display: flex;

    align-items: center;

    gap: 6px;

    padding: 6px 10px;

    border-radius: 20px;

    background: rgba(139, 92, 246, 0.10);

    color: #7c3aed;

    font-size: 10px;

    font-weight: 600;

    white-space: nowrap;
}

.outstanding-po-status i {
    font-size: 10px;
}

body.dark .outstanding-po-status {
    background: rgba(139, 92, 246, 0.15);

    color: #a78bfa;
}


/* =========================================================
   AGE BREAKDOWN
========================================================= */

.outstanding-po-breakdown {
    display: grid;

    grid-template-columns: repeat(5, 1fr);

    gap: 8px;

    margin-top: 16px;
}

.po-age-item {
    display: flex;

    align-items: center;

    justify-content: space-between;

    gap: 8px;

    padding: 8px 10px;

    border-radius: 10px;

    background: rgba(0, 0, 0, 0.035);

    border: 1px solid rgba(0, 0, 0, 0.04);
}

.po-age-label {
    color: var(--muted);

    font-size: 10px;

    font-weight: 600;

    white-space: nowrap;
}

.po-age-item strong {
    color: var(--text);

    font-size: 14px;

    font-weight: 700;
}


/* =========================================================
   CRITICAL 90+ DAYS
========================================================= */

.po-age-item.po-critical {
    background: rgba(239, 68, 68, 0.08);

    border-color: rgba(239, 68, 68, 0.15);
}

.po-age-item.po-critical .po-age-label {
    color: #dc2626;
}

.po-age-item.po-critical strong {
    color: #dc2626;
}

body.dark .po-age-item {
    background: rgba(255, 255, 255, 0.045);

    border-color: rgba(255, 255, 255, 0.05);
}

body.dark .po-age-item.po-critical {
    background: rgba(239, 68, 68, 0.14);

    border-color: rgba(239, 68, 68, 0.2);
}

body.dark .po-age-item.po-critical .po-age-label,
body.dark .po-age-item.po-critical strong {
    color: #f87171;
}


/* =========================================================
   FOOTER / CONTEXT
========================================================= */

.outstanding-po-footer {
    display: flex;

    align-items: center;

    gap: 7px;

    margin-top: 11px;

    color: var(--muted);

    font-size: 10px;
}

.outstanding-po-footer strong {
    color: var(--text);

    font-weight: 600;
}

.po-aging-indicator {
    width: 7px;
    height: 7px;

    flex-shrink: 0;

    border-radius: 50%;

    background: #ef4444;

    box-shadow:
        0 0 0 3px rgba(239, 68, 68, 0.10);
}


/* =========================================================
   RESPONSIVE
========================================================= */

@media (max-width: 900px) {

    .outstanding-po-status {
        display: none;
    }

}

@media (max-width: 600px) {

    .outstanding-po-breakdown {
        grid-template-columns: repeat(2, 1fr);
    }

    .po-age-item {
        justify-content: space-between;
    }

}

/* =========================================================
   FIXED SIDEBAR + STICKY TOPBAR
========================================================= */

/* Sidebar stays visible while page scrolls */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;

    width: 260px;
    height: 100vh;

    z-index: 1000;

    overflow-y: auto;
}


/* Main content moves beside fixed sidebar */
.main-content {
    margin-left: 260px;

    min-height: 100vh;
}


/* Topbar stays visible while scrolling */
.topbar {
    position: sticky;
    top: 0;

    z-index: 900;
}


/* Keep content from creating horizontal overflow */
.content {
    min-width: 0;
}


/* =========================================================
   MOBILE
========================================================= */

@media (max-width: 900px) {

    .sidebar {
        display: none;
    }

    .main-content {
        margin-left: 0;
    }

}

/* =========================================================
   FOLLOW-UP DATA TABS
========================================================= */

.data-tabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 20px;
    margin-bottom: 0;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 0;
}


.data-tab {
    display: flex;
    align-items: center;
    gap: 8px;

    border: none;

    background: #f1f3f5;
    color: #374151;

    padding: 12px 18px;

    border-radius: 7px 7px 0 0;

    cursor: pointer;

    font-size: 14px;
    font-weight: 600;

    transition:
        background 0.2s ease,
        color 0.2s ease,
        transform 0.2s ease;
}


.data-tab:hover {
    background: #e2e8f0;
    color: #1d4ed8;
}


.data-tab.active {
    background: #1d4ed8;
    color: white;
}


.data-tab i {
    font-size: 14px;
}


/* =========================================================
   DATASET INFORMATION
========================================================= */

.dataset-info {
    display: flex;
    justify-content: space-between;
    align-items: center;

    padding: 14px 4px;

    font-size: 14px;
    font-weight: 600;

    color: #374151;
}


.record-count {
    color: #6b7280;
    font-weight: 400;
}


.record-count i {
    margin-right: 5px;
}


/* =========================================================
   TABLE PAGINATION
========================================================= */

.table-pagination {
    display: flex;
    align-items: center;
    justify-content: center;

    gap: 6px;

    margin-top: 20px;
    padding-top: 15px;

    border-top: 1px solid #e5e7eb;
}


.page-button,
.page-number {
    border: none;

    background: #f1f3f5;
    color: #374151;

    padding: 8px 12px;

    border-radius: 5px;

    cursor: pointer;

    font-size: 13px;

    transition:
        background 0.2s ease,
        color 0.2s ease;
}


.page-button:hover:not(:disabled),
.page-number:hover {
    background: #dbeafe;
    color: #1d4ed8;
}


.page-number.active {
    background: #1d4ed8;
    color: white;
}


.page-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}


.page-numbers {
    display: flex;
    gap: 4px;
}


/* =========================================================
   DARK MODE
========================================================= */

body.dark .data-tabs {
    border-bottom-color: #374151;
}


body.dark .data-tab {
    background: #2d333b;
    color: #d1d5db;
}


body.dark .data-tab:hover {
    background: #3a414b;
    color: #60a5fa;
}


body.dark .data-tab.active {
    background: #2563eb;
    color: white;
}


body.dark .dataset-info {
    color: #e5e7eb;
}


body.dark .record-count {
    color: #9ca3af;
}


body.dark .table-pagination {
    border-top-color: #374151;
}


body.dark .page-button,
body.dark .page-number {
    background: #2d333b;
    color: #d1d5db;
}


body.dark .page-button:hover:not(:disabled),
body.dark .page-number:hover {
    background: #374151;
    color: #60a5fa;
}


body.dark .page-number.active {
    background: #2563eb;
    color: white;
}

.table-actions {
    margin-top: 30px;
    padding: 5px 0 5px;
    gap: 18px;
}

.table-actions .card-btn {
    padding: 13px 22px;
}

#calendar {
    margin-top: 20px;
    background: white;
    padding: 15px;
    border-radius: 10px;
}

.dark #calendar {
    background: #1e293b;
    color: white;
}

.fc {
    font-family: Arial, sans-serif;
}

.fc-toolbar-title {
    font-size: 1.4rem !important;
}

.fc-button {
    background: #2563eb !important;
    border-color: #2563eb !important;
}

.fc-button:hover {
    background: #1d4ed8 !important;
    border-color: #1d4ed8 !important;
}

.calendar-actions {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #ddd;
    display: flex;
    justify-content: flex-end;
}

.dark .calendar-actions {
    border-top-color: #475569;
}

/* =========================================================
   MODAL SYSTEM — CLEAN FINAL VERSION
========================================================= */

/* ---------------------------------------------------------
   MODAL OVERLAY
--------------------------------------------------------- */

#jobModal,
#createJobModal,
#maintenanceModal,
#hseqModal,
#certsModal {
    position: fixed !important;
    inset: 0 !important;

    width: 100% !important;
    height: 100% !important;

    margin: 0 !important;
    padding: 20px !important;

    display: none;
    align-items: center !important;
    justify-content: center !important;

    background: rgba(0, 0, 0, 0.70);

    overflow-y: auto;

    z-index: 99999;

    box-sizing: border-box;
}

/* =========================================================
   MODAL OPEN / CLOSE STATE
========================================================= */

#jobModal,
#createJobModal,
#maintenanceModal,
#hseqModal,
#certsModal {
    display: none;
}

#jobModal.is-open,
#createJobModal.is-open,
#maintenanceModal.is-open,
#hseqModal.is-open,
#certsModal.is-open {
    display: flex !important;
}

/* ---------------------------------------------------------
   MODAL CONTENT
--------------------------------------------------------- */

#createJobModal .create-job-modal-content,
#maintenanceModal .maintenance-modal-content,
#hseqModal .hseq-modal-content,
#certsModal .certs-modal-content {
    position: relative !important;

    width: min(600px, 100%) !important;
    max-width: 600px !important;

    max-height: calc(100vh - 40px) !important;

    margin: 0 !important;

    padding: 30px !important;

    background: var(--card-bg) !important;
    color: var(--text) !important;

    border-radius: 16px !important;

    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45) !important;

    overflow-y: auto;

    box-sizing: border-box;

    transform: none !important;
}

#jobModal .job-modal-content {
    position: relative !important;

    width: min(1000px, 100%) !important;
    max-width: 1000px !important;

    max-height: calc(100vh - 40px) !important;

    margin: 0 !important;

    padding: 30px !important;

    background: var(--card-bg) !important;
    color: var(--text) !important;

    border-radius: 16px !important;

    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45) !important;

    overflow-y: auto;

    box-sizing: border-box;

    transform: none !important;
}

/* ---------------------------------------------------------
   MODAL HEADINGS
--------------------------------------------------------- */

#jobModal h2,
#createJobModal h2,
#maintenanceModal h2,
#hseqModal h2,
#certsModal h2 {
    margin: 0 40px 25px 0;

    display: flex;
    align-items: center;

    gap: 10px;

    color: var(--text);

    font-size: 1.5rem;
}


/* ---------------------------------------------------------
   CLOSE BUTTON
--------------------------------------------------------- */

#jobModal .close-modal,
#createJobModal .create-job-close,
#maintenanceModal .maintenance-close,
#hseqModal .hseq-close,
#certsModal .certs-close {
    position: absolute !important;

    top: 12px !important;
    right: 15px !important;

    width: 38px !important;
    height: 38px !important;

    padding: 0 !important;
    margin: 0 !important;

    border: none !important;
    border-radius: 50% !important;

    background: transparent !important;

    color: var(--muted) !important;

    font-size: 30px !important;
    line-height: 38px !important;

    cursor: pointer;

    z-index: 20;
}

#jobModal .close-modal:hover,
#createJobModal .create-job-close:hover,
#maintenanceModal .maintenance-close:hover,
#hseqModal .hseq-close:hover,
#certsModal .certs-close:hover {
    background: rgba(0, 0, 0, 0.08) !important;
    color: var(--text) !important;
}


/* ---------------------------------------------------------
   FORM GROUPS
--------------------------------------------------------- */

#jobModal .form-group,
#createJobModal .create-form-group,
#maintenanceModal .form-group,
#hseqModal .form-group,
#certsModal .form-group {
    margin-bottom: 18px;
}


/* ---------------------------------------------------------
   LABELS
--------------------------------------------------------- */

#jobModal label,
#createJobModal label,
#maintenanceModal label,
#hseqModal label,
#certsModal label {
    display: block;

    margin-bottom: 7px;

    font-weight: 600;

    color: var(--text);
}


/* ---------------------------------------------------------
   INPUTS
--------------------------------------------------------- */

#jobModal input,
#jobModal select,
#jobModal textarea,

#createJobModal input,
#createJobModal select,
#createJobModal textarea,

#maintenanceModal input,
#maintenanceModal select,
#maintenanceModal textarea,

#hseqModal input,
#hseqModal select,
#hseqModal textarea,

#certsModal input,
#certsModal select,
#certsModal textarea {
    width: 100% !important;

    padding: 11px 12px !important;

    margin: 0 !important;

    border: 1px solid #d1d5db !important;

    border-radius: 8px !important;

    background: var(--bg) !important;
    color: var(--text) !important;

    font-family: inherit;

    font-size: 15px;

    box-sizing: border-box;

    outline: none;
}


/* ---------------------------------------------------------
   TEXTAREA
--------------------------------------------------------- */

#jobModal textarea,
#createJobModal textarea,
#maintenanceModal textarea,
#hseqModal textarea,
#certsModal textarea {
    min-height: 90px;

    resize: vertical;
}


/* ---------------------------------------------------------
   FOCUS
--------------------------------------------------------- */

#jobModal input:focus,
#jobModal select:focus,
#jobModal textarea:focus,

#createJobModal input:focus,
#createJobModal select:focus,
#createJobModal textarea:focus,

#maintenanceModal input:focus,
#maintenanceModal select:focus,
#maintenanceModal textarea:focus,

#hseqModal input:focus,
#hseqModal select:focus,
#hseqModal textarea:focus,

#certsModal input:focus,
#certsModal select:focus,
#certsModal textarea:focus {
    border-color: var(--primary) !important;

    box-shadow:
        0 0 0 2px rgba(107, 49, 41, 0.12) !important;
}


/* ---------------------------------------------------------
   ACTION AREAS
--------------------------------------------------------- */

#jobModal .form-actions,
#createJobModal .create-form-actions,
#maintenanceModal .maintenance-actions,
#maintenanceModal .form-actions,
#hseqModal .form-actions,
#certsModal .form-actions {
    display: flex;

    justify-content: flex-end;
    align-items: center;

    gap: 10px;

    margin-top: 25px;
}


/* ---------------------------------------------------------
   MODAL BUTTONS
--------------------------------------------------------- */

#jobModal .form-actions button,
#createJobModal .create-form-actions button,
#maintenanceModal .maintenance-actions button,
#maintenanceModal .form-actions button,
#hseqModal .form-actions button,
#certsModal .form-actions button {
    padding: 11px 20px;

    border: none;
    border-radius: 8px;

    font-family: inherit;
    font-size: 15px;
    font-weight: 600;

    cursor: pointer;

    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease,
        background 0.2s ease;
}


/* ---------------------------------------------------------
   CANCEL
--------------------------------------------------------- */

#jobModal .cancel-btn,
#createJobModal .create-cancel-btn,
#maintenanceModal .cancel-btn,
#maintenanceModal .maintenance-cancel-btn,
#hseqModal .cancel-btn,
#certsModal .cancel-btn {
    background: #e5e7eb !important;
    color: #374151 !important;
}

#jobModal .cancel-btn:hover,
#createJobModal .create-cancel-btn:hover,
#maintenanceModal .cancel-btn:hover,
#maintenanceModal .maintenance-cancel-btn:hover,
#hseqModal .cancel-btn:hover,
#certsModal .cancel-btn:hover {
    background: #d1d5db !important;
    transform: translateY(-1px);
}


/* ---------------------------------------------------------
   SAVE / CREATE
--------------------------------------------------------- */

#jobModal .save-btn,
#createJobModal .create-save-btn,
#maintenanceModal .save-btn,
#maintenanceModal .maintenance-save-btn,
#hseqModal .save-btn,
#certsModal .save-btn {
    background: linear-gradient(
        135deg,
        var(--primary),
        var(--accent)
    ) !important;

    color: white !important;
}

#jobModal .save-btn:hover,
#createJobModal .create-save-btn:hover,
#maintenanceModal .save-btn:hover,
#maintenanceModal .maintenance-save-btn:hover,
#hseqModal .save-btn:hover,
#certsModal .save-btn:hover {
    transform: translateY(-1px);

    box-shadow:
        0 5px 12px rgba(0, 0, 0, 0.15);
}


/* ---------------------------------------------------------
   DARK MODE
--------------------------------------------------------- */

body.dark #jobModal input,
body.dark #jobModal select,
body.dark #jobModal textarea,

body.dark #createJobModal input,
body.dark #createJobModal select,
body.dark #createJobModal textarea,

body.dark #maintenanceModal input,
body.dark #maintenanceModal select,
body.dark #maintenanceModal textarea,

body.dark #hseqModal input,
body.dark #hseqModal select,
body.dark #hseqModal textarea,

body.dark #certsModal input,
body.dark #certsModal select,
body.dark #certsModal textarea {
    background: #0f172a !important;

    border-color: #475569 !important;

    color: #f8fafc !important;
}

body.dark #jobModal .cancel-btn,
body.dark #createJobModal .create-cancel-btn,
body.dark #maintenanceModal .cancel-btn,
body.dark #maintenanceModal .maintenance-cancel-btn,
body.dark #hseqModal .cancel-btn,
body.dark #certsModal .cancel-btn {
    background: #334155 !important;
    color: #e2e8f0 !important;
}

body.dark #jobModal .close-modal:hover,
body.dark #createJobModal .create-job-close:hover,
body.dark #maintenanceModal .maintenance-close:hover,
body.dark #hseqModal .hseq-close:hover,
body.dark #certsModal .certs-close:hover {
    background: #334155 !important;
    color: white !important;
}


/* ---------------------------------------------------------
   MOBILE
--------------------------------------------------------- */

@media (max-width: 600px) {

    #jobModal,
    #createJobModal,
    #maintenanceModal,
    #hseqModal,
    #certsModal {
        padding: 10px !important;
    }

    #jobModal .job-modal-content,
    #createJobModal .create-job-modal-content,
    #maintenanceModal .maintenance-modal-content,
    #hseqModal .hseq-modal-content,
    #certsModal .certs-modal-content {
        width: 100% !important;

        max-width: 100% !important;

        max-height: calc(100vh - 20px) !important;

        padding: 22px !important;
    }

    #jobModal .form-actions,
    #createJobModal .create-form-actions,
    #maintenanceModal .maintenance-actions,
    #maintenanceModal .form-actions,
    #hseqModal .form-actions,
    #certsModal .form-actions {
        flex-direction: column;

        align-items: stretch;
    }

    #jobModal .form-actions button,
    #createJobModal .create-form-actions button,
    #maintenanceModal .maintenance-actions button,
    #maintenanceModal .form-actions button,
    #hseqModal .form-actions button,
    #certsModal .form-actions button {
        width: 100%;
    }
}

.job-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: repeat(5, auto);
    gap: 15px;
    margin-bottom: 20px;
}

.job-info-grid .form-group {
    margin-bottom: 0;
}

.job-info-grid input[readonly] {
    background-color: #f3f4f6;
    color: #374151;
    cursor: not-allowed;
    border: 1px solid #d1d5db;
}

.dark .job-info-grid input[readonly] {
    background-color: #1f2937;
    color: #e5e7eb;
    border-color: #374151;
}

.job-comments {
    width: 100%;
}

/* =========================================================
   JOBS MODAL — OPEN / CLOSE ONLY
========================================================= */

.jobs-modal {
    position: fixed !important;
    inset: 0 !important;

    width: 100vw !important;
    height: 100vh !important;

    display: none !important;

    align-items: center;
    justify-content: center;

    padding: 20px;

    background: rgba(0, 0, 0, 0.70);

    z-index: 999999 !important;

    overflow-y: auto;
    box-sizing: border-box;
}

/* OPEN */
.jobs-modal.is-open {
    display: flex !important;
}

/* CLOSED */
.jobs-modal:not(.is-open) {
    display: none !important;
}


/* Modal content */

.jobs-modal-content {
    position: relative;

    width: min(1100px, 95vw);
    max-height: 90vh;

    background: #ffffff;

    border-radius: 14px;

    overflow: hidden;

    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.35);
}


/* Close button */

.jobs-close {
    position: absolute !important;

    top: 10px !important;
    right: 10px !important;

    width: 45px !important;
    height: 45px !important;

    display: flex !important;

    align-items: center;
    justify-content: center;

    padding: 0 !important;
    margin: 0 !important;

    border: 0 !important;

    background: transparent !important;

    color: #555;

    font-size: 32px;

    line-height: 1;

    cursor: pointer;

    z-index: 1000001 !important;

    pointer-events: auto !important;
}

.jobs-close:hover {
    color: #dc2626;
}


/* =========================================================
   JOB LIST
========================================================= */

.jobs-list {

    padding: 20px 25px 30px;

    overflow-y: auto;

}


/* =========================================================
   JOB CARD
========================================================= */

.job-list-card {

    position: relative;

    background: #ffffff;

    border: 1px solid #e5e7eb;

    border-left: 5px solid #2563eb;

    border-radius: 10px;

    padding: 18px;

    margin-bottom: 15px;

    cursor: pointer;

    transition:
        transform 0.15s ease,
        box-shadow 0.15s ease;

}


.job-list-card:hover {

    transform: translateY(-2px);

    box-shadow:
        0 8px 25px rgba(0,0,0,0.10);

}


/* =========================================================
   TOP
========================================================= */

.job-list-top {

    display: flex;

    justify-content: space-between;

    gap: 20px;

}


.job-list-date {

    display: inline-block;

    font-size: 13px;

    font-weight: 600;

    color: #2563eb;

    margin-bottom: 5px;

}


.job-list-date i {

    margin-right: 5px;

}


.job-list-card h3 {

    margin: 2px 0 4px;

    font-size: 18px;

    color: #111827;

}


.job-number {

    font-size: 13px;

    color: #6b7280;

}


.job-type {

    height: fit-content;

    padding: 6px 12px;

    border-radius: 20px;

    background: #eff6ff;

    color: #2563eb;

    font-size: 12px;

    font-weight: 700;

}


/* =========================================================
   DETAILS GRID
========================================================= */

.job-list-details {

    display: grid;

    grid-template-columns:
        repeat(3, 1fr);

    gap: 12px;

    margin-top: 18px;

    padding-top: 15px;

    border-top: 1px solid #f0f0f0;

}


.job-list-details div {

    display: flex;

    flex-direction: column;

    gap: 3px;

}


.job-list-details strong {

    font-size: 11px;

    text-transform: uppercase;

    letter-spacing: 0.4px;

    color: #9ca3af;

}


.job-list-details span {

    font-size: 14px;

    color: #374151;

}


.critical {

    color: #dc2626 !important;

    font-weight: 700;

}


.non-critical {

    color: #16a34a !important;

    font-weight: 600;

}


/* =========================================================
   NOTES
========================================================= */

.job-list-notes {

    margin-top: 15px;

    padding: 12px;

    background: #f9fafb;

    border-radius: 7px;

}


.job-list-notes strong {

    font-size: 12px;

    color: #6b7280;

}


.job-list-notes p {

    margin: 5px 0 0;

    font-size: 13px;

    line-height: 1.5;

    color: #4b5563;

}


/* =========================================================
   VIEW BUTTON
========================================================= */

.view-job-btn {

    margin-top: 15px;

    padding: 8px 14px;

    border: none;

    border-radius: 6px;

    background: #2563eb;

    color: white;

    font-weight: 600;

    cursor: pointer;

}


.view-job-btn:hover {

    background: #1d4ed8;

}


/* =========================================================
   NO JOBS
========================================================= */

.no-jobs {

    text-align: center;

    padding: 60px 20px;

    color: #6b7280;

}


.no-jobs i {

    font-size: 45px;

    color: #9ca3af;

    margin-bottom: 15px;

}


.no-jobs h3 {

    margin: 0 0 8px;

    color: #374151;

}


/* =========================================================
   DARK MODE
========================================================= */

body.dark .jobs-modal-content {

    background: #1f2937;

    color: #f9fafb;

}


body.dark .jobs-modal-header {

    border-bottom-color: #374151;

}


body.dark .jobs-modal-header h2 {

    color: #f9fafb;

}


body.dark .jobs-modal-header p {

    color: #9ca3af;

}


body.dark .jobs-close {

    color: #d1d5db;

}


body.dark .job-list-card {

    background: #111827;

    border-color: #374151;

}


body.dark .job-list-card h3 {

    color: #f9fafb;

}


body.dark .job-number {

    color: #9ca3af;

}


body.dark .job-list-details {

    border-top-color: #374151;

}


body.dark .job-list-details span {

    color: #d1d5db;

}


body.dark .job-list-notes {

    background: #1f2937;

}


body.dark .job-list-notes p {

    color: #d1d5db;

}


/* =========================================================
   MOBILE
========================================================= */

@media (max-width: 700px) {

    .jobs-modal {

        padding: 10px;

    }


    .jobs-modal-content {

        width: 100%;

        max-height: 95vh;

    }


    .job-list-top {

        flex-direction: column;

    }


    .job-type {

        width: fit-content;

    }


    .job-list-details {

        grid-template-columns: repeat(2, 1fr);

    }

}

/* =========================================================
   JOBS MODAL
========================================================= */

.jobs-modal {
    display: none;
    position: fixed;
    inset: 0;

    width: 100%;
    height: 100%;

    background: rgba(0, 0, 0, 0.55);

    align-items: center;
    justify-content: center;

    padding: 30px;

    box-sizing: border-box;

    z-index: 9999;
}

.jobs-modal.is-open {
    display: flex;
}


.jobs-modal-content {
    width: min(1100px, 95vw);
    max-height: 90vh;

    background: #ffffff;

    border-radius: 14px;

    padding: 28px;

    box-sizing: border-box;

    overflow-y: auto;

    position: relative;

    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}


.jobs-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    margin-bottom: 24px;

    padding-right: 45px;
}


.jobs-modal-header h2 {
    margin: 0 0 5px 0;
}


.jobs-modal-header p {
    margin: 0;

    color: #6b7280;
}


/* =====================================================
   CLOSE BUTTON
===================================================== */

.jobs-close {
    position: absolute;

    top: 18px;
    right: 20px;

    width: 38px;
    height: 38px;

    border: none;

    border-radius: 50%;

    background: #f3f4f6;

    color: #374151;

    font-size: 24px;

    cursor: pointer;

    display: flex;
    align-items: center;
    justify-content: center;
}

.jobs-close:hover {
    background: #e5e7eb;
}


/* =====================================================
   JOB LIST
===================================================== */

.jobs-list {
    display: flex;
    flex-direction: column;

    gap: 16px;

    width: 100%;
}


/* =====================================================
   JOB CARD
===================================================== */

.job-list-card {
    width: 100%;

    box-sizing: border-box;

    background: #ffffff;

    border: 1px solid #e5e7eb;

    border-left: 5px solid #2563eb;

    border-radius: 10px;

    padding: 20px;

    cursor: pointer;

    transition:
        transform 0.15s ease,
        box-shadow 0.15s ease,
        background 0.15s ease;
}

.job-list-card:hover {
    transform: translateY(-2px);

    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.10);

    background: #fafafa;
}


/* =====================================================
   TOP SECTION
===================================================== */

.job-list-top {
    display: flex;

    justify-content: space-between;
    align-items: flex-start;

    gap: 20px;

    margin-bottom: 18px;
}


.job-list-title {
    min-width: 0;
}


.job-list-date {
    display: block;

    font-size: 13px;

    color: #6b7280;

    margin-bottom: 5px;
}


.job-list-title h3 {
    margin: 0 0 5px 0;

    font-size: 18px;

    line-height: 1.3;

    color: #111827;
}


.job-number {
    display: inline-block;

    font-size: 12px;

    color: #6b7280;

    font-weight: 600;
}


.job-type {
    flex-shrink: 0;

    padding: 6px 10px;

    border-radius: 999px;

    background: #eff6ff;

    color: #2563eb;

    font-size: 12px;

    font-weight: 700;
}


/* =====================================================
   DETAILS GRID
===================================================== */

.job-list-details {
    display: grid;

    grid-template-columns:
        repeat(3, minmax(0, 1fr));

    gap: 14px;

    padding: 16px 0;

    border-top: 1px solid #e5e7eb;

    border-bottom: 1px solid #e5e7eb;
}


.job-detail {
    min-width: 0;

    display: flex;
    flex-direction: column;

    gap: 4px;
}


.job-detail strong {
    font-size: 11px;

    text-transform: uppercase;

    letter-spacing: 0.04em;

    color: #6b7280;
}


.job-detail span {
    font-size: 14px;

    color: #111827;

    overflow-wrap: anywhere;
}


/* =====================================================
   CRITICALITY
===================================================== */

.job-detail span.critical {
    color: #dc2626;

    font-weight: 700;
}


.job-detail span.non-critical {
    color: #16a34a;

    font-weight: 700;
}


/* =====================================================
   NOTES
===================================================== */

.job-list-notes {
    margin-top: 16px;
}


.job-list-notes strong {
    display: block;

    font-size: 12px;

    text-transform: uppercase;

    color: #6b7280;

    margin-bottom: 5px;
}


.job-list-notes p {
    margin: 0;

    color: #374151;

    font-size: 14px;

    line-height: 1.5;
}


/* =====================================================
   VIEW BUTTON
===================================================== */

.view-job-btn {
    margin-top: 16px;

    border: none;

    border-radius: 7px;

    background: #2563eb;

    color: white;

    padding: 9px 14px;

    font-size: 13px;

    font-weight: 600;

    cursor: pointer;
}

.view-job-btn:hover {
    background: #1d4ed8;
}


/* =====================================================
   NO JOBS
===================================================== */

.no-jobs {
    text-align: center;

    padding: 60px 20px;

    color: #6b7280;
}

.no-jobs i {
    font-size: 40px;

    margin-bottom: 15px;

    color: #9ca3af;
}

.no-jobs h3 {
    margin: 0 0 8px 0;

    color: #374151;
}

.no-jobs p {
    margin: 0;
}


/* =====================================================
   DARK MODE
===================================================== */

body.dark .jobs-modal-content {
    background: #1f2937;
}

body.dark .job-list-card {
    background: #111827;

    border-color: #374151;
}

body.dark .job-list-card:hover {
    background: #172033;
}

body.dark .job-list-title h3,
body.dark .job-detail span {
    color: #f9fafb;
}

body.dark .job-list-details {
    border-color: #374151;
}

body.dark .job-list-notes p {
    color: #d1d5db;
}

body.dark .jobs-modal-header p,
body.dark .job-list-date,
body.dark .job-number,
body.dark .job-detail strong {
    color: #9ca3af;
}

body.dark .jobs-close {
    background: #374151;
    color: #f9fafb;
}


/* =====================================================
   MOBILE
===================================================== */

@media (max-width: 700px) {

    .jobs-modal {
        padding: 12px;
    }

    .jobs-modal-content {
        width: 100%;
        max-height: 94vh;

        padding: 20px;
    }

    .job-list-details {
        grid-template-columns: 1fr 1fr;
    }

    .job-list-top {
        flex-direction: column;

        gap: 10px;
    }

}


@media (max-width: 450px) {

    .job-list-details {
        grid-template-columns: 1fr;
    }

}

/* =========================================================
   JOBS MODAL — FINAL OPEN / CLOSE FIX
========================================================= */

/* CLOSED */
#jobsModal {
    display: none !important;
}

/* OPEN — class-based */
#jobsModal.is-open {
    display: flex !important;
}

/* OPEN — hidden attribute removed */
#jobsModal:not([hidden]) {
    display: flex !important;
}

/* CLOSED — hidden attribute wins */
#jobsModal[hidden] {
    display: none !important;
}

/* ================= MAINTENANCE TABLE ================= */

.maintenance-section {
    margin-top: 30px;
}

.section-header {
    margin-bottom: 15px;
}

.section-header h2 {
    margin: 0;
    font-size: 22px;
}

.table-container {
    width: 100%;
    overflow-x: auto;
    background: #ffffff;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.maintenance-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 700px;
}

.maintenance-table th {
    background: #1f3c5b;
    color: #ffffff;
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
}

.maintenance-table td {
    padding: 13px 16px;
    border-bottom: 1px solid #e5e7eb;
    color: #333333;
}

.maintenance-table tbody tr:hover {
    background: #f5f8fb;
}

.maintenance-table tbody tr:last-child td {
    border-bottom: none;
}

/* ================= DARK MODE ================= */

body.dark .table-container {
    background: #1e293b;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

body.dark .maintenance-table th {
    background: #0f172a;
}

body.dark .maintenance-table td {
    color: #e2e8f0;
    border-bottom-color: #334155;
}

body.dark .maintenance-table tbody tr:hover {
    background: #273449;
}

/* =========================================================
   READ ONLY JOB INFORMATION
========================================================= */

.readonly-field input {
    background-color: #e5e7eb;
    color: #6b7280;
    border: 1px solid #d1d5db;
    cursor: not-allowed;
}

/* Make the labels slightly muted as well */
.readonly-field label {
    color: #6b7280;
}

/* Prevent the browser from making the field look active */
.readonly-field input:focus {
    outline: none;
    box-shadow: none;
    border-color: #d1d5db;
}


/* =========================================================
   DARK MODE
========================================================= */

body.dark .readonly-field input {
    background-color: #374151;
    color: #9ca3af;
    border-color: #4b5563;
}

body.dark .readonly-field label {
    color: #9ca3af;
}

body.dark .readonly-field input:focus {
    border-color: #4b5563;
}
.job-filter {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.job-filter label {
    font-weight: 600;
}

.job-filter select {
    min-width: 200px;
    padding: 10px 12px;
    border-radius: 6px;
    border: 1px solid #475569;
    background: #0f172a;
    color: white;
}
/* =========================================================
   COMPACT JOB HISTORY
========================================================= */

.history-entry {
    height: auto !important;
    min-height: 0 !important;
}

.history-entry-body {
    display: none !important;

    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;

    margin: 0 !important;
    padding: 12px 18px 14px 18px !important;

    position: static !important;

    text-align: left !important;

    border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
}

.history-entry.open .history-entry-body {
    display: block !important;

    height: auto !important;
    min-height: 0 !important;
}

.history-entry-comments {
    display: block !important;

    position: static !important;

    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;

    margin: 0 !important;
    padding: 0 !important;

    text-align: left !important;

    line-height: 1.45 !important;

    white-space: normal !important;
}

.history-comment-text {
    display: block;
    white-space: pre-wrap;
}

.history-entry-comments strong {
    display: block !important;

    margin: 0 0 5px 0 !important;
    padding: 0 !important;

    text-align: left !important;

    font-size: 12px !important;

    color: #94a3b8 !important;

    text-transform: uppercase !important;

    letter-spacing: 0.05em !important;
}

/* =========================================================
   EXPORT TO EXCEL
========================================================= */

.export-container {
    display: flex;
    justify-content: flex-end;
    margin-top: 15px;
}

.export-excel-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;

    padding: 10px 16px;

    border: none;
    border-radius: 6px;

    background: #16a34a;
    color: white;

    font-size: 14px;
    font-weight: 600;

    cursor: pointer;

    transition:
        background 0.2s ease,
        transform 0.1s ease;
}

.export-excel-btn:hover {
    background: #15803d;
}

.export-excel-btn:active {
    transform: translateY(1px);
}

.export-excel-btn i {
    font-size: 16px;
}

/* =========================================================
   SEARCH
========================================================= */

.job-search {

    width: 320px;

    padding: 10px 12px;

    border-radius: 6px;

    border: 1px solid #475569;

    background: #0f172a;
    color: white;

    font-size: 14px;

    outline: none;
}

.job-search::placeholder {
    color: #94a3b8;
}

.job-search:focus {

    border-color: #3b82f6;

    box-shadow:
        0 0 0 2px
        rgba(59, 130, 246, 0.2);
}


/* LIGHT THEME */

body:not(.dark) .job-search {

    background: white;

    color: #0f172a;

    border-color: #cbd5e1;
}

body:not(.dark) .job-search::placeholder {
    color: #64748b;
}


/* MOBILE */

@media (max-width: 700px) {

    .job-filter {

        flex-direction: column;

        align-items: stretch;

    }

    .job-search,
    .job-filter select {

        width: 100%;

        min-width: 0;

    }

}
/* =========================================================
   POSTPONEMENT HISTORY DROPDOWN
========================================================= */

.postponement-entry {
    height: auto !important;
    min-height: 0 !important;
}


.postponement-entry-header {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    align-items: center;
    gap: 15px;

    padding: 14px 16px;

    cursor: pointer;

    user-select: none;
}


.postponement-entry-header:hover {
    background: rgba(255, 255, 255, 0.03);
}


.postponement-entry-body {
    display: none !important;

    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;

    padding: 16px 18px !important;

    text-align: left !important;

    border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
}


.postponement-entry.open .postponement-entry-body {
    display: block !important;
}


.postponement-chevron {
    transition: transform 0.2s ease;
}


.postponement-entry.open .postponement-chevron {
    transform: rotate(180deg);
}


.postponement-reason strong {
    display: block;

    margin-bottom: 6px;

    font-size: 12px;

    color: #94a3b8;

    text-transform: uppercase;

    letter-spacing: 0.05em;
}


.postponement-reason-text {
    display: block;

    white-space: pre-wrap;

    line-height: 1.45;
}

/* =========================================================
   CALENDAR VESSEL FILTER
========================================================= */

.calendar-vessel-filter {
    height: 38px;
    padding: 0 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: white;
    color: #334155;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

body.dark .calendar-vessel-filter {
    background: #1e293b;
    color: #f8fafc;
    border-color: #475569;
}

.calendar-vessel-filter:focus {
    outline: none;
    border-color: #3b82f6;
}
