:root {
    --bg: #080d13;
    --surface: #101821;
    --surface-2: #151f2a;
    --surface-3: #1a2632;
    --surface-hover: #1d2b38;
    --border: #263441;
    --border-soft: #1d2a35;
    --text: #edf3f7;
    --muted: #8fa0ae;
    --muted-2: #647583;
    --green: #27c281;
    --green-dark: #123a2e;
    --green-bright: #6be0ac;
    --blue: #49a6f2;
    --blue-dark: #15324a;
    --amber: #f0a62e;
    --amber-dark: #3b2d16;
    --red: #ef5b5b;
    --red-dark: #3b1e22;
    --purple: #a989f5;
    --sidebar-width: 248px;
    --topbar-height: 74px;
    --radius: 12px;
    --shadow: 0 14px 35px rgba(0, 0, 0, .25);
}

html[data-theme="light"] {
    color-scheme: light;
    --bg: #eef2f4;
    --surface: #ffffff;
    --surface-2: #f8fafb;
    --surface-3: #e9eff2;
    --surface-hover: #e4ebee;
    --border: #cdd8de;
    --border-soft: #dfe6ea;
    --text: #17242d;
    --muted: #5c6f7a;
    --muted-2: #7a8b94;
    --green: #17815b;
    --green-dark: #dcefe7;
    --green-bright: #126b4c;
    --blue: #357fae;
    --blue-dark: #e0edf5;
    --amber: #a87118;
    --amber-dark: #f4ead6;
    --red: #b9474d;
    --red-dark: #f4dfe1;
    --purple: #6f5aa2;
    --shadow: 0 10px 28px rgba(41, 58, 68, .10);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: auto;
    zoom: 1;
    font-size: 100%;
}

body {
    margin: 0;
    min-width: 320px;
    min-height: 100vh;
    overflow-x: hidden;
    color: var(--text);
    background:
        radial-gradient(circle at 80% -20%, rgba(39, 194, 129, .07), transparent 34%),
        var(--bg);
    font-family: "Segoe UI", Inter, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.45;
    transform: none;
    zoom: 1;
}

.workspace,
.content,
.view {
    transform: none;
    zoom: 1;
}

button,
input,
select {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
select {
    cursor: pointer;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid var(--green);
    outline-offset: 2px;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

.app-shell {
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    z-index: 40;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    background: #0b1219;
    border-right: 1px solid var(--border-soft);
}

.brand {
    height: var(--topbar-height);
    padding: 0 22px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-soft);
}

.brand-mark {
    width: 34px;
    height: 34px;
    padding: 6px;
    display: flex;
    align-items: flex-end;
    gap: 3px;
    border-radius: 8px;
    color: #06130e;
    background: linear-gradient(145deg, var(--green-bright), var(--green));
    box-shadow: 0 0 20px rgba(39, 194, 129, .18);
}

.brand-mark span {
    width: 6px;
    display: block;
    background: currentColor;
    border-radius: 1px 1px 0 0;
}

.brand-mark span:nth-child(1) { height: 50%; }
.brand-mark span:nth-child(2) { height: 90%; }
.brand-mark span:nth-child(3) { height: 68%; }

.brand-copy {
    display: flex;
    flex-direction: column;
    letter-spacing: .03em;
}

.brand-copy strong {
    font-size: 17px;
    letter-spacing: .14em;
}

.brand-copy small,
.sidebar-footer small {
    color: var(--muted);
    font-size: 12px;
}

.main-nav {
    flex: 1;
    padding: 18px 12px;
    overflow-y: auto;
    scrollbar-width: none;
}

.main-nav::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

.nav-label {
    margin: 18px 12px 7px;
    color: var(--muted-2);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
}

.nav-label:first-child {
    margin-top: 0;
}

.main-nav a {
    min-height: 46px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: #9aabb8;
    border: 1px solid transparent;
    border-radius: 8px;
    font-weight: 600;
    transition: .18s ease;
}

.main-nav a:hover {
    color: var(--text);
    background: var(--surface);
}

body:not(:has(.view:target)) .main-nav a[href="#dashboard"],
body:has(#dashboard:target) .main-nav a[href="#dashboard"],
body:has(#machine-details:target) .main-nav a[href="#machine-details"],
body:has(#logs:target) .main-nav a[href="#logs"],
body:has(#consumables:target) .main-nav a[href="#consumables"],
body:has(#settings:target) .main-nav a[href="#settings"],
body:has(#notifications:target) .main-nav a[href="#notifications"],
body:has(#system-debug:target) .main-nav a[href="#system-debug"],
body:has(#about:target) .main-nav a[href="#about"] {
    color: #dff8ec;
    background: linear-gradient(90deg, rgba(39, 194, 129, .17), rgba(39, 194, 129, .06));
    border-color: rgba(39, 194, 129, .17);
    box-shadow: inset 3px 0 var(--green);
}

.nav-icon {
    width: 20px;
    color: var(--muted);
    font-size: 18px;
    text-align: center;
}

.nav-count {
    min-width: 21px;
    height: 21px;
    margin-left: auto;
    display: grid;
    place-items: center;
    color: white;
    background: var(--red);
    border-radius: 10px;
    font-size: 11px;
}

.sidebar-status {
    margin: 10px 14px 16px;
    padding: 12px;
    display: grid;
    gap: 12px;
    background: #0e171f;
    border: 1px solid var(--border-soft);
    border-radius: 9px;
}

.status-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-row > span:last-child {
    display: flex;
    flex-direction: column;
}

.status-row small {
    color: var(--muted);
    font-size: 11px;
}

.status-row strong {
    font-size: 12px;
}

.status-dot {
    width: 8px;
    height: 8px;
    display: inline-block;
    flex: 0 0 auto;
    background: var(--amber);
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(240, 166, 46, .12);
}

.status-dot.online {
    background: var(--green);
    box-shadow: 0 0 0 3px rgba(39, 194, 129, .13), 0 0 10px rgba(39, 194, 129, .35);
}

.status-dot.fault-dot {
    background: var(--red);
    box-shadow: 0 0 0 3px rgba(239, 91, 91, .13);
}

.sidebar-footer {
    position: relative;
    min-height: 70px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-top: 1px solid var(--border-soft);
    cursor: pointer;
}

.user-menu {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: calc(100% + 8px);
    z-index: 50;
    padding: 6px;
    display: grid;
    gap: 2px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
}

.user-menu[hidden] {
    display: none !important;
}

.user-menu a,
.user-menu button {
    width: 100%;
    min-height: 36px;
    padding: 0 10px;
    display: flex;
    align-items: center;
    color: var(--text);
    background: transparent;
    border: 0;
    border-radius: 7px;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.user-menu a:hover,
.user-menu button:hover {
    background: var(--surface-hover);
}

.machines-grid.compact-view {
    grid-template-columns: 1fr;
    gap: 10px;
}

.machines-grid.compact-view .machine-card-body,
.machines-grid.compact-view .custom-gauge,
.machines-grid.compact-view .production-stat .progress,
.machines-grid.compact-view .production-stat p {
    display: none;
}

.machines-grid.compact-view .metric-strip {
    border-top: 0;
}

.sidebar-footer > div:nth-child(2) {
    min-width: 0;
    display: flex;
    flex: 1;
    flex-direction: column;
}

.sidebar-footer strong {
    font-size: 12px;
}

.user-avatar {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    color: #dff8ec;
    background: var(--green-dark);
    border: 1px solid rgba(39, 194, 129, .3);
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
}

.more-icon {
    color: var(--muted);
    letter-spacing: 1px;
}

.workspace {
    min-height: 100vh;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
}

.topbar {
    position: relative;
    z-index: 1;
    height: var(--topbar-height);
    padding: 0 clamp(18px, 2.5vw, 38px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    background: rgba(8, 13, 19, .93);
    border-bottom: 1px solid var(--border-soft);
    backdrop-filter: blur(16px);
}

.settings-frozen-stack {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--bg);
    border-bottom: 1px solid var(--border-soft);
}

.settings-frozen-stack .topbar {
    border-bottom: 0;
}

.settings-sticky-header {
    display: none;
    --settings-title-size: clamp(22px, 1.8vw, 28px);
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 8px clamp(18px, 2.5vw, 38px) 10px;
    background: var(--bg);
}

body:has(#settings:target) .settings-sticky-header,
body:has(.settings-section:target) .settings-sticky-header {
    display: flex;
}

.mobile-brand {
    display: none;
    align-items: center;
    gap: 9px;
    letter-spacing: .1em;
}

.global-search {
    width: min(470px, 48vw);
    min-height: 42px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    background: #0e161e;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.global-search input {
    min-width: 0;
    flex: 1;
    color: var(--text);
    background: transparent;
    border: 0;
    outline: 0;
}

.global-search input::placeholder {
    color: #677986;
}

kbd {
    padding: 3px 7px;
    color: #b4c1ca;
    background: #17222c;
    border: 1px solid #354553;
    border-bottom-width: 2px;
    border-radius: 5px;
    font-family: inherit;
    font-size: 11px;
    white-space: nowrap;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 18px;
}

.system-clock {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    margin-right: 15px;
}

.system-clock strong {
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    letter-spacing: .03em;
    white-space: nowrap;
}

.system-clock span {
    color: var(--muted);
    font-size: 11px;
}

.connection-pill,
.role-pill {
    padding: 6px 10px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--green-bright);
    background: rgba(39, 194, 129, .1);
    border: 1px solid rgba(39, 194, 129, .2);
    border-radius: 99px;
    font-size: 12px;
    font-weight: 700;
}

.connection-pill span {
    width: 6px;
    height: 6px;
    background: var(--green);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--green);
}

.icon-button {
    position: relative;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    color: #c8d4dc;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 20px;
}

.bell-toggle {
    font-size: 18px;
}

.bell-toggle .bell-icon {
    line-height: 1;
}

.theme-toggle {
    font-size: 18px;
}

.theme-toggle .theme-icon {
    line-height: 1;
}

.icon-button b {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 18px;
    height: 18px;
    display: grid;
    place-items: center;
    background: var(--red);
    border: 2px solid var(--bg);
    border-radius: 50%;
    font-size: 10px;
}

.content {
    width: 100%;
    max-width: 1680px;
    margin: 0 auto;
    padding: 28px clamp(18px, 2.5vw, 38px) 42px;
    flex: 1;
}

.view {
    display: none;
    animation: reveal .2s ease;
}

.view:target {
    display: block;
}

body:not(:has(.view:target)):not(:has(.settings-section:target)):not(:has(.dialog:target)):not(:has(.popup:target)) #dashboard {
    display: block;
}

body:has(.settings-section:target) #dashboard {
    display: none;
}

body:has(.settings-section:target) #settings {
    display: block;
}

body:has(#edit-key:target) #dashboard,
body:has(#add-user:target) #dashboard {
    display: none;
}

body:has(#edit-key:target) #settings,
body:has(#add-user:target) #settings {
    display: block;
}

body:has(#confirm-daily:target) #dashboard,
body:has(#confirm-runtime:target) #dashboard,
body:has(#confirm-lifetime:target) #dashboard {
    display: none;
}

body:has(#confirm-daily:target) #machine-details,
body:has(#confirm-runtime:target) #machine-details,
body:has(#confirm-lifetime:target) #machine-details {
    display: block;
}

body:has(#notification-popup:target) #dashboard,
body:has(#notification-settings:target) #dashboard {
    display: none;
}

body:has(#notification-popup:target) #notifications,
body:has(#notification-settings:target) #notifications {
    display: block;
}

body:has(.settings-section:target) .main-nav a[href="#settings"] {
    color: #dff8ec;
    background: linear-gradient(90deg, rgba(39, 194, 129, .17), rgba(39, 194, 129, .06));
    border-color: rgba(39, 194, 129, .17);
    box-shadow: inset 3px 0 var(--green);
}

@keyframes reveal {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: none; }
}

.page-heading {
    min-height: 64px;
    margin-bottom: 24px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
}

.page-heading-compact {
    min-height: 32px;
    margin-bottom: 12px;
    align-items: center;
    gap: 16px;
}

.page-heading-compact > div {
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.page-heading-compact .eyebrow {
    margin-bottom: 0;
    font-size: 10px;
}

.page-heading-compact h1 {
    margin-bottom: 0;
    font-size: 26px;
}

.page-heading-compact p:not(.eyebrow) {
    display: inline;
    margin-bottom: 0;
    font-size: 13px;
}

.settings-shell {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
}

.settings-sticky-row-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding-bottom: 6px;
}

.settings-topbar-heading {
    flex: 0 0 auto;
    min-width: 0;
}

.settings-heading-title-row {
    display: flex;
    align-items: baseline;
    flex-wrap: nowrap;
    gap: 8px;
}

.settings-sticky-header .settings-heading-title-row .eyebrow {
    margin: 0;
    font-size: var(--settings-title-size);
    letter-spacing: .08em;
    line-height: 1.1;
}

.settings-sticky-header .settings-heading-title-row h1 {
    margin: 0;
    font-size: calc(var(--settings-title-size) * 0.5);
    line-height: 1.1;
    letter-spacing: -.025em;
}

.settings-page-desc {
    margin: 0 0 8px;
    color: var(--muted);
    line-height: 1.35;
}

.settings-scroll-body {
    padding-top: 2px;
}

.settings-frozen-stack .settings-sticky-header .settings-nav {
    width: 100%;
    position: static;
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-items: stretch;
    gap: 12px;
    min-width: 0;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 0;
    overflow: visible;
}

.settings-frozen-stack .settings-sticky-header .settings-nav a {
    flex: 1 1 0;
    min-width: 0;
    min-height: 0;
    padding: 7px 10px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    text-align: left;
    gap: 8px;
    background: #0f171f;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.settings-frozen-stack .settings-sticky-header .settings-nav a > span {
    width: auto;
    flex: 0 0 auto;
    font-size: 16px;
}

.settings-frozen-stack .settings-sticky-header .settings-nav a > div {
    align-items: flex-start;
    min-width: 0;
}

.settings-frozen-stack .settings-sticky-header .settings-nav a strong {
    font-size: 13px;
}

.settings-frozen-stack .settings-sticky-header .settings-nav a small {
    font-size: 11px;
}

.settings-frozen-stack .settings-sticky-header .role-pill {
    flex: 0 0 auto;
}

#settings .settings-content {
    padding-top: 0;
}

body:has(#settings:target) .settings-section,
body:has(.settings-section:target) .settings-section {
    scroll-margin-top: calc(var(--topbar-height) + 110px);
}

.page-heading h1 {
    margin-bottom: 4px;
    font-size: clamp(25px, 2.2vw, 34px);
    line-height: 1.15;
    letter-spacing: -.025em;
}

.page-heading p:not(.eyebrow) {
    margin-bottom: 0;
    color: var(--muted);
}

.eyebrow {
    margin-bottom: 6px;
    color: var(--green);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .15em;
    text-transform: uppercase;
}

.heading-actions,
.heading-actions > div,
.heading-actions > span {
    display: flex;
    align-items: center;
    gap: 10px;
}

.updated-label {
    color: var(--muted);
    font-size: 12px;
}

.button {
    min-height: 40px;
    padding: 0 15px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 7px;
    font-weight: 700;
    font-size: 13px;
    white-space: nowrap;
    transition: .16s ease;
}

.button:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.button.primary {
    color: #06130e;
    background: var(--green);
    border-color: var(--green);
}

.button.secondary {
    color: #dce6ec;
    background: #16212b;
}

.button.ghost {
    color: var(--muted);
    background: transparent;
}

.button.warning {
    color: #1d1303;
    background: var(--amber);
    border-color: var(--amber);
}

.button.danger {
    color: white;
    background: var(--red);
    border-color: var(--red);
}

.button.danger-text {
    margin-right: auto;
    color: var(--red);
    background: transparent;
    border-color: transparent;
}

.summary-grid {
    margin-bottom: 20px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.summary-card {
    min-height: 58px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(145deg, var(--surface-2), #101821);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 22px rgba(0, 0, 0, .12);
}

.summary-icon,
.panel-icon {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    border-radius: 8px;
    font-weight: 800;
}

.summary-icon {
    width: 34px;
    height: 34px;
    font-size: 15px;
}

.summary-icon.green,
.panel-icon.green { color: var(--green-bright); background: var(--green-dark); }
.summary-icon.blue,
.panel-icon.blue { color: #86c9ff; background: var(--blue-dark); }
.summary-icon.amber,
.panel-icon.amber { color: #ffc968; background: var(--amber-dark); }
.summary-icon.red,
.panel-icon.red { color: #ff9898; background: var(--red-dark); }
.panel-icon.purple { color: #c9b8ff; background: #2b2542; }

.summary-card > div {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.summary-card small,
.summary-card span {
    color: var(--muted);
    font-size: 10px;
}

.summary-card strong {
    margin: 1px 0;
    font-size: 19px;
    font-variant-numeric: tabular-nums;
}

em {
    color: var(--muted);
    font-size: .45em;
    font-style: normal;
    font-weight: 600;
}

.positive { color: var(--green) !important; }
.negative { color: var(--red) !important; }

.section-heading {
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.section-heading-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.section-heading > div:first-child {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.section-heading h2,
.table-toolbar h2 {
    margin-bottom: 0;
    font-size: 17px;
}

.section-heading span,
.table-toolbar span {
    color: var(--muted);
    font-size: 12px;
}

.segmented {
    padding: 3px;
    display: flex;
    background: #0c141b;
    border: 1px solid var(--border);
    border-radius: 7px;
}

.segmented button {
    min-height: 30px;
    padding: 0 11px;
    color: var(--muted);
    background: transparent;
    border: 0;
    border-radius: 5px;
    font-size: 11px;
}

.segmented button.active {
    color: var(--text);
    background: var(--surface-3);
}

.machines-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.machine-card {
    position: relative;
    min-width: 0;
    overflow: hidden;
    background: linear-gradient(150deg, #151f29, #101820);
    border: 1px solid var(--border);
    border-top: 2px solid var(--green);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: .18s ease;
}

.machine-card:hover {
    border-color: #354754;
    transform: translateY(-2px);
}

.machine-card.stopped-card { border-top-color: var(--amber); }
.machine-card.fault-card { border-top-color: var(--red); }

.machine-card-head {
    padding: 10px 14px 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border-bottom: 1px solid var(--border-soft);
}

.machine-card-head > div,
.hero-identity {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* One-line header: Machine Number · Type · ID (no stacked second line) */
.machine-card-head > div > div,
.hero-identity > div {
    min-width: 0;
    display: flex;
    flex-direction: row;
    align-items: baseline;
    flex-wrap: nowrap;
    gap: 10px;
}

.machine-card-head h3,
.hero-identity h2 {
    margin: 0;
    flex: 0 0 auto;
    font-size: 20px;
    font-weight: 800;
    line-height: 1.15;
    white-space: nowrap;
}

.machine-card-head p,
.hero-identity p {
    margin: 0;
    min-width: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* End of same header line — no longer stacked below title */
.machine-id-meta {
    display: inline;
    flex: 0 0 auto;
    margin-top: 0;
    color: var(--muted);
    font-family: Consolas, monospace;
    font-size: 12px;
    letter-spacing: .02em;
    opacity: .9;
    white-space: nowrap;
}

.machine-number {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    color: #d8e3ea;
    background: #1c2934;
    border: 1px solid #334553;
    border-radius: 8px;
    font-family: Consolas, monospace;
    font-size: 12px;
    font-weight: 700;
}

.machine-number.large {
    width: 42px;
    height: 42px;
    color: var(--green-bright);
    background: var(--green-dark);
    border-color: rgba(39, 194, 129, .25);
    font-size: 13px;
}

.status-badge {
    padding: 6px 9px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 1px solid currentColor;
    border-radius: 99px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .03em;
    white-space: nowrap;
}

.status-badge.running,
.status-badge.healthy {
    color: var(--green-bright);
    background: rgba(39, 194, 129, .09);
    border-color: rgba(39, 194, 129, .25);
}

.status-badge.stopped {
    color: #ffc968;
    background: rgba(240, 166, 46, .09);
    border-color: rgba(240, 166, 46, .25);
}

.status-badge.fault {
    color: #ff9696;
    background: rgba(239, 91, 91, .09);
    border-color: rgba(239, 91, 91, .28);
}

.machine-card-body {
    min-height: 112px;
    padding: 12px 14px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 96px;
    align-items: center;
    gap: 10px 18px;
}

.production-stat {
    min-width: 0;
}

.production-stat > small {
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
}

.production-stat > strong {
    margin: 2px 0 8px;
    display: block;
    font-size: clamp(20px, 2vw, 26px);
    font-variant-numeric: tabular-nums;
}

.progress {
    height: 4px;
    overflow: hidden;
    background: #23303a;
    border-radius: 5px;
    margin-bottom: 8px;
}

.progress span {
    height: 100%;
    display: block;
    background: linear-gradient(90deg, #1e9c69, var(--green));
    border-radius: inherit;
}

.progress.amber span { background: linear-gradient(90deg, #b87314, var(--amber)); }
.progress.red span { background: linear-gradient(90deg, #a73e46, var(--red)); }

.production-stat p {
    margin: 4px 0 0;
    display: flex;
    justify-content: space-between;
    color: var(--muted);
    font-size: 10px;
}

.production-stat p b {
    color: #b9c7d0;
}

.custom-gauge {
    position: relative;
    width: 92px;
    height: 92px;
}

.custom-gauge svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.custom-gauge circle {
    fill: none;
    stroke-width: 8;
}

.custom-gauge .gauge-bg {
    stroke: #26333d;
}

.custom-gauge .gauge-fill {
    stroke: var(--gauge-color);
    stroke-linecap: round;
    stroke-dasharray: 314;
    stroke-dashoffset: calc(314 - (314 * var(--gauge-value)) / 100);
    filter: drop-shadow(0 0 5px color-mix(in srgb, var(--gauge-color), transparent 55%));
}

.custom-gauge > div {
    position: absolute;
    inset: 0;
    display: grid;
    place-content: center;
    text-align: center;
}

.custom-gauge strong {
    font-size: 20px;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.custom-gauge span {
    margin-top: 2px;
    color: var(--muted);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .1em;
}

.metric-strip {
    min-height: 48px;
    padding: 8px 14px;
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    align-items: center;
    gap: 10px;
    background: rgba(5, 10, 14, .28);
    border-top: 1px solid var(--border-soft);
}

.metric-strip > div {
    display: flex;
    flex-direction: column;
}

.metric-strip small {
    color: var(--muted);
    font-size: 9px;
    font-weight: 700;
}

.metric-strip strong {
    margin-top: 1px;
    font-family: Consolas, monospace;
    font-size: 11px;
}

.metric-strip a {
    min-height: 32px;
    padding: 0 10px;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--green-bright);
    background: rgba(39, 194, 129, .08);
    border: 1px solid rgba(39, 194, 129, .17);
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
}

.footer {
    min-height: 52px;
    padding: 0 clamp(18px, 2.5vw, 38px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    color: var(--muted-2);
    border-top: 1px solid var(--border-soft);
    font-size: 11px;
}

.footer span {
    display: flex;
    align-items: center;
    gap: 7px;
}

.panel,
.table-panel {
    background: linear-gradient(145deg, var(--surface-2), #101821);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 10px 28px rgba(0, 0, 0, .13);
}

.hero-machine {
    min-height: 72px;
    margin-bottom: 14px;
    padding: 12px 16px;
    display: grid;
    grid-template-columns: minmax(260px, 1fr) auto minmax(180px, .5fr);
    align-items: center;
    gap: 16px;
    background:
        linear-gradient(90deg, rgba(39, 194, 129, .09), transparent 48%),
        var(--surface);
    border: 1px solid rgba(39, 194, 129, .24);
    border-radius: var(--radius);
}

.hero-rpm {
    padding-left: 24px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    border-left: 1px solid var(--border);
}

.hero-rpm span {
    color: var(--muted);
    font-size: 10px;
    text-transform: uppercase;
}

.hero-rpm strong {
    font-size: 25px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.detail-grid .panel {
    padding: 20px;
}

.panel.span-two,
.action-bar.span-two {
    grid-column: span 2;
}

.detail-grid .action-bar {
    margin-top: 0;
}

.panel-head {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.panel-head > div {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.panel-head h2 {
    margin: 0;
    font-size: 15px;
}

.panel-head p {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 11px;
}

.panel-icon {
    width: 34px;
    height: 34px;
}

.tag {
    padding: 4px 8px;
    color: var(--muted);
    background: #1c2731;
    border-radius: 5px;
    font-size: 10px;
}

.tag.live {
    color: var(--green-bright);
    background: var(--green-dark);
}

.large-metrics,
.three-metrics {
    display: grid;
}

.large-metrics {
    grid-template-columns: 1fr 1fr;
}

.large-metrics > div,
.three-metrics > div {
    padding: 4px 20px;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border);
}

.large-metrics > div:first-child,
.three-metrics > div:first-child {
    padding-left: 0;
    border-left: 0;
}

.large-metrics small,
.three-metrics small,
.reason-box small,
.event-stats small,
.maintenance-values small {
    color: var(--muted);
    font-size: 10px;
}

.large-metrics strong {
    margin: 4px 0;
    font-size: 24px;
}

.large-metrics span {
    color: var(--muted);
    font-size: 10px;
}

.three-metrics {
    grid-template-columns: repeat(3, 1fr);
}

.three-metrics strong {
    margin-top: 7px;
    font-family: Consolas, monospace;
    font-size: 16px;
}

.status-detail {
    display: grid;
    grid-template-columns: 1.1fr 2fr;
    gap: 20px;
}

.reason-box {
    padding: 16px;
    background: #0d161d;
    border: 1px solid var(--border-soft);
    border-left: 3px solid var(--green);
    border-radius: 7px;
}

.reason-box strong {
    margin: 5px 0 3px;
    display: block;
}

.reason-box p {
    margin: 0;
    color: var(--muted);
    font-size: 11px;
}

.event-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.event-stats > div {
    padding: 14px;
    display: flex;
    flex-direction: column;
    background: #121c24;
    border: 1px solid var(--border-soft);
    border-radius: 7px;
}

.event-stats strong {
    margin-top: 4px;
    font-size: 20px;
}

.maintenance-row {
    display: grid;
    grid-template-columns: 1fr 1.4fr;
    align-items: center;
    gap: 28px;
}

.maintenance-progress {
    display: grid;
    grid-template-columns: 104px 1fr;
    align-items: center;
    gap: 20px;
}

.progress-ring {
    width: 96px;
    height: 96px;
    display: grid;
    place-content: center;
    text-align: center;
    background:
        radial-gradient(circle at center, var(--surface-2) 58%, transparent 60%),
        conic-gradient(var(--green) 0 73%, #283640 73% 100%);
    border-radius: 50%;
}

.progress-ring strong {
    font-size: 20px;
}

.progress-ring span,
.maintenance-progress small {
    color: var(--muted);
    font-size: 10px;
}

.maintenance-progress > div:last-child > strong {
    margin: 4px 0 12px;
    display: block;
}

.maintenance-values {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.maintenance-values > div {
    padding: 13px;
    display: flex;
    flex-direction: column;
    background: #121c24;
    border-radius: 7px;
}

.maintenance-values strong {
    margin-top: 4px;
    font-size: 12px;
}

.action-bar {
    margin-top: 16px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    background: #111a22;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.action-bar > div {
    display: flex;
    align-items: center;
    gap: 9px;
}

.action-bar > div:first-child {
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
}

.action-bar strong {
    font-size: 12px;
}

.action-bar span {
    color: var(--muted);
    font-size: 10px;
}

.field {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field > span {
    color: #aebcc6;
    font-size: 11px;
    font-weight: 700;
}

.field input,
.field select,
.inline-filters input,
.inline-filters select,
.mini-select select {
    width: 100%;
    min-height: 40px;
    padding: 0 11px;
    color: #e2e9ee;
    background: #0d161e;
    border: 1px solid var(--border);
    border-radius: 7px;
    outline: 0;
}

.field input:focus,
.field select:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(39, 194, 129, .09);
}

.field.compact {
    min-width: min(340px, 45vw);
}

.field.compact span {
    display: none;
}

.month-tabs-row {
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.month-tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: thin;
    flex: 1;
}

.month-tabs button {
    min-width: max-content;
    min-height: 38px;
    padding: 0 15px;
    color: var(--muted);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 7px;
    font-size: 11px;
    font-weight: 700;
}

.month-tabs button.active {
    color: #07130e;
    background: var(--green);
    border-color: var(--green);
}

.filters-panel {
    margin-bottom: 15px;
    padding: 16px;
}

.filter-grid {
    display: grid;
    grid-template-columns: 1.5fr repeat(4, 1fr) auto;
    align-items: end;
    gap: 11px;
}

.search-field > div {
    position: relative;
}

.search-field b {
    position: absolute;
    z-index: 1;
    left: 11px;
    top: 10px;
    color: var(--muted);
}

.search-field input {
    padding-left: 32px;
}

.filter-actions {
    display: flex;
    gap: 6px;
}

.table-panel {
    overflow: hidden;
}

.table-toolbar {
    min-height: 68px;
    padding: 13px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid var(--border);
}

.table-toolbar > div:first-child {
    display: flex;
    flex-direction: column;
}

.table-scroll {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    display: block;
    box-sizing: border-box;
}

/* Logs grid: sticky header + fixed bottom scrollbar; denser rows. */
#logs .table-scroll {
    max-width: 100%;
    width: 100%;
    max-height: min(56vh, 520px);
    overflow-x: auto;
    overflow-y: auto;
    /* Horizontal scrollbar stays at bottom of this viewport. */
    display: block;
    box-sizing: border-box;
    contain: inline-size;
    overscroll-behavior: contain;
}

#logs #log-table {
    border-collapse: separate;
    border-spacing: 0;
}

#logs #log-table thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    height: 26px;
    padding: 0 14px;
    font-size: 10px;
    background: #0e171f;
    box-shadow: 0 1px 0 var(--border);
}

#logs #log-table th {
    height: 26px;
    padding: 0 14px;
    font-size: 10px;
}

#logs #log-table td {
    height: 30px;
    padding: 2px 14px;
    font-size: 12px;
}

#logs #log-table .empty-filter-row td,
#logs #log-table #log-empty-row td {
    height: 56px;
    padding: 6px 14px;
}

table {
    width: 100%;
    min-width: 850px;
    border-collapse: collapse;
}

th {
    height: 42px;
    padding: 0 14px;
    color: #7e909e;
    background: #0e171f;
    border-bottom: 1px solid var(--border);
    font-size: 10px;
    letter-spacing: .06em;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
}

td {
    height: 53px;
    padding: 8px 14px;
    color: #becbd3;
    border-bottom: 1px solid var(--border-soft);
    font-size: 12px;
    white-space: nowrap;
}

tbody tr:last-child td {
    border-bottom: 0;
}

tr[hidden] {
    display: none;
}

.empty-filter-row td {
    height: 90px;
    color: var(--muted);
    text-align: center;
}

tbody tr:hover td {
    background: rgba(255, 255, 255, .015);
}

td > small {
    display: block;
    color: var(--muted);
    font-size: 10px;
}

td > strong {
    color: var(--text);
    font-weight: 600;
}

.machine-chip {
    min-width: 31px;
    padding: 4px 6px;
    display: inline-grid;
    place-items: center;
    margin-right: 5px;
    color: #b8c8d2;
    background: #1c2934;
    border: 1px solid #30414e;
    border-radius: 5px;
    font-family: Consolas, monospace;
    font-size: 10px;
    font-weight: 700;
}

.table-status {
    padding: 4px 7px;
    display: inline-block;
    border-radius: 5px;
    font-size: 10px;
    font-weight: 700;
}

.table-status.success { color: var(--green-bright); background: var(--green-dark); }
.table-status.error { color: #ff9696; background: var(--red-dark); }
.table-status.warning { color: #ffc968; background: var(--amber-dark); }
.table-status.neutral { color: #aabac5; background: #222e38; }

.pagination {
    min-height: 58px;
    padding: 10px 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--muted);
    border-top: 1px solid var(--border);
    font-size: 11px;
}

.pagination > div {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pagination button {
    min-width: 32px;
    height: 32px;
    color: var(--muted);
    background: #121c24;
    border: 1px solid var(--border);
    border-radius: 5px;
}

.pagination button.active {
    color: #06130e;
    background: var(--green);
}

.pagination button:disabled {
    opacity: .35;
    cursor: default;
}

.info-banner {
    color: #a8ccea;
    background: var(--blue-dark);
    border: 1px solid rgba(73, 166, 242, .22);
    border-radius: 7px;
}

.compact-info {
    padding: 10px 13px;
    font-size: 11px;
}

.active-items-grid {
    margin-bottom: 16px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 13px;
}

.active-item {
    padding: 6px 16px;
    display: flex;
    flex-direction: column;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.active-item > div {
    margin-bottom: 3px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.active-item small,
.active-item > span {
    color: var(--muted);
    font-size: 10px;
    line-height: 1.1;
}

.active-item > strong {
    margin: 0;
    font-size: 17px;
    line-height: 1.15;
}

.active-item p {
    margin: 0;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.2;
}

.heading-actions {
    position: relative;
}

.consumable-entry-context {
    margin: 0 0 18px;
    padding: 0;
}

.consumable-entry-fields {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px 16px;
    padding: 14px 18px;
    margin: 0;
}

.consumable-entry-fields .field input[readonly] {
    opacity: 0.92;
    cursor: default;
    background: color-mix(in srgb, var(--surface) 88%, var(--border));
}

.consumable-entry-actions {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 4px;
}

.consumable-entry-actions span {
    color: var(--muted);
    font-size: 13px;
}

.active-item > strong.active-item-subcategory {
    font-size: 1.15rem;
}

.info-help-btn {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 50%;
    font-size: 14px;
    font-weight: 800;
    font-style: italic;
    cursor: pointer;
}

.workflow-help-panel {
    position: absolute;
    z-index: 40;
    right: 0;
    top: calc(100% + 10px);
    width: min(520px, calc(100vw - 32px));
    padding: 16px 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.workflow-help-panel[hidden] {
    display: none !important;
}

.workflow-help-panel > p:last-of-type {
    margin-bottom: 0;
    color: var(--muted);
    font-size: 11px;
}

.workflow-help-panel h2 {
    margin-bottom: 4px;
    font-size: 17px;
}

.workflow-help-panel .workflow-steps {
    margin-top: 12px;
}

.workflow-panel {
    margin-bottom: 16px;
    padding: 18px 20px;
    display: grid;
    grid-template-columns: minmax(190px, .55fr) 2fr;
    align-items: center;
    gap: 28px;
    background: linear-gradient(110deg, rgba(73, 166, 242, .1), transparent 45%), var(--surface);
    border: 1px solid rgba(73, 166, 242, .23);
    border-radius: var(--radius);
}

.workflow-panel h2 {
    margin-bottom: 4px;
    font-size: 17px;
}

.workflow-panel p:last-child {
    margin-bottom: 0;
    color: var(--muted);
    font-size: 11px;
}

.workflow-steps {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 9px;
}

.workflow-steps > div {
    min-width: 115px;
    min-height: 70px;
    padding: 9px;
    display: grid;
    grid-template-columns: 22px 1fr;
    align-items: center;
    gap: 7px;
    background: #101a22;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.workflow-steps > div > b {
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    color: var(--blue);
    background: var(--blue-dark);
    border-radius: 50%;
    font-size: 10px;
}

.workflow-steps > div > span {
    font-size: 11px;
    font-weight: 700;
}

.workflow-steps kbd,
.workflow-steps em {
    grid-column: 2;
    justify-self: start;
}

.workflow-steps > i {
    color: var(--muted-2);
    font-style: normal;
}

.workflow-steps .saved-step {
    border-color: rgba(39, 194, 129, .28);
}

.workflow-steps .saved-step > b {
    color: var(--green-bright);
    background: var(--green-dark);
}

.workflow-steps .saved-step em {
    color: var(--green-bright);
    font-size: 10px;
}

.inline-filters {
    display: flex;
    align-items: center;
    gap: 7px;
}

.inline-filters label {
    position: relative;
}

.inline-filters label span {
    position: absolute;
    left: 10px;
    top: 9px;
}

.inline-filters input {
    width: 190px;
    padding-left: 30px;
}

.inline-filters select {
    width: 145px;
}

.quantity {
    color: var(--green-bright);
    font-weight: 700;
}

.settings-layout {
    width: 100%;
    min-width: 0;
    display: grid;
    grid-template-columns: 190px minmax(0, 1fr);
    align-items: start;
    gap: 14px;
}

.settings-nav {
    padding: 5px;
    background: #0f171f;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.settings-nav a {
    min-height: 46px;
    padding: 6px 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    border-radius: 7px;
}

.settings-nav a:hover,
.settings-nav a.active {
    color: var(--text);
    background: var(--surface-3);
}

.settings-nav a > span {
    width: 23px;
    text-align: center;
    font-size: 15px;
}

.settings-nav a > div {
    display: flex;
    flex-direction: column;
}

.settings-nav strong {
    font-size: 10px;
}

.settings-nav small {
    color: var(--muted);
    font-size: 9px;
}

.settings-content {
    width: 100%;
    min-width: 0;
    display: grid;
    gap: 12px;
}

.settings-section {
    padding: 20px;
    scroll-margin-top: calc(var(--topbar-height) + 20px);
}

.settings-section .panel-head {
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-soft);
}

.two-column-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 15px;
}

.input-suffix {
    display: flex;
}

.input-suffix input {
    border-radius: 7px 0 0 7px;
}

.input-suffix b {
    min-width: 52px;
    display: grid;
    place-items: center;
    color: var(--muted);
    background: #18232d;
    border: 1px solid var(--border);
    border-left: 0;
    border-radius: 0 7px 7px 0;
    font-size: 10px;
}

.settings-actions {
    margin-top: 18px;
    padding-top: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--muted);
    border-top: 1px solid var(--border-soft);
    font-size: 10px;
}

.settings-actions-with-notice {
    align-items: center;
    gap: 20px;
}

.settings-actions b {
    color: var(--text);
}

.checkbox-field {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
}

.checkbox-field span {
    flex: 1;
}

.checkbox-field input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    flex: 0 0 auto;
}

.settings-inline-notice {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    max-width: 42ch;
}

.wifi-settings-form {
    display: grid;
    gap: 12px;
}

#wifi-status {
    margin: 0;
    white-space: pre-line;
    font-size: 12px;
}

/* TEMP Wi-Fi diagnostic panel — live /api/network/status */
.wifi-diagnostic {
    margin-top: 8px;
    padding: 10px 12px;
    font-family: ui-monospace, "Cascadia Mono", "Consolas", monospace;
    font-size: 12px;
    line-height: 1.45;
    color: #c5d0d8;
    background: #0a1218;
    border: 1px solid var(--border);
}

.wifi-diag-title {
    margin-bottom: 6px;
    font-weight: 600;
    color: #e2e9ee;
}

.wifi-diagnostic .diag-ok {
    color: #3dba6f;
}

.wifi-diagnostic .diag-bad {
    color: #e05555;
}

.wifi-diagnostic .diag-warn {
    color: #e0893a;
}

.wifi-diagnostic .diag-scan {
    color: #3a9be0;
}

/* Collapsed dropdown trigger + open list panel */
.wifi-network-select {
    position: relative;
    width: 100%;
}

.wifi-network-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    min-height: 40px;
    padding: 0 11px;
    color: #e2e9ee;
    background: #0d161e;
    border: 1px solid var(--border);
    border-radius: 7px;
    outline: 0;
    cursor: pointer;
    font: inherit;
    text-align: left;
}

.wifi-network-trigger:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(39, 194, 129, .09);
}

.wifi-network-trigger-label {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
}

.wifi-network-trigger-caret {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 12px;
}

.wifi-network-select.is-open .wifi-network-trigger-caret {
    transform: rotate(180deg);
}

.wifi-networks-list {
    position: absolute;
    z-index: 40;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 220px;
    overflow-y: auto;
    padding: 4px;
    color: #e2e9ee;
    background: #0d161e;
    border: 1px solid var(--border);
    border-radius: 7px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, .35);
}

.wifi-networks-list[hidden] {
    display: none !important;
}

.wifi-networks-empty {
    padding: 10px 11px;
    color: var(--muted);
    font-size: 13px;
}

.wifi-network-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    margin: 0;
    padding: 8px 11px;
    color: inherit;
    background: transparent;
    border: 0;
    border-radius: 6px;
    text-align: left;
    cursor: pointer;
    font: inherit;
}

.wifi-network-item:hover {
    background: rgba(255, 255, 255, .04);
}

.wifi-network-item.is-selected {
    background: rgba(39, 194, 129, .12);
    box-shadow: inset 0 0 0 1px rgba(39, 194, 129, .35);
}

.wifi-network-ssid {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 600;
}

.wifi-network-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
    flex: 0 0 auto;
}

.wifi-network-security {
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

/* 4-bar Wi-Fi signal (HTML/CSS only — no Unicode block glyphs) */
.wifi-signal {
    display: inline-flex;
    align-items: flex-end;
    gap: 2px;
    height: 14px;
    line-height: 0;
}

.wifi-signal-bar {
    display: block;
    width: 3px;
    border-radius: 1px;
    background: #6b7780; /* inactive */
}

.wifi-signal-bar:nth-child(1) { height: 4px; }
.wifi-signal-bar:nth-child(2) { height: 7px; }
.wifi-signal-bar:nth-child(3) { height: 10px; }
.wifi-signal-bar:nth-child(4) { height: 14px; }

.wifi-signal[data-bars="1"] .wifi-signal-bar:nth-child(1) {
    background: #e74c3c; /* Red — weak */
}

.wifi-signal[data-bars="2"] .wifi-signal-bar:nth-child(-n+2) {
    background: #f0a62e; /* Orange — fair */
}

.wifi-signal[data-bars="3"] .wifi-signal-bar:nth-child(-n+3) {
    background: #a8e048; /* Lime — good */
}

.wifi-signal[data-bars="4"] .wifi-signal-bar:nth-child(-n+4) {
    background: #27c281; /* Green — excellent */
}

html[data-theme="light"] .wifi-network-trigger,
html[data-theme="light"] .wifi-networks-list {
    color: var(--text);
    background: #f7f9fa;
}

html[data-theme="light"] .wifi-network-item:hover {
    background: rgba(0, 0, 0, .04);
}

html[data-theme="light"] .wifi-signal-bar {
    background: #c5ccd2;
}

.wifi-checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 14px 18px;
    margin-top: -2px;
}

.wifi-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 12px;
    cursor: pointer;
}

.wifi-checkbox input {
    margin: 0;
}

.netcfg-static-fields {
    display: contents;
}

.netcfg-password-row {
    grid-column: 1 / -1;
}

#netcfg-mdns-hint,
.netcfg-ap-notice {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
}

.netcfg-ap-notice {
    margin: 8px 0 0;
}

#netcfg-status {
    margin: 10px 0 0;
    min-height: 1.2em;
    white-space: pre-wrap;
}

.wifi-action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.device-config-form {
    display: grid;
    gap: 12px;
}

.device-info-list {
    display: grid;
    gap: 8px;
}

.device-info-row {
    display: flex;
    align-items: baseline;
    gap: 10px;
    font-size: 13px;
}

.device-info-label {
    min-width: 140px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
}

.device-info-value {
    color: var(--text);
    font-family: Consolas, monospace;
}

.device-config-actions {
    justify-content: flex-start;
}

.restart-notice,
.safety-banner {
    margin-top: 16px;
    padding: 11px 13px;
    display: flex;
    align-items: center;
    gap: 11px;
    color: #f6c56e;
    background: rgba(240, 166, 46, .08);
    border: 1px solid rgba(240, 166, 46, .2);
    border-radius: 7px;
}

.restart-notice-inline {
    margin-top: 0;
    padding: 8px 12px;
    flex: 0 0 auto;
}

.restart-notice-inline strong {
    font-size: 11px;
}

.restart-notice-inline p {
    display: inline;
    margin: 0 0 0 4px;
    font-size: 10px;
}

.restart-notice > span,
.safety-banner > span {
    width: 24px;
    height: 24px;
    display: grid;
    place-items: center;
    background: var(--amber-dark);
    border-radius: 50%;
    font-weight: 800;
}

.restart-notice strong,
.safety-banner strong {
    font-size: 11px;
}

.restart-notice p,
.safety-banner p {
    margin: 1px 0 0;
    color: #a89777;
    font-size: 10px;
}

.mini-select {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 10px;
}

.mini-select select {
    width: 125px;
    min-height: 34px;
}

.keyboard-section {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    padding-top: 17px;
    padding-bottom: 17px;
    box-sizing: border-box;
}

.keyboard-scroll {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding-bottom: 0;
    overflow: hidden;
}

.full-keyboard {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(160px, 22%);
    align-items: stretch;
    gap: 8px;
    box-sizing: border-box;
}

.keyboard {
    min-width: 0;
    padding: 6px;
    display: grid;
    gap: 4px;
    background: #080d12;
    border: 1px solid #202c36;
    border-radius: 9px;
}

.key-row {
    display: flex;
    gap: 4px;
}

.key-row > a {
    min-width: 0;
    height: 62px;
    padding: 4px 5px;
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    color: #9aabb7;
    background: linear-gradient(#1b2731, #151f27);
    border: 1px solid #34434f;
    border-bottom-width: 3px;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, .3);
    font-size: 10px;
}

.key-row > a:hover {
    color: var(--text);
    border-color: var(--green);
    transform: translateY(1px);
}

.key-tooltip {
    position: fixed;
    z-index: 1200;
    max-width: min(240px, calc(100vw - 24px));
    padding: 8px 10px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.35;
    pointer-events: none;
    white-space: normal;
    word-break: break-word;
}

.key-tooltip[hidden] {
    display: none !important;
}

html[data-theme="light"] .key-tooltip {
    color: var(--text);
    background: var(--surface);
    border-color: var(--border);
    box-shadow: var(--shadow);
}

.key-row > a b {
    font-size: 10px;
    text-align: center;
}

.key-row > a small {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-align: center;
    color: var(--green-bright);
    font-size: 9px;
    line-height: 1.2;
    text-overflow: ellipsis;
    max-height: 2.4em;
}

.key-row > a.mapped {
    background: linear-gradient(#183429, #14271f);
    border-color: rgba(39, 194, 129, .44);
}

.key-row > a.wide { flex: 1.8 1 0; }
.key-row > a.medium { flex: 1.45 1 0; }
.key-row > a.caps { flex: 1.75 1 0; }
.key-row > a.enter { flex: 2.05 1 0; }
.key-row > a.shift { flex: 2.25 1 0; }
.key-row > a.space { flex: 7 1 0; align-items: center; justify-content: center; }

.function-row {
    margin-bottom: 3px;
}

.function-row > a {
    height: 42px;
}

.function-row > i {
    flex: .35 1 0;
}

.bottom-row > a {
    height: 54px;
}

.keyboard-legend {
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 15px;
    color: var(--muted);
    font-size: 10px;
}

.keyboard-legend span {
    display: flex;
    align-items: center;
    gap: 5px;
}

.keyboard-legend i {
    width: 12px;
    height: 12px;
    display: inline-block;
    background: #1b2731;
    border: 1px solid #34434f;
    border-radius: 2px;
}

.keyboard-legend i.mapped-swatch {
    background: #183429;
    border-color: var(--green);
}

.keyboard-legend b {
    margin-left: auto;
    color: var(--green-bright);
}

.keyboard-section .panel-head {
    margin-bottom: 4px;
    padding-bottom: 8px;
}

.column-picker {
    margin: 0 0 10px;
    padding: 10px 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    background: var(--surface-2);
    border: 1px solid var(--border-soft);
    border-radius: 8px;
}

.column-picker[hidden] {
    display: none !important;
}

.column-picker label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 12px;
}

.user-actions {
    display: flex;
    gap: 6px;
}

.user-actions .button {
    min-height: 30px;
    padding: 4px 8px;
    font-size: 11px;
}

.numpad {
    align-self: stretch;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 100%;
    padding: 8px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: repeat(5, minmax(0, 1fr));
    gap: 5px;
    background: #080d12;
    border: 1px solid #202c36;
    border-radius: 9px;
    box-sizing: border-box;
}

.numpad > a {
    min-width: 0;
    min-height: 0;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 2px;
    color: #a8b7c1;
    background: linear-gradient(#1b2731, #151f27);
    border: 1px solid #34434f;
    border-bottom-width: 3px;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, .3);
    font-size: 11px;
}

.numpad > a:hover {
    color: var(--text);
    border-color: var(--green);
    transform: translateY(1px);
}

.numpad small {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-align: center;
    color: var(--muted);
    font-size: 9px;
    line-height: 1.2;
    text-overflow: ellipsis;
    max-height: 2.4em;
}

.numpad-tall {
    grid-row: span 2;
}

.plus-key {
    grid-column: 4;
    grid-row: 2 / span 2;
}

.enter-key {
    grid-column: 4;
    grid-row: 4 / span 2;
}

.numpad-zero {
    grid-column: span 2;
}

.account-limit {
    margin-bottom: 16px;
    padding: 12px 14px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 10px;
    background: #101a22;
    border-radius: 7px;
    font-size: 10px;
}

.account-limit > div {
    height: 5px;
    overflow: hidden;
    background: #2a3741;
    border-radius: 5px;
}

.account-limit > div b {
    height: 100%;
    display: block;
    background: var(--green);
}

.account-limit small {
    grid-column: 1 / -1;
    color: var(--muted);
}

.user-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-cell > b {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    color: var(--green-bright);
    background: var(--green-dark);
    border-radius: 50%;
    font-size: 10px;
}

.role-pill.user-role {
    color: #a9cfee;
    background: var(--blue-dark);
    border-color: rgba(73, 166, 242, .2);
}

.dots-button {
    width: 32px;
    height: 30px;
    color: var(--muted);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 5px;
}

.safety-banner {
    margin: 0 0 16px;
    color: #ff9696;
    background: rgba(239, 91, 91, .07);
    border-color: rgba(239, 91, 91, .2);
}

.safety-banner > span {
    background: var(--red-dark);
}

.safety-banner p {
    color: #aa8585;
}

.backup-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}

.backup-grid > div {
    padding: 18px;
    background: #101921;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
}

.backup-icon {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    color: var(--green-bright);
    background: var(--green-dark);
    border-radius: 7px;
    font-size: 18px;
}

.backup-grid h3 {
    margin: 12px 0 4px;
    font-size: 13px;
}

.backup-grid p {
    min-height: 35px;
    margin-bottom: 13px;
    color: var(--muted);
    font-size: 10px;
}

.backup-grid > div > div {
    display: flex;
    gap: 7px;
}

.backup-grid > div > small {
    margin-top: 10px;
    display: block;
    color: var(--muted);
    font-size: 10px;
}

.file-drop {
    min-height: 70px;
    margin-bottom: 10px;
    display: grid;
    place-content: center;
    color: #b8c7d0;
    background: #0b131a;
    border: 1px dashed #3b4b57;
    border-radius: 7px;
    text-align: center;
    cursor: pointer;
}

.file-drop small {
    color: var(--muted);
    font-size: 10px;
}

.file-drop input {
    display: none;
}

.notification-summary {
    margin-bottom: 16px;
    display: grid;
    grid-template-columns: repeat(3, 150px) 1fr;
    gap: 12px;
}

.notification-summary > article {
    min-height: 72px;
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 9px;
}

.notification-summary article > div {
    display: flex;
    flex-direction: column;
}

.notification-summary article strong {
    font-size: 20px;
}

.notification-summary article small {
    color: var(--muted);
    font-size: 10px;
}

.notification-filters-row {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.notification-filters {
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    flex: 1;
}

.notification-action-buttons {
    display: flex;
    align-items: center;
    gap: 10px;
}

.notification-filters button {
    min-height: 35px;
    padding: 0 11px;
    color: var(--muted);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 11px;
}

.notification-filters button.active {
    color: var(--text);
    background: var(--surface-3);
    border-color: var(--border);
}

.notification-filters b {
    margin-left: 4px;
    color: white;
    background: var(--red);
    border-radius: 8px;
    padding: 1px 5px;
    font-size: 10px;
}

.notification-list {
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.notification-item {
    position: relative;
    min-height: 112px;
    padding: 18px;
    display: grid;
    grid-template-columns: 40px 1fr auto;
    gap: 14px;
    border-bottom: 1px solid var(--border-soft);
}

.notification-item:last-child {
    border-bottom: 0;
}

.notification-item.unread {
    background: rgba(255, 255, 255, .015);
}

.notification-item.unread::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--blue);
}

.notification-item.critical::before { background: var(--red); }
.notification-item.warning::before { background: var(--amber); }

.notification-symbol {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    color: #9bcfff;
    background: var(--blue-dark);
    border-radius: 8px;
    font-weight: 800;
}

.critical .notification-symbol { color: #ff9797; background: var(--red-dark); }
.warning .notification-symbol { color: #ffcb70; background: var(--amber-dark); }

.notification-item header {
    display: flex;
    justify-content: space-between;
    gap: 15px;
}

.notification-item header strong {
    font-size: 12px;
}

.notification-item time {
    color: var(--muted);
    font-size: 10px;
}

.notification-item p {
    margin: 5px 0 11px;
    color: var(--muted);
    font-size: 11px;
}

.notification-item footer {
    display: flex;
    align-items: center;
    gap: 11px;
    color: var(--muted);
    font-size: 10px;
}

.notification-item footer a {
    margin-left: auto;
    color: var(--green-bright);
    font-weight: 700;
}

.notification-item > button {
    width: 32px;
    height: 32px;
    color: var(--muted);
    background: transparent;
    border: 0;
}

.notification-settings-list {
    display: grid;
    gap: 12px;
}

.notification-settings-list label {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-size: 14px;
}

.nav-count[hidden],
.alert-button b[hidden] {
    display: none !important;
}

.about-grid {
    display: grid;
    grid-template-columns: .9fr 1.1fr;
    gap: 16px;
}

.about-grid .panel {
    padding: 22px;
}

.product-card {
    min-height: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    background:
        radial-gradient(circle at 50% 25%, rgba(39, 194, 129, .12), transparent 38%),
        linear-gradient(145deg, var(--surface-2), #101821);
}

.product-logo {
    width: 78px;
    height: 78px;
    margin-bottom: 18px;
    display: grid;
    place-items: center;
    background: rgba(39, 194, 129, .07);
    border: 1px solid rgba(39, 194, 129, .16);
    border-radius: 18px;
}

.large-logo {
    width: 48px;
    height: 48px;
    padding: 8px;
}

.product-card h2 {
    margin-bottom: 8px;
    font-size: 22px;
}

.product-card > p:not(.eyebrow) {
    max-width: 420px;
    color: var(--muted);
    font-size: 12px;
}

.version-badge {
    margin-top: 12px;
    padding: 5px 9px;
    color: var(--green-bright);
    background: var(--green-dark);
    border-radius: 5px;
    font-size: 10px;
}

.system-info-card dl {
    margin: 0;
}

.system-info-card dl > div {
    min-height: 38px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    border-bottom: 1px solid var(--border-soft);
}

.system-info-card dl > div:last-child {
    border-bottom: 0;
}

.system-info-card dt {
    color: var(--muted);
    font-size: 11px;
}

.system-info-card dd {
    margin: 0;
    font-family: Consolas, monospace;
    font-size: 11px;
    text-align: right;
}

.component-list {
    display: grid;
}

.component-list > div {
    min-height: 48px;
    display: grid;
    grid-template-columns: 12px 1fr auto;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border-soft);
}

.component-list > div:last-child {
    border-bottom: 0;
}

.component-list > div > span:nth-child(2) {
    display: flex;
    flex-direction: column;
}

.component-list strong,
.component-list b {
    font-size: 11px;
}

.component-list small {
    color: var(--muted);
    font-size: 10px;
}

.component-list b {
    color: var(--green-bright);
}

.support-card > p {
    color: var(--muted);
    font-size: 11px;
}

.support-card > div {
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    border-top: 1px solid var(--border-soft);
    font-size: 11px;
}

.support-card > div span {
    color: var(--muted);
}

.support-card .button {
    margin-top: 14px;
}

.mobile-nav {
    display: none;
}

.popup,
.dialog {
    position: fixed;
    z-index: 1100;
    inset: 0;
    display: none;
}

body:has(.dialog:target) .global-search,
body:has(.dialog.is-open) .global-search,
body:has(.popup:target) .global-search,
.global-search.is-disabled {
    opacity: .45;
    pointer-events: none;
    filter: grayscale(.2);
}

body:has(.dialog:target) .global-search input,
body:has(.dialog.is-open) .global-search input,
body:has(.popup:target) .global-search input,
.global-search.is-disabled input {
    pointer-events: none;
}

.popup:target,
.dialog:target,
.dialog.is-open {
    display: flex;
}

.popup {
    justify-content: flex-end;
    align-items: flex-start;
    padding: calc(var(--topbar-height) + 8px) 24px 24px;
    background: rgba(3, 7, 10, .45);
    backdrop-filter: blur(3px);
}

.popup-card {
    width: min(390px, calc(100vw - 30px));
    overflow: hidden;
    background: #101922;
    border: 1px solid #344552;
    border-radius: 11px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
}

.popup-card > header,
.dialog-card > header {
    min-height: 66px;
    padding: 13px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    border-bottom: 1px solid var(--border);
}

.popup-card header h2,
.dialog-card header h2 {
    margin: 0;
    font-size: 15px;
}

.popup-card header span,
.dialog-card header p {
    margin: 1px 0 0;
    color: var(--muted);
    font-size: 10px;
}

.popup-card header a,
.dialog-card header > a {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    color: var(--muted);
    border-radius: 5px;
    font-size: 20px;
}

.popup-list > a {
    min-height: 80px;
    padding: 13px 16px;
    display: grid;
    grid-template-columns: 34px 1fr;
    gap: 10px;
    border-bottom: 1px solid var(--border-soft);
}

.popup-list > a > span {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    color: #ffcb70;
    background: var(--amber-dark);
    border-radius: 7px;
}

.popup-list > a.critical > span {
    color: #ff9797;
    background: var(--red-dark);
}

.popup-list strong {
    font-size: 11px;
}

.popup-list p {
    margin: 2px 0;
    color: var(--muted);
    font-size: 10px;
}

.popup-list time {
    color: var(--muted-2);
    font-size: 10px;
}

.popup-card > footer {
    min-height: 48px;
    display: grid;
    place-items: center;
}

.popup-card footer a {
    color: var(--green-bright);
    font-size: 11px;
    font-weight: 700;
}

.dialog {
    padding: 20px;
    align-items: center;
    justify-content: center;
    background: rgba(3, 7, 10, .92);
    backdrop-filter: blur(8px);
}

.dialog-card {
    width: min(520px, 100%);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    background: #111a23;
    border: 1px solid #354754;
    border-radius: 12px;
    box-shadow: 0 28px 80px rgba(0, 0, 0, .65);
    animation: dialog-in .18s ease;
}

@keyframes dialog-in {
    from { opacity: 0; transform: translateY(8px) scale(.985); }
    to { opacity: 1; transform: none; }
}

.dialog-card > header > div {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dialog-body {
    padding: 18px;
}

.dialog-body.two-column-form {
    display: grid;
}

.dialog-card > footer {
    min-height: 66px;
    padding: 12px 18px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    border-top: 1px solid var(--border);
}

.selected-key,
.preview-key {
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--muted);
    font-size: 11px;
}

.selected-key kbd {
    padding: 8px 14px;
    color: var(--text);
    font-size: 14px;
}

.dialog-body .field small {
    color: var(--muted);
    font-size: 10px;
}

.preview-key {
    margin: 17px 0 0;
    padding-top: 15px;
    border-top: 1px solid var(--border-soft);
}

.preview-key > div {
    width: 82px;
    height: 62px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    color: var(--green-bright);
    background: #183429;
    border: 1px solid rgba(39, 194, 129, .5);
    border-bottom-width: 3px;
    border-radius: 6px;
}

.preview-key small {
    font-size: 10px;
}

.confirm-card {
    width: min(430px, 100%);
    padding-top: 24px;
    text-align: center;
}

.confirm-card > h2 {
    margin: 13px 20px 7px;
    font-size: 19px;
}

.confirm-card > p {
    margin: 0 auto 18px;
    padding: 0 24px;
    max-width: 390px;
    color: var(--muted);
    font-size: 11px;
}

.confirm-card > .field {
    margin: 0 22px 20px;
    text-align: left;
}

.dialog-symbol {
    width: 48px;
    height: 48px;
    margin: 0 auto;
    display: grid;
    place-items: center;
    border-radius: 50%;
    font-size: 22px;
    font-weight: 800;
}

.warning-symbol { color: #ffcb70; background: var(--amber-dark); }
.danger-symbol { color: #ff9797; background: var(--red-dark); }
.success-symbol { color: #7dffb3; background: #183429; }

/* Single app message dialog — centered overlay, OK to dismiss */
#message-dialog .dialog-card > footer {
    justify-content: center;
}
#message-dialog-body {
    white-space: pre-line;
}

.dialog-summary {
    margin: 0 22px 20px;
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #0c141b;
    border-radius: 7px;
    font-size: 11px;
}

.dialog-summary span {
    color: var(--muted);
}

html[data-theme="light"] body {
    background:
        radial-gradient(circle at 80% -20%, rgba(23, 129, 91, .08), transparent 34%),
        var(--bg);
}

html[data-theme="light"] .sidebar {
    background: #f7f9fa;
}

html[data-theme="light"] .topbar {
    background: rgba(238, 242, 244, .94);
}

html[data-theme="light"] .settings-frozen-stack {
    background: var(--bg);
    border-bottom-color: var(--border-soft);
}

html[data-theme="light"] .settings-sticky-header {
    background: var(--bg);
}

html[data-theme="light"] .settings-page-desc {
    color: var(--muted);
}

html[data-theme="light"] .settings-frozen-stack .settings-sticky-header .settings-nav a {
    background: var(--surface);
    border-color: var(--border);
    color: var(--muted);
}

html[data-theme="light"] .settings-frozen-stack .settings-sticky-header .settings-nav a:hover,
html[data-theme="light"] .settings-frozen-stack .settings-sticky-header .settings-nav a.active {
    background: var(--surface-hover);
    color: var(--text);
}

html[data-theme="light"] .main-nav a,
html[data-theme="light"] .nav-icon {
    color: #566b77;
}

html[data-theme="light"] .main-nav a:hover,
html[data-theme="light"] .settings-nav a:hover,
html[data-theme="light"] .settings-nav a.active {
    color: var(--text);
    background: #e8eef1;
}

html[data-theme="light"] body:not(:has(.view:target)) .main-nav a[href="#dashboard"],
html[data-theme="light"] body:has(#dashboard:target) .main-nav a[href="#dashboard"],
html[data-theme="light"] body:has(#machine-details:target) .main-nav a[href="#machine-details"],
html[data-theme="light"] body:has(#logs:target) .main-nav a[href="#logs"],
html[data-theme="light"] body:has(#consumables:target) .main-nav a[href="#consumables"],
html[data-theme="light"] body:has(#settings:target) .main-nav a[href="#settings"],
html[data-theme="light"] body:has(#notifications:target) .main-nav a[href="#notifications"],
html[data-theme="light"] body:has(#system-debug:target) .main-nav a[href="#system-debug"],
html[data-theme="light"] body:has(#about:target) .main-nav a[href="#about"],
html[data-theme="light"] body:has(.settings-section:target) .main-nav a[href="#settings"] {
    color: #115f45;
    background: linear-gradient(90deg, rgba(23, 129, 91, .14), rgba(23, 129, 91, .04));
    border-color: rgba(23, 129, 91, .2);
}

html[data-theme="light"] .sidebar-status,
html[data-theme="light"] .global-search,
html[data-theme="light"] .segmented,
html[data-theme="light"] .settings-nav,
html[data-theme="light"] .settings-actions,
html[data-theme="light"] .month-tabs button,
html[data-theme="light"] .pagination button,
html[data-theme="light"] .inline-filters input,
html[data-theme="light"] .inline-filters select,
html[data-theme="light"] .mini-select select,
html[data-theme="light"] .field input,
html[data-theme="light"] .field select {
    color: var(--text);
    background: #f7f9fa;
}

html[data-theme="light"] .summary-card,
html[data-theme="light"] .machine-card,
html[data-theme="light"] .panel,
html[data-theme="light"] .table-panel,
html[data-theme="light"] .active-item,
html[data-theme="light"] .notification-list,
html[data-theme="light"] .notification-summary > article,
html[data-theme="light"] .popup-card,
html[data-theme="light"] .dialog-card {
    background: linear-gradient(145deg, #ffffff, #f7f9fa);
}

html[data-theme="light"] .hero-machine,
html[data-theme="light"] .action-bar,
html[data-theme="light"] .workflow-panel,
html[data-theme="light"] .workflow-help-panel {
    background:
        linear-gradient(90deg, rgba(23, 129, 91, .07), transparent 50%),
        #ffffff;
}

html[data-theme="light"] .metric-strip,
html[data-theme="light"] th,
html[data-theme="light"] .reason-box,
html[data-theme="light"] .event-stats > div,
html[data-theme="light"] .maintenance-values > div,
html[data-theme="light"] .workflow-steps > div,
html[data-theme="light"] .account-limit,
html[data-theme="light"] .backup-grid > div,
html[data-theme="light"] .dialog-summary {
    background: #f2f6f7;
}

html[data-theme="light"] th {
    color: #536874;
}

html[data-theme="light"] #logs #log-table thead th {
    background: #f2f6f7;
}

html[data-theme="light"] td {
    color: #3f535e;
}

html[data-theme="light"] .compact-info {
    color: #315f7b;
}

html[data-theme="light"] .button.secondary,
html[data-theme="light"] .icon-button,
html[data-theme="light"] .tag {
    color: #344b58;
    background: #edf2f4;
}

html[data-theme="light"] kbd,
html[data-theme="light"] .input-suffix b {
    color: #425864;
    background: #e7edef;
}

html[data-theme="light"] .keyboard,
html[data-theme="light"] .numpad {
    background: #dfe6e9;
    border-color: #bac8cf;
}

html[data-theme="light"] .key-row > a,
html[data-theme="light"] .numpad > a {
    color: #263943;
    background: linear-gradient(#ffffff, #eef2f4);
    border-color: #afbdc4;
    box-shadow: 0 2px 3px rgba(38, 57, 67, .15);
}

html[data-theme="light"] .key-row > a.mapped {
    background: linear-gradient(#e5f3ed, #d8ebe3);
    border-color: #6ba98f;
}

html[data-theme="light"] .key-row > a small {
    color: #176e50;
}

html[data-theme="light"] .progress-ring {
    background:
        radial-gradient(circle at center, #ffffff 58%, transparent 60%),
        conic-gradient(var(--green) 0 73%, #d5dfe3 73% 100%);
}

html[data-theme="light"] .mobile-nav {
    background: rgba(247, 249, 250, .97);
}

@media (max-width: 1240px) {
    :root { --sidebar-width: 218px; }
    .summary-grid { grid-template-columns: repeat(2, 1fr); }
    .filter-grid { grid-template-columns: repeat(3, 1fr); }
    .filter-actions { grid-column: span 3; justify-content: flex-end; }
    .active-items-grid { grid-template-columns: repeat(2, 1fr); }
    .workflow-panel { grid-template-columns: 1fr; }
    .notification-summary { grid-template-columns: repeat(3, 1fr); }
    .notification-filters-row { flex-direction: column; align-items: stretch; }
    .notification-filters { justify-content: flex-start; }
    .notification-action-buttons { width: 100%; justify-content: stretch; gap: 8px; }
    .notification-action-buttons .button { flex: 1; }
}

@media (max-width: 980px) {
    :root { --sidebar-width: 76px; }
    .brand { justify-content: center; padding: 0; }
    .brand-copy,
    .main-nav a > span:not(.nav-icon):not(.nav-count),
    .nav-label,
    .sidebar-status,
    .sidebar-footer > div:nth-child(2),
    .more-icon { display: none; }
    .main-nav { padding: 15px 10px; }
    .main-nav a { padding: 0; justify-content: center; }
    .nav-count { position: absolute; margin: -27px -26px 0 0; }
    .sidebar-footer { justify-content: center; padding: 10px; }
    .machines-grid { grid-template-columns: 1fr; }
    .settings-layout { grid-template-columns: 1fr; }
    .settings-section {
        width: 100%;
        max-width: 100%;
    }
    .settings-nav {
        position: static;
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        overflow: hidden;
    }
    .settings-nav a { min-width: 0; }
    .status-detail,
    .maintenance-row { grid-template-columns: 1fr; }
    .inline-filters { flex-wrap: wrap; justify-content: flex-end; }
}

@media (max-width: 760px) {
    :root { --topbar-height: 62px; }
    .sidebar { display: none; }
    .workspace { margin-left: 0; }
    .topbar { padding: 0 14px; }
    .settings-sticky-header { padding: 8px 14px 10px; }
    .full-keyboard { grid-template-columns: minmax(0, 1fr) minmax(140px, 34%); gap: 6px; }
    .mobile-brand { display: flex; }
    .mobile-brand .brand-mark { width: 31px; height: 31px; }
    .global-search { width: auto; min-width: 0; flex: 1; }
    .global-search kbd,
    .system-clock,
    .connection-pill { display: none; }
    .topbar-actions { gap: 8px; }
    .content { padding: 20px 14px 88px; }
    .settings-section {
        width: 100%;
        max-width: 100%;
    }
    .page-heading { align-items: flex-start; flex-direction: column; gap: 14px; }
    .page-heading .heading-actions { width: 100%; flex-wrap: wrap; }
    .page-heading-compact { flex-direction: column; align-items: flex-start; }
    .page-heading-compact > div { flex-direction: column; align-items: flex-start; gap: 6px; }
    .month-tabs-row { flex-direction: column; align-items: stretch; gap: 10px; }
    .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .summary-card { min-height: 52px; padding: 6px 12px; }
    .summary-icon { width: 30px; height: 30px; }
    .summary-card strong { font-size: 17px; }
    .section-heading-actions {
        width: 100%;
        justify-content: flex-start;
    }
    .section-heading .segmented { display: none; }
    .hero-machine { grid-template-columns: 1fr auto; padding: 10px 12px; }
    .hero-machine > .status-badge { justify-self: end; }
    .hero-rpm { grid-column: 1 / -1; padding: 12px 0 0; align-items: flex-start; border-top: 1px solid var(--border); border-left: 0; }
    .detail-grid { grid-template-columns: 1fr; }
    .panel.span-two { grid-column: auto; }
    .event-stats { grid-template-columns: repeat(2, 1fr); }
    .action-bar { align-items: stretch; flex-direction: column; }
    .action-bar > div:last-child { flex-wrap: wrap; }
    .filter-grid { grid-template-columns: repeat(2, 1fr); }
    .filter-actions { grid-column: span 2; }
    .compact-info { width: 100%; }
    .active-items-grid { grid-template-columns: repeat(2, 1fr); }
    .consumable-entry-fields { grid-template-columns: 1fr 1fr; }
    .workflow-steps { overflow-x: auto; justify-content: flex-start; padding-bottom: 8px; }
    .workflow-steps > div { flex: 0 0 120px; }
    .table-toolbar { align-items: flex-start; flex-direction: column; }
    .inline-filters { width: 100%; justify-content: flex-start; }
    .inline-filters label,
    .inline-filters input,
    .inline-filters select { width: 100%; }
    .two-column-form { grid-template-columns: 1fr; }
    .backup-grid { grid-template-columns: 1fr; }
    .about-grid { grid-template-columns: 1fr; }
    .notification-summary { grid-template-columns: repeat(3, 1fr); }
    .notification-item { grid-template-columns: 36px 1fr; }
    .notification-item > button { display: none; }
    .footer { display: none; }
    .mobile-nav {
        position: fixed;
        z-index: 60;
        left: 0;
        right: 0;
        bottom: 0;
        height: 67px;
        padding: 6px 8px max(6px, env(safe-area-inset-bottom));
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        background: rgba(10, 17, 24, .97);
        border-top: 1px solid var(--border);
        backdrop-filter: blur(15px);
    }
    .mobile-nav a {
        display: flex;
        align-items: center;
        justify-content: center;
        flex-direction: column;
        gap: 2px;
        color: var(--muted);
        border-radius: 6px;
        font-size: 10px;
        font-weight: 700;
    }
    .mobile-nav a span { font-size: 17px; }
    body:not(:has(.view:target)) .mobile-nav a[href="#dashboard"],
    body:has(#dashboard:target) .mobile-nav a[href="#dashboard"],
    body:has(#machine-details:target) .mobile-nav a[href="#machine-details"],
    body:has(#logs:target) .mobile-nav a[href="#logs"],
    body:has(#consumables:target) .mobile-nav a[href="#consumables"],
    body:has(#settings:target) .mobile-nav a[href="#settings"],
    body:has(.settings-section:target) .mobile-nav a[href="#settings"] {
        color: var(--green-bright);
        background: rgba(39, 194, 129, .08);
    }
}

@media (max-width: 520px) {
    body { font-size: 13px; }
    .mobile-brand strong { display: none; }
    .page-heading h1 { font-size: 27px; }
    .summary-grid { grid-template-columns: 1fr; }
    .summary-card { min-height: 48px; }
    .machine-card-body { grid-template-columns: minmax(0, 1fr) 84px; padding: 10px 12px; }
    .custom-gauge { width: 80px; height: 80px; }
    .custom-gauge strong { font-size: 18px; }
    .machine-card-head { padding: 8px 12px; }
    .metric-strip { grid-template-columns: 1fr 1fr; padding: 8px 12px; }
    .metric-strip a { grid-column: 1 / -1; justify-content: center; }
    .large-metrics,
    .three-metrics { grid-template-columns: 1fr; gap: 13px; }
    .large-metrics > div,
    .three-metrics > div { padding: 0; border-left: 0; }
    .maintenance-progress { grid-template-columns: 82px 1fr; }
    .progress-ring { width: 78px; height: 78px; }
    .maintenance-values { grid-template-columns: 1fr; }
    .action-bar > div:last-child,
    .action-bar .button { width: 100%; }
    .filter-grid { grid-template-columns: 1fr; }
    .filter-actions { grid-column: auto; }
    .filter-actions .button { flex: 1; }
    .active-items-grid { grid-template-columns: 1fr; }
    .consumable-entry-fields { grid-template-columns: 1fr; }
    .notification-summary { grid-template-columns: 1fr; }
    .notification-filters-row { flex-direction: column; align-items: stretch; gap: 10px; }
    .notification-filters { overflow-x: auto; }
    .notification-action-buttons { width: 100%; flex-direction: column; }
    .notification-action-buttons .button { width: 100%; }
    .notification-item header { flex-direction: column; gap: 2px; }
    .notification-item footer { flex-wrap: wrap; }
    .notification-item footer a { width: 100%; margin-left: 0; }
    .settings-actions-with-notice { flex-direction: column; align-items: stretch; gap: 12px; }
    .restart-notice-inline { width: 100%; }
    .settings-section { padding: 15px; }
    .settings-actions { align-items: stretch; flex-direction: column; gap: 10px; }
    .settings-actions .button { width: 100%; }
    .backup-grid > div > div { flex-direction: column; }
    .backup-grid .button { width: 100%; }
    .account-limit { grid-template-columns: 1fr auto; }
    .account-limit > span { grid-column: 1 / -1; }
    .popup { padding: calc(var(--topbar-height) + 6px) 8px 75px; }
    .dialog { padding: 10px; }
    .dialog-card > footer { flex-wrap: wrap; }
    .dialog-card > footer .button { flex: 1; }
    .dialog-card > footer .danger-text { order: 2; flex-basis: 100%; margin: 0; }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
    }
}

.key-labels-print {
    display: none;
}

@media print {
    @page {
        margin: 10mm;
    }

    html,
    body {
        width: auto;
        height: auto;
        margin: 0;
        padding: 0;
        background: #fff !important;
        overflow: visible !important;
    }

    body > *:not(.key-labels-print) {
        display: none !important;
    }

    .key-labels-print,
    .key-labels-print * {
        visibility: visible !important;
    }

    .key-labels-print {
        display: block !important;
        position: static;
        width: 100%;
        max-width: 100%;
        margin: 0;
        padding: 0;
        color: #000000;
        background: #fff;
        overflow: visible;
        page-break-after: avoid;
        break-after: avoid;
    }

    .key-labels-print .full-keyboard {
        width: 100%;
        max-width: 100%;
        transform: none !important;
        page-break-inside: avoid;
        break-inside: avoid;
    }

    .key-labels-print .keyboard,
    .key-labels-print .numpad {
        background: #fff;
        border: 1px solid #444;
        box-shadow: none;
    }

    .key-labels-print .key-row > a,
    .key-labels-print .numpad > a {
        color: #000000 !important;
        background: #fff;
        border: 1px solid #555;
        border-bottom-width: 2px;
        box-shadow: none;
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .key-labels-print .key-row > a {
        font-size: 11px;
    }

    .key-labels-print .numpad > a {
        font-size: 12px;
    }

    .key-labels-print .key-row > a b {
        color: #000000 !important;
        font-size: 11px !important;
    }

    .key-labels-print .numpad > a b {
        color: #000000 !important;
        font-size: 12px !important;
    }

    .key-labels-print .key-row > a.mapped,
    .key-labels-print .numpad > a.mapped {
        background: #eef8f2;
        border-color: #2a8f5f;
    }

    .key-labels-print .key-row > a small,
    .key-labels-print .numpad small {
        color: #000000 !important;
        -webkit-line-clamp: 2;
    }

    .key-labels-print .key-row > a small {
        font-size: 10px !important;
    }

    .key-labels-print .numpad small {
        font-size: 10px !important;
    }

    .key-labels-print .key-row > a:hover,
    .key-labels-print .numpad > a:hover {
        transform: none;
    }

    .key-tooltip {
        display: none !important;
    }
}

/* ---- Login view (current Web UI language) ---- */
.login-view {
    min-height: 100vh;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(ellipse at 20% 10%, rgba(39, 194, 129, 0.12), transparent 45%),
        radial-gradient(ellipse at 80% 90%, rgba(70, 120, 180, 0.1), transparent 40%),
        var(--bg, #080d13);
}

/* Pending: blank (no Login flash). Logged-out: Login. Logged-in: shell. */
body.malwa-auth-pending .login-view,
body.malwa-auth-pending #login-view {
    display: none !important;
}

body.malwa-logged-out .login-view,
body.malwa-logged-out #login-view {
    display: flex;
}

body.malwa-logged-in .login-view,
body.malwa-logged-in #login-view {
    display: none !important;
}

body.malwa-auth-pending .app-shell,
body.malwa-logged-out .app-shell {
    display: none !important;
}

.login-card {
    width: min(400px, 100%);
    padding: 28px 26px 22px;
    border: 1px solid var(--border-soft, #1c2a36);
    border-radius: 14px;
    background: var(--panel, #0f1820);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 22px;
}

.login-brand strong {
    display: block;
    letter-spacing: 0.14em;
    font-size: 17px;
}

.login-brand small {
    color: var(--muted, #8da0b0);
}

.login-card h1 {
    margin: 0 0 6px;
    font-size: 22px;
}

.login-subtitle,
.login-hint {
    color: var(--muted, #8da0b0);
    font-size: 13px;
}

.login-subtitle {
    margin: 0 0 20px;
}

.login-hint {
    margin: 16px 0 0;
    text-align: center;
    font-size: 11px;
}

.login-card .field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}

.login-card .field span {
    font-size: 12px;
    color: var(--muted, #8da0b0);
}

.login-card .field input {
    min-height: 42px;
    padding: 0 12px;
    border-radius: 8px;
    border: 1px solid var(--border-soft, #1c2a36);
    background: var(--input-bg, #0a1219);
    color: inherit;
}

.login-show-pass {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 14px;
    font-size: 12px;
    color: var(--muted, #8da0b0);
}

.login-error {
    margin: 0 0 12px;
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(220, 60, 60, 0.12);
    border: 1px solid rgba(220, 60, 60, 0.35);
    color: #ff8f8f;
    font-size: 13px;
}

.login-card .button.primary {
    width: 100%;
    min-height: 44px;
}

html[data-theme="light"] .login-view {
    background:
        radial-gradient(ellipse at 20% 10%, rgba(39, 194, 129, 0.1), transparent 45%),
        #eef2f4;
}

html[data-theme="light"] .login-card {
    background: #ffffff;
    border-color: #d5dde4;
    box-shadow: 0 14px 36px rgba(20, 40, 60, 0.08);
}

html[data-theme="light"] .login-error {
    color: #b42318;
    background: rgba(180, 35, 24, 0.08);
}

/* ---- Normal User role visibility (ESP32 session role; not localStorage) ---- */
body.malwa-role-normal-user a[href="#logs"],
body.malwa-role-normal-user #logs,
body.malwa-role-normal-user #logs:target,
body.malwa-role-normal-user #network-settings,
body.malwa-role-normal-user #wifi-settings,
body.malwa-role-normal-user #advanced-network-settings,
body.malwa-role-normal-user #remote-settings,
body.malwa-role-normal-user #keyboard-settings,
body.malwa-role-normal-user #users-settings,
body.malwa-role-normal-user #device-configuration,
body.malwa-role-normal-user #backup-settings,
body.malwa-role-normal-user .settings-nav a[href="#network-settings"],
body.malwa-role-normal-user .settings-nav a[href="#remote-settings"],
body.malwa-role-normal-user .settings-nav a[href="#keyboard-settings"],
body.malwa-role-normal-user .settings-nav a[href="#users-settings"],
body.malwa-role-normal-user .settings-nav a[href="#backup-settings"],
body.malwa-role-normal-user #dashboard-reset-all-btn,
body.malwa-role-normal-user a[href="#confirm-lifetime"],
body.malwa-role-normal-user #confirm-lifetime,
body.malwa-role-normal-user #confirm-reset-all-counters,
body.malwa-role-normal-user #consumable-export-csv,
body.malwa-role-normal-user #log-download-month,
body.malwa-role-normal-user #ms-number,
body.malwa-role-normal-user label.field:has(#ms-number),
body.malwa-role-normal-user label.field:has(#ms-operator),
body.malwa-role-normal-user label.field:has(#ms-type),
body.malwa-role-normal-user label.field:has(#ms-subcategory) {
    display: none !important;
}

/* If Normal User somehow lands on #logs, keep dashboard visible. */
body.malwa-role-normal-user:has(#logs:target) #dashboard {
    display: block;
}

