/*
  Kleurgebruik geïnspireerd op de GoodLife Foods huisstijl (fris groen, warme accent-kleur,
  crème achtergrond, rustige donkere tekstkleur). De exacte merk-hexcodes konden niet
  automatisch van de live website worden afgelezen; pas onderstaande variabelen gerust aan
  als de echte huisstijlkleuren afwijken.
*/
:root {
    --color-primary: #1F6F4E;
    --color-primary-dark: #16543A;
    --color-primary-light: #E7F2EC;
    --color-accent: #F2A93B;
    --color-bg: #F7F5EF;
    --color-surface: #FFFFFF;
    --color-text: #22261F;
    --color-text-muted: #6B7268;
    --color-border: #E4E1D6;
    --color-danger: #C0392B;
    --radius: 14px;
    --shadow: 0 2px 10px rgba(34, 38, 31, 0.06);
    --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font);
    background: var(--color-bg);
    color: var(--color-text);
}

a {
    color: inherit;
}

header.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 28px;
    background: var(--color-primary);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 10;
}

header.topbar .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: 0.2px;
}

header.topbar .brand .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--color-accent);
}

header.topbar nav a {
    text-decoration: none;
    color: #fff;
    opacity: 0.9;
    margin-left: 20px;
    font-size: 0.92rem;
    font-weight: 600;
}

header.topbar nav a:hover {
    opacity: 1;
    text-decoration: underline;
}

main {
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px 28px 60px;
}

.plant-section {
    margin-bottom: 36px;
}

.plant-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.plant-header h2 {
    margin: 0;
    font-size: 1.3rem;
    color: var(--color-primary-dark);
}

.plant-header .plant-desc {
    color: var(--color-text-muted);
    font-size: 0.88rem;
}

.plant-meta {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.plant-meta.error {
    color: var(--color-danger);
    font-weight: 600;
}

/* One row per production line (stacked vertically) rather than a card grid, so each line takes
   the full page width and only 1-2 lines of height - much more scannable when there are many
   lines running at once. */
.machine-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.machine-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 10px 18px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 22px;
}

.machine-card .machine-id {
    flex: 0 0 150px;
    min-width: 150px;
}

.machine-card .machine-code {
    font-weight: 700;
    font-size: 1.02rem;
    line-height: 1.2;
}

.machine-card .machine-desc {
    font-size: 0.78rem;
    color: var(--color-text-muted);
    line-height: 1.2;
}

.status-pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 700;
    white-space: nowrap;
    flex: 0 0 auto;
}

.machine-product {
    flex: 1 1 220px;
    min-width: 180px;
}

.product-line {
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1.2;
}

.product-code {
    font-size: 0.76rem;
    color: var(--color-text-muted);
    line-height: 1.2;
}

.times-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 0.76rem;
    color: var(--color-text-muted);
    flex: 0 0 150px;
}

.machine-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1 1 200px;
    min-width: 160px;
}

.progress-track {
    flex: 1 1 auto;
    height: 8px;
    background: var(--color-primary-light);
    border-radius: 999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--color-primary);
}

.qty-inline {
    font-size: 0.76rem;
    color: var(--color-text-muted);
    white-space: nowrap;
    flex: 0 0 auto;
}

.oee-row {
    display: flex;
    gap: 8px;
    flex: 0 0 auto;
}

.oee-badge {
    text-align: center;
    background: var(--color-primary-light);
    color: var(--color-primary-dark);
    border-radius: 8px;
    padding: 3px 10px;
    font-size: 0.72rem;
    min-width: 52px;
}

.oee-badge b {
    display: block;
    font-size: 0.9rem;
}

.machine-card.no-data {
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

.machine-card.no-data .machine-desc {
    font-style: italic;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--color-text-muted);
}

/* --- Admin pagina --- */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px 22px;
    margin-bottom: 24px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}

.form-grid .full {
    grid-column: 1 / -1;
}

label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text-muted);
    margin-bottom: 4px;
}

input[type="text"],
input[type="url"],
input[type="password"],
textarea,
select {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: var(--font);
    background: #fff;
    color: var(--color-text);
}

button {
    font-family: var(--font);
    cursor: pointer;
    border: none;
    border-radius: 8px;
    padding: 10px 18px;
    font-weight: 700;
    font-size: 0.88rem;
}

button.primary {
    background: var(--color-primary);
    color: #fff;
}

button.primary:hover {
    background: var(--color-primary-dark);
}

button.secondary {
    background: var(--color-primary-light);
    color: var(--color-primary-dark);
}

button.danger {
    background: #fbeae7;
    color: var(--color-danger);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.86rem;
}

table th, table td {
    text-align: left;
    padding: 10px 8px;
    border-bottom: 1px solid var(--color-border);
}

table th {
    color: var(--color-text-muted);
    font-weight: 600;
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.actions-cell {
    display: flex;
    gap: 8px;
}

.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--color-primary-dark);
    color: #fff;
    padding: 12px 18px;
    border-radius: 10px;
    box-shadow: var(--shadow);
    font-size: 0.86rem;
    max-width: 360px;
    z-index: 50;
}

.toast.error {
    background: var(--color-danger);
}

/* --- OEE-pagina --- */
.back-link {
    display: inline-block;
    margin-bottom: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-primary-dark);
    text-decoration: none;
}

.back-link:hover {
    text-decoration: underline;
}

.site-oee-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.site-oee-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 20px;
    cursor: pointer;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.site-oee-card:hover {
    box-shadow: 0 6px 18px rgba(34, 38, 31, 0.12);
    transform: translateY(-2px);
}

.site-oee-card h3 {
    margin: 0 0 2px;
    color: var(--color-primary-dark);
}

.site-oee-avg {
    margin: 10px 0 12px;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--color-primary-dark);
}

.site-oee-avg span {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.week-bars {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 48px;
}

.week-bar {
    flex: 1;
    min-height: 4px;
    background: var(--color-primary);
    border-radius: 3px 3px 0 0;
    cursor: pointer;
    opacity: 0.85;
}

.week-bar:hover {
    opacity: 1;
}

.day-oee-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
}

.day-oee-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    cursor: pointer;
    text-align: center;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.day-oee-card:hover {
    box-shadow: 0 6px 18px rgba(34, 38, 31, 0.12);
    transform: translateY(-2px);
}

.day-oee-date {
    font-weight: 700;
    text-transform: capitalize;
    margin-bottom: 6px;
}

.day-oee-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-primary-dark);
    margin-bottom: 8px;
}

.day-oee-meta {
    margin-top: 6px;
    font-size: 0.72rem;
    color: var(--color-text-muted);
}

/* --- OEE-verliesboom (categorieën/subcategorieën per machine) --- */
.oee-cat-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 760px;
}

.oee-cat-row {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 12px 16px;
}

.oee-cat-row.highlight {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
}

.oee-cat-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 0.92rem;
    margin-bottom: 6px;
}

.oee-cat-desc {
    font-weight: 700;
    color: var(--color-text);
}

.oee-cat-row.highlight .oee-cat-desc {
    color: var(--color-primary-dark);
}

.oee-cat-pct {
    font-weight: 700;
    color: var(--color-primary-dark);
    white-space: nowrap;
    font-size: 0.82rem;
}

.oee-timeline-bar {
    display: flex;
    width: 100%;
    height: 34px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--color-border);
    /* Verticale hulplijnen elke 3 uur (24u / 8 = 12,5% per lijn). */
    background-image: repeating-linear-gradient(to right,
        rgba(0, 0, 0, 0.18) 0, rgba(0, 0, 0, 0.18) 1px,
        transparent 1px, transparent 12.5%);
}

.oee-timeline-slice {
    height: 100%;
    min-width: 2px;
    transition: opacity 0.1s ease;
}

.oee-timeline-slice:hover {
    opacity: 0.8;
}

.oee-timeline-axis {
    position: relative;
    height: 16px;
    margin-top: 2px;
    margin-bottom: 12px;
}

.oee-timeline-tick {
    position: absolute;
    transform: translateX(-2px);
    font-size: 0.7rem;
    color: var(--color-text-muted);
    white-space: nowrap;
}

.oee-timeline-tick:last-child {
    transform: translateX(-100%);
}

.oee-timeline-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    margin-bottom: 18px;
}

.oee-timeline-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--color-text-muted);
}

.oee-timeline-swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}

.oee-subcat-list {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed var(--color-border);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.oee-subcat-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
    color: var(--color-text-muted);
    padding-left: 8px;
}

/* --- Statistiekpagina --- */
.backfill-row {
    display: grid;
    grid-template-columns: 180px 1fr 120px;
    align-items: center;
    gap: 12px;
    font-size: 0.86rem;
}

.backfill-plant {
    font-weight: 600;
}

.backfill-meta {
    color: var(--color-text-muted);
    font-size: 0.78rem;
    text-align: right;
}

.trend-flag {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 700;
    white-space: nowrap;
    background: var(--color-primary-light);
    color: var(--color-text-muted);
}

.trend-flag-normal {
    background: var(--color-primary-light);
    color: var(--color-primary-dark);
}

.trend-flag-above {
    background: #FCF1DC;
    color: #8A5A12;
}

.trend-flag-below {
    background: #FBEAE7;
    color: var(--color-danger);
}

/* --- Tabs (statistiekpagina) --- */
.tab-bar {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 20px;
    overflow-x: auto;
}

.tab-button {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    padding: 10px 16px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--color-text-muted);
    white-space: nowrap;
}

.tab-button:hover {
    color: var(--color-text);
}

.tab-button.active {
    color: var(--color-primary-dark);
    border-bottom-color: var(--color-primary);
}

.deviation-row {
    cursor: pointer;
}

.deviation-row:hover {
    background: var(--color-primary-light);
}

/* --- Type-ahead article picker (Trend per Article) --- */
.autocomplete-list {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 20;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    max-height: 260px;
    overflow-y: auto;
    margin-top: 4px;
}

.autocomplete-item {
    padding: 8px 11px;
    font-size: 0.88rem;
    cursor: pointer;
}

.autocomplete-item:hover {
    background: var(--color-primary-light);
}

.autocomplete-item.autocomplete-empty {
    color: var(--color-text-muted);
    cursor: default;
}

.autocomplete-item.autocomplete-empty:hover {
    background: none;
}

/* --- Login page --- */
.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg);
}

.login-card {
    width: 100%;
    max-width: 360px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 32px 28px;
}

.login-card .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--color-primary-dark);
    margin-bottom: 22px;
}

.login-card .brand .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--color-accent);
}

.login-card button.primary {
    width: 100%;
    margin-top: 8px;
}

.login-error {
    background: #fbeae7;
    color: var(--color-danger);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 0.84rem;
    margin-bottom: 14px;
}

.login-notice {
    background: var(--color-primary-light);
    color: var(--color-primary-dark);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 0.84rem;
    margin-bottom: 14px;
}

/* --- Loading indicator: shown while OEE figures are being refreshed after moving the period
   slider, so it's never unclear whether the numbers on screen are current or stale. --- */
.oee-loading-spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(120, 128, 115, 0.35);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: oee-spin 0.7s linear infinite;
    flex-shrink: 0;
}

.oee-loading-spinner.visible {
    display: inline-block;
}

@keyframes oee-spin {
    to { transform: rotate(360deg); }
}

.oee-refreshing {
    opacity: 0.45;
    transition: opacity 0.15s ease;
}

/* --- Dashboard: total OEE tile + period slider --- */
.period-control {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.period-control input[type="range"] {
    flex: 1;
}

.period-control .period-label {
    min-width: 110px;
    text-align: right;
    font-weight: 700;
    color: var(--color-primary-dark);
    font-size: 0.9rem;
}

.total-oee-tile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    width: 100%;
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px 28px;
    cursor: pointer;
    text-align: left;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.total-oee-tile:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(34, 38, 31, 0.18);
}

.total-oee-tile .total-oee-label {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.85;
}

.total-oee-tile .total-oee-value {
    font-size: 2.6rem;
    font-weight: 700;
    line-height: 1;
    margin-top: 6px;
}

.total-oee-tile .total-oee-arrow {
    font-size: 1.6rem;
    opacity: 0.85;
}

.region-block {
    margin-bottom: 28px;
}

.region-block-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 12px;
}

.region-block-header h3 {
    margin: 0;
    color: var(--color-primary-dark);
}

.region-block-avg {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-primary-dark);
}

.plant-oee-wide-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 22px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.plant-oee-wide-card:hover {
    box-shadow: 0 6px 18px rgba(34, 38, 31, 0.12);
    transform: translateY(-2px);
}

.plant-oee-wide-card .plant-oee-info h4 {
    margin: 0 0 2px;
    color: var(--color-primary-dark);
}

.plant-oee-wide-card .plant-oee-info .plant-desc {
    margin: 0;
}

.plant-oee-wide-card .plant-oee-bar {
    flex: 1;
    max-width: 340px;
}

.plant-oee-wide-card .plant-oee-value {
    min-width: 90px;
    text-align: right;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--color-primary-dark);
}

/* --- Users tab (admin.html) --- */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 700;
    white-space: nowrap;
    background: var(--color-primary-light);
    color: var(--color-primary-dark);
}

.badge.muted {
    background: var(--color-border);
    color: var(--color-text-muted);
}

.plant-checkbox-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    max-height: 160px;
    overflow-y: auto;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
}

.plant-checkbox-list label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 400;
    color: var(--color-text);
    margin-bottom: 0;
}

.plant-checkbox-list input[type="checkbox"] {
    width: auto;
}
