:root {
  color-scheme: light;
  --ink: #132035;
  --ink-soft: #536176;
  --navy: #101a2d;
  --navy-2: #192641;
  --paper: #f3f5f7;
  --surface: #ffffff;
  --line: #dce2e9;
  --line-strong: #c7d0db;
  --orange: #f59e42;
  --orange-dark: #c96b18;
  --mint: #36b887;
  --red: #db5757;
  --blue: #4d7df3;
  --purple: #8b6ce0;
  --shadow: 0 12px 32px rgba(25, 38, 65, 0.08);
  --radius: 12px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--paper); color: var(--ink); }
body { font-size: 16px; line-height: 1.5; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(420px, 1.15fr) minmax(420px, .85fr); }
.login-brand { position: relative; overflow: hidden; padding: 48px 7vw; display: flex; flex-direction: column; justify-content: space-between; color: #fff; background: var(--navy); }
.login-brand::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 15% 85%, rgba(77,125,243,.23), transparent 35%), radial-gradient(circle at 88% 24%, rgba(245,158,66,.16), transparent 28%), linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px); background-size: auto, auto, 44px 44px, 44px 44px; }
.login-brand::after { content: ""; position: absolute; width: 420px; height: 420px; right: -230px; bottom: 7%; border: 1px solid rgba(255,255,255,.13); border-radius: 50%; box-shadow: 0 0 0 70px rgba(255,255,255,.025), 0 0 0 140px rgba(255,255,255,.018); }
.login-brand > * { position: relative; z-index: 1; }
.brand-lockup { display: flex; align-items: center; gap: 11px; font-size: 1.15rem; font-weight: 750; letter-spacing: -.02em; }
.brand-lockup--large { font-size: 1.35rem; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; color: var(--navy); background: var(--orange); border-radius: 8px; font-weight: 900; }
.brand-lockup--large .brand-mark { width: 40px; height: 40px; }
.eyebrow { margin: 0 0 13px; color: var(--orange-dark); font-size: .76rem; line-height: 1; font-weight: 800; letter-spacing: .14em; }
.login-brand .eyebrow { color: var(--orange); }
.login-statement h1 { max-width: 720px; margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(3.4rem, 6.2vw, 6.8rem); line-height: .9; letter-spacing: -.055em; font-weight: 500; }
.login-statement h1 em { color: var(--orange); font-weight: 500; }
.login-copy { max-width: 540px; margin: 32px 0 0; color: #bec8d8; font-size: 1.05rem; }
.system-line { display: flex; align-items: center; gap: 10px; color: #b9c3d2; font-size: .88rem; }
.pulse { width: 9px; height: 9px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 0 6px rgba(54,184,135,.13); }
.login-panel { display: grid; place-items: center; padding: 48px; background: #f8f9fb; }
.login-card { width: min(420px, 100%); display: grid; gap: 24px; }
.login-card h2 { margin: 0; font-size: 2rem; line-height: 1.15; letter-spacing: -.035em; }
.login-card p:not(.eyebrow):not(.form-error) { margin: 8px 0 0; color: var(--ink-soft); }
label { display: grid; gap: 8px; color: #354359; font-size: .88rem; font-weight: 700; }
input, select, textarea { width: 100%; border: 1px solid var(--line-strong); border-radius: 9px; background: #fff; color: var(--ink); padding: 12px 13px; outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(77,125,243,.13); }
textarea { min-height: 140px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .86rem; }
.form-error { min-height: 24px; margin: 0; color: var(--red); font-size: .88rem; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 40px; border: 1px solid transparent; border-radius: 9px; padding: 9px 15px; font-weight: 760; font-size: .9rem; transition: transform .15s, background .15s, box-shadow .15s; }
.button:hover { transform: translateY(-1px); }
.button--primary { color: #18243a; background: var(--orange); box-shadow: 0 7px 18px rgba(245,158,66,.2); }
.button--primary:hover { background: #ffad58; }
.button--secondary { color: var(--ink); background: #fff; border-color: var(--line-strong); }
.button--danger { color: #fff; background: var(--red); }
.button--ghost { color: var(--ink-soft); background: transparent; }
.button--wide { width: 100%; min-height: 48px; justify-content: space-between; padding-inline: 18px; }
.button:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 244px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 26px 18px 18px; color: #e7ecf5; background: var(--navy); border-right: 1px solid #202c43; }
.sidebar .brand-lockup { padding: 0 10px 30px; }
.primary-nav { display: grid; gap: 4px; }
.nav-item { position: relative; display: flex; align-items: center; gap: 11px; width: 100%; min-height: 43px; border: 0; border-radius: 8px; padding: 0 11px; color: #9fabc0; background: transparent; text-align: left; font-weight: 650; font-size: .9rem; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.055); }
.nav-item.is-active { color: #fff; background: var(--navy-2); }
.nav-item.is-active::before { content: ""; position: absolute; left: -18px; width: 3px; height: 24px; border-radius: 0 3px 3px 0; background: var(--orange); }
.nav-icon { width: 20px; color: #8390a7; font-size: 1.05rem; text-align: center; }
.nav-item.is-active .nav-icon { color: var(--orange); }
.nav-count { margin-left: auto; min-width: 21px; padding: 1px 6px; border-radius: 999px; color: var(--navy); background: var(--orange); font-size: .7rem; text-align: center; }
.nav-section { margin: 23px 11px 8px; color: #66748c; font-size: .67rem; font-weight: 800; letter-spacing: .14em; }
.sidebar-foot { margin-top: auto; display: grid; gap: 12px; }
.cloud-health { display: flex; align-items: center; gap: 10px; padding: 11px; border: 1px solid #273650; border-radius: 9px; background: #141f34; }
.cloud-health div { display: grid; }
.cloud-health strong { font-size: .78rem; }
.cloud-health span:last-child { color: #77859c; font-size: .69rem; }
.status-dot { flex: 0 0 auto; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #95a0b2; }
.status-dot--online, .status-dot--passed { background: var(--mint); box-shadow: 0 0 0 4px rgba(54,184,135,.12); }
.status-dot--running { background: var(--blue); box-shadow: 0 0 0 4px rgba(77,125,243,.12); }
.status-dot--failed, .status-dot--setup_failed { background: var(--red); }
.status-dot--paused, .status-dot--queued { background: var(--orange); }
.user-chip { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 9px; width: 100%; border: 0; border-top: 1px solid #2b3850; padding: 15px 4px 0; color: #fff; background: transparent; text-align: left; }
.user-chip > span:first-child { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: #2c3a55; color: var(--orange); font-size: .72rem; font-weight: 800; }
.user-chip > span:nth-child(2) { display: grid; }
.user-chip strong { font-size: .78rem; }
.user-chip small { color: #8290a7; }
.text-button { border: 0; padding: 2px 4px; color: #7f8ca2; background: transparent; text-align: left; font-size: .76rem; }
.main-shell { min-width: 0; }
.topbar { min-height: 104px; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 22px 34px; background: var(--surface); border-bottom: 1px solid var(--line); }
.breadcrumb { margin: 0 0 3px; color: #8c97a7; font-size: .75rem; font-weight: 650; }
.topbar h1 { margin: 0; font-size: 1.65rem; line-height: 1.15; letter-spacing: -.035em; }
.topbar-actions { display: flex; align-items: center; gap: 9px; }
.icon-button { position: relative; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--ink-soft); font-size: 1.1rem; }
.notification-button span { position: absolute; top: 7px; right: 7px; width: 7px; height: 7px; border: 2px solid #fff; border-radius: 50%; background: var(--red); }
.page-content { padding: 28px 34px 60px; }
.page-head { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 22px; }
.page-head h2 { margin: 0; font-size: 1.2rem; }
.page-head p { margin: 4px 0 0; color: var(--ink-soft); font-size: .88rem; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat-card { position: relative; min-height: 136px; overflow: hidden; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 3px 10px rgba(25,38,65,.025); }
.stat-card::after { content: ""; position: absolute; right: -25px; bottom: -38px; width: 95px; height: 95px; border: 16px solid #f1f4f8; border-radius: 50%; }
.stat-card > * { position: relative; z-index: 1; }
.stat-label { color: var(--ink-soft); font-size: .78rem; font-weight: 700; }
.stat-value { display: block; margin: 16px 0 4px; font-family: Georgia, "Times New Roman", serif; font-size: 2.45rem; line-height: 1; }
.stat-foot { color: #7e8a9b; font-size: .72rem; }
.stat-accent { position: absolute; z-index: 1; top: 19px; right: 19px; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; color: var(--blue); background: #edf2ff; font-size: .82rem; font-weight: 900; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(290px, .75fr); gap: 18px; align-items: start; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 4px 16px rgba(25,38,65,.035); }
.panel-head { min-height: 61px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.panel-head h2, .panel-head h3 { margin: 0; font-size: .98rem; }
.panel-body { padding: 18px; }
.live-stack { display: grid; gap: 11px; }
.live-card { display: grid; grid-template-columns: 46px 1fr auto; align-items: center; gap: 13px; padding: 15px; border: 1px solid var(--line); border-radius: 10px; background: #fbfcfd; }
.live-card:hover { border-color: var(--line-strong); }
.device-glyph { display: grid; place-items: center; width: 42px; height: 54px; border: 2px solid #64748b; border-radius: 7px; color: #64748b; background: #edf1f5; font-size: .75rem; }
.live-main strong { display: block; margin-bottom: 2px; font-size: .9rem; }
.live-main p { margin: 0; color: var(--ink-soft); font-size: .78rem; }
.progress-line { height: 4px; margin-top: 10px; overflow: hidden; border-radius: 5px; background: #e8ecf1; }
.progress-line span { display: block; height: 100%; border-radius: 5px; background: var(--blue); }
.run-meta { min-width: 105px; text-align: right; }
.run-meta strong { display: block; font-family: ui-monospace, Consolas, monospace; font-size: .78rem; }
.run-meta span { color: var(--ink-soft); font-size: .71rem; }
.status-badge { display: inline-flex; align-items: center; gap: 6px; border: 1px solid transparent; border-radius: 999px; padding: 4px 9px; font-size: .7rem; font-weight: 800; text-transform: capitalize; }
.status-badge--passed, .status-badge--published, .status-badge--online { color: #147453; background: #e8f8f2; border-color: #c9eddf; }
.status-badge--running { color: #315dbb; background: #edf2ff; border-color: #d6e0ff; }
.status-badge--queued, .status-badge--paused, .status-badge--draft { color: #975410; background: #fff3e4; border-color: #f9dec0; }
.status-badge--failed, .status-badge--setup_failed, .status-badge--offline { color: #aa3939; background: #fff0f0; border-color: #f3cccc; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 11px 14px; color: #7e899a; background: #f8fafb; border-bottom: 1px solid var(--line); font-size: .69rem; letter-spacing: .06em; text-align: left; text-transform: uppercase; }
td { padding: 13px 14px; border-bottom: 1px solid #edf0f3; font-size: .82rem; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcfd; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .75rem; }
.muted { color: var(--ink-soft); }
.link-button { border: 0; padding: 0; color: #315fbd; background: transparent; font-weight: 700; }
.health-list { display: grid; gap: 14px; }
.health-row { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; }
.health-row strong { font-size: .82rem; }
.health-row small { color: var(--ink-soft); }
.empty-state { display: grid; place-items: center; min-height: 220px; padding: 32px; color: var(--ink-soft); text-align: center; }
.empty-state-icon { display: grid; place-items: center; width: 56px; height: 56px; margin-bottom: 13px; border: 1px dashed #aab5c3; border-radius: 50%; color: #8b97a8; font-size: 1.4rem; }
.empty-state h3 { margin: 0 0 6px; color: var(--ink); }
.empty-state p { max-width: 440px; margin: 0 0 16px; font-size: .86rem; }
.card-grid { display: grid; grid-template-columns: repeat(3, minmax(240px, 1fr)); gap: 15px; }
.scenario-card, .device-card { padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.scenario-card header, .device-card header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.scenario-card h3, .device-card h3 { margin: 0; font-size: .96rem; }
.scenario-card p, .device-card p { min-height: 40px; margin: 8px 0 16px; color: var(--ink-soft); font-size: .79rem; }
.card-meta { display: flex; align-items: center; gap: 14px; padding-top: 14px; border-top: 1px solid var(--line); color: #748094; font-size: .73rem; }
.card-actions { display: flex; gap: 7px; margin-top: 14px; }
.filterbar { display: flex; align-items: center; gap: 9px; margin-bottom: 16px; }
.filterbar input { max-width: 290px; }
.filterbar select { width: auto; min-width: 145px; }
.modal-backdrop { position: fixed; z-index: 50; inset: 0; display: grid; place-items: center; padding: 24px; background: rgba(10,18,32,.62); backdrop-filter: blur(4px); }
.modal { width: min(680px, 100%); max-height: calc(100vh - 48px); overflow: auto; border-radius: 14px; background: #fff; box-shadow: 0 30px 80px rgba(6,12,23,.3); }
.modal--wide { width: min(930px, 100%); }
.modal-head { position: sticky; z-index: 2; top: 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 20px 22px; background: #fff; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 1.15rem; }
.modal-head p { margin: 4px 0 0; color: var(--ink-soft); font-size: .8rem; }
.modal-close { border: 0; color: #798599; background: transparent; font-size: 1.2rem; }
.modal-body { display: grid; gap: 17px; padding: 22px; }
.modal-foot { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 9px; padding: 15px 22px; background: #fbfcfd; border-top: 1px solid var(--line); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.step-list { display: grid; gap: 9px; }
.step-row { display: grid; grid-template-columns: 30px 145px 1fr 34px; gap: 8px; align-items: center; padding: 9px; border: 1px solid var(--line); border-radius: 9px; background: #f9fafb; }
.step-number { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 6px; color: #47566d; background: #e8edf2; font-size: .72rem; font-weight: 800; }
.remove-step { width: 32px; height: 32px; border: 0; border-radius: 7px; color: var(--red); background: #ffeded; }
.check-list { display: grid; gap: 8px; }
.check-option { display: flex; grid-template-columns: none; flex-direction: row; align-items: center; gap: 9px; font-weight: 600; }
.check-option input { width: auto; }
.toast-root { position: fixed; z-index: 100; right: 22px; bottom: 22px; display: grid; gap: 8px; }
.toast { min-width: 270px; max-width: 400px; padding: 13px 15px; border-left: 4px solid var(--blue); border-radius: 8px; color: #fff; background: var(--navy); box-shadow: var(--shadow); font-size: .82rem; animation: toast-in .2s ease-out; }
.toast--error { border-left-color: var(--red); }
.toast--success { border-left-color: var(--mint); }
.timeline { position: relative; display: grid; gap: 0; }
.timeline::before { content: ""; position: absolute; left: 13px; top: 18px; bottom: 18px; width: 1px; background: var(--line); }
.timeline-item { position: relative; display: grid; grid-template-columns: 28px 1fr; gap: 12px; padding: 10px 0; }
.timeline-dot { z-index: 1; width: 9px; height: 9px; margin: 7px 0 0 9px; border: 2px solid #fff; border-radius: 50%; background: var(--blue); box-shadow: 0 0 0 2px #b9c9ed; }
.timeline-item strong { display: block; font-size: .8rem; }
.timeline-item p { margin: 2px 0 0; color: var(--ink-soft); font-size: .75rem; }
.screen-stage { min-height: 440px; display: grid; place-items: center; border-radius: 10px; color: #8190a5; background: #111a2b; }
.screen-frame { width: 230px; height: 410px; display: grid; place-items: center; border: 7px solid #2b3850; border-radius: 18px; background: #1c2940; box-shadow: 0 20px 45px rgba(0,0,0,.28); text-align: center; }
.manual-bar { display: grid; grid-template-columns: auto auto minmax(120px,1fr) auto; gap: 8px; align-items: center; margin-top: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: #f7f9fb; }
.manual-bar p { grid-column: 1 / -1; margin: 2px 0 0; color: var(--ink-soft); font-size: .74rem; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 18px; }
.pairing-code { display: block; margin: 14px 0; padding: 15px; border: 1px dashed #adbac9; border-radius: 9px; background: #f4f6f8; font-family: ui-monospace, Consolas, monospace; font-size: 1.25rem; font-weight: 800; letter-spacing: .09em; text-align: center; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .card-grid { grid-template-columns: 1fr 1fr; }
  .grid-2, .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 780px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { min-height: 320px; padding: 28px; }
  .login-statement h1 { font-size: 3rem; }
  .login-copy { display: none; }
  .login-panel { padding: 34px 24px; }
  .app-shell { grid-template-columns: 74px minmax(0, 1fr); }
  .sidebar { padding-inline: 12px; }
  .sidebar .brand-lockup span:last-child, .nav-item:not(.is-active) .nav-count, .nav-item { font-size: 0; }
  .nav-item { justify-content: center; padding: 0; }
  .nav-icon { font-size: 1.08rem; }
  .nav-item.is-active::before { left: -12px; }
  .nav-section, .cloud-health, .user-chip span:nth-child(2), .user-chip span:last-child, .text-button { display: none; }
  .user-chip { display: flex; justify-content: center; }
  .topbar { min-height: 88px; padding: 18px; }
  .topbar h1 { font-size: 1.3rem; }
  .breadcrumb { display: none; }
  .page-content { padding: 20px 18px 40px; }
  .stats-grid, .card-grid, .form-grid { grid-template-columns: 1fr; }
  .topbar-actions .icon-button { display: none; }
  .step-row { grid-template-columns: 28px 1fr 32px; }
  .step-row input { grid-column: 2 / 4; }
  .manual-bar { grid-template-columns: 1fr 1fr; }
  .manual-bar input { grid-column: 1 / -1; }
}
