:root {
    --blue: #265bff;
    --navy: #002087;
    --bg: #f4f8ff;
    --surface: #ffffff;
    --border: #d9e6ff;
    --text: #111827;
    --muted: #64748b;
    --green: #16a34a;
    --amber: #d97706;
    --red: #dc2626;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    letter-spacing: 0;
}
a { color: var(--blue); text-decoration: none; }
.topbar {
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 10px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 240px; }
.brand img { width: 128px; height: 34px; object-fit: contain; }
.brand strong, .brand span { display: block; }
.brand span, .muted { color: var(--muted); font-size: 13px; }
nav { display: flex; gap: 6px; flex-wrap: wrap; }
nav a, .userbox a, .btn {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 12px;
    background: #fff;
    color: var(--navy);
    font-weight: 600;
    cursor: pointer;
}
nav a.active, .btn.primary {
    background: var(--blue);
    color: #fff;
    border-color: var(--blue);
}
.userbox { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.page { width: min(1280px, calc(100% - 32px)); margin: 24px auto 48px; }
.hero, .card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, .06);
}
.hero { padding: 22px; margin-bottom: 18px; display: flex; justify-content: space-between; gap: 16px; }
h1, h2, h3 { margin: 0 0 8px; color: var(--navy); }
.grid { display: grid; gap: 16px; }
.grid.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.two { grid-template-columns: 1.1fr .9fr; }
.card { padding: 18px; }
.stat-value { font-size: 32px; font-weight: 800; color: var(--navy); }
.stat-label { color: var(--muted); }
.status { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 9px; font-size: 12px; font-weight: 700; }
.online { background: #dcfce7; color: #166534; }
.offline { background: #fee2e2; color: #991b1b; }
.pending { background: #fef3c7; color: #92400e; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; }
input, select, textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    background: #fff;
    color: var(--text);
}
label { display: grid; gap: 6px; font-weight: 650; color: var(--navy); }
form.inline { display: inline; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.notice { padding: 12px 14px; border-radius: 8px; margin-bottom: 16px; border: 1px solid; }
.notice.success { background: #ecfdf5; border-color: #bbf7d0; color: #166534; }
.notice.error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.login {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: linear-gradient(135deg, #f4f8ff, #eaf2ff);
}
.login-card { width: min(440px, 100%); padding: 28px; }
.login-card img { width: 150px; display: block; margin-bottom: 20px; }
@media (max-width: 820px) {
    .topbar, .hero { flex-direction: column; align-items: stretch; }
    .grid.stats, .grid.two, .form-grid { grid-template-columns: 1fr; }
}

/* OEE dashboard/detail layout inspired by DashboardOEESJA2 */
.oee-shell {
    --primary-color: #1e88e5;
    --success-color: #2e7d32;
    --warning-color: #f9a825;
    --danger-color: #c62828;
    --panel: #ffffff;
    --panel-2: #f7f9fc;
    --line: #dfe7f3;
    --soft-text: #65758b;
    background: #eef3f9;
}
.oee-shell.dark-theme {
    --panel: #1f2430;
    --panel-2: #2a3040;
    --line: #394254;
    --text: #edf2f7;
    --soft-text: #aab7c8;
    background: #151923;
    color: var(--text);
}
.oee-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 10px 22px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 2px 18px rgba(15, 23, 42, .08);
}
.header-left, .header-right, .date-time, .dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 14px;
}
.header-left .logo {
    width: 140px;
    height: 40px;
    object-fit: contain;
}
.header-left h1 {
    margin: 0;
    font-size: 1.45rem;
    color: var(--text);
}
.sidebar-toggle-btn, .theme-toggle, .dropdown-toggle {
    border: 1px solid var(--line);
    background: var(--panel-2);
    color: var(--text);
    border-radius: 8px;
    min-height: 38px;
    cursor: pointer;
}
.sidebar-toggle-btn {
    width: 42px;
    display: grid;
    place-items: center;
    gap: 4px;
    padding: 8px;
}
.sidebar-toggle-btn span {
    display: block;
    width: 20px;
    height: 2px;
    background: currentColor;
}
.theme-toggle {
    padding: 8px 12px;
    font-weight: 700;
}
.date-time {
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    color: var(--soft-text);
    font-size: .82rem;
}
.user-menu {
    position: relative;
}
.dropdown-toggle {
    padding: 7px 10px;
    font-weight: 700;
}
.user-icon {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: #fff;
    background: var(--primary-color);
}
.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 170px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 14px 40px rgba(15, 23, 42, .16);
    overflow: hidden;
}
.dropdown-menu.show {
    display: block;
}
.dropdown-menu a {
    display: block;
    padding: 10px 12px;
    color: var(--text);
}
.main-container {
    display: flex;
    min-height: 100vh;
    padding-top: 70px;
}
.sidebar2 {
    position: fixed;
    top: 70px;
    bottom: 0;
    left: 0;
    width: 250px;
    overflow-y: auto;
    background: var(--panel);
    border-right: 1px solid var(--line);
    transition: width .2s ease;
}
.sidebar2.collapsed {
    width: 80px;
}
.sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 18px 10px;
    color: var(--text);
}
.sidebar-header .logo {
    width: 34px;
    height: 34px;
    object-fit: contain;
}
.sidebar-nav {
    list-style: none;
    padding: 8px;
    margin: 0;
}
.sidebar-nav li {
    margin-bottom: 6px;
}
.sidebar-nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 8px;
    color: var(--soft-text);
    font-weight: 700;
}
.sidebar-nav-link.active, .sidebar-nav-link:hover {
    background: var(--primary-color);
    color: #fff;
}
.nav-icon {
    width: 24px;
    text-align: center;
    font-size: 1.1rem;
}
.sidebar2.collapsed .sidebar-nav-link span:last-child,
.sidebar2.collapsed .sidebar-header strong,
.sidebar2.collapsed .sidebar-footer {
    display: none;
}
.sidebar-footer {
    position: absolute;
    left: 16px;
    right: 16px;
    bottom: 18px;
    color: var(--soft-text);
    font-size: .78rem;
}
.version-info {
    font-weight: 800;
    color: var(--text);
    margin-bottom: 6px;
}
.content {
    margin-left: 250px;
    width: calc(100% - 250px);
    padding: 24px;
    transition: margin-left .2s ease, width .2s ease;
}
.content.expanded {
    margin-left: 80px;
    width: calc(100% - 80px);
}
.kpi-strip {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 22px;
}
.kpi-strip div, .machine-card, .detail-card, .filter-bar {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(15, 23, 42, .07);
}
.kpi-strip div {
    padding: 16px;
}
.kpi-strip span {
    display: block;
    color: var(--soft-text);
    font-size: .82rem;
    margin-bottom: 5px;
}
.kpi-strip strong {
    font-size: 1.8rem;
    color: var(--text);
}
.dashboard-section-title {
    margin: 6px 0 14px;
    font-size: 1.35rem;
    color: var(--text);
}
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 18px;
}
.machine-card {
    overflow: hidden;
    cursor: pointer;
    transition: transform .16s ease, box-shadow .16s ease;
}
.machine-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 34px rgba(15, 23, 42, .13);
}
.card-header-new {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 52px;
    padding: 12px 14px;
    color: #fff;
    font-weight: 800;
}
.card-status-badge {
    border-radius: 999px;
    padding: 4px 9px;
    background: rgba(0, 0, 0, .22);
    font-size: .78rem;
}
.card-body-new {
    padding: 16px;
}
.oee-chart-container {
    min-height: 142px;
    display: grid;
    place-items: center;
}
.oee-ring {
    --value: 0;
    width: 128px;
    height: 128px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: conic-gradient(var(--primary-color) calc(var(--value) * 1%), #e6ebf2 0);
    position: relative;
}
.oee-ring::after {
    content: "";
    position: absolute;
    inset: 14px;
    border-radius: 50%;
    background: var(--panel);
}
.oee-ring span {
    position: relative;
    z-index: 1;
    font-size: 1.45rem;
    font-weight: 900;
    color: var(--text);
}
.oee-ring.large {
    width: 170px;
    height: 170px;
    flex: 0 0 auto;
}
.oee-ring.large span {
    font-size: 1.75rem;
}
.off-state-message {
    color: var(--soft-text);
    font-weight: 800;
}
.oee-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}
.metric-item {
    text-align: center;
    padding: 10px 6px;
    border-radius: 8px;
    background: var(--panel-2);
}
.metric-item h4 {
    margin: 0 0 4px;
    color: var(--primary-color);
}
.metric-item p {
    margin: 0;
    color: var(--soft-text);
    font-size: .78rem;
}
.card-footer-counter {
    padding: 14px 16px;
    border-top: 1px solid var(--line);
}
.counter-grid, .mini-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.counter-label, .mini-meta {
    color: var(--soft-text);
    font-size: .78rem;
}
.counter-value {
    color: var(--text);
    font-size: 1.2rem;
    font-weight: 900;
}
.mini-meta {
    margin-top: 10px;
}
.section-divider {
    border: 0;
    border-top: 1px solid var(--line);
    margin: 26px 0 20px;
}
.empty-state {
    color: var(--soft-text);
    padding: 18px;
}
.filter-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 14px;
    margin-bottom: 18px;
}
.filter-title {
    font-weight: 900;
    color: var(--text);
    margin-right: 8px;
}
.filter-bar label {
    display: inline;
    color: var(--soft-text);
}
.filter-bar select {
    width: auto;
    min-width: 150px;
}
.btn-settings {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-2);
    color: var(--text);
    font-weight: 800;
}
.status-panel {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
}
.detail-card {
    padding: 18px;
    margin-bottom: 18px;
}
.detail-card-title {
    font-size: 1.05rem;
    font-weight: 900;
    color: var(--text);
    margin-bottom: 12px;
}
.detail-card p {
    margin: 0;
    color: var(--soft-text);
}
.status-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    color: var(--soft-text);
}
.status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #bdbdbd;
    margin-right: 5px;
}
.status-dot.running { background: var(--success-color); }
.status-dot.breakdown { background: var(--danger-color); }
.status-dot.setting { background: var(--warning-color); }
.timeline-chart {
    min-height: 120px;
    display: flex;
    align-items: stretch;
    gap: 3px;
}
.timeline-chart span {
    flex: 1;
    min-width: 5px;
    border-radius: 5px;
}
.timeline-chart .running { background: var(--success-color); }
.timeline-chart .setting { background: var(--warning-color); }
.timeline-chart .breakdown { background: var(--danger-color); }
.detail-grid {
    display: grid;
    grid-template-columns: 1.15fr .85fr;
    gap: 18px;
}
.counter-bars {
    height: 220px;
    display: flex;
    align-items: flex-end;
    gap: 4px;
    padding-top: 10px;
}
.counter-bars span {
    flex: 1;
    min-width: 6px;
    border-radius: 5px 5px 0 0;
    background: linear-gradient(180deg, var(--primary-color), #6db9ff);
}
.oee-section {
    display: flex;
    align-items: center;
    gap: 22px;
}
.oee-bars {
    flex: 1;
    display: grid;
    gap: 12px;
}
.oee-bar-row {
    display: grid;
    grid-template-columns: 24px 1fr 48px;
    gap: 10px;
    align-items: center;
    font-weight: 800;
}
.bar-track {
    height: 12px;
    border-radius: 999px;
    overflow: hidden;
    background: var(--panel-2);
}
.bar-fill {
    height: 100%;
    border-radius: inherit;
    background: var(--primary-color);
}
.bar-value {
    color: var(--soft-text);
    text-align: right;
}
.apq-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}
.apq-box {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-2);
}
.apq-header {
    padding: 11px 13px;
    color: #fff;
    background: var(--primary-color);
    font-weight: 900;
}
.loss-box .apq-header {
    background: var(--danger-color);
}
.apq-body {
    padding: 12px;
    display: grid;
    gap: 10px;
}
.apq-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--soft-text);
}
.apq-row b {
    color: var(--text);
    text-align: right;
}
.table-scroll {
    overflow-x: auto;
}
.detail-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}
.detail-table th, .detail-table td {
    border-bottom: 1px solid var(--line);
    padding: 10px;
}
.detail-table th {
    color: var(--soft-text);
    text-align: left;
    font-size: .78rem;
    text-transform: uppercase;
}
.oee-shell.dark-theme input,
.oee-shell.dark-theme select,
.oee-shell.dark-theme textarea {
    background: var(--panel-2);
    color: var(--text);
    border-color: var(--line);
}
@media (max-width: 1000px) {
    .kpi-strip, .apq-grid, .detail-grid {
        grid-template-columns: 1fr 1fr;
    }
    .status-panel, .oee-section {
        align-items: stretch;
        flex-direction: column;
    }
}
@media (max-width: 760px) {
    .oee-header {
        position: static;
        flex-direction: column;
        align-items: stretch;
    }
    .main-container {
        padding-top: 0;
    }
    .sidebar2 {
        position: static;
        width: 100%;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }
    .sidebar2.collapsed {
        width: 100%;
    }
    .content, .content.expanded {
        width: 100%;
        margin-left: 0;
        padding: 16px;
    }
    .kpi-strip, .apq-grid, .detail-grid {
        grid-template-columns: 1fr;
    }
    .date-time {
        align-items: flex-start;
    }
}
