:root {
  --brand-bg: #d7d7d7;
  --brand-blue: #003b88;
  --brand-green: #0e8f6d;
  --brand-green-dark: #0a6e57;
  --bg: #f0f4f6;
  --bg-layer: #dfe7ec;
  --surface: #ffffff;
  --surface-soft: #f7fafc;
  --line: #d2dde4;
  --text: #1f2b33;
  --muted: #576975;
  --ok: #1f8f55;
  --warn: #b57700;
  --alert: #c43434;
  --offline: #5d666e;
  --neutral: #196684;
  --shadow: 0 10px 28px rgba(24, 38, 48, 0.12);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--brand-bg);
  color: var(--text);
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  line-height: 1.4;
}

h1,
h2,
h3,
p {
  margin: 0;
}

a {
  color: inherit;
}

.hidden {
  display: none !important;
}

.app-shell {
  width: min(1880px, calc(100% - 48px));
  margin: 24px auto 30px;
  padding-bottom: 30px;
  animation: fade-in 0.38s ease;
}

.brand-banner {
  display: flex;
  align-items: flex-end;
  margin-bottom: 12px;
}

.brand-copy {
  display: flex;
  flex-direction: column;
}

.brand-logo {
  display: block;
  width: min(430px, 48vw);
  max-width: 100%;
  height: auto;
}

.brand-title {
  margin-top: 5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.78rem;
  font-weight: 700;
  color: #2b5a70;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(130deg, #f8fbfd 0%, #eef5f9 100%);
  box-shadow: var(--shadow);
}

.kicker {
  color: var(--neutral);
  font-weight: 600;
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

h1 {
  margin-top: 2px;
  font-size: clamp(1.55rem, 2.7vw, 2.3rem);
  font-family: "Barlow Condensed", "Arial Narrow", sans-serif;
  letter-spacing: 0.02em;
}

.subtitle {
  margin-top: 5px;
  color: var(--muted);
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.clock-card {
  min-width: 168px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.clock-label {
  color: var(--muted);
  font-size: 0.82rem;
}

.clock-value {
  margin-top: 3px;
  font-family: "Barlow Condensed", "Arial Narrow", sans-serif;
  font-size: 1.55rem;
  font-weight: 700;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--neutral);
  text-decoration: none;
  font-weight: 600;
  margin-bottom: 10px;
}

.back-link:hover {
  background: #edf6fb;
}

.filters-panel {
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
}

.filters-group {
  display: grid;
  gap: 6px;
}

.filters-group label {
  font-size: 0.86rem;
  color: var(--muted);
  font-weight: 600;
}

select {
  min-width: 190px;
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid #bccbd6;
  background: var(--surface);
  padding: 10px 12px;
  font-size: 0.98rem;
  color: var(--text);
}

select:focus-visible,
.btn:focus-visible,
.line-action:focus-visible,
.back-link:focus-visible,
.drawer-scrim:focus-visible {
  outline: 2px solid #0c84b6;
  outline-offset: 2px;
}

.formula-chip {
  min-height: 44px;
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  padding: 10px 14px;
  border: 1px dashed #9cb7c5;
  border-radius: 999px;
  font-size: 0.9rem;
  color: var(--muted);
  background: #f5fbff;
}

[data-tooltip] {
  position: relative;
  cursor: help;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 220px;
  max-width: 300px;
  border-radius: 8px;
  padding: 8px 10px;
  background: #1f2b33;
  color: #f7fbfe;
  font-size: 0.82rem;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 30;
  text-align: center;
}

[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::after {
  opacity: 1;
}

.summary-strip {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(4, minmax(170px, 1fr));
  gap: 12px;
}

.summary-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}

.summary-label {
  color: var(--muted);
  font-size: 0.85rem;
}

.summary-value {
  margin-top: 2px;
}

.metric-number {
  font-family: "Barlow Condensed", "Arial Narrow", sans-serif;
  font-size: 1.9rem;
  font-weight: 700;
}

.content-layout {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 12px;
}

.line-grid-wrap,
.machine-grid-wrap {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 16px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
}

.section-head h2 {
  font-family: "Barlow Condensed", "Arial Narrow", sans-serif;
  font-size: 1.5rem;
}

.section-subtitle {
  color: var(--muted);
  font-size: 0.9rem;
}

.line-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(320px, 1fr));
  gap: 12px;
}

.line-card,
.machine-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(150deg, #fefefe 0%, #f7fbfd 100%);
  padding: 14px;
  animation: rise-in 0.36s ease both;
}

.line-card[data-status="WARN"],
.machine-card[data-status="WARN"] {
  border-left: 8px solid var(--warn);
}

.line-card[data-status="ALERT"],
.machine-card[data-status="ALERT"] {
  border-left: 8px solid var(--alert);
}

.line-card[data-status="OFFLINE"],
.machine-card[data-status="OFFLINE"] {
  border-left: 8px solid var(--offline);
}

.line-card[data-status="OK"],
.machine-card[data-status="OK"] {
  border-left: 8px solid var(--ok);
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.card-title {
  font-weight: 700;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 78px;
  min-height: 32px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
}

.status-pill[data-status="OK"] {
  color: #0d6339;
  background: #def6e9;
  border-color: #9fd8b7;
}

.status-pill[data-status="WARN"] {
  color: #7f5200;
  background: #fff2d4;
  border-color: #f1c879;
}

.status-pill[data-status="ALERT"] {
  color: #8d1313;
  background: #ffe1e1;
  border-color: #ecaaaa;
}

.status-pill[data-status="OFFLINE"] {
  color: #434b52;
  background: #eceff2;
  border-color: #bec5ca;
}

.kpi-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 8px;
}

.kpi-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
  padding: 10px;
}

.kpi-label {
  color: var(--muted);
  font-size: 0.8rem;
}

.kpi-value {
  margin-top: 2px;
  font-family: "Barlow Condensed", "Arial Narrow", sans-serif;
  font-size: 1.45rem;
  font-weight: 700;
}

.line-action {
  margin-top: 10px;
  min-height: 44px;
  width: 100%;
  border-radius: 10px;
  border: 1px solid #b8ccd8;
  background: linear-gradient(180deg, #fbfdff 0%, #ebf5fb 100%);
  color: #17495f;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.line-action:hover {
  background: linear-gradient(180deg, #f2f9ff 0%, #ddeef9 100%);
}

.alerts-panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 14px;
  display: flex;
  flex-direction: column;
  min-height: 400px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
  margin-bottom: 10px;
}

.panel-head h2 {
  font-family: "Barlow Condensed", "Arial Narrow", sans-serif;
  font-size: 1.42rem;
}

.alert-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
  overflow: auto;
}

.alert-item {
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #f8fbfd;
  padding: 10px;
}

.alert-item[data-severity="ALERT"] {
  border-color: #e4a3a3;
  background: #fff0f0;
}

.alert-item[data-severity="WARN"] {
  border-color: #efcd8f;
  background: #fff7e4;
}

.alert-item[data-severity="CRITICAL"] {
  border-color: #d89a9a;
  background: #ffe2e2;
}

.alert-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.alert-severity {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.07em;
}

.alert-time {
  color: var(--muted);
  font-size: 0.79rem;
}

.alert-msg {
  font-size: 0.88rem;
}

.machine-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(320px, 1fr));
  gap: 12px;
}

.machine-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.8rem;
}

.trend-block {
  margin-top: 10px;
}

.trend-block.compact .trend-head {
  font-size: 0.74rem;
  margin-bottom: 4px;
}

.trend-block.compact .trend-legend {
  font-size: 0.72rem;
  margin-bottom: 4px;
}

.trend-block.compact .legend-dot {
  width: 8px;
  height: 8px;
}

.trend-head {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 6px;
}

.trend-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
  font-size: 0.79rem;
  color: var(--muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.legend-dot.actual {
  background: #1e76ac;
}

.legend-dot.expected {
  background: #6a7d8b;
}

.trend-compare {
  height: 72px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f8fcff;
  padding: 4px;
}

.trend-compare.compact {
  height: 58px;
}

.trend-compare svg {
  width: 100%;
  height: 100%;
}

.trend-compare .grid-line {
  stroke: #d4e1e9;
  stroke-width: 1;
}

.trend-compare .line-actual,
.trend-compare .line-expected {
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.trend-compare .line-actual {
  stroke: #1e76ac;
}

.trend-compare .line-expected {
  stroke: #6a7d8b;
  stroke-dasharray: 5 3;
}

.empty-state {
  border: 2px dashed #b2c4cf;
  border-radius: 14px;
  padding: 22px;
  text-align: center;
  background: #f4fafd;
  color: var(--muted);
}

.btn {
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 10px 14px;
  font-size: 0.94rem;
  font-weight: 700;
  cursor: pointer;
}

.btn.ghost {
  border-color: #b6c8d3;
  background: #f8fcff;
  color: #1f5a73;
}

.btn.ghost:hover {
  background: #edf6fb;
}

.btn-small {
  min-height: 36px;
  padding: 7px 10px;
}

.drawer-scrim {
  position: fixed;
  inset: 0;
  display: none;
  border: 0;
  background: rgba(18, 26, 31, 0.42);
  z-index: 60;
}

body.drawer-open .drawer-scrim {
  display: block;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade-in {
  from {
    opacity: 0.35;
  }

  to {
    opacity: 1;
  }
}

@media (max-width: 1360px) {
  .summary-strip {
    grid-template-columns: repeat(2, minmax(170px, 1fr));
  }

  .line-grid,
  .machine-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1100px) {
  .app-shell {
    width: min(980px, calc(100% - 28px));
    margin-top: 14px;
  }

  .brand-banner {
    margin-bottom: 10px;
  }

  .brand-logo {
    width: min(360px, 65vw);
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-meta {
    justify-content: space-between;
  }

  .content-layout {
    grid-template-columns: 1fr;
  }

  .alerts-panel {
    position: fixed;
    right: 0;
    top: 0;
    width: min(92vw, 390px);
    height: 100dvh;
    transform: translateX(102%);
    transition: transform 0.22s ease;
    z-index: 80;
    border-radius: 0;
    border-left: 1px solid var(--line);
    border-right: 0;
    border-top: 0;
    border-bottom: 0;
    box-shadow: -7px 0 22px rgba(22, 34, 41, 0.22);
  }

  body.drawer-open .alerts-panel {
    transform: translateX(0);
  }
}

@media (min-width: 1101px) {
  #openAlerts,
  #closeAlerts,
  .drawer-scrim {
    display: none !important;
  }
}

@media (max-width: 760px) {
  .brand-banner {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .brand-logo {
    width: min(320px, 82vw);
  }

  .filters-panel {
    flex-direction: column;
    align-items: stretch;
  }

  .formula-chip {
    margin-left: 0;
    border-radius: 12px;
  }

  select {
    width: 100%;
  }

  .summary-strip {
    grid-template-columns: 1fr;
  }

  .clock-card {
    min-width: 130px;
  }
}
