* {
  box-sizing: border-box;
}

:root {
  --bg: #070c12;
  --panel: rgba(10, 17, 25, 0.86);
  --panel-strong: rgba(18, 29, 42, 0.88);
  --line: rgba(126, 158, 196, 0.16);
  --text: #f4f7fb;
  --muted: #9bb0c7;
  --blue: #74a7ff;
  --green: #2f9961;
  --green-soft: rgba(47, 153, 97, 0.18);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px),
    radial-gradient(circle at 70% 0%, rgba(44, 70, 102, 0.18), transparent 32%),
    var(--bg);
  background-size: 95px 95px, 95px 95px, auto, auto;
}

.app-shell {
  min-height: 100vh;
}

.login-view {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(7, 12, 18, 0.96);
}

.login-view.is-hidden {
  display: none;
}

.is-hidden {
  display: none !important;
}

.command-toast-stack {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 30;
  width: min(420px, calc(100vw - 32px));
  display: grid;
  gap: 10px;
}

.command-toast {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 14px 14px 16px;
  border: 1px solid rgba(126, 158, 196, 0.22);
  color: var(--text);
  background: rgba(10, 17, 25, 0.96);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.34);
}

.command-toast strong {
  display: block;
  margin-bottom: 4px;
  font-size: 15px;
}

.command-toast span {
  display: block;
  color: #d6e2ef;
  font-size: 14px;
  line-height: 1.4;
}

.command-toast button {
  width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  flex: 0 0 auto;
  color: var(--text);
  background: transparent;
  border: 1px solid rgba(126, 158, 196, 0.18);
}

.command-toast button:hover {
  background: rgba(126, 158, 196, 0.16);
}

.command-toast.is-waiting {
  border-left: 4px solid var(--blue);
}

.command-toast.is-success {
  border-left: 4px solid var(--green);
}

.command-toast.is-error {
  border-left: 4px solid #d64d4d;
}

.command-toast.is-warning {
  border-left: 4px solid #d6a84d;
}

.login-panel {
  width: min(100%, 380px);
  padding: 28px;
  border: 1px solid rgba(126, 158, 196, 0.18);
  background: rgba(10, 17, 25, 0.92);
  display: grid;
  gap: 14px;
  justify-items: center;
}

.login-logo {
  width: 138px;
  height: 138px;
  object-fit: contain;
  margin-bottom: 12px;
}

.login-panel h1 {
  margin-bottom: 24px;
  font-size: 42px;
}

.login-panel input,
.login-panel button {
  width: 100%;
}

.login-panel .state {
  min-height: 20px;
  margin-top: 10px;
  color: #ff6b6b;
  font-size: 16px;
  font-weight: bold;
  text-align: center;
}

.topbar {
  min-height: 210px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 54px 52px 30px;
  border-bottom: 1px solid rgba(126, 158, 196, 0.14);
}

.brand {
  display: flex;
  align-items: center;
  gap: 28px;
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.device-indicator {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.16), 0 0 16px rgba(239, 68, 68, 0.5);
}

.device-indicator.is-online {
  background: #35c878;
  box-shadow: 0 0 0 4px rgba(53, 200, 120, 0.16), 0 0 16px rgba(53, 200, 120, 0.5);
}

.eyebrow {
  margin: 2px 0 12px;
  color: var(--blue);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 6px;
}

h1,
h2 {
  margin: 0;
  font-weight: 700;
  letter-spacing: 0;
}

h1 {
  font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
  font-size: 52px;
  line-height: 1.05;
  font-weight: 700;
}

h2 {
  font-size: 32px;
  line-height: 1.15;
}

.motto {
  width: 172px;
  max-height: 92px;
  object-fit: contain;
}

.workspace {
  display: grid;
  grid-template-columns: 540px minmax(0, 1fr);
  min-height: calc(100vh - 210px);
}

.command-panel {
  padding: 28px 30px 34px;
  border-right: 1px solid rgba(126, 158, 196, 0.18);
  background: rgba(7, 12, 18, 0.42);
}

.field-label {
  margin: 28px 0 10px;
  color: #b5c7dd;
  font-size: 20px;
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 0;
}

.timer-grid {
  margin-top: 18px;
}

label {
  display: grid;
  gap: 10px;
  color: #b5c7dd;
  font-size: 18px;
}

input,
select {
  width: 100%;
  min-height: 52px;
  padding: 0 14px;
  border: 1px solid rgba(126, 158, 196, 0.22);
  color: var(--text);
  background: rgba(11, 18, 28, 0.86);
  font: inherit;
  border-radius: 0;
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #b5c7dd 50%),
    linear-gradient(135deg, #b5c7dd 50%, transparent 50%);
  background-position:
    calc(100% - 20px) 50%,
    calc(100% - 14px) 50%;
  background-size:
    6px 6px,
    6px 6px;
  background-repeat: no-repeat;
  padding-right: 40px;
}

button {
  width: 100%;
  min-height: 62px;
  margin-top: 12px;
  border: 0;
  border-radius: 0;
  color: #ffffff;
  background: var(--green);
  font-size: 20px;
  font-weight: 800;
  cursor: pointer;
}

.secondary-button {
  min-height: 52px;
  margin-top: 0;
  background: rgba(126, 158, 196, 0.16);
  border: 1px solid rgba(126, 158, 196, 0.22);
}

.compact-button {
  min-height: 52px;
  margin-top: 0;
  font-size: 18px;
}

.secondary-button:hover,
.secondary-button.is-active {
  background: #2b67a4;
}

.mode-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

button:hover {
  background: #37a96d;
}

.secondary-button:hover {
  background: #2b67a4;
}

button:disabled {
  cursor: default;
  background: #586575;
}

button:disabled:hover,
.secondary-button:disabled:hover {
  background: #586575;
}

.state {
  min-height: 26px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.45;
}

.program-panel {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid rgba(126, 158, 196, 0.16);
}

.program-panel h2 {
  font-size: 24px;
}

.pid-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 16px;
}

.pid-grid label {
  font-size: 15px;
}

.pid-grid input {
  min-height: 46px;
}

.pid-settings #savePidButton {
  margin-top: 12px;
}

.program-status {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.45;
}

.firmware-settings {
  display: grid;
  gap: 14px;
}

.firmware-settings label {
  font-size: 15px;
}

.firmware-settings input {
  min-height: 46px;
}

.firmware-settings input[type="file"] {
  padding: 10px;
}

.firmware-settings progress {
  width: 100%;
  height: 14px;
  border: 0;
  background: rgba(126, 158, 196, 0.16);
}

.firmware-settings progress::-webkit-progress-bar {
  background: rgba(126, 158, 196, 0.16);
}

.firmware-settings progress::-webkit-progress-value {
  background: var(--green);
}

.firmware-settings progress::-moz-progress-bar {
  background: var(--green);
}

.program-steps {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.program-step {
  padding: 14px;
  border: 1px solid rgba(126, 158, 196, 0.14);
  background: rgba(10, 17, 25, 0.62);
}

.program-step-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.program-step-head strong {
  font-size: 17px;
}

.program-step-head select,
.program-finish select {
  min-height: 42px;
}

.program-step-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 10px;
}

.program-ramp-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.program-step label {
  font-size: 15px;
}

.program-step input {
  min-height: 46px;
}

.program-block-note {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

.program-finish {
  display: grid;
  gap: 8px;
  margin-top: 16px;
  color: #b5c7dd;
  font-size: 15px;
}

.program-preview {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid rgba(126, 158, 196, 0.14);
  color: var(--muted);
  background: rgba(10, 17, 25, 0.5);
  font-size: 14px;
  line-height: 1.45;
}

.program-preview strong {
  display: block;
  margin-bottom: 6px;
  color: var(--text);
}

.program-preview ul {
  margin: 0;
  padding-left: 18px;
}

.program-library {
  display: grid;
  gap: 12px;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid rgba(126, 158, 196, 0.14);
  background: rgba(10, 17, 25, 0.42);
}

.program-library label {
  font-size: 15px;
}

.program-library input,
.program-library select {
  min-height: 44px;
}

.content-panel {
  display: flex;
  min-height: 0;
  flex-direction: column;
  contain: size;
  overflow: hidden;
  padding: 28px 30px 48px;
}

.live-card {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(0, 1.4fr);
  gap: 1px;
  background: var(--panel-strong);
  border: 1px solid rgba(126, 158, 196, 0.16);
}

.temperature-block {
  padding: 28px 24px;
  background: rgba(10, 17, 25, 0.88);
}

.temperature-block .label {
  display: block;
  color: var(--blue);
  font-size: 16px;
}

.temperature-block strong {
  display: block;
  margin-top: 14px;
  color: #f7fbff;
  font-size: clamp(54px, 6vw, 86px);
  line-height: 1;
}

.temperature-block small {
  margin-left: 8px;
  font-size: 28px;
}

.temperature-block p {
  margin: 22px 0 0;
  color: #b8cbe2;
  font-size: 20px;
  line-height: 1.45;
}

.temperature-block .active-target-temperature {
  margin-top: 18px;
  color: var(--muted);
  font-size: 16px;
}

.temperature-block .active-target-temperature b {
  margin-left: 4px;
  color: var(--blue);
  font-size: 20px;
}

.temperature-block .temperature-fault {
  margin-top: 12px;
  color: #ff6b6b;
  font-size: 16px;
  font-weight: 800;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin: 0;
  background: rgba(126, 158, 196, 0.14);
}

.status-grid div {
  min-height: 112px;
  padding: 20px;
  background: rgba(10, 17, 25, 0.88);
}

dt {
  color: var(--blue);
  font-size: 14px;
}

dd {
  margin: 8px 0 0;
  color: #f4f7fb;
  font-size: 20px;
  font-weight: 800;
}

.temperature-chart-section {
  margin-top: 28px;
  padding: 24px;
  border: 1px solid rgba(126, 158, 196, 0.16);
  background: rgba(10, 17, 25, 0.72);
}

.temperature-chart-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 16px;
}

.temperature-chart-toolbar label {
  color: var(--muted);
  font-size: 14px;
}

.temperature-chart-toolbar select {
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid rgba(126, 158, 196, 0.28);
  background: rgba(7, 12, 18, 0.88);
  color: #f4f7fb;
  font: inherit;
}

.temperature-chart-wrap {
  position: relative;
  height: 250px;
  margin-top: 16px;
  border: 1px solid rgba(126, 158, 196, 0.12);
  background:
    radial-gradient(circle at 50% 0%, rgba(74, 165, 255, 0.08), transparent 58%),
    rgba(7, 12, 18, 0.68);
}

.temperature-chart-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.temperature-chart-wrap .empty-log {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  text-align: center;
}

.temperature-chart-tooltip {
  position: absolute;
  z-index: 2;
  pointer-events: none;
  min-width: 132px;
  padding: 8px 10px;
  border: 1px solid rgba(126, 158, 196, 0.28);
  background: rgba(5, 10, 16, 0.94);
  color: #f7fbff;
  font-size: 13px;
  line-height: 1.45;
  transform: translate(-50%, calc(-100% - 12px));
}

.log-section {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  margin-top: 28px;
  padding: 24px;
  border: 1px solid rgba(126, 158, 196, 0.16);
  background: rgba(10, 17, 25, 0.72);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.section-head span {
  color: var(--muted);
  font-size: 16px;
}

.log-filter {
  display: grid;
  grid-template-columns: auto minmax(180px, 260px);
  gap: 12px;
  align-items: center;
  margin-top: 16px;
}

.log-filter label {
  color: var(--muted);
  font-size: 14px;
}

.log-filter select {
  width: 100%;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid rgba(126, 158, 196, 0.28);
  background: rgba(7, 12, 18, 0.88);
  color: #f4f7fb;
  font: inherit;
}

.log-list {
  display: grid;
  min-height: 0;
  flex: 1;
  gap: 10px;
  margin-top: 20px;
  align-content: start;
  overflow-y: auto;
  padding-right: 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(126, 158, 196, 0.58) rgba(10, 17, 25, 0.64);
}

.log-list::-webkit-scrollbar {
  width: 10px;
}

.log-list::-webkit-scrollbar-track {
  background: rgba(10, 17, 25, 0.64);
}

.log-list::-webkit-scrollbar-thumb {
  background: rgba(126, 158, 196, 0.58);
  border: 2px solid rgba(10, 17, 25, 0.64);
}

.pagination {
  display: grid;
  grid-template-columns: 120px 1fr 120px;
  gap: 12px;
  align-items: center;
  margin-top: 16px;
}

.pagination span {
  color: var(--muted);
  font-size: 16px;
  text-align: center;
}

.pagination button {
  min-height: 44px;
  margin-top: 0;
}

.log-item {
  display: grid;
  grid-template-columns: 1fr 140px 180px;
  gap: 16px;
  align-items: center;
  padding: 16px;
  border: 1px solid rgba(126, 158, 196, 0.12);
  background: rgba(7, 12, 18, 0.68);
}

.log-item strong {
  display: block;
  color: #f7fbff;
  font-size: 20px;
}

.log-item span {
  display: block;
  margin-top: 4px;
  color: var(--blue);
  font-size: 15px;
}

.log-item .sensor-fault-note {
  color: #ff6b6b;
  font-weight: 800;
}

.log-item dt {
  font-size: 12px;
}

.log-item dd {
  font-size: 16px;
}

.empty-log {
  margin: 0;
  color: var(--muted);
  font-size: 18px;
}

@media (max-width: 980px) {
  .topbar {
    min-height: auto;
    padding: 28px 22px;
  }

  .brand {
    gap: 16px;
  }

  .motto {
    display: none;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .content-panel,
  .temperature-chart-section,
  .log-section {
    display: block;
  }

  .content-panel {
    contain: none;
    overflow: visible;
  }

  .log-list {
    max-height: min(620px, 62vh);
  }

  .temperature-chart-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .temperature-chart-wrap {
    height: 220px;
  }

  .command-panel {
    border-right: 0;
    border-bottom: 1px solid rgba(126, 158, 196, 0.18);
  }

  .live-card {
    grid-template-columns: 1fr;
  }

  .control-grid,
  .mode-row,
  .status-grid,
  .program-step-grid,
  .program-ramp-grid {
    grid-template-columns: 1fr;
  }

  .log-item {
    grid-template-columns: 1fr;
  }

  .log-filter {
    grid-template-columns: 1fr;
  }

  .pagination {
    grid-template-columns: 1fr;
  }

  .stat {
    border-right: 0;
    border-bottom: 1px solid rgba(126, 158, 196, 0.14);
  }

}
