/* =========================================================
   MaxLLG GUI
   Main application stylesheet
   ========================================================= */

:root {
    --maxllg-green: #3fae5a;
    --maxllg-green-dark: #318c47;

    --maxllg-blue: #1683a8;
    --maxllg-blue-dark: #126b88;

    --maxllg-navy: #17212b;

    --maxllg-background: #f5f7f9;
    --maxllg-surface: #ffffff;
    --maxllg-border: #dfe5ea;

    --maxllg-text: #263238;
    --maxllg-muted: #6c757d;

    --maxllg-shadow:
        0 2px 8px rgba(0, 0, 0, 0.08);

    --maxllg-shadow-hover:
        0 6px 18px rgba(0, 0, 0, 0.12);

    --maxllg-radius: 8px;
}


/* =========================================================
   General page
   ========================================================= */

html {
    background: var(--maxllg-background);
}

body {
    background: var(--maxllg-background);
    color: var(--maxllg-text);

    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Helvetica,
        Arial,
        sans-serif;

    line-height: 1.5;
}


/* =========================================================
   Main application container
   ========================================================= */

.container {
    width: 100%;
    max-width: 1400px;

    margin-left: auto;
    margin-right: auto;

    padding-left: 24px;
    padding-right: 24px;
}


/* =========================================================
   Navigation
   ========================================================= */

.navbar {
    background-color: var(--maxllg-navy) !important;

    min-height: 60px;

    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.15);
}

.navbar-brand {
    font-size: 1.35rem;
    font-weight: 600;
    letter-spacing: 0.2px;

    margin-right: 28px;
}

.navbar-dark .navbar-nav .nav-link {
    color: rgba(255, 255, 255, 0.82);

    padding-left: 12px;
    padding-right: 12px;

    transition:
        color 0.2s ease,
        background-color 0.2s ease;
}

.navbar-dark .navbar-nav .nav-link:hover {
    color: #ffffff;

    background-color:
        rgba(255, 255, 255, 0.08);

    border-radius: 5px;
}

.navbar-dark .navbar-nav .nav-link:focus {
    color: #ffffff;
}

.nav-link-str {
    color: rgba(255, 255, 255, 0.65);
}


/* =========================================================
   Dropdown menus
   ========================================================= */

.dropdown-menu {
    border: 1px solid var(--maxllg-border);
    border-radius: 7px;

    box-shadow:
        0 5px 15px rgba(0, 0, 0, 0.12);

    padding-top: 6px;
    padding-bottom: 6px;
}

.dropdown-item {
    padding: 8px 16px;

    color: var(--maxllg-text);
}

.dropdown-item:hover,
.dropdown-item:focus {
    background-color: #f1f5f7;
    color: var(--maxllg-text);
}


/* =========================================================
   Headings
   ========================================================= */

h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--maxllg-text);
}

h2 {
    font-weight: 600;
}


/* =========================================================
   MaxLLG buttons
   ========================================================= */

.button,
.button2,
.button3,
.button4,
.button5 {
    border-radius: var(--maxllg-radius);

    transition:
        background-color 0.2s ease,
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        transform 0.2s ease;
}

.button,
.button4 {
    background-color: var(--maxllg-green);
    border-color: var(--maxllg-green);
}

.button2,
.button3 {
    background-color: var(--maxllg-blue);
    border-color: var(--maxllg-blue);
}

.button5 {
    background-color: #dc3545;
    border-color: #dc3545;
}

.button:hover,
.button2:hover,
.button3:hover,
.button4:hover,
.button5:hover {
    color: white;

    transform: translateY(-1px);

    box-shadow:
        var(--maxllg-shadow-hover);
}

.button:hover,
.button4:hover {
    background-color: var(--maxllg-green-dark);
    border-color: var(--maxllg-green-dark);
}

.button2:hover,
.button3:hover {
    background-color: var(--maxllg-blue-dark);
    border-color: var(--maxllg-blue-dark);
}

.button5:hover {
    background-color: #bd2130;
    border-color: #bd2130;
}


/* =========================================================
   Flash messages
   ========================================================= */

.flashes {
    background-color: var(--maxllg-blue);

    color: white;
    font-weight: 500;

    border-radius: var(--maxllg-radius);

    padding: 12px 16px;

    margin-bottom: 20px;

    box-shadow: var(--maxllg-shadow);
}

ul.flash {
    padding-left: 24px;
    margin-top: 0;
    margin-bottom: 0;
}

.closebtn {
    margin-left: 15px;

    color: white;

    float: right;

    font-size: 24px;
    line-height: 20px;

    cursor: pointer;

    opacity: 0.8;

    transition:
        opacity 0.2s ease;
}

.closebtn:hover {
    color: white;
    opacity: 1;
}


/* =========================================================
   Tables
   ========================================================= */

table.dataTable {
    background-color: var(--maxllg-surface);

    border: 1px solid var(--maxllg-border);

    border-radius: var(--maxllg-radius);

    overflow: hidden;
}

table.dataTable tbody tr:hover {
    background-color: #f5f8fa !important;
}


/* =========================================================
   Footer
   ========================================================= */

.footer {
    color: var(--maxllg-muted);
    border-top: 1px solid var(--maxllg-border);

    margin-top: 0;

    padding-top: 16px;
    padding-bottom: 16px;

    background-color: var(--maxllg-background);
    box-sizing: border-box;
}

.footer a {
    color: var(--maxllg-blue);
}

.footer a:hover {
    color: var(--maxllg-blue-dark);
}

/* =========================================================
   Workflow pages
   ========================================================= */

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;

    margin-top: 15px;
    margin-bottom: 25px;
}

.page-header h2 {
    margin: 0 0 6px 0;
    font-weight: 600;
}

.page-header p {
    margin: 0;
    color: var(--maxllg-muted);
}


/* ---------------------------------------------------------
   Workflow cards
   --------------------------------------------------------- */

.workflow-card {
    background: var(--maxllg-surface);

    border: 1px solid var(--maxllg-border);
    border-radius: var(--maxllg-radius);

    box-shadow: var(--maxllg-shadow);

    padding: 24px;

    margin-bottom: 22px;
}

.workflow-card-header {
    display: flex;
    align-items: flex-start;

    margin-bottom: 22px;
}

.workflow-card-header h3 {
    margin: 0 0 5px 0;

    font-size: 1.15rem;
    font-weight: 600;
}

.workflow-card-header p {
    margin: 0;

    color: var(--maxllg-muted);
}


.workflow-card-icon {
    width: 42px;
    height: 42px;

    flex-shrink: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    margin-right: 14px;

    border-radius: 8px;

    background: #eaf5f8;
    color: var(--maxllg-blue);

    font-size: 20px;
    font-weight: 600;
}


/* ---------------------------------------------------------
   Upload controls
   --------------------------------------------------------- */

.upload-controls {
    display: flex;
    align-items: center;

    gap: 12px;
}

.file-input-wrapper {
    flex: 1;
}

.file-input-wrapper input[type="file"] {
    height: auto;

    padding: 8px 12px;

    border: 1px solid var(--maxllg-border);
    border-radius: 6px;

    background: #fafbfc;
}

.form-help {
    margin-top: 9px;

    color: var(--maxllg-muted);

    font-size: 0.85rem;
}


/* ---------------------------------------------------------
   Information notice
   --------------------------------------------------------- */

.info-notice {
    display: flex;
    align-items: flex-start;

    gap: 10px;

    margin-bottom: 20px;

    padding: 12px 15px;

    background: #f5f8fa;

    border-left: 4px solid var(--maxllg-blue);
    border-radius: 5px;

    color: var(--maxllg-text);

    font-size: 0.9rem;
}

.info-notice strong {
    white-space: nowrap;

    color: var(--maxllg-blue-dark);
}


/* ---------------------------------------------------------
   Table
   --------------------------------------------------------- */

.table-wrapper {
    overflow-x: auto;
}

table.dataTable {
    width: 100% !important;
}

table.dataTable thead th {
    background-color: #f5f7f9;

    color: var(--maxllg-text);

    font-weight: 600;

    border-bottom: 1px solid var(--maxllg-border);
}

table.dataTable tbody td {
    vertical-align: middle;
}

table.dataTable tbody tr:hover {
    background-color: #f7fafb !important;
}


/* ---------------------------------------------------------
   Table action buttons
   --------------------------------------------------------- */

table.dataTable .button,
table.dataTable .button2 {
    display: inline-block;

    padding: 6px 12px;

    font-size: 0.85rem;

    text-decoration: none;

    white-space: nowrap;
}

/* =========================================================
   Constants / parameter entry
   ========================================================= */

.constants-table {
    width: 100%;

    border-collapse: separate;
    border-spacing: 0;

    background: var(--maxllg-surface);
}

.constants-table thead th {
    padding: 12px 14px;

    background: #f5f7f9;

    color: var(--maxllg-text);

    font-size: 0.9rem;
    font-weight: 600;

    text-align: left;

    border-bottom: 1px solid var(--maxllg-border);
}

.constants-table thead th:first-child {
    border-top-left-radius: 6px;
}

.constants-table thead th:last-child {
    border-top-right-radius: 6px;
}

.constants-table tbody td {
    padding: 12px 14px;

    border-bottom: 1px solid #edf0f2;

    vertical-align: middle;
}

.constants-table tbody tr:last-child td {
    border-bottom: none;
}

.constants-table tbody tr:hover {
    background-color: #fafcfd;
}


/* ---------------------------------------------------------
   Parameter inputs
   --------------------------------------------------------- */

.constants-table input[type="number"],
.constants-table input[type="text"] {
    width: 100%;
    max-width: 180px;

    padding: 7px 9px;

    border: 1px solid var(--maxllg-border);
    border-radius: 5px;

    background: #ffffff;

    color: var(--maxllg-text);

    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}

.constants-table input[type="number"]:focus,
.constants-table input[type="text"]:focus {
    border-color: var(--maxllg-blue);

    outline: none;

    box-shadow:
        0 0 0 2px rgba(22, 131, 168, 0.12);
}


/* ---------------------------------------------------------
   Material rows
   --------------------------------------------------------- */

.material-colour {
    min-width: 100px;
}

.material-colour-box {
    box-shadow:
        inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}


/* ---------------------------------------------------------
   Additional settings
   --------------------------------------------------------- */

.constants-table .settings-row td {
    background: #fafbfc;
}

.constants-table .settings-row td:first-child {
    font-size: 0.9rem;
}

.constants-table .submit-row td {
    padding-top: 18px;
    padding-bottom: 6px;
}


/* ---------------------------------------------------------
   Preview
   --------------------------------------------------------- */

.preview-card {
    margin-top: 22px;
}

.object-preview {
    display: flex;
    align-items: center;
    justify-content: center;

    min-height: 280px;

    padding: 20px;

    background: #fafbfc;

    border: 1px solid var(--maxllg-border);
    border-radius: 7px;

    margin-bottom: 18px;
}

.object-preview img {
    max-width: 100%;
    height: auto;

    border: 1px solid var(--maxllg-border);
    border-radius: 4px;

    box-shadow:
        0 2px 6px rgba(0, 0, 0, 0.08);
}


/* ---------------------------------------------------------
   Matrix creation spinner
   --------------------------------------------------------- */

[name="matrix"] img {
    width: 24px;
    height: 24px;

    margin-left: 10px;

    vertical-align: middle;
}

/* =========================================================
   3D CAD editor
   ========================================================= */

.cad-section {
    margin-bottom: 22px;
}

.cad-section-header {
    display: flex;
    align-items: flex-start;

    padding: 18px 22px;

    background: var(--maxllg-navy);

    color: white;

    border-radius:
        var(--maxllg-radius)
        var(--maxllg-radius)
        0
        0;
}

.cad-section-header h3,
.cad-section-header h4 {
    margin: 0;

    color: white;

    font-weight: 600;
}

.cad-section-header p {
    margin: 5px 0 0 0;

    color: rgba(255, 255, 255, 0.75);

    font-size: 0.9rem;
}

.cad-section-body {
    background: var(--maxllg-surface);

    border:
        1px solid var(--maxllg-border);

    border-top: none;

    border-radius:
        0
        0
        var(--maxllg-radius)
        var(--maxllg-radius);

    box-shadow: var(--maxllg-shadow);

    padding: 22px;
}

.cad-section-description {
    margin-bottom: 20px;

    color: var(--maxllg-muted);
}


/* ---------------------------------------------------------
   CAD form rows
   --------------------------------------------------------- */

.cad-form-row {
    display: grid;

    grid-template-columns: 240px 1fr;

    gap: 20px;

    align-items: center;

    padding: 13px 0;

    border-bottom: 1px solid #edf0f2;
}

.cad-form-row:last-child {
    border-bottom: none;
}

.cad-form-label {
    font-weight: 600;

    color: var(--maxllg-text);
}

.cad-form-help {
    margin-top: 4px;

    color: var(--maxllg-muted);

    font-size: 0.84rem;

    font-weight: normal;
}


/* ---------------------------------------------------------
   CAD inputs
   --------------------------------------------------------- */

.cad-section input[type="text"],
.cad-section input[type="number"] {
    padding: 7px 9px;

    border:
        1px solid var(--maxllg-border);

    border-radius: 5px;

    background: white;

    color: var(--maxllg-text);

    max-width: 420px;
}

.cad-section input[type="number"] {
    width: 150px;
}

.cad-section input[type="text"]:focus,
.cad-section input[type="number"]:focus {
    outline: none;

    border-color: var(--maxllg-blue);

    box-shadow:
        0 0 0 2px rgba(22, 131, 168, 0.12);
}


/* ---------------------------------------------------------
   File selection
   --------------------------------------------------------- */

.cad-file-existing {
    display: flex;

    align-items: center;

    gap: 10px;

    margin-bottom: 8px;
}

.cad-file-name {
    max-width: 420px;
}

.cad-file-new {
    display: flex;

    align-items: center;

    gap: 10px;

    flex-wrap: wrap;
}

.cad-file-new input[type="file"] {
    max-width: 420px;

    padding: 5px;

    border:
        1px solid var(--maxllg-border);

    border-radius: 5px;

    background: #fafbfc;
}


/* ---------------------------------------------------------
   Fast method
   --------------------------------------------------------- */

.cad-option {
    display: flex;

    align-items: flex-start;

    gap: 10px;

    padding: 14px;

    background: #f5f8fa;

    border-radius: 6px;

    border-left:
        4px solid var(--maxllg-blue);
}

.cad-option input[type="checkbox"] {
    margin-top: 4px;

    width: 17px;
    height: 17px;
}


/* ---------------------------------------------------------
   Axis diagram
   --------------------------------------------------------- */

.axis-guide {
    margin-top: 15px;

    padding: 15px;

    background: #fafbfc;

    border:
        1px solid var(--maxllg-border);

    border-radius: 6px;

    text-align: center;
}

.axis-guide img {
    max-width: 200px;
    height: auto;

    border: 1px solid var(--maxllg-border);

    border-radius: 4px;
}


/* ---------------------------------------------------------
   Save section
   --------------------------------------------------------- */

.cad-save {
    display: flex;

    align-items: center;

    gap: 20px;

    padding: 20px;

    background: #f5f8fa;

    border:
        1px solid var(--maxllg-border);

    border-radius: var(--maxllg-radius);
}

.cad-save p {
    margin: 0;

    color: var(--maxllg-muted);

    font-size: 0.9rem;
}

/* =========================================================
   Existing 3D CAD form
   ========================================================= */

table.cad-editor,
#form3d > table {
    width: 100%;

    border-collapse: separate;
    border-spacing: 0;

    background: var(--maxllg-surface);

    border:
        1px solid var(--maxllg-border);

    border-radius: var(--maxllg-radius);

    overflow: hidden;

    box-shadow: var(--maxllg-shadow);
}


/* Main section headings */

#form3d .header {
    background: var(--maxllg-navy);

    color: white;
}

#form3d .header h3 {
    margin: 3px 0;

    color: white;

    font-size: 1.05rem;
}


/* Sub headings */

#form3d .sub_header {
    background: #edf4f7;

    color: var(--maxllg-text);

    border-top:
        1px solid var(--maxllg-border);
}

#form3d .sub_header h3,
#form3d .sub_header h4 {
    margin: 4px 0;

    color: var(--maxllg-text);

    font-weight: 600;
}


/* Normal rows */

#form3d .standard {
    background: var(--maxllg-surface);

    color: var(--maxllg-text);
}

#form3d .standard:hover {
    background: #fafcfd;
}


/* Form table cells */

#form3d td,
#form3d th {
    padding: 12px 14px;

    border-bottom:
        1px solid #edf0f2;
}

#form3d tr:last-child td {
    border-bottom: none;
}


/* Labels */

#form3d th {
    width: 240px;

    text-align: left;

    font-weight: 600;

    color: var(--maxllg-text);
}


/* Inputs */

#form3d input[type="text"],
#form3d input[type="number"] {
    padding: 7px 9px;

    border:
        1px solid var(--maxllg-border);

    border-radius: 5px;

    background: white;
}

#form3d input[type="text"]:focus,
#form3d input[type="number"]:focus {
    outline: none;

    border-color: var(--maxllg-blue);

    box-shadow:
        0 0 0 2px rgba(22, 131, 168, 0.12);
}


/* File inputs */

#form3d input[type="file"] {
    padding: 5px;

    border:
        1px solid var(--maxllg-border);

    border-radius: 5px;

    background: #fafbfc;
}


/* Existing readonly filenames */

#form3d input[readonly] {
    background: #f5f7f9;

    color: var(--maxllg-muted);
}


/* Notes / explanatory text */

#form3d em {
    color: var(--maxllg-muted);

    font-size: 0.9rem;

    line-height: 1.5;
}


/* Axis image */

#form3d img {
    border-radius: 4px;
}


/* Save button row */

#form3d input[type="submit"] {
    margin-top: 4px;
}

/* =========================================================
   Run Solver / matrix files
   ========================================================= */

.solver-status {
    margin-bottom: 20px;

    padding: 12px 16px;

    background: #edf6f8;

    border-left: 4px solid var(--maxllg-blue);
    border-radius: 5px;

    color: var(--maxllg-text);
}


/* ---------------------------------------------------------
   Matrix table
   --------------------------------------------------------- */

.solver-table-wrapper {
    overflow-x: auto;

    margin-top: 5px;
}

#targets.solver-table {
    width: 100% !important;

    border-collapse: separate;
    border-spacing: 0;

    font-size: 0.9rem;
}

#targets.solver-table thead th {
    padding: 11px 10px;
    background-color: #f5f7f9;

    color: var(--maxllg-text);

    font-weight: 600;

    border-bottom: 1px solid var(--maxllg-border);

    white-space: nowrap;
}

#targets.solver-table tbody td {
    padding: 10px;

    vertical-align: middle;

    border-bottom: 1px solid #edf0f2;
}

#targets.solver-table tbody tr:hover {
    background: #fafcfd;
}


/* ---------------------------------------------------------
   Matrix thumbnails
   --------------------------------------------------------- */

.matrix-thumbnail {
    width: 70px;
    height: 70px;

    object-fit: contain;

    border: 1px solid var(--maxllg-border);
    border-radius: 5px;

    cursor: pointer;

    background: #fff;
}

.matrix-thumbnail:hover {
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.15);
}


/* ---------------------------------------------------------
   Solver action icons
   --------------------------------------------------------- */

.solver-actions {
    display: flex;

    align-items: center;
    justify-content: center;

    gap: 8px;

    white-space: nowrap;
}

.solver-actions a {
    display: inline-flex;

    align-items: center;
    justify-content: center;
}

.solver-actions img {
    object-fit: contain;

    transition:
        transform 0.15s ease,
        opacity 0.15s ease;
}

.solver-actions a:hover img {
    transform: translateY(-1px);

    opacity: 0.8;
}


/* ---------------------------------------------------------
   Progress
   --------------------------------------------------------- */

.solver-progress {
    text-align: center;

    font-weight: 600;
}

.solver-stopped {
    color: #a94442;
}

.solver-running {
    color: var(--maxllg-blue);
}


/* ---------------------------------------------------------
   Join files
   --------------------------------------------------------- */

.join-card {
    margin-top: 22px;
}

.join-description {
    margin-bottom: 18px;

    color: var(--maxllg-muted);
}

.join-form-row {
    display: flex;

    align-items: center;

    gap: 12px;

    margin-bottom: 10px;
}

.join-form-row label {
    min-width: 130px;

    font-weight: 600;
}

.join-form-row input[type="text"] {
    width: 350px;
    max-width: 100%;

    padding: 8px 10px;

    border:
        1px solid var(--maxllg-border);

    border-radius: 5px;
}

.join-form-row input[type="text"]:focus {
    outline: none;

    border-color: var(--maxllg-blue);

    box-shadow:
        0 0 0 2px rgba(22, 131, 168, 0.12);
}

.join-help {
    margin-left: 142px;

    margin-bottom: 18px;

    color: var(--maxllg-muted);

    font-size: 0.85rem;
}


/* ---------------------------------------------------------
   Upload card
   --------------------------------------------------------- */

.matrix-upload-controls {
    display: flex;

    align-items: center;

    gap: 12px;
}

.matrix-upload-controls input[type="file"] {
    flex: 1;

    padding: 7px 10px;

    border:
        1px solid var(--maxllg-border);

    border-radius: 5px;

    background: #fafbfc;
}

.matrix-upload-help {
    margin-top: 8px;

    color: var(--maxllg-muted);

    font-size: 0.85rem;
}

/* =========================================================
   Batch configuration
   ========================================================= */

.batch-file-info {
    color: var(--maxllg-muted);
    margin-top: -15px;
    margin-bottom: 25px;
}


/* ---------------------------------------------------------
   Batch upload
   --------------------------------------------------------- */

.batch-upload-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.batch-upload-controls input[type="file"] {
    flex: 1;

    padding: 7px 10px;

    border: 1px solid var(--maxllg-border);
    border-radius: 5px;

    background: #fafbfc;
}

.batch-upload-help {
    margin-top: 8px;

    color: var(--maxllg-muted);
    font-size: 0.85rem;
}


/* ---------------------------------------------------------
   Batch editor
   --------------------------------------------------------- */

.batch-editor {
    width: 100%;
}

.batch-general {
    margin-bottom: 25px;
}

.batch-run-control {
    display: flex;
    align-items: center;
    gap: 15px;

    padding: 15px;

    background: #f5f8fa;

    border-left: 4px solid var(--maxllg-blue);
    border-radius: 5px;
}

.batch-run-control label {
    font-weight: 600;
    margin: 0;
}

.batch-run-control input {
    width: 130px;

    padding: 7px 9px;

    border: 1px solid var(--maxllg-border);
    border-radius: 5px;
}

.batch-fields {
    width: 100%;
}

.batch-fields-header {
    display: grid;
    grid-template-columns: 45px 1fr 1fr 1fr;

    gap: 15px;

    padding: 11px 14px;

    background: #f5f7f9;

    border: 1px solid var(--maxllg-border);
    border-radius: 6px 6px 0 0;

    font-size: 0.9rem;
    font-weight: 600;
}

.batch-field-row {
    display: grid;
    grid-template-columns: 45px 1fr 1fr 1fr;

    gap: 15px;

    align-items: center;

    padding: 12px 14px;

    background: white;

    border-left: 1px solid var(--maxllg-border);
    border-right: 1px solid var(--maxllg-border);
    border-bottom: 1px solid #edf0f2;
}

.batch-field-row:last-child {
    border-radius: 0 0 6px 6px;
}

.batch-field-number {
    font-weight: 600;
    color: var(--maxllg-muted);
}

.batch-field-row select,
.batch-field-row input {
    width: 100%;

    padding: 7px 9px;

    border: 1px solid var(--maxllg-border);
    border-radius: 5px;

    background: white;

    color: var(--maxllg-text);
}

.batch-field-row select:focus,
.batch-field-row input:focus,
.batch-run-control input:focus {
    outline: none;

    border-color: var(--maxllg-blue);

    box-shadow:
        0 0 0 2px rgba(22, 131, 168, 0.12);
}


/* ---------------------------------------------------------
   Batch actions
   --------------------------------------------------------- */

.batch-actions {
    display: flex;
    align-items: center;

    gap: 10px;

    margin-top: 20px;
}


/* ---------------------------------------------------------
   Batch validation
   --------------------------------------------------------- */

#errors {
    margin-top: 18px;
}

#errors:empty {
    display: none;
}

#errors.warning {
    padding: 12px 15px;

    background: #fff8e6;

    border-left: 4px solid #e0a800;
    border-radius: 5px;

    color: #664d03;
}

#errors .warning {
    margin-bottom: 0;
}

/* =========================================================
   Keep DataTables inside the content container
   ========================================================= */

.maxllg-output-page {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.maxllg-card {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.maxllg-table-wrap {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
}

/* DataTables wrapper */
.maxllg-table-wrap .dataTables_wrapper {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box;
}

/* The actual DataTable */
.maxllg-table-wrap table.dataTable,
.maxllg-table-wrap table.display {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;

    table-layout: fixed !important;

    box-sizing: border-box;
}

/* Stop long filenames / paths / statuses forcing columns wider */
.maxllg-table-wrap th,
.maxllg-table-wrap td {
    min-width: 0 !important;

    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Keep normal text visually tidy */
.maxllg-table-wrap th {
    white-space: normal !important;
}

/* DataTables generated elements */
.maxllg-table-wrap .dataTables_scroll,
.maxllg-table-wrap .dataTables_scrollHead,
.maxllg-table-wrap .dataTables_scrollBody {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box;
}

/* Don't let the DataTables header become wider than its body */
.maxllg-table-wrap .dataTables_scrollHeadInner,
.maxllg-table-wrap .dataTables_scrollHeadInner table {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
}


/* ---------------------------------------------------------
   Responsive
   --------------------------------------------------------- */

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

    .batch-upload-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .batch-fields-header {
        display: none;
    }

    .batch-field-row {
        grid-template-columns: 35px 1fr;

        gap: 8px;

        padding: 14px;
    }

    .batch-field-row select,
    .batch-field-row input {
        grid-column: 2;
    }

    .batch-field-number {
        grid-row: span 3;
    }

    .batch-run-control {
        align-items: flex-start;
        flex-direction: column;
    }
}

.constants_header, .output_header, .input_header, .boundary_condition, .magnetic header{
    color: white !important;
}


/* ---------------------------------------------------------
   Responsive
   --------------------------------------------------------- */

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

    .matrix-upload-controls {
        flex-direction: column;

        align-items: stretch;
    }

    .join-form-row {
        flex-direction: column;

        align-items: stretch;
    }

    .join-form-row label {
        min-width: 0;
    }

    .join-help {
        margin-left: 0;
    }
}


/* ---------------------------------------------------------
   Responsive
   --------------------------------------------------------- */

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

    .cad-form-row {
        grid-template-columns: 1fr;

        gap: 7px;
    }

    .cad-section-body {
        padding: 17px;
    }

    .cad-file-existing,
    .cad-file-new {
        align-items: stretch;

        flex-direction: column;
    }

}


/* ---------------------------------------------------------
   Responsive constants table
   --------------------------------------------------------- */

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

    .constants-table {
        min-width: 650px;
    }

    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

}


/* ---------------------------------------------------------
   Responsive
   --------------------------------------------------------- */

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

    .upload-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .upload-controls .button2 {
        width: 100%;
    }

    .workflow-card {
        padding: 18px;
    }

    .info-notice {
        flex-direction: column;
        gap: 4px;
    }
}


/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 767px) {

    .container {
        padding-left: 15px;
        padding-right: 15px;
    }

    .navbar-brand {
        margin-right: 10px;
    }

}


/* =========================================================
   DataTables - align table with card's inner content
   ========================================================= */

.maxllg-card .maxllg-table-wrap {
    margin-left: 14px;
    margin-right: 14px;
    width: auto;
}

.maxllg-card .maxllg-table-wrap .dataTables_wrapper {
    width: 100% !important;
    max-width: 100% !important;
}

.maxllg-card .maxllg-table-wrap table.dataTable {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
}

/* =========================================================
   DataTables - allow wide tables to fit the page
   ========================================================= */

.maxllg-table-wrap .dataTables_wrapper {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden;
}

.maxllg-table-wrap table.dataTable {
    width: 100% !important;
    max-width: 100% !important;
    table-layout: fixed !important;
    box-sizing: border-box;
}

/* Allow cell contents to wrap instead of forcing
   the table wider than its container */
.maxllg-table-wrap table.dataTable th,
.maxllg-table-wrap table.dataTable td {
    white-space: normal !important;
    overflow-wrap: anywhere;
    word-break: normal;
    box-sizing: border-box;
}

/* Don't let DataTables' scrolling container
   re-introduce horizontal scrolling */
.maxllg-table-wrap .dataTables_scroll,
.maxllg-table-wrap .dataTables_scrollHead,
.maxllg-table-wrap .dataTables_scrollBody {
    max-width: 100% !important;
    overflow-x: hidden !important;
}

/* =========================================================
   DataTables
   ========================================================= */

.dataTables_wrapper {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/*
 * Allow a table to use its natural width when necessary.
 * If it is wider than the available space, the wrapper
 * becomes horizontally scrollable.
 */
.dataTables_wrapper {
    overflow-x: auto;
}

.dataTables_wrapper table.dataTable {
    width: max-content !important;
    min-width: 100% !important;
    max-width: none !important;
    table-layout: auto !important;
    box-sizing: border-box;
}

/* Normal table cells */
.dataTables_wrapper table.dataTable th,
.dataTables_wrapper table.dataTable td {
    box-sizing: border-box;
    vertical-align: middle;
    white-space: normal;
}

/*
 * Don't let long text force a column indefinitely wide.
 */
.dataTables_wrapper table.dataTable td {
    overflow-wrap: break-word;
}

/* =========================================================
   Matrix Files table
   ========================================================= */

/*
 * Long matrix filenames should wrap.
 */
#targets th:nth-child(2),
#targets td:nth-child(2) {
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
}

/*
 * Keep the small action columns intact.
 */
#targets th:nth-child(8),
#targets td:nth-child(8),
#targets th:nth-child(9),
#targets td:nth-child(9),
#targets th:nth-child(10),
#targets td:nth-child(10),
#targets th:nth-child(11),
#targets td:nth-child(11),
#targets th:nth-child(12),
#targets td:nth-child(12) {
    white-space: nowrap !important;
    text-align: center;
}

/*
 * Keep the thumbnail/icon column sensible.
 */
#targets td:first-child img {
    max-width: 70px;
    height: auto;
}

/* =========================================================
   Join toggle
   ========================================================= */

.join-toggle-bar {
    display: flex;
    justify-content: flex-end;
    margin: 10px 0 12px;
}

.join-toggle {
    display: inline-flex;
    align-items: center;
    gap: 7px;

    padding: 7px 13px;

    border: 1px solid var(--maxllg-border);
    border-radius: 6px;

    background: #ffffff;
    color: var(--maxllg-text);

    font-size: 0.9rem;
    font-weight: 600;

    cursor: pointer;

    transition:
        background-color 0.15s ease,
        border-color 0.15s ease,
        box-shadow 0.15s ease;
}

.join-toggle:hover {
    background: #f5f8fa;
    border-color: var(--maxllg-blue);
}

.join-toggle:focus {
    outline: none;
    border-color: var(--maxllg-blue);
    box-shadow: 0 0 0 2px rgba(22, 131, 168, 0.12);
}

#joinToggleIcon {
    font-size: 1.1rem;
    line-height: 1;
}

/* DataTables row hover */
table.dataTable tbody tr:hover > td,
table.dataTable tbody tr:hover > th {
    background-color: #eef2f5 !important;
}

/* =========================================================
   DataTables - site-wide sorting indicators
   ========================================================= */

table.dataTable thead th.sorting,
table.dataTable thead th.sorting_asc,
table.dataTable thead th.sorting_desc {
    position: relative;
    cursor: pointer;
    padding-right: 28px !important;
    background-image: none !important;
}

/* Unsorted */
table.dataTable thead th.sorting::after {
    content: "↕";
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 13px;
    line-height: 1;
    opacity: 0.45;
}

/* Ascending */
table.dataTable thead th.sorting_asc::after {
    content: "↑";
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 13px;
    line-height: 1;
    opacity: 0.85;
}

/* Descending */
table.dataTable thead th.sorting_desc::after {
    content: "↓";
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 13px;
    line-height: 1;
    opacity: 0.85;
}

/* =========================================================
   Site-wide DataTables header styling
   ========================================================= */

table.dataTable thead th {
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.78rem;
    font-weight: 700;
    white-space: normal;
    vertical-align: middle;
}

/* =========================================================
   Site-wide DataTables sorting indicators
   ========================================================= */

table.dataTable thead th.sorting,
table.dataTable thead th.sorting_asc,
table.dataTable thead th.sorting_desc {
    position: relative;
    cursor: pointer;
    padding-right: 28px !important;
    background-image: none !important;
}

table.dataTable thead th.sorting::after {
    content: "↕";
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 13px;
    line-height: 1;
    opacity: 0.45;
}

table.dataTable thead th.sorting_asc::after {
    content: "↑";
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 13px;
    line-height: 1;
    opacity: 0.85;
}

table.dataTable thead th.sorting_desc::after {
    content: "↓";
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 13px;
    line-height: 1;
    opacity: 0.85;
}

.sorting_1{
    background: #ffffff !important;
}

/* Keep the Matrix Files "File name" header on one line */
#targets.solver-table thead th:nth-child(2) {
    white-space: nowrap !important;
    word-break: normal !important;
    overflow-wrap: normal !important;
}

/* Keep the Join columns compact */
#targets.solver-table thead th:nth-child(8),
#targets.solver-table thead th:nth-child(9) {
    white-space: normal !important;
    width: 70px !important;
    max-width: 70px !important;
    text-align: center;
}

/* ---------------------------------------------------------
   Parameters page - upload / cross-section controls
   --------------------------------------------------------- */

.params-top-row {
    display: flex;
    align-items: stretch;
    gap: 20px;
    margin-bottom: 20px;
}

.params-top-row .params-upload {
    flex: 1 1 auto;
    margin: 0;
}

.params-top-row #cross-section {
    float: none;
    flex: 0 0 190px;
    width: auto !important;
    box-sizing: border-box;
    margin: 0;
    padding: 18px;
    background: var(--maxllg-surface);
    color: var(--maxllg-text);
    border: 1px solid var(--maxllg-border);
    border-left: 4px solid var(--maxllg-green);
    border-radius: var(--maxllg-radius);
    box-shadow: var(--maxllg-shadow);
}

.params-top-row #cross-section h5 {
    margin: 0 0 12px;
    font-weight: 700;
}

.params-top-row #cross-section input[type="number"] {
    width: 82px;
    min-height: 32px;
    box-sizing: border-box;
}

@media (max-width: 700px) {
    .params-top-row {
        flex-direction: column;
    }

    .params-top-row #cross-section {
        flex-basis: auto;
        width: 100% !important;
    }
}

/* Parameters section headers */
.signal,
.signal td,
.signal th,
.boundary_condition,
.boundary_condition td,
.boundary_condition th,
.constants_header,
.constants_header td,
.constants_header th,
.output_header,
.output_header td,
.output_header th,
.magnetic_header,
.magnetic_header td,
.magnetic_header th,
.statistical_header,
.statistical_header td,
.statistical_header th {
    color: #ffffff !important;
}

.footer {
    box-sizing: border-box;
    bottom: 2px;
}
.footer, .footer > .container {
    background: #dddddd !important;
}

.footer {
    padding-top: 0 !important;
}

.login-card {
    max-width: 500px;
    margin: 40px auto;
    padding: 28px 32px;
    background: #ffffff;
    border: 1px solid var(--maxllg-border);
    border-radius: 12px;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
}

.login-card h1 {
    margin-top: 0;
    margin-bottom: 24px;
}

.login-card p {
    margin-bottom: 20px;
}

.login-card input[type="text"],
.login-card input[type="password"] {
    width: 100%;
    box-sizing: border-box;
    margin-top: 6px;
}

.login-card .button2 {
    width: auto;
}

/* =========================================================
   Output table - Display button
   ========================================================= */

table.dataTable .button2,
table.display .button2 {
    display: inline-block !important;

    padding: 7px 13px !important;

    background-color: var(--maxllg-blue) !important;
    border: 1px solid var(--maxllg-blue) !important;
    border-radius: var(--maxllg-radius) !important;

    color: #ffffff !important;

    font-size: 0.85rem;
    font-weight: 600;

    text-decoration: none !important;
    white-space: nowrap;

    cursor: pointer;
}

table.dataTable .button2:hover,
table.display .button2:hover {
    background-color: var(--maxllg-blue-dark) !important;
    border-color: var(--maxllg-blue-dark) !important;
    color: #ffffff !important;
}