@font-face{
    font-family: "Digi";
    src: url('/picoreflow/assets/fonts/digital-7-webfont.eot');
    src: local("Digital 7"),
    url('/picoreflow/assets/fonts/digital-7-webfont.woff') format("woff"),
    url('/picoreflow/assets/fonts/digital-7-webfont.ttf') format("truetype");
}

@font-face{
    font-family: "Tables";
    src: url('/picoreflow/assets/fonts/tables.eot');
    src: local("Tables"),
    url('/picoreflow/assets/fonts/tables.woff') format("woff"),
    url('/picoreflow/assets/fonts/tables.ttf') format("truetype");
}

body {
    background: var(--bg);
    color: var(--fg);
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

:root {
    --bg: #201f1c;
    --fg: #d8d3c5;
    --muted: #8b8989;
    --muted-2: #a8a49a;
    --panel-bg: #3F3E3A;
    --panel-border: #b9b6af;
    --panel-heading-bg: #fafafa;
    --panel-heading-fg: #333;
    --panel-heading-strong: #444;
    --panel-body-bg: rgba(0,0,0,0.25);
    --panel-body-shadow: inset 0 0 42px 0 #000;
    --surface: #2b2a26;
    --surface-2: #33322d;
    --surface-3: #45433c;
    --border: #5a5853;
    --border-soft: rgba(255,255,255,0.07);
    --row-border: #5a5853;
    --hover: rgba(255,255,255,0.04);
    --heading-time-label: #777;
    --heading-time-value: #333;
    --ds-input-bg: #3F3E3A;
    --ds-input-fg: #d8d3c5;
    --ds-input-border: #5a5853;
    --ds-input-shadow: inset 0 0 12px 0 #000;
    --run-green-top: rgba(164,179,87,1);
    --run-green-bottom: rgba(117,137,12,1);
}

:root.light {
    --bg: #efede6;
    --fg: #2c2a26;
    --muted: #7a766e;
    --muted-2: #8f8a80;
    --panel-bg: #ffffff;
    --panel-border: #d6d4cd;
    --panel-heading-bg: #f4f3ef;
    --panel-heading-fg: #333;
    --panel-heading-strong: #444;
    --panel-body-bg: #faf9f6;
    --panel-body-shadow: inset 0 0 30px 0 rgba(0,0,0,0.05);
    --surface: #f2f0eb;
    --surface-2: #eae8e2;
    --surface-3: #dedbd3;
    --border: #d6d4cd;
    --border-soft: rgba(0,0,0,0.08);
    --row-border: #e3e1db;
    --hover: rgba(0,0,0,0.03);
    --heading-time-label: #8a857a;
    --heading-time-value: #333;
    --ds-input-bg: #ffffff;
    --ds-input-fg: #2c2a26;
    --ds-input-border: #c9c6bf;
    --ds-input-shadow: inset 0 0 8px 0 rgba(0,0,0,0.12);
}

/* bootstrap's .text-muted resolves --bs-secondary-color, which defaults
   to a light-theme gray (rgba(33,37,41,.75)) because our custom dark
   theme does not set data-bs-theme=dark. remap it to our own muted
   variable so muted text stays readable on dark panels; light mode
   keeps bootstrap's original value. modals keep their light background
   even in dark mode, so they are exempted and stay with bootstrap's
   darker gray. */
:root:not(.light) .text-muted {
    --bs-secondary-color: var(--muted-2);
}

:root:not(.light) .modal-content .text-muted {
    --bs-secondary-color: rgba(33, 37, 41, 0.75);
}

#theme_toggle {
    margin-left: 8px;
}

/* ---------------------------------------------------------------------------
   Navbar / tabs
--------------------------------------------------------------------------- */

.navbar {
    position: relative;
    box-shadow: 0 2px 10px rgba(0,0,0,0.4);
    border-bottom: 1px solid #000;
}

/* let the tab row wrap below the brand/theme/status cluster instead of
   running under the centered status indicator on narrow screens */
.navbar-expand > .container-fluid {
    flex-wrap: wrap;
    justify-content: flex-start;
}

.navbar-nav {
    margin-left: auto;
}

.conn-indicator {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-left: 10px;
    padding: 3px 10px;
    border-radius: 20px;
    background: rgba(255,255,255,0.07);
    font-size: 12px;
    color: #d8d3c5;
    white-space: nowrap;
    pointer-events: none;
    z-index: 10;
}

.conn-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #f0ad4e;
}

.conn-indicator.connected .conn-dot {
    background: linear-gradient(to bottom, var(--run-green-top) 0%, var(--run-green-bottom) 100%);
}

.conn-indicator.connected {
    color: var(--run-green-top);
}

.conn-indicator.disconnected .conn-dot {
    background: #e5484d;
    animation: conn-blink 1.2s ease-in-out infinite;
}

.conn-indicator.disconnected {
    color: #f0b3b5;
}

@keyframes conn-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.25; }
}

.navbar .nav-link {
    color: #d8d3c5;
    border-radius: 4px;
}

.navbar .nav-link:hover {
    color: #fff;
}

.navbar .nav-link.active {
    color: #fff;
    font-weight: 600;
    background: rgba(255,255,255,0.08);
}

/* ---------------------------------------------------------------------------
   Overview grid
--------------------------------------------------------------------------- */

.overview-grid {
    display: grid;
    grid-template-columns: 1fr;
    align-items: start;
    gap: 12px;
}

.overview-grid > * {
    min-width: 0;
}

.overview-grid.editing {
    grid-template-columns: 1fr;
}

@media (max-width: 991.98px) {
    .overview-grid,
    .overview-grid.editing {
        grid-template-columns: 1fr;
    }
}

#status {
    min-width: 0;
}

.info-list {
    display: flex;
    flex-direction: column;
}

.info-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 0;
    border-bottom: 1px solid var(--border-soft);
}

.info-row:last-of-type {
    border-bottom: none;
}

.info-label {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--muted-2);
    white-space: nowrap;
}

.info-group {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    white-space: nowrap;
    min-width: 0;
}

.info-value {
    font-size: 20px;
    color: var(--fg);
}

.info-value-status {
    font-size: 20px;
    font-weight: 600;
}

.info-unit {
    font-size: 13px;
    color: var(--muted-2);
}

.progress {
    height: 14px;
    background: var(--surface);
    border-radius: 7px;
    margin: 0 14px 14px;
    --bs-progress-bar-bg: #75890c;
}

.progress-bar {
    font-size: 12px;
    border-radius: 7px;
    transition: width 0.3s ease;
}

/* ---------------------------------------------------------------------------
   Main panel
--------------------------------------------------------------------------- */

.panel-default {
    border-radius: 10px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.25);
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
}

.panel-heading {
    background: var(--panel-heading-bg);
    border-radius: 10px 10px 0 0;
    padding: 10px 12px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border-bottom: 1px solid var(--panel-border);
    color: var(--panel-heading-fg);
}

.panel-heading strong {
    color: var(--panel-heading-strong);
}

.panel-heading a {
    color: #1d4e89;
    text-decoration: none;
    font-size: 13px;
}

.panel-heading a:hover {
    text-decoration: underline;
}

#profile_selector {
    display: flex;
    align-items: center;
    gap: 6px;
}

#profile_selector .info-value {
    color: var(--panel-heading-fg);
    font-size: 18px;
    font-weight: 600;
}

#profile_selector .form-select {
    width: 190px;
    border-radius: 5px;
    font-size: 14px;
}

#profile_selector .sim-badge,
#profile_selector .overview-status {
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    padding: 4px 8px;
    white-space: nowrap;
}

.time-left {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    margin-right: 10px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

#overview_heading {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
}

#overview_heading .time-left {
    justify-self: center;
    margin-right: 0;
}

#overview_heading .heading-times {
    justify-self: center;
    display: inline-flex;
    align-items: baseline;
    gap: 20px;
}

#overview_heading #profile_selector {
    justify-self: start;
}

#overview_heading .heading-temps {
    justify-self: end;
    display: inline-flex;
    align-items: baseline;
    gap: 20px;
}

.panel-heading .time-left .info-label {
    color: var(--heading-time-label);
}

.panel-heading .time-left .info-value {
    color: var(--heading-time-value);
    font-size: 18px;
    font-weight: 600;
}

#profile_editor .panel-body {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

#profile_editor .input-group {
    flex-wrap: wrap;
    flex: 1 1 320px;
    max-width: 640px;
}

#profile_editor .input-group .form-control {
    min-width: 120px;
}

#profile_editor #profile_table {
    flex-basis: 100%;
}

.panel-body {
    background: var(--panel-body-bg);
    box-shadow: var(--panel-body-shadow);
    border-radius: 0 0 10px 10px;
    padding: 8px;
}

.graph {
    position: relative;
    width: 100%;
    height: clamp(260px, 48vh, 460px);
}

.panel-footer {
    background: var(--panel-heading-bg);
    border-radius: 0 0 10px 10px;
    padding: 12px;
    border-top: 1px solid var(--panel-border);
}

.panel-footer h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 16px;
    color: var(--panel-heading-strong);
}

.panel-footer .table {
    margin-bottom: 0;
}

.panel-footer .form-control {
    display: inline-block;
    width: auto;
}

.panel-footer .point-input {
    width: 110px;
    font-size: 1.15rem;
}

.ds-trend {
    font-size: 18px;
    text-shadow: 1px 1px 0 rgba(255,255,255,0.25), -1px -1px 0 rgba(0,0,0,0.4);
    color: rgb(233,233,233);
}

.ds-input {
    color: var(--ds-input-fg);
    font-family: "Digi";
    font-size: 22px;
    background: var(--ds-input-bg);
    box-shadow: var(--ds-input-shadow);
    border: 1px solid var(--ds-input-border);
    text-align: right;
}

.ds-input.ds-slope {
    width: 52px;
    flex: 0 0 auto;
}

/* ---------------------------------------------------------------------------
   Profiles tab
--------------------------------------------------------------------------- */

.profile-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--row-border);
    flex-wrap: wrap;
}

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

.profile-row:hover {
    background: var(--hover);
}

.profile-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--fg);
}

.profile-meta {
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px;
}

.profile-tags {
    margin-top: 4px;
}

.profile-tags .badge {
    margin-right: 4px;
    font-weight: 500;
}

.ds-empty {
    color: var(--muted);
    font-style: italic;
    margin: 0;
    padding: 8px 4px;
}

/* ---------------------------------------------------------------------------
   Tuning: stat boxes
--------------------------------------------------------------------------- */

.stats {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
}

.stat-box {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.25);
    flex-wrap: wrap;
    min-width: 0;
    max-width: 100%;
}

.stat-tag {
    font-size: 11px;
    letter-spacing: 0.06em;
    text-align: center;
    color: var(--muted);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 3px 7px;
}

.stat-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4px 10px;
    border-left: 1px solid var(--border);
    min-width: 64px;
}

.stat-top {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
}

.stat-bottom {
    font-family: "Digi";
    font-size: 30px;
    line-height: 1.05;
    color: var(--fg);
}

#temp-stats .stat-cell:last-child .stat-bottom {
    color: #9cb310;
}

#error-stats .stat-bottom {
    color: #ff8a80;
}

#heat-stats .stat-bottom {
    color: #ffb14e;
}

#catchingup .stat-bottom {
    color: #6ec6ff;
}

/* ---------------------------------------------------------------------------
   Tuning: charts
--------------------------------------------------------------------------- */

.charts {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin: 10px 0;
}

.chart-panel {
    min-width: 0;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.25);
    padding: 8px;
}

.chart-title {
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 2px 4px 6px;
}

.chart-body {
    position: relative;
    height: 240px;
}

.window-control {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 4px 2px;
}

.window-control input[type="range"] {
    flex: 1 1 120px;
    min-width: 0;
}

.window-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--muted-2);
    white-space: nowrap;
}

.window-control input[type="range"] {
    flex: 1;
    min-width: 0;
    accent-color: #75890c;
}

.window-value {
    font-size: 13px;
    color: var(--fg);
    min-width: 46px;
    text-align: right;
    white-space: nowrap;
}

/* ---------------------------------------------------------------------------
   Buttons
--------------------------------------------------------------------------- */

.btn-success {
    background: linear-gradient(to bottom, var(--run-green-top) 0%, var(--run-green-bottom) 100%);
    border-color: #75890c;
}

.btn-success:hover,
.btn-success:focus {
    background: linear-gradient(to bottom, rgba(117,137,12,1) 0%, rgba(94,110,10,1) 100%);
    border-color: #5f700a;
}

/* everything green uses the run-button green */
.badge.text-bg-success,
.toast.bg-success {
    background: linear-gradient(to bottom, var(--run-green-top) 0%, var(--run-green-bottom) 100%) !important;
}

/* ---------------------------------------------------------------------------
   Modals
--------------------------------------------------------------------------- */

.modal-content {
    background: linear-gradient(to bottom, #f5f5f5 0%, #e8e8e8 100%);
    border-radius: 10px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.3);
}

.modal-header {
    border-bottom: 1px solid #d6d4cd;
}

.modal-footer {
    border-top: 1px solid #d6d4cd;
}

.modal-body td {
    width: 50%;
}

/* ---------------------------------------------------------------------------
   Toasts
--------------------------------------------------------------------------- */

#toastContainer {
    z-index: 1080;
}

#toastContainer .toast {
    box-shadow: 0 6px 18px rgba(0,0,0,0.35);
    opacity: 0.97;
}

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

@media (min-width: 900px) {
    .charts {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 575.98px) {
    .conn-indicator {
        padding: 3px 7px;
    }

    .conn-text {
        display: none;
    }

    #overview_heading {
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
    }

    #overview_heading .heading-times {
        order: 3;
        width: 100%;
        justify-content: center;
        margin: 4px 0 0;
        flex-wrap: wrap;
    }

    #overview_heading .heading-temps {
        margin-left: auto;
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    #profile_selector {
        flex-wrap: wrap;
    }

    #profile_selector .form-select {
        width: 150px;
    }
}
