:root {
  --convert-red: #df0712;
  --convert-red-dark: #b80009;
  --convert-red-soft: #fff1f2;
  --ink: #171717;
  --muted: #66707a;
  --line: #dfe3e7;
  --paper: #f3f4f6;
  --green: #2a9d6f;
  --amber: #e39a28;
  --red: #d34b4b;
  --shadow: 0 14px 38px rgba(20, 24, 28, .075);
}

* { box-sizing: border-box; }
html { font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--ink); background: var(--paper); }
body { margin: 0; overflow-x: hidden; }
button, input, select { font: inherit; }

.topbar {
  min-height: 92px;
  background: rgba(255, 255, 255, .98);
  border-bottom: 3px solid var(--convert-red);
  box-shadow: 0 4px 18px rgba(20, 24, 28, .06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  padding: 12px 30px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 20px; color: var(--ink); text-decoration: none; min-width: 0; }
.brand-logo { display: block; width: min(285px, 31vw); height: auto; }
.brand-divider { width: 1px; height: 43px; background: var(--line); flex: 0 0 auto; }
.brand-product { color: #42474c; font-size: 14px; font-weight: 800; line-height: 1.2; }
.account { display: flex; align-items: center; justify-content: flex-end; gap: 12px; color: var(--ink); font-size: 13px; }
.account form { margin: 0; }
.user-avatar { width: 42px; height: 42px; flex: 0 0 42px; display: grid; place-items: center; border-radius: 50%; background: var(--convert-red-soft); color: var(--convert-red-dark); border: 1px solid #ffc8cc; font-weight: 850; }
.user-details { display: grid; line-height: 1.2; }
.user-details small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.link-button { margin-left: 8px; padding: 6px 0; background: transparent; color: #555d65; border: 0; text-decoration: underline; font-weight: 650; cursor: pointer; }

.shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: calc(100vh - 92px); }
aside { background: linear-gradient(180deg, #181818 0%, #242424 72%, #35080b 100%); color: #fff; padding: 28px 18px; display: flex; flex-direction: column; }
.site-picker { color: #b8bdc2; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .13em; }
.site-picker select { width: 100%; margin-top: 9px; padding: 12px; border: 1px solid #444; border-radius: 10px; background: #fff; color: var(--ink); text-transform: none; letter-spacing: 0; font-weight: 750; }
nav { display: grid; gap: 6px; margin-top: 27px; }
nav a { position: relative; padding: 13px 15px 13px 19px; border-radius: 10px; color: #d7dadd; text-decoration: none; font-size: 14px; font-weight: 650; transition: background .15s, color .15s, transform .15s; }
nav a::before { content: ""; position: absolute; left: 0; top: 11px; bottom: 11px; width: 3px; border-radius: 9px; background: transparent; }
nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; transform: translateX(2px); }
nav a.active { background: rgba(223, 7, 18, .17); color: #fff; }
nav a.active::before { background: var(--convert-red); }
.side-status { margin-top: auto; border-top: 1px solid rgba(255, 255, 255, .13); padding: 20px 5px 0; display: flex; gap: 11px; align-items: flex-start; }
.side-status div { display: grid; }
.side-status b { font-size: 12px; }
.side-status small { margin-top: 4px; color: #aeb4b9; font-size: 10px; line-height: 1.35; }

.content { width: 100%; max-width: 1540px; margin: auto; padding: 34px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 24px; }
.eyebrow { margin: 0 0 8px; color: var(--convert-red); font-size: 11px; font-weight: 850; text-transform: uppercase; letter-spacing: .15em; }
h1 { margin: 0; font-size: clamp(27px, 3vw, 36px); line-height: 1.08; }
h2 { margin: 0; font-size: 18px; }
.page-subtitle { margin: 10px 0 0; color: #d5d8db; font-size: 13px; }

.overview-head { position: relative; isolation: isolate; overflow: hidden; min-height: 178px; align-items: center; padding: 32px 38px; border-radius: 22px; color: #fff; background: linear-gradient(118deg, #171717 0%, #292929 62%, #3d090c 100%); box-shadow: 0 18px 42px rgba(16, 18, 20, .15); }
.overview-head::after { content: ""; position: absolute; z-index: -1; width: 260px; height: 260px; right: -70px; top: -125px; border: 42px solid rgba(223, 7, 18, .47); border-radius: 50%; }
.overview-head .eyebrow { color: #ff7a81; }
.health, .lock-state { display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px; border-radius: 999px; font-size: 12px; font-weight: 850; white-space: nowrap; }
.health::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.health.healthy, .lock-state.open { color: #176b4b; background: #dff3e9; }
.health.warning { color: #80520d; background: #fff0d5; }
.health.danger, .lock-state.closed { color: #9e3030; background: #fde4e4; }

.hero-grid { display: grid; grid-template-columns: 1.5fr repeat(3, 1fr); gap: 16px; }
.machine-card, .metric, .panel, .command-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.machine-card { min-height: 160px; padding: 24px; display: flex; align-items: center; gap: 22px; }
.machine-card h2 { font-size: 25px; }
.machine-card p:last-child { color: var(--muted); font-size: 13px; }
.machine-visual { width: 126px; height: 88px; flex: 0 0 126px; position: relative; border-radius: 9px; background: linear-gradient(145deg, #d4d8da, #939da2); box-shadow: inset 0 0 0 8px #bbc2c6, 0 10px 22px rgba(20, 24, 28, .12); }
.fan { width: 55px; height: 55px; position: absolute; left: 18px; top: 16px; border: 7px solid #67737a; border-radius: 50%; }
.fan::before, .fan::after { content: ""; width: 8px; height: 45px; position: absolute; left: 16px; top: -2px; border-radius: 10px; background: #67737a; }
.fan::after { transform: rotate(90deg); }
.machine-led { width: 9px; height: 9px; position: absolute; right: 14px; top: 16px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(42, 157, 111, .14); }
.machine-led.danger { background: var(--red); box-shadow: 0 0 0 4px rgba(211, 75, 75, .14); }
.metric { min-height: 160px; padding: 24px; display: flex; flex-direction: column; justify-content: center; border-top: 4px solid #232323; }
.metric.accent { color: #fff; border: 0; background: linear-gradient(145deg, var(--convert-red), #a90008); box-shadow: 0 16px 34px rgba(191, 0, 9, .2); }
.metric span { color: var(--muted); font-size: 12px; }
.metric.accent span, .metric.accent small { color: #ffe1e3; }
.metric strong { margin: 10px 0 4px; font-size: 31px; }
.metric small { color: var(--muted); font-size: 11px; }

.panel { margin-top: 18px; padding: 24px; }
.panel-head { margin-bottom: 20px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.panel-head .eyebrow { margin-bottom: 5px; }
.panel-head a { color: var(--convert-red-dark); text-decoration: none; font-size: 13px; font-weight: 750; }
.panel-head a:hover { text-decoration: underline; }
.state-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.state-row > div { min-height: 68px; padding: 12px 14px; display: grid; grid-template-columns: auto 1fr; align-content: center; column-gap: 11px; border-radius: 11px; background: #f7f8f9; }
.state-row .status-dot { grid-row: 1 / 3; }
.state-row b { font-size: 13px; }
.state-row small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.status-dot { width: 10px; height: 10px; margin-top: 3px; display: inline-block; flex: 0 0 auto; border-radius: 50%; background: #aab4ba; box-shadow: 0 0 0 4px rgba(170, 180, 186, .15); }
.status-dot.ok { background: var(--green); box-shadow: 0 0 0 4px rgba(42, 157, 111, .14); }
.status-dot.warning { background: var(--amber); box-shadow: 0 0 0 4px rgba(227, 154, 40, .13); }
.status-dot.danger { background: var(--red); box-shadow: 0 0 0 4px rgba(211, 75, 75, .13); }

.table-wrap { overflow: auto; padding: 0; }
table { width: 100%; min-width: 650px; border-collapse: collapse; }
th { padding: 13px 18px; color: #626b73; background: #f0f1f2; text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: .1em; }
td { padding: 14px 18px; border-top: 1px solid var(--line); font-size: 13px; }
td small { margin-top: 4px; display: block; color: var(--muted); font-size: 10px; }
.badge { display: inline-block; padding: 5px 8px; border-radius: 999px; background: #e8edf0; font-size: 10px; font-weight: 850; }
.badge.acknowledged { color: #176b4b; background: #dff3e9; }
.badge.failed { color: #9e3030; background: #fde4e4; }
.badge.pending, .badge.dispatched { color: #8a5a10; background: #fff0d5; }
.notice, .flash { margin: 0 0 18px; padding: 14px 16px; border-radius: 10px; color: #333; background: #f0f1f2; border-left: 4px solid var(--convert-red); font-size: 13px; }
.notice.warning, .flash.error { color: #9c3232; background: #fde7e7; }
.flash.success { color: #176b4b; background: #def3e8; border-left-color: var(--green); }
.command-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.command-card { padding: 18px; display: grid; grid-template-columns: 1fr 150px auto; gap: 14px; align-items: center; }
.command-card div { display: grid; }
.command-card small { margin-top: 5px; color: var(--muted); font-size: 10px; }
input, select { padding: 11px; border: 1px solid #cdd3d8; border-radius: 9px; background: #fff; }
input:focus, select:focus { border-color: var(--convert-red); outline: 3px solid rgba(223, 7, 18, .11); }
.primary { padding: 11px 16px; color: #fff; background: linear-gradient(135deg, var(--convert-red), #c9000a); border: 0; border-radius: 9px; box-shadow: 0 7px 18px rgba(223, 7, 18, .18); font-weight: 800; cursor: pointer; }
.primary:hover { background: var(--convert-red-dark); }
.switch-form { margin-top: 20px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.switch { display: flex; align-items: center; gap: 10px; }
.switch input { width: 20px; height: 20px; accent-color: var(--convert-red); }
.details { margin: 20px 0 0; display: grid; grid-template-columns: repeat(3, 1fr); }
.details div { padding-left: 14px; border-left: 3px solid var(--convert-red); }
.details dt { color: var(--muted); font-size: 11px; }
.details dd { margin: 4px 0 0; font-size: 18px; font-weight: 800; }
.empty { padding: 100px 20px; text-align: center; }
.panel > p { color: var(--muted); font-size: 13px; }

.login-body { min-height: 100vh; background: radial-gradient(circle at 12% 12%, rgba(223, 7, 18, .14), transparent 24rem), radial-gradient(circle at 88% 88%, rgba(30, 30, 30, .09), transparent 28rem), #eef0f2; }
.login-shell { width: min(1040px, calc(100% - 36px)); min-height: 100vh; margin: auto; padding: 46px 0 24px; display: grid; grid-template-columns: 1.08fr .92fr; align-content: center; overflow: hidden; border-radius: 26px; filter: drop-shadow(0 24px 42px rgba(20, 24, 28, .16)); }
.login-brand-panel { min-height: 610px; position: relative; isolation: isolate; overflow: hidden; padding: 54px 52px; display: flex; flex-direction: column; color: #fff; background: linear-gradient(145deg, #171717 0%, #252525 58%, #47070b 100%); }
.login-brand-panel::before { content: ""; width: 430px; height: 430px; position: absolute; z-index: -1; right: -210px; bottom: -210px; border: 58px solid rgba(223, 7, 18, .58); border-radius: 50%; }
.login-logo-frame { width: min(390px, 100%); padding: 15px 18px 12px; background: #fff; border-radius: 15px; box-shadow: 0 10px 30px rgba(0, 0, 0, .18); }
.login-logo { display: block; width: 100%; height: auto; }
.login-brand-copy { max-width: 470px; margin-top: auto; padding-top: 60px; }
.login-kicker { color: #ff737b; font-size: 12px; font-weight: 850; letter-spacing: .15em; text-transform: uppercase; }
.login-brand-copy h1 { margin: 12px 0 15px; font-size: clamp(2.1rem, 4vw, 3.35rem); line-height: 1.02; }
.login-brand-copy p { margin: 0; color: #d9dcdf; font-size: 1.02rem; line-height: 1.65; }
.login-brand-mark { width: 72px; height: 5px; margin-top: 30px; border-radius: 99px; background: var(--convert-red); }
.login-form-panel { min-height: 610px; padding: 64px 58px 46px; display: flex; flex-direction: column; justify-content: center; background: #fff; }
.login-form-heading h2 { margin: 8px 0 10px; font-size: 2rem; }
.login-form-heading > p:last-child { margin: 0 0 26px; color: var(--muted); line-height: 1.5; }
.login-form { display: grid; gap: 17px; }
.login-form label { display: grid; gap: 7px; font-size: 12px; font-weight: 750; }
.login-form input { min-height: 50px; }
.login-submit { width: 100%; min-height: 51px; margin-top: 8px; font-size: 1rem; }
.login-note { margin: 20px 0 0; color: #858c93; text-align: center; font-size: .78rem; }
.muted { color: var(--muted); font-size: 13px; }

@media (max-width: 1100px) {
  .hero-grid { grid-template-columns: repeat(3, 1fr); }
  .machine-card { grid-column: 1 / -1; }
  .command-card { grid-template-columns: 1fr; }
  .command-grid { grid-template-columns: 1fr; }
}

@media (max-width: 800px) {
  .topbar { min-height: 76px; padding: 10px 15px; }
  .brand-logo { width: min(225px, 53vw); }
  .brand-divider, .brand-product, .user-avatar, .user-details { display: none; }
  .link-button { margin-left: 0; }
  .shell { grid-template-columns: 1fr; min-height: calc(100vh - 76px); }
  aside { padding: 12px 14px; position: static; border-bottom: 0; }
  aside nav { margin-top: 12px; display: flex; overflow-x: auto; scrollbar-width: thin; }
  nav a { flex: 0 0 auto; padding: 11px 13px; }
  nav a::before { display: none; }
  nav a.active { background: var(--convert-red); }
  .side-status { display: none; }
  .content { padding: 20px 14px 28px; }
  .overview-head { min-height: 155px; padding: 27px 24px; border-radius: 17px; align-items: flex-start; }
  .page-head { align-items: flex-start; }
  .page-subtitle { max-width: 72%; }
  .hero-grid { grid-template-columns: 1fr; }
  .machine-card { grid-column: auto; }
  .state-row { grid-template-columns: 1fr; gap: 10px; }
  .details { grid-template-columns: 1fr; gap: 18px; }
  .switch-form { align-items: flex-start; flex-direction: column; }
  .login-shell { width: min(100% - 20px, 520px); min-height: auto; padding: 18px 0 14px; grid-template-columns: 1fr; align-content: start; border-radius: 20px; }
  .login-brand-panel { min-height: 275px; padding: 30px 26px; }
  .login-logo-frame { width: min(320px, 100%); padding: 11px 13px 9px; border-radius: 12px; }
  .login-brand-copy { padding-top: 34px; }
  .login-brand-copy h1 { margin: 9px 0; font-size: 2rem; }
  .login-brand-copy p { font-size: .9rem; line-height: 1.5; }
  .login-brand-mark { margin-top: 18px; }
  .login-form-panel { min-height: 0; padding: 34px 26px 30px; }
  .login-form-heading h2 { font-size: 1.7rem; }
}

@media (max-width: 520px) {
  .overview-head { flex-direction: column; }
  .overview-head::after { right: -140px; }
  .page-subtitle { max-width: 100%; }
  .machine-card { align-items: flex-start; flex-direction: column; }
  .machine-visual { width: 100%; }
  .metric { min-height: 130px; }
  .panel { padding: 18px; }
  .panel-head { align-items: flex-start; }
}
