/* ============================================================
   FATHOM — Offshore Solutions LLC
   Dark, AI-forward theme: gradient mesh, glass panels, glow.
   ============================================================ */

:root {
    --bg-0: #060913;
    --bg-1: #0b1020;
    --panel: rgba(148, 163, 184, 0.055);
    --panel-strong: rgba(148, 163, 184, 0.10);
    --panel-border: rgba(148, 163, 184, 0.14);
    --text-hi: #eaf0fb;
    --text: #a9b4cc;
    --text-lo: #66718c;
    --cyan: #22d3ee;
    --violet: #a78bfa;
    --green: #34d399;
    --amber: #fbbf24;
    --rose: #fb7185;
    --radius: 16px;
    --font-display: 'Space Grotesk', system-ui, sans-serif;
    --font-body: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-body);
    font-size: 14.5px;
    color: var(--text);
    background: var(--bg-0);
}

/* Gradient mesh backdrop */
body {
    background:
        radial-gradient(1100px 750px at 88% -12%, rgba(167, 139, 250, 0.16), transparent 60%),
        radial-gradient(950px 700px at -12% 28%, rgba(34, 211, 238, 0.13), transparent 55%),
        radial-gradient(800px 620px at 55% 115%, rgba(52, 211, 153, 0.09), transparent 60%),
        var(--bg-0);
    background-attachment: fixed;
}

/* Faint grid overlay */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(148, 163, 184, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(148, 163, 184, 0.05) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, black 25%, transparent 80%);
    z-index: 0;
}

h1, h2, h3 { color: var(--text-hi); font-family: var(--font-display); }
h1:focus { outline: none; }
a { color: var(--cyan); text-decoration: none; }
.mono { font-family: var(--font-mono); font-size: 0.92em; }
.text-lo { color: var(--text-lo); }

/* ---------- Shell ---------- */
.shell {
    display: grid;
    grid-template-columns: 232px 1fr;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

.sidebar {
    display: flex;
    flex-direction: column;
    padding: 22px 14px;
    border-right: 1px solid var(--panel-border);
    background: rgba(9, 13, 26, 0.72);
    backdrop-filter: blur(18px);
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 10px;
    text-decoration: none;
}

.brand-mark {
    font-size: 22px;
    background: linear-gradient(120deg, var(--cyan), var(--violet));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0 0 12px rgba(34, 211, 238, 0.55));
}

.brand-text {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 19px;
    letter-spacing: 0.24em;
    background: linear-gradient(100deg, #eaf0fb 20%, var(--cyan) 60%, var(--violet));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.brand-sub {
    padding: 2px 10px 18px;
    font-size: 11px;
    letter-spacing: 0.08em;
    color: var(--text-lo);
}

.nav { display: flex; flex-direction: column; gap: 4px; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--text);
    font-weight: 500;
    border: 1px solid transparent;
    transition: all 0.18s ease;
}

.nav-link:hover {
    color: var(--text-hi);
    background: var(--panel);
    border-color: var(--panel-border);
}

.nav-link.active {
    color: var(--text-hi);
    background: linear-gradient(100deg, rgba(34, 211, 238, 0.13), rgba(167, 139, 250, 0.10));
    border-color: rgba(34, 211, 238, 0.30);
    box-shadow: 0 0 18px rgba(34, 211, 238, 0.12), inset 0 0 14px rgba(34, 211, 238, 0.05);
}

.nav-icon { width: 18px; text-align: center; opacity: 0.85; }

.sidebar-footer { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--panel-border); }

.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px 10px; }
.user-dot {
    width: 9px; height: 9px; border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 10px var(--green);
}
.user-name { color: var(--text-hi); font-size: 13px; font-weight: 600; }
.user-logout { font-size: 12px; color: var(--text-lo); }
.user-logout:hover { color: var(--rose); }

.main { padding: 28px 34px 60px; max-width: 1440px; width: 100%; }

/* ---------- Page chrome ---------- */
.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    margin-bottom: 22px;
    flex-wrap: wrap;
}

.page-title {
    margin: 0 0 4px;
    font-size: 26px;
    letter-spacing: 0.01em;
}

.page-sub { color: var(--text-lo); font-size: 13px; }

.live-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    border-radius: 999px;
    font-family: var(--font-display);
    font-size: 12px;
    letter-spacing: 0.22em;
    color: var(--green);
    border: 1px solid rgba(52, 211, 153, 0.35);
    background: rgba(52, 211, 153, 0.07);
    box-shadow: 0 0 18px rgba(52, 211, 153, 0.15);
}

/* ---------- Cards / panels ---------- */
.card {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-bottom: 18px;
    backdrop-filter: blur(10px);
}

.card-title {
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-lo);
    margin-bottom: 14px;
}

.empty-card, .empty-note { color: var(--text-lo); padding: 10px 0; }

/* ---------- KPI tiles ---------- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.kpi {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    padding: 16px 18px;
    position: relative;
    overflow: hidden;
}

.kpi::after {
    content: "";
    position: absolute;
    top: 0; left: 18px; right: 18px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(34, 211, 238, 0.5), transparent);
}

.kpi-label {
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-lo);
    margin-bottom: 8px;
}

.kpi-value {
    font-family: var(--font-display);
    font-size: 30px;
    font-weight: 700;
    color: var(--text-hi);
    line-height: 1;
}

.kpi-dim { font-size: 17px; color: var(--text-lo); font-weight: 500; }
.kpi-cyan { color: var(--cyan); text-shadow: 0 0 22px rgba(34, 211, 238, 0.4); }
.kpi-green { color: var(--green); text-shadow: 0 0 22px rgba(52, 211, 153, 0.4); }
.kpi-rose { color: var(--rose); text-shadow: 0 0 22px rgba(251, 113, 133, 0.4); }

/* ---------- Machine cards ---------- */
.machine-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.machine-card {
    display: block;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    padding: 18px;
    color: var(--text);
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.machine-card:hover {
    transform: translateY(-3px);
    border-color: rgba(34, 211, 238, 0.4);
    box-shadow: 0 14px 34px rgba(2, 6, 16, 0.5), 0 0 24px rgba(34, 211, 238, 0.10);
}

.machine-offline { opacity: 0.62; }

.machine-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.machine-name { font-family: var(--font-display); font-size: 17px; font-weight: 600; color: var(--text-hi); }
.machine-site { font-size: 12px; color: var(--text-lo); margin-top: 2px; }

.machine-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin: 16px 0 12px;
}

.stat-num { font-family: var(--font-display); font-size: 21px; font-weight: 700; color: var(--text-hi); }
.stat-unit { font-size: 13px; color: var(--text-lo); }
.stat-label { font-size: 11px; color: var(--text-lo); letter-spacing: 0.05em; }

.util-track {
    height: 6px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.12);
    overflow: hidden;
}

.util-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--cyan), var(--green));
    box-shadow: 0 0 12px rgba(34, 211, 238, 0.5);
    transition: width 0.6s ease;
}

.alarm-strip {
    margin-top: 12px;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 13px;
    color: #ffd7de;
    background: rgba(251, 113, 133, 0.10);
    border: 1px solid rgba(251, 113, 133, 0.35);
    box-shadow: 0 0 16px rgba(251, 113, 133, 0.12);
}

.alarm-code { font-family: var(--font-mono); color: var(--rose); margin-right: 6px; }

/* ---------- Pills / dots ---------- */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    color: var(--pill, var(--text));
    border: 1px solid color-mix(in srgb, var(--pill, #94a3b8) 45%, transparent);
    background: color-mix(in srgb, var(--pill, #94a3b8) 10%, transparent);
}

.pill-lg { font-size: 14px; padding: 8px 16px; }

.pulse-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    animation: pulse 1.8s ease-in-out infinite;
}

.pulse-green { background: var(--green); }

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 0%, transparent); opacity: 1; }
    50% { opacity: 0.55; }
}

/* ---------- Tables ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }

.tbl th {
    text-align: left;
    padding: 8px 10px;
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-lo);
    border-bottom: 1px solid var(--panel-border);
}

.tbl td {
    padding: 9px 10px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.07);
    color: var(--text);
}

.tbl tbody tr:hover { background: rgba(34, 211, 238, 0.04); }

.row-active-alarm td { background: rgba(251, 113, 133, 0.07); color: #ffd7de; }

.cell-actions { text-align: right; white-space: nowrap; }

/* ---------- Severity / scope chips ---------- */
.sev {
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
}

/* Troubleshooting-tip marker (hover for the tip) and guide link on alarm rows */
.tip-flag { margin-left: 6px; cursor: help; }
.tip-link { margin-left: 4px; text-decoration: none; }

/* Tip line under an alarm message on the history page */
.alarm-tip {
    margin-top: 3px;
    font-size: 12px;
    color: var(--text-lo, #94a3b8);
}
.alarm-tip a { margin-left: 8px; }

.sev-info { color: var(--cyan); background: rgba(34, 211, 238, 0.10); border: 1px solid rgba(34, 211, 238, 0.3); }
.sev-warning { color: var(--amber); background: rgba(251, 191, 36, 0.10); border: 1px solid rgba(251, 191, 36, 0.3); }
.sev-fault { color: var(--rose); background: rgba(251, 113, 133, 0.10); border: 1px solid rgba(251, 113, 133, 0.3); }
.sev-critical { color: #fecdd3; background: rgba(251, 113, 133, 0.22); border: 1px solid rgba(251, 113, 133, 0.55); box-shadow: 0 0 12px rgba(251, 113, 133, 0.2); }

.scope-chip {
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    color: var(--violet);
    background: rgba(167, 139, 250, 0.10);
    border: 1px solid rgba(167, 139, 250, 0.3);
}

/* ---------- Forms / buttons ---------- */
.field {
    width: 100%;
    padding: 9px 12px;
    border-radius: 10px;
    color: var(--text-hi);
    background: rgba(9, 13, 26, 0.65);
    border: 1px solid var(--panel-border);
    font-family: var(--font-body);
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field:focus {
    border-color: rgba(34, 211, 238, 0.55);
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.12);
}

.field-inline { width: auto; min-width: 170px; }

.field-label {
    display: block;
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-lo);
    margin: 0 0 6px 2px;
}

.filter-row { display: flex; gap: 10px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }

.chk-label { display: inline-flex; align-items: center; gap: 7px; color: var(--text); font-size: 13px; margin-right: 12px; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    align-items: end;
    margin-top: 12px;
}

.form-wide { grid-column: span 2; }
.form-btn { display: flex; align-items: flex-end; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 16px;
    border-radius: 10px;
    font-family: var(--font-body);
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-hi);
    background: var(--panel-strong);
    border: 1px solid var(--panel-border);
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn:hover { border-color: rgba(34, 211, 238, 0.45); box-shadow: 0 0 14px rgba(34, 211, 238, 0.12); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }

.btn-primary {
    background: linear-gradient(100deg, rgba(34, 211, 238, 0.9), rgba(167, 139, 250, 0.9));
    border: none;
    color: #04131c;
    box-shadow: 0 4px 18px rgba(34, 211, 238, 0.3);
}

.btn-primary:hover { filter: brightness(1.1); box-shadow: 0 4px 24px rgba(34, 211, 238, 0.45); }

.btn-xs { padding: 4px 10px; font-size: 12px; border-radius: 8px; }
.btn-danger:hover { border-color: rgba(251, 113, 133, 0.55); box-shadow: 0 0 14px rgba(251, 113, 133, 0.15); color: #ffd7de; }
.btn-row { display: flex; gap: 10px; margin-top: 12px; }

/* ---------- Timeline (machine detail) ---------- */
.timeline {
    position: relative;
    height: 34px;
    border-radius: 8px;
    background: rgba(148, 163, 184, 0.08);
    overflow: hidden;
}

.timeline-seg { position: absolute; top: 0; bottom: 0; min-width: 1px; }

.timeline-legend { display: flex; gap: 16px; margin-top: 10px; flex-wrap: wrap; font-size: 12px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; color: var(--text-lo); }
.legend-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

/* ---------- Bar chart (production) ---------- */
.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    height: 190px;
    padding-top: 20px;
}

.bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    height: 100%;
    min-width: 26px;
}

.bar {
    width: 100%;
    max-width: 46px;
    border-radius: 6px 6px 0 0;
    background: linear-gradient(180deg, var(--cyan), rgba(34, 211, 238, 0.25));
    box-shadow: 0 0 14px rgba(34, 211, 238, 0.2);
}

.bar-value { font-family: var(--font-mono); font-size: 11px; color: var(--text-lo); margin-bottom: 4px; }
.bar-label { font-size: 11px; color: var(--text-lo); margin-top: 6px; }

/* ---------- Pareto ---------- */
.pareto-track {
    position: relative;
    height: 20px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.10);
    overflow: hidden;
}

.pareto-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--rose), var(--amber));
    box-shadow: 0 0 12px rgba(251, 113, 133, 0.35);
}

.pareto-pct {
    position: absolute;
    top: 50%; right: 10px;
    transform: translateY(-50%);
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-hi);
}

/* ---------- Admin ---------- */
.admin-block { margin-bottom: 12px; }
.admin-block-title { color: var(--text-hi); font-weight: 600; margin-bottom: 4px; }
.admin-line { padding: 2px 0 2px 8px; font-size: 13px; }

.key-reveal {
    padding: 12px 14px;
    margin-bottom: 14px;
    border-radius: 10px;
    font-size: 13px;
    color: #d3f8e8;
    background: rgba(52, 211, 153, 0.08);
    border: 1px solid rgba(52, 211, 153, 0.4);
    box-shadow: 0 0 18px rgba(52, 211, 153, 0.12);
}

.key-code { display: block; margin-top: 6px; word-break: break-all; color: var(--green); }

/* ---------- Notes ---------- */
.note-area { min-height: 90px; resize: vertical; }
.note-text { white-space: pre-wrap; color: var(--text-hi); }
.note-author { margin-top: 6px; font-size: 12px; color: var(--text-lo); }

/* ---------- Login ---------- */
.login-stage {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
}

.login-card {
    width: min(400px, 92vw);
    padding: 38px 34px;
    border-radius: 20px;
    background: rgba(11, 16, 32, 0.75);
    border: 1px solid var(--panel-border);
    backdrop-filter: blur(20px);
    box-shadow: 0 30px 80px rgba(2, 6, 16, 0.6);
    position: relative;
    z-index: 2;
}

.login-brand { text-align: center; margin-bottom: 26px; }
.login-mark { font-size: 40px; }

.login-title {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 700;
    letter-spacing: 0.3em;
    margin-top: 8px;
    background: linear-gradient(100deg, #eaf0fb 20%, var(--cyan) 60%, var(--violet));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.login-sub { font-size: 12px; color: var(--text-lo); margin-top: 6px; }

.login-card .field { margin-bottom: 14px; }
.login-btn { width: 100%; justify-content: center; margin-top: 6px; }

.login-error {
    padding: 9px 13px;
    margin: 10px 0 14px;
    border-radius: 10px;
    font-size: 13px;
    color: #ffd7de;
    background: rgba(251, 113, 133, 0.10);
    border: 1px solid rgba(251, 113, 133, 0.4);
}

.login-glow {
    position: fixed;
    width: 640px; height: 640px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(34, 211, 238, 0.12), transparent 65%);
    animation: drift 14s ease-in-out infinite alternate;
    pointer-events: none;
}

@keyframes drift {
    from { transform: translate(-24vw, -12vh) scale(1); }
    to { transform: translate(22vw, 14vh) scale(1.25); }
}

/* ---------- Loading shimmer ---------- */
.loading-shimmer {
    padding: 40px 0;
    text-align: center;
    font-family: var(--font-display);
    letter-spacing: 0.16em;
    color: var(--text-lo);
    animation: shimmer 1.6s ease-in-out infinite;
}

@keyframes shimmer {
    0%, 100% { opacity: 0.45; }
    50% { opacity: 1; }
}

/* ---------- Plant floor ---------- */
.head-actions { display: flex; align-items: center; gap: 10px; }

.site-tabs { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }

.site-tab {
    padding: 7px 16px;
    border-radius: 999px;
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    background: var(--panel);
    border: 1px solid var(--panel-border);
    cursor: pointer;
    transition: all 0.15s ease;
}

.site-tab.active {
    color: var(--text-hi);
    background: linear-gradient(100deg, rgba(34, 211, 238, 0.13), rgba(167, 139, 250, 0.10));
    border-color: rgba(34, 211, 238, 0.35);
    box-shadow: 0 0 14px rgba(34, 211, 238, 0.12);
}

.floor-wrap {
    position: relative;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    padding: 10px;
    backdrop-filter: blur(10px);
}

.floor-controls {
    position: absolute;
    top: 18px;
    right: 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 5;
}

.floor-ctl {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    font-size: 16px;
    line-height: 1;
    color: var(--text-hi);
    background: rgba(10, 15, 30, 0.85);
    border: 1px solid var(--panel-border);
    backdrop-filter: blur(10px);
    cursor: pointer;
    transition: all 0.15s ease;
}

.floor-ctl:hover {
    border-color: rgba(34, 211, 238, 0.5);
    box-shadow: 0 0 12px rgba(34, 211, 238, 0.15);
}

.floor-selpanel {
    position: absolute;
    top: 18px;
    left: 18px;
    z-index: 6;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 230px;
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(10, 15, 30, 0.92);
    border: 1px solid rgba(167, 139, 250, 0.45);
    backdrop-filter: blur(14px);
    box-shadow: 0 12px 32px rgba(2, 6, 16, 0.55), 0 0 18px rgba(167, 139, 250, 0.12);
}

.selpanel-title {
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-hi);
}

.selpanel-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.selpanel-value { font-family: var(--font-mono); font-size: 12px; color: var(--cyan); min-width: 34px; text-align: center; }

.floor-hint {
    position: absolute;
    bottom: 16px;
    right: 18px;
    font-size: 11px;
    letter-spacing: 0.06em;
    color: var(--text-lo);
    background: rgba(10, 15, 30, 0.7);
    padding: 3px 10px;
    border-radius: 999px;
    pointer-events: none;
    z-index: 5;
}

.floor-wrap.editing { border-color: rgba(167, 139, 250, 0.5); box-shadow: 0 0 22px rgba(167, 139, 250, 0.12); }

.floor-svg { width: 100%; display: block; touch-action: none; }

.floor-bg { fill: #0a101f; stroke: rgba(148, 163, 184, 0.22); stroke-width: 0.6; }

/* machinery glyph parts (referenced by MachineGlyphs SVG) */
.m-bed { fill: #101a2e; stroke: rgba(148, 163, 184, 0.42); stroke-width: 0.55; }
.m-body { fill: #16213c; stroke: rgba(148, 163, 184, 0.55); stroke-width: 0.55; }
.m-line { stroke: rgba(148, 163, 184, 0.26); stroke-width: 0.45; fill: none; }
.m-detail { fill: #1d2a4a; stroke: rgba(148, 163, 184, 0.42); stroke-width: 0.4; }

.m-hit { fill: transparent; }
.m-ring { fill: none; stroke-width: 0.55; opacity: 0.9; }

.floor-machine { cursor: pointer; }
.floor-machine:hover .m-ring { stroke-width: 1; }
.floor-machine:hover .m-body, .floor-machine:hover .m-bed { filter: brightness(1.35); }
.glyph-offline { opacity: 0.55; }

.editing .floor-machine { cursor: grab; }
.editing .floor-machine:active { cursor: grabbing; }

.m-label {
    font-family: var(--font-body);
    font-size: 3.4px;
    font-weight: 600;
    fill: #c4cde0;
    text-anchor: middle;
    pointer-events: none;
}

.order-chip-g { cursor: pointer; }
.order-chip { fill: rgba(34, 211, 238, 0.10); stroke: rgba(34, 211, 238, 0.55); stroke-width: 0.3; }
.order-chip-text {
    font-family: var(--font-mono);
    font-size: 2.8px;
    fill: var(--cyan);
    text-anchor: middle;
}

.alarm-ping {
    fill: var(--rose);
    stroke: rgba(251, 113, 133, 0.5);
    stroke-width: 0.8;
    transform-box: fill-box;
    transform-origin: center;
    animation: ping 1.4s ease-in-out infinite;
}

@keyframes ping {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.55; transform: scale(1.35); }
}

/* decor */
.wall-rect { fill: #1c2740; stroke: rgba(148, 163, 184, 0.45); stroke-width: 0.35; }
.dock-rect { fill: #121c31; stroke: rgba(251, 191, 36, 0.5); stroke-width: 0.45; }
.dock-slat { stroke: rgba(251, 191, 36, 0.55); stroke-width: 0.8; }
.office-rect { fill: rgba(148, 163, 184, 0.06); stroke: rgba(148, 163, 184, 0.4); stroke-width: 0.4; stroke-dasharray: 1.6 1; }

.zone-label {
    font-family: var(--font-display);
    font-size: 3.2px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-anchor: middle;
    opacity: 0.85;
}

.item-label {
    font-family: var(--font-body);
    font-size: 2.9px;
    fill: var(--text-lo);
    text-anchor: middle;
}

.floor-text {
    font-family: var(--font-display);
    font-size: 4.6px;
    font-weight: 600;
    letter-spacing: 0.22em;
    fill: rgba(148, 163, 184, 0.5);
    text-anchor: middle;
}

.label-hit { fill: transparent; }

.editing .floor-item { cursor: grab; }

.item-selected rect, .item-selected text {
    filter: brightness(1.6) drop-shadow(0 0 1.5px rgba(167, 139, 250, 0.9));
}

.item-selected rect { stroke: var(--violet); stroke-dasharray: 2 1.2; }

/* selected machine: unmistakable violet dashed ring (overrides the state-color attribute) */
.glyph-selected .m-ring {
    stroke: var(--violet);
    stroke-dasharray: 2 1.4;
    stroke-width: 1;
}

.resize-handle {
    fill: var(--violet);
    stroke: #fff;
    stroke-width: 0.3;
    cursor: nwse-resize;
}

/* material-flow arrows */
.flow-line {
    stroke: rgba(34, 211, 238, 0.55);
    stroke-width: 0.6;
    fill: none;
    stroke-dasharray: 2.4 1.8;
    animation: flowdash 1.1s linear infinite;
}

@keyframes flowdash {
    to { stroke-dashoffset: -4.2; }
}

.flow-hit { stroke: transparent; stroke-width: 5; fill: none; cursor: pointer; }
.flow-arrow-g:hover .flow-line { stroke: var(--cyan); stroke-width: 0.9; filter: drop-shadow(0 0 2px rgba(34, 211, 238, 0.7)); }
.flow-selected .flow-line { stroke: var(--violet); stroke-width: 0.9; }

.flow-label-text {
    font-family: var(--font-body);
    font-size: 2.8px;
    fill: rgba(34, 211, 238, 0.85);
    text-anchor: middle;
    pointer-events: none;
}

.flow-dir { color: var(--cyan); }
.connect-hint { color: var(--violet); font-size: 13px; font-weight: 600; }
.selpanel-flowdesc { font-size: 13px; color: var(--text-hi); }

/* flow drawer */
.flow-order {
    padding: 10px 0;
    border-bottom: 1px solid rgba(148, 163, 184, 0.08);
}

.flow-order-no { display: block; font-size: 15px; color: var(--cyan); margin-bottom: 6px; }

.flow-order-legs { display: flex; align-items: center; gap: 8px; }
.flow-leg { flex: 1; min-width: 0; }
.flow-leg-dim { opacity: 0.55; }
.flow-leg-machine { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-lo); }
.flow-leg-time { font-size: 12.5px; color: var(--text-hi); }
.flow-leg-count { font-size: 12px; color: var(--green); }
.flow-leg-arrow { text-align: center; color: var(--cyan); font-size: 15px; }
.flow-leg-lag { display: block; font-size: 10.5px; color: var(--text-lo); }
.flow-leg-pending { color: var(--text-lo); font-size: 12px; }

/* edit toolbar */
.floor-toolbar {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
    padding: 12px 16px;
    margin-bottom: 12px;
}

.tool-group { display: flex; align-items: center; gap: 6px; }

.tool-label {
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-lo);
    margin-right: 4px;
    white-space: nowrap;
}

.tool-x { color: var(--text-lo); }
.tool-hint { font-size: 12px; color: var(--text-lo); margin-left: auto; }

.field-tiny { width: 70px; padding: 6px 8px; }
.field-color { width: 44px; height: 32px; padding: 2px; }

/* stats drawer */
.stats-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(360px, 92vw);
    padding: 24px 22px;
    overflow-y: auto;
    background: rgba(10, 15, 30, 0.92);
    border-left: 1px solid rgba(34, 211, 238, 0.25);
    backdrop-filter: blur(22px);
    box-shadow: -24px 0 60px rgba(2, 6, 16, 0.6);
    z-index: 60;
    animation: drawer-in 0.22s ease;
}

@keyframes drawer-in {
    from { transform: translateX(40px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.drawer-title { font-family: var(--font-display); font-size: 20px; font-weight: 700; color: var(--text-hi); }
.drawer-sub { font-size: 12px; color: var(--text-lo); margin-top: 2px; }

.drawer-close {
    background: none;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    color: var(--text-lo);
    padding: 4px 9px;
    cursor: pointer;
}

.drawer-close:hover { color: var(--rose); border-color: rgba(251, 113, 133, 0.5); }

.drawer-pill { margin-bottom: 12px; }
.pill-since { font-weight: 400; opacity: 0.75; margin-left: 4px; }

.drawer-section {
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-lo);
    margin: 18px 0 8px;
    padding-top: 14px;
    border-top: 1px solid var(--panel-border);
}

.drawer-order { font-size: 19px; color: var(--cyan); margin-bottom: 8px; word-break: break-all; }

.drawer-rows { display: flex; flex-direction: column; gap: 6px; }
.drawer-row { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-lo); }
.drawer-row b { color: var(--text-hi); font-weight: 600; }

.drawer-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.drawer-link { width: 100%; justify-content: center; margin-top: 18px; }

/* ---------- Order trace ---------- */
.trace-search { display: flex; gap: 12px; align-items: center; }

.trace-input {
    flex: 1;
    font-size: 16px;
    font-family: var(--font-mono);
    padding: 12px 16px;
}

.row-click { cursor: pointer; }
.row-click:hover td { background: rgba(34, 211, 238, 0.06); }
.trace-order-cell { color: var(--cyan); }

.trace-head { display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; }

.trace-order {
    font-size: 26px;
    color: var(--cyan);
    text-shadow: 0 0 24px rgba(34, 211, 238, 0.4);
    margin-bottom: 4px;
    word-break: break-all;
}

.trace-kpis { display: flex; gap: 26px; }

.flow-wrap {
    display: flex;
    align-items: stretch;
    gap: 6px;
    margin-bottom: 18px;
    overflow-x: auto;
    padding: 4px 2px 10px;
}

.flow-station {
    flex: 0 0 210px;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    padding: 14px 16px;
    text-align: center;
    backdrop-filter: blur(10px);
}

.flow-latest {
    border-color: rgba(34, 211, 238, 0.5);
    box-shadow: 0 0 24px rgba(34, 211, 238, 0.14), inset 0 0 20px rgba(34, 211, 238, 0.04);
}

.flow-glyph { width: 110px; height: 52px; margin: 0 auto 6px; display: block; }

.flow-name { font-family: var(--font-display); font-weight: 600; color: var(--text-hi); font-size: 15px; }
.flow-kind { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-lo); margin-bottom: 8px; }
.flow-count { font-size: 15px; color: var(--text); margin-bottom: 6px; }
.flow-count b { color: var(--cyan); font-family: var(--font-display); font-size: 18px; }
.flow-progress { margin-bottom: 8px; }
.flow-times { font-size: 11.5px; color: var(--text-lo); }

.flow-here {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--green);
}

.flow-arrow {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    padding: 0 4px;
}

.flow-arrow-line { font-size: 26px; color: rgba(34, 211, 238, 0.65); line-height: 1; }
.flow-arrow-label { font-size: 10.5px; color: var(--text-lo); margin-top: 4px; white-space: nowrap; }

.field-mini { width: auto; padding: 4px 8px; font-size: 12px; }
.custom-cat { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.custom-cat .field-mini { width: 120px; }

/* ---------- Maintenance ---------- */
.alert-line {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    margin-bottom: 6px;
    font-size: 13.5px;
    color: var(--text);
    background: rgba(148, 163, 184, 0.05);
}

.alert-active {
    color: #ffd7de;
    background: rgba(251, 113, 133, 0.10);
    border: 1px solid rgba(251, 113, 133, 0.35);
}

.alert-age { margin-left: auto; font-size: 11.5px; color: var(--text-lo); white-space: nowrap; }
.alert-dot-cleared { color: var(--green); }

.ticket {
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    margin-bottom: 8px;
    overflow: hidden;
}

.ticket-expanded { border-color: rgba(34, 211, 238, 0.35); }

.ticket-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    flex-wrap: wrap;
}

.ticket-head:hover { background: rgba(34, 211, 238, 0.04); }

.ticket-status {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.1em;
    padding: 3px 9px;
    border-radius: 999px;
}

.ticket-status.ticket-open { color: var(--rose); background: rgba(251, 113, 133, 0.12); border: 1px solid rgba(251, 113, 133, 0.4); }
.ticket-status.ticket-inprogress { color: var(--amber); background: rgba(251, 191, 36, 0.10); border: 1px solid rgba(251, 191, 36, 0.4); }
.ticket-status.ticket-resolved { color: var(--green); background: rgba(52, 211, 153, 0.10); border: 1px solid rgba(52, 211, 153, 0.4); }

.ticket-prio { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-lo); }
.prio-high { color: var(--amber); }
.prio-critical { color: var(--rose); font-weight: 700; }

.ticket-title { font-weight: 600; color: var(--text-hi); }
.ticket-meta { margin-left: auto; font-size: 12px; color: var(--text-lo); }

.ticket-body { padding: 4px 16px 14px; border-top: 1px solid rgba(148, 163, 184, 0.08); }

.ticket-section {
    font-size: 10.5px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-lo);
    margin: 12px 0 4px;
}

.ticket-text { color: var(--text-hi); font-size: 13.5px; white-space: pre-wrap; }
.ticket-resolution { color: #d3f8e8; }

.ticket-note {
    padding: 7px 10px;
    border-left: 2px solid rgba(34, 211, 238, 0.35);
    background: rgba(148, 163, 184, 0.04);
    border-radius: 0 8px 8px 0;
    margin-bottom: 6px;
    font-size: 13px;
}

.ticket-note-input { flex: 1; min-width: 200px; }
.ticket-new { padding: 12px; border: 1px dashed rgba(34, 211, 238, 0.35); border-radius: 12px; margin-bottom: 12px; }
.ticket-filter { float: right; margin-top: -4px; }

/* ---------- Reports ---------- */
.report-orders { font-size: 12px; color: var(--text-lo); }
.report-alarm-row { font-size: 12px; }
.api-doc-intro { color: var(--text); font-size: 13.5px; }
.api-doc-intro code { color: var(--cyan); font-family: var(--font-mono); }

/* ---------- Validation / error UI (Blazor built-ins) ---------- */
.valid.modified:not([type=checkbox]) { outline: 1px solid rgba(52, 211, 153, 0.6); }
.invalid { outline: 1px solid rgba(251, 113, 133, 0.6); }
.validation-message { color: var(--rose); }

#blazor-error-ui {
    background: #2b1220;
    color: #ffd7de;
    border-top: 1px solid var(--rose);
    bottom: 0;
    box-shadow: 0 -6px 24px rgba(2, 6, 16, 0.6);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .shell { grid-template-columns: 1fr; }

    .sidebar {
        position: static;
        height: auto;
        flex-direction: row;
        align-items: center;
        gap: 8px;
        padding: 10px 12px;
        overflow-x: auto;
    }

    .brand-sub, .sidebar-footer { display: none; }
    .nav { flex-direction: row; gap: 2px; }
    .nav-link { padding: 8px 10px; white-space: nowrap; font-size: 13px; }
    .nav-icon { display: none; }

    .main { padding: 18px 14px 40px; }
    .two-col { grid-template-columns: 1fr; }
    .kpi-value { font-size: 24px; }
    .bar-chart { overflow-x: auto; }
}

/* ---------- PM checklists ---------- */
.pm-desc { color: var(--text-lo); font-size: 13px; margin-bottom: 12px; }

.pm-item {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 10px;
    background: rgba(255, 255, 255, 0.02);
}

.pm-item-done { border-color: rgba(52, 211, 153, 0.4); background: rgba(52, 211, 153, 0.05); }

.pm-item-head {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
}

.pm-item-head input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--green); }
.pm-item-title { font-weight: 600; }
.pm-item-instructions { color: var(--text-lo); font-size: 13px; margin: 6px 0 0 27px; white-space: pre-wrap; }

.pm-item-img {
    display: block;
    max-width: 320px;
    max-height: 220px;
    border-radius: 8px;
    border: 1px solid var(--line);
    margin: 10px 0 0 27px;
    cursor: zoom-in;
}

.pm-item-note { margin: 10px 0 0 27px; width: calc(100% - 27px); }

.pm-notify-hint { color: var(--text-lo); font-size: 12.5px; align-self: center; }

.pm-history { border-top: 1px solid var(--line); padding: 10px 0; font-size: 13.5px; }
.pm-history:first-of-type { border-top: none; }
.pm-history-head { margin-bottom: 4px; }
.pm-history-notes { color: var(--text-lo); margin: 2px 0 4px; }
.pm-history-item { color: var(--text-lo); font-size: 12.5px; padding-left: 12px; }

.pm-edit-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    font-size: 13.5px;
}

.pm-edit-item-title { flex: 1; }

.pm-thumb {
    height: 40px;
    border-radius: 6px;
    border: 1px solid var(--line);
    cursor: zoom-in;
}

.pm-error { color: var(--rose); font-size: 13px; margin-top: 8px; }

.pm-zoom {
    position: fixed;
    inset: 0;
    background: rgba(5, 10, 18, 0.88);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    cursor: zoom-out;
}

.pm-zoom img { max-width: 92vw; max-height: 92vh; border-radius: 10px; }

.kpi-link { display: block; text-decoration: none; color: inherit; cursor: pointer; }
.kpi-link:hover { border-color: rgba(34, 211, 238, 0.45); }
