:root {
    --maret-brand: #e51b2b;
    --maret-brand-dark: #bd1020;
    --maret-brand-soft: #fff0f2;
    --maret-bg: #f4f6f9;
    --maret-surface: #ffffff;
    --maret-surface-muted: #f8fafc;
    --maret-text: #172033;
    --maret-text-muted: #667085;
    --maret-border: #e4e8ef;
    --maret-success: #15803d;
    --maret-warning: #b45309;
    --maret-danger: #c81e2b;
    --maret-info: #2563eb;
    --maret-radius-sm: 8px;
    --maret-radius: 14px;
    --maret-radius-lg: 20px;
    --maret-shadow: 0 8px 24px rgba(23, 32, 51, .07);
    --maret-shadow-hover: 0 14px 34px rgba(23, 32, 51, .12);
    --maret-transition: 180ms ease;
}

html { scroll-behavior: smooth; }
body {
    background: var(--maret-bg);
    color: var(--maret-text);
    font-family: Inter, Roboto, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--maret-info); text-decoration: none; }
a:hover { color: #1d4ed8; }
:focus-visible { outline: 3px solid rgba(37, 99, 235, .35) !important; outline-offset: 2px; }

.main-content { max-width: 1720px; margin-inline: auto; }
.main-content.dashboard { min-height: calc(100vh - 88px); }

.box, .card {
    background: var(--maret-surface);
    border: 1px solid var(--maret-border) !important;
    border-radius: var(--maret-radius) !important;
    box-shadow: var(--maret-shadow) !important;
}
.card, .box { transition: transform var(--maret-transition), box-shadow var(--maret-transition); }
.hover-shadow:hover, .card-hover:hover { transform: translateY(-2px); box-shadow: var(--maret-shadow-hover) !important; }

.page-intro { display:flex; justify-content:space-between; align-items:flex-end; gap:20px; margin-bottom:24px; }
.page-eyebrow { color:var(--maret-brand); font-weight:700; letter-spacing:.08em; text-transform:uppercase; font-size:.72rem; }
.page-heading { margin:.25rem 0; font-size:clamp(1.5rem,2vw,2rem); font-weight:750; color:var(--maret-text); }
.page-description { color:var(--maret-text-muted); margin:0; max-width:760px; }

.ui-kpi-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:16px; margin-bottom:24px; }
.ui-kpi { padding:20px; display:flex; align-items:center; gap:16px; min-height:118px; }
.ui-kpi__icon { width:48px; height:48px; flex:0 0 48px; display:grid; place-items:center; border-radius:14px; background:var(--maret-brand-soft); color:var(--maret-brand); font-size:24px; }
.ui-kpi__label { color:var(--maret-text-muted); font-size:.82rem; font-weight:600; }
.ui-kpi__value { color:var(--maret-text); font-size:1.75rem; line-height:1.15; font-weight:750; font-variant-numeric:tabular-nums; }

.status-dot { width:9px; height:9px; border-radius:50%; display:inline-block; margin-right:7px; background:#98a2b3; box-shadow:0 0 0 4px rgba(152,162,179,.15); }
.status-dot.is-online { background:#22c55e; box-shadow:0 0 0 4px rgba(34,197,94,.15); }
.status-dot.is-warning { background:#f59e0b; box-shadow:0 0 0 4px rgba(245,158,11,.15); }
.status-dot.is-offline { background:#ef4444; box-shadow:0 0 0 4px rgba(239,68,68,.15); }

.badge { font-weight:650; letter-spacing:.01em; }
.bg-success { background-color:var(--maret-success) !important; }
.bg-danger { background-color:var(--maret-danger) !important; }
.bg-warning { background-color:var(--maret-warning) !important; }

.btn { min-height:42px; border-radius:10px; font-weight:650; transition:all var(--maret-transition); }
.btn-primary { background:var(--maret-brand); border-color:var(--maret-brand); }
.btn-primary:hover, .btn-primary:focus { background:var(--maret-brand-dark); border-color:var(--maret-brand-dark); }
.btn-outline-success { color:var(--maret-brand); border-color:var(--maret-brand); }
.btn-outline-success:hover { background:var(--maret-brand); border-color:var(--maret-brand); }

.form-label { color:#344054; font-weight:650; margin-bottom:7px; }
.form-control, .form-select {
    min-height:44px; border:1px solid #d0d5dd; border-radius:10px; background-color:#fff;
    color:var(--maret-text); box-shadow:0 1px 2px rgba(16,24,40,.03);
}
.form-control:focus, .form-select:focus { border-color:#8aaef8; box-shadow:0 0 0 4px rgba(37,99,235,.12); }
.text-danger, .validation-message { font-size:.82rem; font-weight:550; }

.table-responsive, .dataTables_wrapper { background:#fff; border:1px solid var(--maret-border); border-radius:var(--maret-radius); overflow:auto; box-shadow:var(--maret-shadow); }
.table { margin-bottom:0; color:var(--maret-text); }
.table > :not(caption) > * > * { padding:14px 16px; border-bottom-color:var(--maret-border); vertical-align:middle; }
.table thead th { position:sticky; top:0; z-index:2; background:#f8fafc; color:#475467; font-size:.76rem; text-transform:uppercase; letter-spacing:.04em; white-space:nowrap; }
.table tbody tr { transition:background var(--maret-transition); }
.table tbody tr:hover { background:#f8fafc; }

.main-header { background:rgba(255,255,255,.94); border-bottom:1px solid var(--maret-border); backdrop-filter:blur(12px); }
.main-title { color:var(--maret-text); font-weight:750; }
.sidebar { border-right:1px solid rgba(255,255,255,.07); }
.sidebar-menu a { border-radius:9px; transition:background var(--maret-transition), color var(--maret-transition); }
.sidebar-menu a.active { background:rgba(229,27,43,.16); color:#fff; box-shadow:inset 3px 0 0 var(--maret-brand); }
.sidebar-menu a.active i { color:#fff; }
.sidebar-logo img { max-height:48px; }
.sidebar-search { margin:0 18px 14px; position:relative; }
.sidebar-search input { width:100%; height:40px; border:1px solid rgba(255,255,255,.12); border-radius:10px; padding:0 38px 0 12px; background:rgba(255,255,255,.07); color:#fff; }
.sidebar-search input::placeholder { color:rgba(255,255,255,.55); }
.sidebar-search i { position:absolute; right:12px; top:11px; color:rgba(255,255,255,.6); }
.sidebar-no-result { display:none; color:rgba(255,255,255,.65); padding:18px 30px; font-size:.85rem; }

.connection-pill { display:flex; align-items:center; border:1px solid var(--maret-border); border-radius:999px; padding:8px 12px; color:var(--maret-text-muted); background:#fff; font-size:.78rem; white-space:nowrap; }
.sagbar { display:flex; justify-content:space-between; align-items:center; gap:20px; margin:0 0 10px; padding:13px 16px; border:1px solid var(--maret-border); border-radius:10px; background:var(--maret-surface-muted); color:var(--maret-text-muted); }
.sagbar b { color:var(--maret-text); font-variant-numeric:tabular-nums; text-align:right; }
#loader { min-height:180px; display:grid; place-items:center; color:var(--maret-text-muted); background:var(--maret-surface); border:1px solid var(--maret-border); border-radius:var(--maret-radius); }
.apexcharts-canvas { margin-inline:auto; }

.empty-state { padding:48px 24px; text-align:center; color:var(--maret-text-muted); }
.empty-state i { display:block; font-size:42px; color:#98a2b3; margin-bottom:10px; }
.skeleton { background:linear-gradient(90deg,#eef1f5 25%,#f8fafc 50%,#eef1f5 75%); background-size:200% 100%; animation:ui-skeleton 1.5s infinite; border-radius:8px; }
@keyframes ui-skeleton { to { background-position:-200% 0; } }

#ui-toast-region { position:fixed; right:20px; bottom:20px; z-index:11000; display:grid; gap:10px; }
.ui-toast { min-width:280px; max-width:420px; background:#172033; color:#fff; border-radius:12px; padding:14px 16px; box-shadow:0 16px 36px rgba(0,0,0,.22); animation:ui-toast-in .2s ease; }
.ui-toast.success { border-left:4px solid #22c55e; }
.ui-toast.error { border-left:4px solid #ef4444; }
@keyframes ui-toast-in { from { transform:translateY(8px); opacity:0; } }

@media (max-width:1199px) { .ui-kpi-grid { grid-template-columns:repeat(2,minmax(0,1fr)); } }
@media (max-width:767px) {
    .main-content { padding:16px !important; }
    .page-intro { align-items:flex-start; flex-direction:column; }
    .ui-kpi-grid { grid-template-columns:1fr; }
    .ui-kpi { min-height:96px; }
    .main-header .connection-pill { display:none; }
    .responsive-text { display:none !important; }
    .table-responsive, .dataTables_wrapper { border-radius:10px; }
    .btn { min-height:44px; }
}

@media (prefers-reduced-motion:reduce) {
    *, *::before, *::after { scroll-behavior:auto !important; animation-duration:.01ms !important; animation-iteration-count:1 !important; transition-duration:.01ms !important; }
}

/* ========================================================================== 
   Maret SCADA — modern light control-room shell
   ========================================================================== */
:root {
    --scada-sidebar-width: 288px;
    --scada-header-height: 82px;
    --scada-navy-950: #0b1220;
    --scada-navy-900: #111827;
    --scada-navy-800: #1f2937;
    --scada-canvas: #f2f5f8;
    --scada-panel: #ffffff;
    --scada-panel-soft: #f8fafc;
    --scada-line: #dfe5ec;
    --scada-copy: #172033;
    --scada-muted: #647184;
    --scada-red: #e31b2a;
    --scada-red-dark: #bd1220;
    --scada-green: #16834a;
    --scada-amber: #b76a00;
    --scada-blue: #1769c2;
    --scada-radius: 12px;
    --scada-shadow: 0 1px 2px rgba(15,23,42,.04), 0 8px 24px rgba(15,23,42,.055);
}

html { background: var(--scada-canvas); }
body.scada-shell { min-height:100vh; background:var(--scada-canvas) !important; color:var(--scada-copy); overflow-x:hidden; }
.skip-link { position:fixed; left:16px; top:-80px; z-index:2000; padding:10px 14px; border-radius:8px; background:#fff; color:var(--scada-copy); box-shadow:var(--scada-shadow); }
.skip-link:focus { top:12px; }

/* Sidebar */
body.scada-shell .sidebar {
    position:fixed; inset:0 auto 0 0; width:var(--scada-sidebar-width); height:100vh;
    border:0; border-right:1px solid var(--scada-line); border-radius:0; background:#fff;
    box-shadow:4px 0 20px rgba(15,23,42,.045); overflow:hidden; transform:translateX(0); z-index:1050;
}
body.scada-shell .sidebar::after { content:""; position:absolute; inset:auto 0 0; height:2px; background:linear-gradient(90deg,var(--scada-red),transparent); }
body.scada-shell .sidebar-logo {
    height:104px; padding:18px 20px; display:flex; align-items:center; justify-content:space-between;
    border-bottom:1px solid var(--scada-line); background:#fff;
}
.scada-brand { display:flex !important; flex-direction:column; align-items:flex-start; gap:5px; min-width:0; }
.scada-brand img { width:138px; height:auto !important; max-height:44px; object-fit:contain; }
.scada-brand__meta { color:#778499; font-size:10.5px; font-weight:700; letter-spacing:.17em; white-space:nowrap; }
.scada-brand__meta b { color:#ff5967; font-weight:800; }
body.scada-shell .sidebar-close {
    position:static; display:none; width:38px; height:38px; margin:0; padding:0; border:1px solid var(--scada-line);
    border-radius:9px; background:#f6f8fa; color:#526176; font-size:24px; place-items:center;
}
.sidebar-section-label { padding:16px 22px 8px; color:#62718a; font-size:10.5px; font-weight:800; letter-spacing:.18em; text-transform:uppercase; }
body.scada-shell .sidebar-search { margin:0 16px 12px; }
body.scada-shell .sidebar-search input {
    height:42px; padding:0 39px 0 14px; border:1px solid var(--scada-line); border-radius:9px;
    background:#f7f9fb; color:var(--scada-copy); font-size:14px; outline:0;
}
body.scada-shell .sidebar-search input:focus { border-color:rgba(255,89,103,.7); box-shadow:0 0 0 3px rgba(227,27,42,.13); }
body.scada-shell .sidebar-search input::placeholder { color:#8d98a9; }
body.scada-shell .sidebar-search i { top:12px; color:#8190a7; }
body.scada-shell .sidebar { display:flex; flex-direction:column; }
body.scada-shell .sidebar > * { flex:0 0 auto; }
body.scada-shell .simlebar-sc { flex:1 1 auto; min-height:0; height:auto; overflow-y:auto; overscroll-behavior:contain; padding-bottom:40px; }
body.scada-shell .sidebar-menu.tf { padding:0 12px 30px; }
body.scada-shell .sidebar-menu { padding:0; }
body.scada-shell .sidebar-menu > li { margin:2px 0; }
body.scada-shell .sidebar-menu > li > a {
    position:relative; width:100%; height:auto; min-height:46px; padding:11px 12px; border-radius:9px;
    color:#526176; font-size:14.5px; font-weight:600; line-height:1.25; text-transform:none; letter-spacing:.005em;
}
body.scada-shell .sidebar-menu > li > a > i { width:22px; flex:0 0 22px; margin-right:10px; color:#7e8da4; font-size:21px; text-align:center; }
body.scada-shell .sidebar-menu > li > a:hover { color:#1f2937; background:#f4f6f9; }
body.scada-shell .sidebar-menu > li > a:hover > i { color:var(--scada-red); }
body.scada-shell .sidebar-menu > li > a.active,
body.scada-shell .sidebar-menu > li > a.active-parent {
    color:#a81421; background:linear-gradient(90deg,#fff0f2,#fff8f9); box-shadow:inset 3px 0 0 var(--scada-red);
}
body.scada-shell .sidebar-menu > li > a.active > i,
body.scada-shell .sidebar-menu > li > a.active-parent > i { color:#ff7180; }
body.scada-shell .sidebar-menu-dropdown .dropdown-icon { right:9px; color:#64748b; }
body.scada-shell .sidebar-menu-dropdown-content { height:0; overflow:hidden; margin:2px 0 4px; border-left:1px solid #e7ebf0; }
body.scada-shell .sidebar-menu-dropdown-content.active { height:auto; }
body.scada-shell .sidebar-menu.sidebar-menu-dropdown-content > li > a {
    min-height:36px; height:auto; padding:8px 10px 8px 43px; border-radius:7px; color:#708096; font-size:13.5px; font-weight:500;
}
body.scada-shell .sidebar-menu.sidebar-menu-dropdown-content > li > a::before {
    content:""; position:absolute; left:25px; width:4px; height:4px; border-radius:50%; background:#4b5a70;
}
body.scada-shell .sidebar-menu.sidebar-menu-dropdown-content > li > a:hover { color:#1f2937; background:#f5f7f9; }
body.scada-shell .sidebar-menu.sidebar-menu-dropdown-content > li > a.active { color:#a81421; background:#fff2f3; }
body.scada-shell .sidebar-menu.sidebar-menu-dropdown-content > li > a.active::before { background:#ff5967; box-shadow:0 0 0 4px rgba(227,27,42,.12); }
body.scada-shell .sidebar-no-result { padding:18px 22px; color:#94a3b8; }

/* Topbar */
body.scada-shell .scada-topbar {
    position:fixed; top:0; right:0; left:var(--scada-sidebar-width); z-index:1000; height:var(--scada-header-height);
    display:flex; align-items:center; justify-content:space-between; gap:20px; padding:0 28px;
    border-bottom:1px solid var(--scada-line); background:rgba(255,255,255,.96); box-shadow:0 1px 8px rgba(15,23,42,.035); backdrop-filter:blur(14px);
}
.scada-topbar__identity, .scada-topbar__actions { display:flex; align-items:center; }
.scada-topbar__identity { min-width:0; gap:13px; }
.scada-topbar__actions { gap:9px; }
.scada-page-identity { min-width:0; }
.scada-page-identity__kicker { display:flex; align-items:center; gap:7px; margin-bottom:2px; color:#8490a3; font-size:10.5px; font-weight:800; letter-spacing:.15em; text-transform:uppercase; }
.scada-page-identity__kicker span { width:14px; height:2px; background:var(--scada-red); }
.scada-page-identity__title { overflow:hidden; color:var(--scada-copy); font-size:19px; font-weight:750; line-height:1.2; text-overflow:ellipsis; white-space:nowrap; }
.scada-icon-button, .scada-header-action {
    min-width:42px; height:42px; min-height:42px; display:inline-flex; align-items:center; justify-content:center;
    border:1px solid var(--scada-line); border-radius:9px; background:#fff; color:#465368; box-shadow:0 1px 2px rgba(15,23,42,.03); transition:all 160ms ease;
}
.scada-icon-button { padding:0; font-size:21px; }
.scada-icon-button:hover, .scada-header-action:hover { border-color:#cbd4df; background:#f7f9fb; color:var(--scada-red); transform:translateY(-1px); }
.scada-header-action--wide { gap:8px; padding:0 14px; font-size:13.5px; font-weight:700; }
.scada-header-action--wide i { color:var(--scada-red); font-size:20px; }
.scada-user-button {
    height:46px; display:flex; align-items:center; gap:10px; padding:4px 10px 4px 5px; border:1px solid var(--scada-line);
    border-radius:10px; background:#fff; color:var(--scada-copy); transition:all 160ms ease;
}
.scada-user-button:hover { border-color:#c8d0db; box-shadow:0 4px 12px rgba(15,23,42,.06); }
.scada-user-avatar { width:34px; height:34px; display:grid; place-items:center; border-radius:8px; background:#fff0f2; color:var(--scada-red); font-size:20px; }
.scada-user-copy { max-width:150px; display:flex; flex-direction:column; align-items:flex-start; line-height:1.15; }
.scada-user-copy small { color:#8a96a8; font-size:10.5px; font-weight:650; text-transform:uppercase; letter-spacing:.07em; }
.scada-user-copy strong { overflow:hidden; max-width:100%; color:#344054; font-size:13px; font-weight:750; text-overflow:ellipsis; white-space:nowrap; }
.scada-user-chevron { color:#98a2b3; font-size:17px; }
.scada-user-dropdown { min-width:220px; margin-top:10px !important; padding:8px; border:1px solid var(--scada-line); border-radius:11px; box-shadow:0 18px 40px rgba(15,23,42,.13); }
.scada-dropdown-heading { padding:7px 10px 9px; color:#98a2b3; font-size:10.5px; font-weight:800; letter-spacing:.1em; text-transform:uppercase; }
.scada-user-dropdown .dropdown-item { display:flex; align-items:center; gap:10px; padding:10px; border-radius:8px; font-size:13.5px; font-weight:600; }
.scada-user-dropdown .dropdown-item i { width:18px; font-size:19px; }
body.scada-shell .mobile-toggle { display:grid; margin:0; }

/* Canvas and page components */
body.scada-shell .main { min-height:100vh; padding-left:var(--scada-sidebar-width); transition:padding-left 200ms ease; }
body.scada-shell .main-content { width:100%; max-width:none; min-height:100vh; margin:0; padding:calc(var(--scada-header-height) + 28px) 30px 40px; }
body.scada-shell.sidebar-expand.active .sidebar { transform:translateX(-100%); }
body.scada-shell.sidebar-expand.active .main { padding-left:0; }
body.scada-shell.sidebar-expand.active .scada-topbar { left:0; }
body.scada-shell .page-intro { margin-bottom:20px; padding:2px 0; }
body.scada-shell .page-eyebrow { color:var(--scada-red); font-size:10.5px; font-weight:800; letter-spacing:.14em; }
body.scada-shell .page-heading { font-size:26px; letter-spacing:-.025em; }
body.scada-shell .page-description { color:var(--scada-muted); font-size:14.5px; }
body.scada-shell .box, body.scada-shell .card {
    border:1px solid var(--scada-line) !important; border-radius:var(--scada-radius) !important; background:var(--scada-panel); box-shadow:var(--scada-shadow) !important;
}
body.scada-shell .box { padding:20px; }
body.scada-shell .box.left-dot { position:relative; overflow:hidden; }
body.scada-shell .box.left-dot::before { content:""; position:absolute; inset:0 auto 0 0; width:3px; background:var(--scada-red); }
body.scada-shell .box-title, body.scada-shell .card-title { color:var(--scada-copy); font-size:15px; font-weight:750; }
body.scada-shell .ui-kpi-grid { grid-template-columns:repeat(4,minmax(0,1fr)); gap:14px; }
body.scada-shell .ui-kpi { min-height:104px; padding:17px; border-top:2px solid #edf0f4 !important; }
body.scada-shell .ui-kpi__icon { width:44px; height:44px; flex-basis:44px; border-radius:10px; font-size:22px; }
body.scada-shell .ui-kpi__value { font-size:25px; letter-spacing:-.03em; }
body.scada-shell .ui-kpi__label { margin-bottom:3px; font-size:12px; text-transform:uppercase; letter-spacing:.055em; }
.scada-machine-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:14px; margin-bottom:24px; }
.scada-machine-card {
    position:relative; min-height:188px; display:flex !important; flex-direction:column; padding:17px; overflow:hidden;
    border:1px solid var(--scada-line); border-radius:var(--scada-radius); background:#fff; color:var(--scada-copy);
    box-shadow:var(--scada-shadow); transition:transform 160ms ease,border-color 160ms ease,box-shadow 160ms ease;
}
.scada-machine-card::before { content:""; position:absolute; inset:0 0 auto; height:2px; background:#d6dce5; }
.scada-machine-card.is-running::before { background:var(--scada-green); }
.scada-machine-card.is-stopped::before { background:var(--scada-red); }
.scada-machine-card:hover { color:var(--scada-copy); border-color:#cbd4df; box-shadow:0 12px 30px rgba(15,23,42,.09); transform:translateY(-2px); }
.scada-machine-card__top { display:flex; justify-content:space-between; align-items:center; gap:12px; }
.scada-machine-card__icon { width:34px; height:34px; display:grid; place-items:center; border-radius:8px; background:#f2f5f8; color:#64748b; font-size:20px; }
.scada-machine-card.is-running .scada-machine-card__icon { background:#edf8f2; color:var(--scada-green); }
.scada-machine-card.is-stopped .scada-machine-card__icon { background:#fff1f2; color:var(--scada-red); }
.scada-machine-state { display:flex; align-items:center; padding:6px 8px; border:1px solid var(--scada-line); border-radius:6px; background:#fafbfd; color:#536176; font-size:11px; font-weight:800; letter-spacing:.045em; text-transform:uppercase; }
.scada-machine-card__name { min-height:38px; margin:15px 0 12px; font-size:15px; font-weight:750; line-height:1.35; }
.scada-machine-card__metric { display:flex; align-items:flex-end; justify-content:space-between; gap:12px; }
.scada-machine-card__metric span:first-child { display:flex; flex-direction:column; }
.scada-machine-card__metric small { margin-bottom:2px; color:#8994a6; font-size:11px; font-weight:700; letter-spacing:.06em; text-transform:uppercase; }
.scada-machine-card__metric strong { font-size:22px; font-weight:780; letter-spacing:-.03em; font-variant-numeric:tabular-nums; }
.scada-machine-card__unit { margin-bottom:3px; color:#98a2b3; font-size:10px; font-weight:800; letter-spacing:.12em; }
.scada-machine-card__footer { display:flex; align-items:center; justify-content:space-between; margin-top:auto; padding-top:11px; border-top:1px solid #edf0f4; color:#718096; font-size:12px; font-weight:650; }
.scada-machine-card__footer i { color:var(--scada-red); font-size:18px; transition:transform 160ms ease; }
.scada-machine-card:hover .scada-machine-card__footer i { transform:translateX(3px); }

/* Controls */
body.scada-shell .btn { min-height:40px; padding:8px 14px; border-radius:8px; font-size:13.5px; font-weight:700; box-shadow:none; }
body.scada-shell .btn-primary { background:var(--scada-red); border-color:var(--scada-red); }
body.scada-shell .btn-primary:hover { background:var(--scada-red-dark); border-color:var(--scada-red-dark); }
body.scada-shell .btn-outline-success { color:var(--scada-green); border-color:#a7d6bd; }
body.scada-shell .btn-outline-success:hover { background:var(--scada-green); border-color:var(--scada-green); color:#fff; }
body.scada-shell .btn-danger { background:#c92432; border-color:#c92432; }
body.scada-shell .form-label { margin-bottom:6px; color:#405066; font-size:12.5px; font-weight:750; letter-spacing:.025em; }
body.scada-shell .form-control, body.scada-shell .form-select {
    min-height:42px; border-color:#ced6e0; border-radius:8px; color:var(--scada-copy); font-size:14px;
}
body.scada-shell .form-control::placeholder { color:#99a4b4; }
body.scada-shell .form-control:focus, body.scada-shell .form-select:focus { border-color:#768aa5; box-shadow:0 0 0 3px rgba(23,105,194,.1); }

/* Operational data */
body.scada-shell .badge { border-radius:6px !important; font-size:12px; font-weight:750; }
body.scada-shell .status-dot { width:7px; height:7px; box-shadow:none; }
body.scada-shell .sagbar { min-height:46px; padding:10px 13px; border-color:var(--scada-line); border-radius:8px; background:#fafbfd; font-size:15px; }
body.scada-shell .sagbar b { font-size:13.5px; }
body.scada-shell canvas { max-width:100%; }
body.scada-shell #preview-textfield { color:var(--scada-copy); font-variant-numeric:tabular-nums; }
body.scada-shell #loader { min-height:160px; display:grid; place-items:center; color:var(--scada-muted); background:#fff; border:1px solid var(--scada-line); border-radius:var(--scada-radius); }
body.scada-shell #loader[style*="display: none"], body.scada-shell #loader.hidden { display:none !important; }

/* Tables and DataTables */
body.scada-shell .table-responsive, body.scada-shell .dataTables_wrapper { border-color:var(--scada-line); border-radius:10px; box-shadow:var(--scada-shadow); }
body.scada-shell .table { color:var(--scada-copy); font-size:13.5px; }
body.scada-shell .table > :not(caption) > * > * { padding:12px 14px; }
body.scada-shell .table thead th { background:#f5f7fa; color:#56647a; font-size:11px; font-weight:800; letter-spacing:.075em; }
body.scada-shell .table tbody tr:hover { background:#fafbfc; }
body.scada-shell .dataTables_wrapper { padding:16px; overflow:visible; }
body.scada-shell .dataTables_wrapper table { margin:12px 0 !important; }
body.scada-shell .dataTables_filter input, body.scada-shell .dataTables_length select { min-height:36px; border:1px solid #ced6e0; border-radius:7px; padding:6px 9px; background:#fff; }
body.scada-shell .page-link { color:#475569; border-color:var(--scada-line); font-size:13px; }
body.scada-shell .page-item.active .page-link { background:var(--scada-red); border-color:var(--scada-red); }

/* Legacy action buttons now share one professional language */
body.scada-shell .btn-modern, body.scada-shell .btn-modern-kullanici, body.scada-shell .btn-sorunbildir {
    min-height:42px; border:1px solid var(--scada-line); border-radius:9px; background:#fff; color:#465368; box-shadow:none;
}
body.scada-shell .btn-modern:hover, body.scada-shell .btn-modern-kullanici:hover, body.scada-shell .btn-sorunbildir:hover { border-color:#c8d0db; background:#f7f9fb; color:var(--scada-red); }

/* Session surface */
body.scada-shell #sessionExpiredModal { background:rgba(11,18,32,.62); backdrop-filter:blur(5px); }
body.scada-shell #sessionExpiredModal .session-modal-content { margin:12vh auto 0; padding:32px; border:1px solid var(--scada-line); border-radius:14px; box-shadow:0 24px 70px rgba(15,23,42,.25); }
body.scada-shell .modal-button { min-height:42px; border-radius:8px; background:var(--scada-red); font-weight:700; }
body.scada-shell .modal-button:hover { background:var(--scada-red-dark); }

@media (max-width:1400px) {
    :root { --scada-sidebar-width:260px; }
    body.scada-shell .ui-kpi-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
    .scada-machine-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
}

@media (max-width:1200px) {
    :root { --scada-sidebar-width:288px; }
    body.scada-shell .sidebar { transform:translateX(-101%); box-shadow:12px 0 35px rgba(15,23,42,.22); }
    body.scada-shell.sidebar-expand.active .sidebar { transform:translateX(0); }
    body.scada-shell .sidebar-close { display:grid; }
    body.scada-shell .main, body.scada-shell.sidebar-expand.active .main { padding-left:0; }
    body.scada-shell .scada-topbar, body.scada-shell.sidebar-expand.active .scada-topbar { left:0; }
    body.scada-shell .mobile-toggle { display:grid; }
    body.scada-shell .overlay { position:fixed; inset:0; z-index:1040; display:none; background:rgba(11,18,32,.48); backdrop-filter:blur(2px); }
    body.scada-shell .overlay.active { display:block; }
}

@media (max-width:767px) {
    :root { --scada-header-height:68px; }
    body.scada-shell .scada-topbar { padding:0 14px; }
    .scada-page-identity__kicker { display:none; }
    .scada-page-identity__title { max-width:180px; font-size:16px; }
    .scada-header-action--wide { width:42px; padding:0; }
    .scada-header-action--wide span, .scada-user-copy, .scada-user-chevron { display:none; }
    .scada-user-button { width:42px; padding:4px; }
    body.scada-shell .main-content { padding:calc(var(--scada-header-height) + 18px) 14px 28px !important; margin:0; }
    body.scada-shell .ui-kpi-grid { grid-template-columns:1fr 1fr; gap:10px; }
    body.scada-shell .ui-kpi { min-height:88px; padding:13px; gap:11px; }
    body.scada-shell .ui-kpi__icon { width:38px; height:38px; flex-basis:38px; }
    body.scada-shell .ui-kpi__value { font-size:21px; }
    body.scada-shell .sagbar { align-items:flex-start; flex-direction:column; gap:4px; }
    body.scada-shell .sagbar b { text-align:left; }
    .scada-machine-grid { grid-template-columns:1fr; gap:10px; }
    .scada-machine-card { min-height:174px; }
}

@media (max-width:420px) {
    body.scada-shell .ui-kpi-grid { grid-template-columns:1fr; }
    .scada-page-identity__title { max-width:130px; }
}


/* ==========================================================================
   Okunabilirlik ve kullanım iyileştirmeleri
   ========================================================================== */
html { font-size: 106.25%; }
body.scada-shell { font-size: 17px; line-height: 1.5; }

/* Sol menü: masaüstünde de açılır-kapanır, geçişler yumuşak */
body.scada-shell .sidebar { transition: transform 240ms cubic-bezier(.4,0,.2,1), box-shadow 240ms ease; }
body.scada-shell .scada-topbar { transition: left 240ms cubic-bezier(.4,0,.2,1); }
body.scada-shell .main { transition: padding-left 240ms cubic-bezier(.4,0,.2,1); }
body.scada-shell.sidebar-expand.active .sidebar { box-shadow: none; }
.mobile-toggle { cursor: pointer; transition: background var(--maret-transition), color var(--maret-transition), transform var(--maret-transition); }
.mobile-toggle:hover { color: var(--scada-red); }
.mobile-toggle:active { transform: scale(.94); }
body.scada-shell:not(.active) .mobile-toggle i::before { content: "\ea4a"; }

/* Formlar */
body.scada-shell .form-control, body.scada-shell .form-select, body.scada-shell select, body.scada-shell input[type="text"],
body.scada-shell input[type="date"], body.scada-shell input[type="number"], body.scada-shell input[type="search"] { font-size: 15.5px; min-height: 40px; }
body.scada-shell label, body.scada-shell .form-label { font-size: 14.5px; font-weight: 600; }
body.scada-shell .btn { font-size: 15px; font-weight: 600; border-radius: 9px; }

/* Tablolar */
body.scada-shell .table td, body.scada-shell .table th { font-size: 15px; vertical-align: middle; }
body.scada-shell .table thead th { font-size: 13px; }
body.scada-shell .table tbody tr { transition: background var(--maret-transition); }
body.scada-shell .table tbody tr:hover { background: #f6f9fc; }

/* Kaydırma çubuğu ve genel detaylar */
body.scada-shell ::-webkit-scrollbar { width: 10px; height: 10px; }
body.scada-shell ::-webkit-scrollbar-thumb { background: #cbd3de; border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
body.scada-shell ::-webkit-scrollbar-thumb:hover { background: #a9b4c4; background-clip: padding-box; border: 2px solid transparent; }
body.scada-shell .main-content { animation: maret-fade-in 220ms ease backwards; }
@keyframes maret-fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { body.scada-shell .main-content { animation: none; } }
body.scada-shell .sidebar-menu > li > a { min-height: 44px; }
body.scada-shell .scada-user-button, body.scada-shell .scada-header-action { min-height: 42px; }

@media (max-width: 767px) {
    html { font-size: 100%; }
    body.scada-shell { font-size: 16px; }
}

/* ==========================================================================
   Saat, tam ekran, ilerleme çubuğu, yukarı çık, kart cilası
   ========================================================================== */
.scada-clock { display:flex; align-items:center; gap:10px; padding:0 14px; height:44px; border:1px solid var(--scada-line); border-radius:10px; background:#fafbfd; color:#475467; }
.scada-clock > i { color:var(--scada-red); font-size:22px; }
.scada-clock span { display:flex; flex-direction:column; line-height:1.15; }
.scada-clock strong { font-size:16px; font-weight:750; font-variant-numeric:tabular-nums; letter-spacing:.01em; color:var(--scada-copy); }
.scada-clock small { font-size:11px; font-weight:600; color:#8a96a8; text-transform:capitalize; }
@media (max-width:1100px) { .scada-clock small { display:none; } }
@media (max-width:767px) { .scada-clock { display:none; } #fullscreen-toggle { display:none !important; } }

#nav-progress { position:fixed; top:0; left:0; z-index:3000; height:3px; width:0; background:linear-gradient(90deg,var(--scada-red),#ff7a85); box-shadow:0 0 10px rgba(227,27,42,.5); opacity:0; pointer-events:none; }
#nav-progress.is-running { opacity:1; width:88%; transition:width 8s cubic-bezier(.1,.7,.2,1); }

#back-to-top { position:fixed; right:22px; bottom:22px; z-index:900; width:46px; height:46px; display:grid; place-items:center; border:1px solid var(--scada-line); border-radius:12px; background:#fff; color:var(--scada-red); font-size:26px; box-shadow:var(--scada-shadow); opacity:0; transform:translateY(12px); pointer-events:none; transition:opacity 180ms ease, transform 180ms ease, background 160ms ease; cursor:pointer; }
#back-to-top.is-visible { opacity:1; transform:none; pointer-events:auto; }
#back-to-top:hover { background:var(--scada-red); color:#fff; }

/* Menü: geçişler */
body.scada-shell .sidebar-menu > li > a { transition:background 160ms ease, color 160ms ease, padding-left 160ms ease; }
body.scada-shell .sidebar-menu-dropdown-content > li > a { transition:background 160ms ease, color 160ms ease, transform 160ms ease; }
body.scada-shell .sidebar-menu-dropdown-content > li > a:hover { transform:translateX(3px); }
body.scada-shell .sidebar-search input { transition:border-color 160ms ease, box-shadow 160ms ease, background 160ms ease; }
body.scada-shell .sidebar-search input:focus { background:#fff; }

/* KPI ve makine kartları */
body.scada-shell .ui-kpi { position:relative; overflow:hidden; transition:transform 180ms ease, box-shadow 180ms ease; }
body.scada-shell .ui-kpi:hover { transform:translateY(-3px); box-shadow:0 14px 34px rgba(15,23,42,.12) !important; }
body.scada-shell .ui-kpi:nth-child(1) { border-top-color:#94a3b8 !important; }
body.scada-shell .ui-kpi:nth-child(2) { border-top-color:var(--scada-green) !important; }
body.scada-shell .ui-kpi:nth-child(3) { border-top-color:var(--scada-red) !important; }
body.scada-shell .ui-kpi:nth-child(4) { border-top-color:var(--scada-blue) !important; }
body.scada-shell .ui-kpi__value { font-size:28px; }
.scada-machine-card.is-running .scada-machine-state { background:#edf8f2; border-color:#bfe3cf; color:var(--scada-green); }
.scada-machine-card.is-stopped .scada-machine-state { background:#fff1f2; border-color:#f7c6cb; color:var(--scada-red); }
.scada-machine-card.is-running .scada-machine-state::before { content:""; width:8px; height:8px; margin-right:7px; border-radius:50%; background:var(--scada-green); animation:maret-pulse 1.8s ease-out infinite; }
.scada-machine-card.is-stopped .scada-machine-state::before { content:""; width:8px; height:8px; margin-right:7px; border-radius:50%; background:var(--scada-red); }
@keyframes maret-pulse { 0% { box-shadow:0 0 0 0 rgba(22,131,74,.5); } 70% { box-shadow:0 0 0 8px rgba(22,131,74,0); } 100% { box-shadow:0 0 0 0 rgba(22,131,74,0); } }
@media (prefers-reduced-motion:reduce) { .scada-machine-card.is-running .scada-machine-state::before { animation:none; } #nav-progress.is-running { transition:none; } }

/* Başlık alanı */
body.scada-shell .page-intro { padding-bottom:16px; border-bottom:1px solid var(--scada-line); }
body.scada-shell .page-heading { font-size:30px; font-weight:800; }

/* Yazdırma: menü ve üst çubuk gizlenir, içerik tam sayfa */
@media print {
    body.scada-shell .sidebar, body.scada-shell .scada-topbar, #back-to-top, #nav-progress, .overlay, #ui-toast-region { display:none !important; }
    body.scada-shell .main { padding-left:0 !important; }
    body.scada-shell .main-content { padding:0 !important; }
    body.scada-shell .box, body.scada-shell .card { box-shadow:none !important; break-inside:avoid; }
}

/* ==========================================================================
   Modal pencereler: yeni açık temaya uyum (kullanıcı ekle/düzenle vb.)
   ========================================================================== */
.modal { z-index: 2000 !important; }
.modal-backdrop { z-index: 1990 !important; background: #0b1220; }
.modal-backdrop.show { opacity: .55; }
body.scada-shell .modal-dialog { margin-top: 5vh; }
body.scada-shell .modal-content {
    border: 1px solid var(--scada-line); border-radius: 16px; background: #fff; overflow: hidden;
    box-shadow: 0 30px 80px rgba(11,18,32,.35);
}
body.scada-shell .modal-header {
    position: relative; padding: 20px 24px 16px; border-bottom: 1px solid var(--scada-line);
    background: linear-gradient(180deg, #fbfcfd, #f4f7fa);
}
body.scada-shell .modal-header::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--scada-red); }
body.scada-shell .modal-title { color: var(--scada-copy); font-size: 19px; font-weight: 800; letter-spacing: -.01em; }
body.scada-shell .modal-header .close, body.scada-shell .modal-header .btn-close {
    width: 38px; height: 38px; margin: -4px -6px -4px auto; padding: 0; display: grid; place-items: center;
    border: 0; border-radius: 10px; background: #eef2f6; color: #475467; font-size: 26px; line-height: 1; opacity: 1; cursor: pointer;
    transition: background .16s, color .16s;
}
body.scada-shell .modal-header .close:hover, body.scada-shell .modal-header .btn-close:hover { background: #fde8ea; color: var(--scada-red); }
body.scada-shell .modal-body { padding: 22px 24px 8px; }
body.scada-shell .modal-body label { display: block; margin: 0 0 6px; color: #405066; font-size: 13.5px; font-weight: 700; }
body.scada-shell .modal-body br { display: none; }
body.scada-shell .modal-body .form-control, body.scada-shell .modal-body .form-select { margin-bottom: 16px !important; }
body.scada-shell .modal-footer { padding: 14px 24px 20px; border-top: 0; gap: 10px; }
body.scada-shell .modal-footer .btn { min-width: 120px; min-height: 44px; border-radius: 10px; font-weight: 700; }
body.scada-shell .modal-footer .btn-outline-success, body.scada-shell .modal-footer .btn-success, body.scada-shell .modal-footer button[type="submit"] {
    background: var(--scada-red); border-color: var(--scada-red); color: #fff;
}
body.scada-shell .modal-footer .btn-outline-success:hover, body.scada-shell .modal-footer .btn-success:hover, body.scada-shell .modal-footer button[type="submit"]:hover {
    background: var(--scada-red-dark); border-color: var(--scada-red-dark); color: #fff;
}
@media (max-width: 575px) { body.scada-shell .modal-dialog { margin: 10px; } body.scada-shell .modal-header, body.scada-shell .modal-body, body.scada-shell .modal-footer { padding-left: 16px; padding-right: 16px; } }

/* Üst çubuk: sistem sağlık göstergesi */
.scada-health { display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 14px; border: 1px solid var(--scada-line); border-radius: 10px; background: #fafbfd; color: #475467; font-size: 13.5px; font-weight: 700; white-space: nowrap; cursor: default; }
.scada-health__dot { width: 10px; height: 10px; border-radius: 50%; background: #94a3b8; flex: 0 0 10px; }
.scada-health.is-ok { color: #166534; border-color: #bbe5cb; background: #f0fbf4; }
.scada-health.is-ok .scada-health__dot { background: #22c55e; box-shadow: 0 0 0 0 rgba(34,197,94,.6); animation: scada-health-pulse 2s ease-out infinite; }
.scada-health.is-warn { color: #92400e; border-color: #f4d9a6; background: #fff8eb; }
.scada-health.is-warn .scada-health__dot { background: #f59e0b; }
.scada-health.is-bad { color: #991b1b; border-color: #f6c6c6; background: #fff1f2; }
.scada-health.is-bad .scada-health__dot { background: #ef4444; animation: scada-health-blink 1s ease-in-out infinite; }
@keyframes scada-health-pulse { 70% { box-shadow: 0 0 0 7px rgba(34,197,94,0); } 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); } }
@keyframes scada-health-blink { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .scada-health__dot { animation: none !important; } }
@media (max-width: 991px) { .scada-health__text { display: none; } .scada-health { padding: 0 12px; } }
