:root {
  color-scheme: light;
  --bg: #f7f3f5;
  --card: #ffffff;
  --primary: #8b5cf6;
  --secondary: #f8d7e3;
  --text: #2c2430;
  --muted: #7c6b76;
  --border: #eadfe6;
  --ok: #22c55e;
  --warning: #f59e0b;
  --critical: #ef4444;
  --shadow: 0 20px 50px rgba(74, 54, 69, 0.12);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: "Inter", system-ui, sans-serif;
}

body {
  background: linear-gradient(180deg, #f4e1ea 0%, #f7f3f5 40%, #f9f8fb 100%);
  color: var(--text);
}

.page {
  max-width: 1440px;
  margin: 32px auto 64px;
  padding: 0 24px;
}

.login-page {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.login-grid {
  display: grid;
  grid-template-columns: minmax(0, 420px);
  gap: 20px;
  justify-content: center;
}

.login-centered {
  max-width: 880px;
  margin: 0 auto;
}

.login-card h2 {
  font-size: 22px;
  margin-bottom: 8px;
}

.login-form {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.login-form label {
  display: grid;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.login-form input {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  font-size: 14px;
}

.form-error {
  color: var(--critical);
  font-size: 12px;
  min-height: 16px;
}

.login-hint {
  margin-top: 18px;
  background: var(--bg);
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 12px;
  color: var(--muted);
}

.login-hint ul {
  margin-top: 8px;
  padding-left: 18px;
  display: grid;
  gap: 6px;
}

.login-info {
  display: grid;
  gap: 16px;
  align-content: start;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow);
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-pill {
  background: var(--secondary);
  color: #944b6d;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 10px 14px;
  border-radius: 999px;
}

.brand h1 {
  font-size: 24px;
}

.brand p {
  color: var(--muted);
  font-size: 13px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f0fdf4;
  color: #166534;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: none;
  cursor: pointer;
}

.status-pill.offline {
  background: #fef2f2;
  color: #991b1b;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.dot.online {
  background: var(--ok);
}

.dot.offline {
  background: var(--critical);
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
}

.user-menu-button {
  border: none;
  cursor: pointer;
  text-align: left;
}

.user-pill strong {
  display: block;
  font-size: 13px;
}

.user-pill span {
  color: var(--muted);
}

.avatar {
  background: var(--primary);
  color: white;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
}

.icon-button {
  border: none;
  background: var(--bg);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--text);
}

.icon-button svg {
  width: 18px;
  height: 18px;
}

.menu-wrapper {
  position: relative;
}

.menu-popup {
  position: absolute;
  right: 0;
  top: 48px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  display: none;
  min-width: 160px;
  z-index: 5;
}

.menu-popup.open {
  display: grid;
  gap: 8px;
}

.menu-popup a {
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}

.icon-button.small {
  padding: 4px 8px;
}

.hamburger {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text);
  position: relative;
}

.hamburger::before,
.hamburger::after {
  content: "";
  position: absolute;
  left: 0;
  width: 18px;
  height: 2px;
  background: var(--text);
}

.hamburger::before {
  top: -6px;
}

.hamburger::after {
  top: 6px;
}

.dashboard {
  display: flex;
  flex-direction: column;
  gap: 28px;
  margin-top: 28px;
}

.grid {
  display: grid;
  gap: 20px;
}


.component-two-column {
  grid-template-columns: 1.35fr 1fr;
  gap: 20px;
  align-items: stretch;
}

.component-documents {
  min-height: 100%;
}

@media (max-width: 960px) {
  .component-two-column {
    grid-template-columns: 1fr;
  }
}


.grid-hero {
  grid-template-columns: 2.2fr 1fr;
}

.grid-lower {
  grid-template-columns: 1.4fr 1fr;
}

.card {
  background: var(--card);
  border-radius: 20px;
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-header.compact {
  margin-bottom: 12px;
}

.card-header h2,
.card-header h3 {
  font-size: 18px;
}

.ghost-button {
  border: 1px solid var(--border);
  background: transparent;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
}

.system-overview {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.overview-image {
  position: relative;
  border-radius: 16px;
  background: #e2e8f0;
  height: 500px;
  overflow: hidden;
}

.system-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
}

.overlay-label {
  position: absolute;
  top: 16px;
  left: 16px;
  background: rgba(255, 255, 255, 0.85);
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 600;
  z-index: 1;
}

.node {
  position: absolute;
  z-index: 2;
  width: 70px;
  height: 70px;
  background: transparent;
  border: none;
  color: transparent;
  text-shadow: none;
  cursor: pointer;
  text-decoration: none;
  display: block;
}


.node-a {
  top: 44%;
  left: 24%;
}

.node-b {
  bottom: 17%;
  right: 44%;
}

.node-c {
  bottom: 17%;
  left: 23%;
}

.node-d {
  top: 44%;
  left: 8%;
}

.overview-footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
}

.overview-footer h3 {
  font-size: 16px;
  margin-bottom: 4px;
}

.overview-footer p {
  color: var(--muted);
  font-size: 13px;
}

.overview-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(80px, 1fr));
  gap: 16px;
  text-align: center;
}

.overview-metrics strong {
  display: block;
  font-size: 18px;
}

.overview-metrics span {
  font-size: 12px;
  color: var(--muted);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}

.status-indicator {
  border-radius: 16px;
  padding: 12px;
  text-align: center;
  color: white;
}

.status-indicator span {
  display: block;
  font-size: 12px;
}

.status-indicator strong {
  font-size: 20px;
}

.status-indicator.ok {
  background: linear-gradient(135deg, #16a34a, #22c55e);
}

.status-indicator.warning {
  background: linear-gradient(135deg, #d97706, #f59e0b);
}

.status-indicator.critical {
  background: linear-gradient(135deg, #dc2626, #ef4444);
}

.muted {
  color: var(--muted);
  font-size: 12px;
}

.calendar {
  background: var(--bg);
  border-radius: 16px;
  padding: 12px;
  margin-bottom: 12px;
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  font-size: 11px;
  text-align: center;
}

.calendar-grid span {
  padding: 6px 0;
  border-radius: 8px;
}

.calendar-grid .today {
  background: #e0e7ff;
  color: #3730a3;
  font-weight: 700;
}

.calendar-grid .inactive {
  color: var(--muted);
}

.calendar-grid .service {
  color: white;
  font-weight: 600;
}

.calendar-grid .service.ok {
  background: var(--ok);
}

.calendar-grid .service.warning {
  background: var(--warning);
}

.calendar-grid .service.critical {
  background: var(--critical);
}

.service-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.service-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--border);
  background: var(--card);
  padding: 10px 12px;
  border-radius: 14px;
  cursor: pointer;
}

.service-item span {
  color: var(--muted);
  font-size: 12px;
}

.badge {
  background: var(--bg);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
}

.badge.warning {
  background: #fef3c7;
  color: #92400e;
}

.badge.ok {
  background: #dcfce7;
  color: #166534;
}

.badge.critical {
  background: #fee2e2;
  color: #991b1b;
}

.alarm-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 296px;
  overflow-y: auto;
  padding-right: 6px;
}

.alarm {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
}

.alarm div {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.alarm span {
  color: var(--muted);
  font-size: 12px;
}

.alarm-component {
  display: block;
}

.alarm .pill {
  background: var(--bg);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
}

.alarm.critical {
  border-left: 4px solid var(--critical);
}

.alarm.warning {
  border-left: 4px solid var(--warning);
}

.alarm.ok {
  border-left: 4px solid var(--ok);
}

.activity-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 6px;
}

.activity-list div {
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}

.activity-list span {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

.motor-dashboard {
  background: #f8fafc;
  padding: 28px;
  border-radius: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.motor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.motor-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-areas:
    "motor trend-temp trend-vibration"
    "motor control documents";
  gap: 20px;
}

.motor-card {
  grid-area: motor;
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-items: center;
  padding: 24px;
}

.motor-hero {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
}

.motor-image {
  width: min(100%, 240px);
  height: 220px;
  border-radius: 16px;
  object-fit: cover;
  background: #e2e8f0;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.15);
}

.live-status-card {
  width: 100%;
  background: var(--bg);
  border-radius: 16px;
  padding: 16px;
  border: 1px solid var(--border);
}

.status-list {
  list-style: none;
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding: 0;
}

.status-list li {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}

.status-list span {
  color: var(--muted);
}

.status-readout {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  background: var(--bg);
  padding: 16px;
  border-radius: 16px;
}

.status-readout span {
  color: var(--muted);
  font-size: 12px;
}

.status-readout strong {
  font-size: 16px;
}

.trend-chart {
  background: var(--bg);
  border-radius: 14px;
  padding: 12px;
}

.trend-chart-large {
  background: #fff;
  border-radius: 16px;
  padding: 16px;
  border: 1px solid var(--border);
}

.trend-temp {
  grid-area: trend-temp;
}

.trend-vibration {
  grid-area: trend-vibration;
}

.control-card {
  grid-area: control;
}

.documents-card {
  grid-area: documents;
}

.chart-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  margin-bottom: 8px;
  color: var(--muted);
}

.trend-frame {
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: stretch;
  gap: 10px;
}

.trend-scale {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  padding: 2px 0;
}

.trend-scale span {
  line-height: 1;
}



.line-trend-chart {
  width: 100%;
  height: 180px;
  border-radius: 12px;
  background:
    linear-gradient(to top, rgba(148, 163, 184, 0.12) 1px, transparent 1px) 0 0 / 100% 25%,
    linear-gradient(to right, rgba(148, 163, 184, 0.08) 1px, transparent 1px) 0 0 / 8.33% 100%;
}

.line-trend-path {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.line-trend-area {
  opacity: 0.16;
}

.line-trend-point {
  stroke: #fff;
  stroke-width: 1.5;
}

.trend-time-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 11px;
  color: var(--muted);
  min-height: 14px;
}

.chart-bars {
  display: flex;
  gap: 6px;
  align-items: flex-end;
  height: 80px;
}

.chart-bars span {
  flex: 1;
  background: linear-gradient(180deg, #8b5cf6, #f472b6);
  border-radius: 6px;
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.control-panel label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.control-panel input[type="range"] {
  width: 100%;
}

.button-row {
  display: flex;
  gap: 12px;
}

.primary,
.danger {
  flex: 1;
  border: none;
  padding: 10px 12px;
  border-radius: 12px;
  color: white;
  font-weight: 600;
  cursor: pointer;
}

.primary {
  background: linear-gradient(135deg, #22c55e, #16a34a);
}

.danger {
  background: linear-gradient(135deg, #ef4444, #b91c1c);
}

.motor-state-lights {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.state-light-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
}

.state-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.state-light {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #d1d5db;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08);
}

#state-on-card .state-light.active {
  background: var(--ok);
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.18);
}

#state-off-card .state-light.active {
  background: var(--critical);
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.18);
}

.speed-readout {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
}

.mqtt-form {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}

.mqtt-form label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.mqtt-form input {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 13px;
}

.mqtt-form select {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 13px;
  background: white;
}

.mqtt-popup {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 20;
}

.mqtt-popup.open {
  display: flex;
}

.mqtt-popup-card {
  background: var(--card);
  border-radius: 20px;
  padding: 20px;
  box-shadow: var(--shadow);
  max-width: 480px;
  width: 100%;
}

.mqtt-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.data-history {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-chart {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  height: 90px;
  align-items: end;
}

.history-chart.large {
  grid-template-columns: repeat(12, 1fr);
  height: 180px;
  gap: 8px;
}

.history-chart span {
  background: linear-gradient(180deg, #f97316, #fde68a);
  border-radius: 6px;
  height: 100%;
  min-height: 6%;
  box-shadow: inset 0 -1px 0 rgba(15, 23, 42, 0.15);
}

.history-chart.temp-trend span {
  background: linear-gradient(180deg, #38bdf8, #22c55e);
}

.history-chart.vibration-trend span {
  background: linear-gradient(180deg, #f472b6, #f59e0b);
}

.document-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.document-list li {
  font-size: 13px;
}

.document-list .service-item {
  width: 100%;
  text-decoration: none;
  color: inherit;
}

.document-list .service-item div {
  text-align: left;
}

.disabled-link {
  opacity: 0.55;
  cursor: not-allowed;
}


#custom-documents-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.document-list span {
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 1100px) {
  .grid-hero,
  .grid-lower {
    grid-template-columns: 1fr;
  }

  .motor-card {
    grid-column: auto;
  }
}

@media (max-width: 1200px) {
  .motor-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "motor trend-temp"
      "motor trend-vibration"
      "control documents";
  }
}

@media (max-width: 860px) {
  .motor-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "motor"
      "trend-temp"
      "trend-vibration"
      "control"
      "documents";
  }

  .motor-image {
    height: 200px;
  }
}

@media (max-width: 720px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .overview-footer {
    flex-direction: column;
    align-items: flex-start;
  }

  .motor-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .login-grid {
    grid-template-columns: 1fr;
  }
}


.doc-popup {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 25;
}

.doc-popup.open {
  display: flex;
}

.doc-popup-card {
  background: var(--card);
  border-radius: 20px;
  padding: 20px;
  box-shadow: var(--shadow);
  max-width: 520px;
  width: 100%;
}

.doc-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.spec-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 16px;
}

.spec-grid dt {
  color: var(--muted);
  font-size: 12px;
}

.spec-grid dd {
  font-weight: 600;
}
