@import url('https://fonts.googleapis.com/css2?family=Barlow+Semi+Condensed:wght@500;600;700&family=Inter:wght@400;500;600&display=swap');

:root {
  --ink: #073a46;
  --ink-deep: #032a34;
  --teal: #0b9f96;
  --teal-bright: #20c6b7;
  --mist: #e9f0ef;
  --paper: #f7f8f5;
  --white: #fff;
  --muted: #6f7f83;
  --line: #d8e1df;
  --danger: #d94a45;
  --danger-soft: #fce9e6;
  --shadow: 0 18px 50px rgba(4, 49, 59, .09);
  --display: "Barlow Semi Condensed", Arial, sans-serif;
  --body: "Inter", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); }
body { min-height: 100vh; margin: 0; color: var(--ink); background: var(--paper); font-family: var(--body); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; }
button, a, select { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button { color: inherit; }
h1, h2, p { margin-top: 0; }
h1, h2 { font-family: var(--display); }
h1 { margin-bottom: 12px; font-size: clamp(2.7rem, 5vw, 4.9rem); line-height: .94; letter-spacing: -.04em; }

.topbar { position: sticky; z-index: 20; top: 0; height: 84px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0 clamp(20px, 4vw, 64px); border-bottom: 1px solid var(--line); background: rgba(247, 248, 245, .92); backdrop-filter: blur(18px); }
.brand { display: inline-flex; width: max-content; align-items: center; gap: 13px; }
.brand > span:last-child, .login-brand > span:last-child { display: flex; flex-direction: column; }
.brand strong, .login-brand strong { font-family: var(--display); font-size: 1.75rem; line-height: .8; letter-spacing: -.03em; }
.brand small, .login-brand small { margin-top: 7px; color: var(--muted); font-size: .63rem; font-weight: 600; letter-spacing: .15em; text-transform: uppercase; }
.brand-mark { position: relative; display: block; width: 32px; height: 34px; transform: skew(-13deg); }
.brand-mark i { position: absolute; display: block; width: 7px; border-radius: 1px; background: var(--teal); }
.brand-mark i:nth-child(1) { bottom: 0; left: 1px; height: 18px; }
.brand-mark i:nth-child(2) { bottom: 0; left: 12px; height: 27px; background: var(--teal-bright); }
.brand-mark i:nth-child(3) { bottom: 0; left: 23px; height: 34px; background: var(--ink); }
.history-nav { display: flex; gap: 8px; }
.icon-button { width: 40px; height: 40px; display: inline-grid; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: transparent; cursor: pointer; transition: .2s ease; }
.icon-button:hover { border-color: var(--ink); background: var(--white); transform: translateY(-1px); }
.icon-button svg, .tile-footer svg { width: 19px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.account { justify-self: end; display: flex; align-items: center; gap: 20px; }
.account-copy { display: flex; flex-direction: column; text-align: right; font-size: .78rem; font-weight: 600; }
.account-copy small { margin-bottom: 3px; color: var(--muted); font-size: .62rem; letter-spacing: .12em; text-transform: uppercase; }
.logout-button, .text-button { padding: 0; border: 0; border-bottom: 1px solid currentColor; background: transparent; font-size: .75rem; font-weight: 600; cursor: pointer; }

.page-shell { width: min(1420px, calc(100% - 48px)); margin: 0 auto; padding: clamp(50px, 7vw, 100px) 0 90px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 40px; margin-bottom: 58px; }
.page-heading p, .machine-heading p { margin-bottom: 0; color: var(--muted); font-size: .93rem; }
.eyebrow { display: inline-block; margin-bottom: 17px; color: var(--teal); font-size: .67rem; font-weight: 700; letter-spacing: .2em; text-transform: uppercase; }
.eyebrow.light { color: var(--teal-bright); }
.sort-control { display: flex; align-items: center; padding: 5px; border: 1px solid var(--line); border-radius: 99px; background: var(--white); }
.sort-control > span { padding: 0 14px; color: var(--muted); font-size: .65rem; text-transform: uppercase; letter-spacing: .1em; }
.sort-control a { min-width: 56px; padding: 10px 13px; border-radius: 99px; text-align: center; font-size: .72rem; font-weight: 600; }
.sort-control a.active { color: var(--white); background: var(--ink); }
.summary-line { display: flex; align-items: center; gap: 18px; margin-bottom: 22px; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .12em; }
.summary-line b { color: var(--ink); }
.summary-line i { height: 1px; flex: 1; background: var(--line); }
.tile-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.data-tile { position: relative; aspect-ratio: 1 / 1; min-height: 260px; display: flex; flex-direction: column; padding: 25px; overflow: hidden; border: 1px solid var(--line); background: var(--white); transition: border-color .25s ease, transform .25s ease, box-shadow .25s ease; }
.data-tile::before { content: ""; position: absolute; inset: auto 0 0; height: 3px; background: var(--teal); transform: scaleX(0); transform-origin: left; transition: transform .25s ease; }
.data-tile:hover { z-index: 2; border-color: rgba(11,159,150,.5); transform: translateY(-5px); box-shadow: var(--shadow); }
.data-tile:hover::before { transform: scaleX(1); }
.tile-index { color: #a6b2b4; font-family: var(--display); font-size: .72rem; letter-spacing: .08em; }
.client-glyph { position: relative; width: 84px; height: 67px; margin: auto; }
.client-glyph span { position: absolute; bottom: 0; width: 23px; border: 1px solid #9bb4b5; background: var(--mist); }
.client-glyph span:nth-child(1) { left: 0; height: 42px; }
.client-glyph span:nth-child(2) { left: 30px; height: 66px; border-color: var(--teal); background: rgba(32,198,183,.16); }
.client-glyph span:nth-child(3) { right: 0; height: 53px; }
.tile-main h2 { max-width: 250px; margin-bottom: 5px; font-size: 1.55rem; line-height: 1; letter-spacing: -.02em; }
.tile-main p { margin: 0; color: var(--muted); font-size: .72rem; }
.tile-footer { min-height: 40px; display: flex; align-items: flex-end; gap: 12px; margin-top: 20px; padding-top: 15px; border-top: 1px solid var(--line); font-size: .66rem; }
.tile-footer > span:first-child { margin-right: auto; color: var(--muted); }
.tile-footer b { color: var(--ink); font-family: var(--display); font-size: 1rem; }
.ok-text { color: var(--teal); }
.alert-text { color: var(--danger); }
.tile-footer svg { align-self: center; }
.empty-state { grid-column: 1 / -1; padding: 60px; border: 1px dashed var(--line); color: var(--muted); text-align: center; }
.breadcrumb { display: inline-block; margin-bottom: 35px; color: var(--muted); font-size: .7rem; }
.breadcrumb span { padding: 0 8px; color: #b1bcbd; }

.client-heading { margin-bottom: 48px; }
.fleet-stats { display: flex; gap: 8px; }
.fleet-stats > div { min-width: 108px; padding: 16px 18px; border-left: 2px solid var(--teal); background: var(--white); }
.fleet-stats b { display: block; font-family: var(--display); font-size: 1.7rem; line-height: 1; }
.fleet-stats span { color: var(--muted); font-size: .65rem; }
.fleet-stats .danger-stat { border-color: var(--danger); }
.danger-stat b { color: var(--danger); }
.filter-row { min-height: 63px; display: flex; align-items: center; justify-content: space-between; gap: 30px; margin-bottom: 22px; padding: 10px 13px 10px 22px; border: 1px solid var(--line); background: var(--white); }
.group-filter { display: flex; align-items: center; gap: 14px; }
.group-filter > span { color: var(--muted); font-size: .66rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; }
.select-wrap select, .parameter-control select { min-width: 210px; padding: 10px 35px 10px 12px; border: 0; border-left: 1px solid var(--line); outline: none; color: var(--ink); background: var(--white); font-size: .75rem; font-weight: 600; cursor: pointer; }
.group-filter .text-button { margin-left: 6px; color: var(--teal); }
.result-count { color: var(--muted); font-size: .68rem; }
.machine-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.machine-tile.status-error::before { background: var(--danger); transform: scaleX(1); }
.machine-tile.status-error { border-bottom-color: var(--danger); }
.machine-topline { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.status-pill { width: max-content; display: inline-flex; align-items: center; gap: 7px; color: var(--teal); font-size: .64rem; font-weight: 700; letter-spacing: .12em; }
.status-pill i, .live-label i { width: 7px; height: 7px; display: block; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 4px rgba(11,159,150,.11); }
.status-error, .machine-tile.status-error .status-pill { color: var(--danger); }
.status-offline { color: var(--muted); }
.serial { color: #9ba9ac; font-family: var(--display); font-size: .66rem; letter-spacing: .05em; }
.machine-symbol { position: relative; width: 106px; height: 72px; margin: auto; }
.machine-symbol span { position: absolute; top: 22px; height: 30px; border: 1px solid #92adaf; }
.machine-symbol span:first-child { left: 11px; width: 52px; background: var(--mist); }
.machine-symbol span:nth-child(2) { right: 4px; width: 38px; border-color: var(--teal); background: rgba(32,198,183,.12); border-radius: 50%; }
.machine-symbol i { position: absolute; top: 35px; left: 0; width: 106px; height: 3px; background: var(--ink); opacity: .6; }
.machine-tile .tile-footer { align-items: center; }
.machine-tile .tile-footer time { display: block; margin-top: 3px; color: var(--ink); }

.group-dialog { width: min(540px, calc(100% - 30px)); padding: 30px; border: 0; color: var(--ink); background: var(--white); box-shadow: 0 30px 90px rgba(0,20,25,.3); }
.group-dialog::backdrop { background: rgba(3,42,52,.72); backdrop-filter: blur(5px); }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; }
.dialog-heading h2 { margin-bottom: 0; font-size: 2rem; }
.dialog-heading .icon-button { font-size: 1.45rem; }
.muted { color: var(--muted); }
.group-dialog > p { font-size: .77rem; line-height: 1.6; }
.group-list { margin: 24px 0; padding: 0; border-top: 1px solid var(--line); list-style: none; }
.group-list li { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 15px 0; border-bottom: 1px solid var(--line); }
.group-list li > span { display: flex; flex-direction: column; gap: 3px; font-size: .78rem; }
.group-list small { color: var(--muted); font-size: .65rem; }
.delete-button { padding: 7px 0; border: 0; border-bottom: 1px solid transparent; color: var(--danger); background: transparent; font-size: .68rem; cursor: pointer; }
.delete-button:hover { border-color: currentColor; }
.add-group-form { padding: 18px; background: var(--mist); }
.add-group-form label { display: block; margin-bottom: 8px; font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; }
.add-group-form > div { display: flex; }
.add-group-form input { width: 100%; min-width: 0; padding: 12px; border: 1px solid var(--line); outline: 0; }
.primary-button { display: flex; align-items: center; justify-content: space-between; gap: 30px; padding: 13px 18px; border: 0; color: var(--white); background: var(--ink); font-size: .76rem; font-weight: 600; cursor: pointer; transition: background .2s ease; }
.primary-button:hover { background: var(--teal); }
button:disabled { opacity: .5; cursor: wait; }

.login-page { background: var(--ink-deep); }
.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(420px, 1.15fr) minmax(480px, .85fr); }
.login-intro { position: relative; display: flex; flex-direction: column; justify-content: space-between; padding: clamp(40px, 6vw, 90px); overflow: hidden; color: var(--white); background: linear-gradient(145deg, #053e49 0%, #032a34 72%); }
.login-intro::before { content: ""; position: absolute; width: 55vw; height: 55vw; right: -28vw; bottom: -27vw; border: 1px solid rgba(32,198,183,.2); border-radius: 50%; box-shadow: 0 0 0 7vw rgba(32,198,183,.025), 0 0 0 14vw rgba(32,198,183,.02); }
.login-brand { display: flex; align-items: center; gap: 16px; }
.login-brand strong { color: var(--white); font-size: 2.2rem; }
.login-brand small { color: rgba(255,255,255,.5); }
.brand-mark-large { width: 39px; height: 41px; }
.brand-mark-large i { width: 8px; }
.brand-mark-large i:nth-child(1) { height: 23px; }
.brand-mark-large i:nth-child(2) { left: 14px; height: 33px; }
.brand-mark-large i:nth-child(3) { left: 28px; height: 41px; background: #dff4ef; }
.intro-copy { position: relative; z-index: 1; max-width: 670px; margin: auto 0; padding: 80px 0; }
.intro-copy h1 { margin-bottom: 25px; font-size: clamp(4rem, 7vw, 7.7rem); line-height: .82; color: var(--white); }
.intro-copy p { max-width: 430px; color: rgba(255,255,255,.6); font-size: 1rem; line-height: 1.7; }
.signal-visual { position: relative; z-index: 1; height: 54px; display: flex; align-items: flex-end; gap: 8px; }
.signal-visual span { width: 5px; background: var(--teal-bright); }
.signal-visual span:nth-child(1) { height: 20%; opacity: .25; }.signal-visual span:nth-child(2) { height: 44%; opacity: .45; }.signal-visual span:nth-child(3) { height: 78%; opacity: .65; }.signal-visual span:nth-child(4) { height: 100%; }.signal-visual span:nth-child(5) { width: 110px; height: 1px; margin: 0 0 26px 8px; opacity: .5; }
.login-panel { display: grid; place-items: center; align-content: center; gap: 38px; padding: 50px clamp(35px, 7vw, 110px); background: var(--paper); }
.login-form, .demo-access { width: min(430px, 100%); }
.login-form h2 { margin-bottom: 8px; font-size: 2.6rem; letter-spacing: -.03em; }
.login-form > p { margin-bottom: 30px; font-size: .8rem; }
.login-form label { display: block; margin: 17px 0 7px; color: var(--muted); font-size: .65rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.login-form input { width: 100%; padding: 15px 2px; border: 0; border-bottom: 1px solid #bfcac9; outline: 0; color: var(--ink); background: transparent; }
.login-form input:focus { border-color: var(--teal); }
.login-form .primary-button { width: 100%; margin-top: 30px; padding: 16px 20px; }
.form-error { padding: 12px 14px; color: #9f302d; background: var(--danger-soft); font-size: .75rem; }
.demo-access { padding-top: 23px; border-top: 1px solid var(--line); }
.demo-access > span { display: block; margin-bottom: 10px; color: var(--muted); font-size: .62rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; }
.demo-access button { width: 100%; display: flex; justify-content: space-between; gap: 15px; padding: 7px 0; border: 0; color: var(--ink); background: transparent; font-size: .68rem; cursor: pointer; }
.demo-access code { color: var(--muted); font-size: .65rem; }

.machine-page { padding-top: 55px; }
.machine-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; margin-bottom: 45px; }
.machine-heading h1 { font-size: clamp(3rem, 5vw, 5.3rem); }
.status-pill.large { margin-bottom: 9px; padding: 13px 17px; border: 1px solid currentColor; }
.chart-panel, .frames-panel { margin-bottom: 18px; border: 1px solid var(--line); background: var(--white); }
.panel-heading { min-height: 92px; display: flex; align-items: center; justify-content: space-between; gap: 30px; padding: 18px 26px; border-bottom: 1px solid var(--line); }
.panel-heading > div:first-child { display: flex; align-items: center; gap: 17px; }
.section-number { color: var(--teal); font-family: var(--display); font-size: .75rem; }
.panel-heading h2 { margin: 0 0 3px; font-size: 1.35rem; }
.panel-heading p { margin: 0; color: var(--muted); font-size: .67rem; }
.parameter-control { display: flex; align-items: center; gap: 10px; }
.parameter-control label { color: var(--muted); font-size: .63rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; }
.parameter-control select { border: 1px solid var(--line); }
.chart-meta { display: flex; align-items: baseline; gap: 15px; padding: 25px 34px 0; }
.chart-meta strong { font-family: var(--display); font-size: 2rem; }
.chart-meta span { color: var(--muted); font-size: .65rem; }
.chart-wrap { position: relative; height: clamp(260px, 34vw, 440px); padding: 10px 25px 20px; }
#telemetry-chart { width: 100%; height: 100%; }
.chart-tooltip { position: absolute; min-width: 130px; padding: 9px 11px; border: 1px solid var(--line); background: rgba(255,255,255,.94); box-shadow: 0 8px 25px rgba(4,49,59,.12); pointer-events: none; transform: translate(-50%, -100%); }
.chart-tooltip b, .chart-tooltip span { display: block; font-size: .68rem; }
.chart-tooltip span { margin-top: 3px; color: var(--muted); font-size: .58rem; }
.live-label { display: flex; align-items: center; gap: 8px; color: var(--teal); font-size: .65rem; }
.frames-table { overflow: hidden; }
.frame-row { border-bottom: 1px solid var(--line); }
.frame-row:last-child { border-bottom: 0; }
.frame-row.table-head, .frame-row summary { min-height: 61px; display: grid; grid-template-columns: 175px 110px minmax(250px, 1fr) 70px; align-items: center; gap: 18px; padding: 11px 26px; }
.frame-row.table-head { min-height: 42px; color: var(--muted); background: #f3f6f4; font-size: .6rem; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; }
.frame-row summary { cursor: pointer; list-style: none; font-size: .7rem; }
.frame-row summary::-webkit-details-marker { display: none; }
.frame-row summary:hover { background: #fafbf9; }
.frame-row code { overflow: hidden; color: var(--muted); font-size: .65rem; text-overflow: ellipsis; white-space: nowrap; }
.status-pill.compact { font-size: .59rem; }
.source-tag { width: max-content; padding: 4px 7px; color: var(--muted); background: var(--mist); font-size: .58rem; text-transform: uppercase; }
.frame-row pre { margin: 0; padding: 20px 26px 20px 329px; overflow-x: auto; color: #d6f5ef; background: var(--ink-deep); font: 12px/1.6 Consolas, monospace; }
.toast { position: fixed; z-index: 100; right: 24px; bottom: 24px; max-width: min(390px, calc(100% - 48px)); padding: 14px 18px; color: var(--white); background: var(--ink); box-shadow: var(--shadow); font-size: .74rem; transform: translateY(25px); opacity: 0; pointer-events: none; transition: .25s ease; }
.toast.visible { transform: translateY(0); opacity: 1; }
.toast[data-type="error"] { background: var(--danger); }

@media (max-width: 1100px) {
  .tile-grid, .machine-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .login-shell { grid-template-columns: 1fr 1fr; }
  .intro-copy h1 { font-size: clamp(3.5rem, 7vw, 5.7rem); }
}

@media (max-width: 820px) {
  .topbar { height: 72px; grid-template-columns: 1fr auto auto; gap: 16px; padding: 0 20px; }
  .account-copy { display: none; }
  .account { gap: 0; }
  .page-shell { width: min(100% - 30px, 680px); padding-top: 45px; }
  .page-heading, .machine-heading { align-items: flex-start; flex-direction: column; margin-bottom: 38px; }
  .client-heading { gap: 28px; }
  .tile-grid, .machine-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .login-shell { grid-template-columns: 1fr; }
  .login-intro { min-height: 42vh; padding: 35px; }
  .intro-copy { padding: 70px 0 30px; }
  .intro-copy h1 { font-size: clamp(3.7rem, 14vw, 6.3rem); }
  .signal-visual { display: none; }
  .login-panel { padding: 65px 28px; }
  .frame-row.table-head { display: none; }
  .frame-row summary { grid-template-columns: 145px 80px minmax(150px, 1fr); }
  .source-tag { display: none; }
  .frame-row pre { padding-left: 25px; }
}

@media (max-width: 540px) {
  h1 { font-size: 3rem; }
  .brand small { display: none; }
  .brand strong { font-size: 1.45rem; }
  .history-nav { gap: 4px; }
  .topbar .icon-button { width: 35px; height: 35px; }
  .logout-button { font-size: .68rem; }
  .page-shell { width: calc(100% - 24px); padding-bottom: 55px; }
  .page-heading { gap: 25px; }
  .page-heading p { line-height: 1.5; }
  .sort-control { width: 100%; }
  .sort-control a { flex: 1; }
  .tile-grid, .machine-grid { grid-template-columns: 1fr; }
  .data-tile { aspect-ratio: 1.2 / 1; min-height: 270px; }
  .filter-row { align-items: stretch; flex-direction: column; gap: 12px; padding: 15px; }
  .group-filter { display: grid; grid-template-columns: 1fr auto; }
  .group-filter > span { grid-column: 1 / -1; }
  .select-wrap select { width: 100%; min-width: 0; border: 1px solid var(--line); }
  .fleet-stats { width: 100%; }
  .fleet-stats > div { flex: 1; }
  .panel-heading { align-items: flex-start; flex-direction: column; }
  .parameter-control { width: 100%; justify-content: space-between; }
  .parameter-control select { min-width: 0; width: 68%; }
  .chart-meta { align-items: flex-start; flex-direction: column; gap: 4px; padding-left: 20px; }
  .chart-wrap { padding-right: 10px; padding-left: 5px; }
  .frame-row summary { grid-template-columns: 1fr auto; gap: 8px; padding: 15px 18px; }
  .frame-row code { grid-column: 1 / -1; }
  .login-intro { min-height: 390px; padding: 28px; }
  .intro-copy { padding-top: 65px; }
  .intro-copy p { font-size: .85rem; }
  .demo-access button { align-items: flex-start; flex-direction: column; gap: 3px; padding: 9px 0; }
  .group-dialog { padding: 22px; }
  .add-group-form > div { flex-direction: column; gap: 8px; }
}

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