* {
  box-sizing: border-box;
}

:root {
  --bg: #eef7fb;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: rgba(148, 163, 184, 0.25);
  --primary: #0284c7;
  --primary-dark: #0369a1;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #f59e0b;
  --shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: Arial, Helvetica, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(14, 165, 233, 0.18), transparent 30%),
    radial-gradient(circle at top right, rgba(34, 197, 94, 0.12), transparent 28%),
    var(--bg);
  color: var(--text);
}

button,
input,
textarea {
  font-family: inherit;
}

.page {
  width: min(1500px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.hero {
  background: linear-gradient(135deg, #ffffff, #ecfeff);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 22px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin-bottom: 20px;
}

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

.logo-box {
  width: 82px;
  height: 82px;
  border-radius: 22px;
  background: #ffffff;
  display: grid;
  place-items: center;
  box-shadow: 0 14px 32px rgba(16, 183, 196, 0.18);
  border: 1px solid rgba(148, 163, 184, 0.22);
  overflow: hidden;
  flex-shrink: 0;
}

.school-logo {
  width: 74px;
  height: 74px;
  object-fit: contain;
  display: block;
}

.school {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary-dark);
  letter-spacing: 0.6px;
  text-transform: uppercase;
  margin-bottom: 5px;
}

h1 {
  margin: 0 0 7px;
  font-size: clamp(24px, 3vw, 38px);
  line-height: 1.1;
}

.hero p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

.hero-status {
  min-width: 260px;
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
  font-weight: 700;
  color: #0f172a;
}

.status-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--warning);
  box-shadow: 0 0 0 6px rgba(245, 158, 11, 0.14);
}

.status-dot.ok {
  background: var(--success);
  box-shadow: 0 0 0 6px rgba(22, 163, 74, 0.14);
}

.status-dot.bad {
  background: var(--danger);
  box-shadow: 0 0 0 6px rgba(220, 38, 38, 0.14);
}

.status-dot.warn {
  background: var(--warning);
  box-shadow: 0 0 0 6px rgba(245, 158, 11, 0.14);
}

.layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 20px;
  align-items: start;
}

.content {
  display: grid;
  gap: 20px;
}

.sidebar {
  display: grid;
  gap: 20px;
  position: sticky;
  top: 16px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.metric-card,
.panel {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 24px;
}

.metric-card {
  padding: 18px;
  display: flex;
  gap: 14px;
  align-items: center;
  min-height: 122px;
}

.metric-icon {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: linear-gradient(135deg, #e0f2fe, #ccfbf1);
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 900;
  flex-shrink: 0;
  white-space: nowrap;
}

.metric-card p {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 14px;
}

.metric-card h2 {
  margin: 0;
  font-size: 31px;
  letter-spacing: -0.5px;
}

.metric-card small {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.panel {
  padding: 20px;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-title span {
  min-width: 46px;
  height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  background: #e0f2fe;
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.panel-title h2 {
  margin: 0;
  font-size: 20px;
}

.panel-desc {
  color: var(--muted);
  margin: -6px 0 18px;
  line-height: 1.6;
}

/* CHART */

.chart-panel {
  padding: 18px;
}

.chart-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.chart-section-header h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 900;
  color: #0f172a;
}

.chart-section-header span {
  color: #64748b;
  font-size: 13px;
  font-weight: 800;
}

.chart-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.modern-chart-card {
  padding: 16px 16px 14px;
  border-radius: 18px;
  background: #f8fbff;
  border: 1px solid rgba(203, 213, 225, 0.9);
  box-shadow: none;
}

.chart-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 8px;
}

.chart-card-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 900;
  color: #0f172a;
}

.chart-card-head p {
  margin: 4px 0 0;
  color: #94a3b8;
  font-size: 13px;
  font-weight: 700;
}

.chart-card-head strong {
  color: #0891b2;
  font-size: 18px;
  font-weight: 900;
  white-space: nowrap;
}

.modern-chart-card canvas {
  width: 100%;
  height: 155px !important;
  display: block;
  border-radius: 14px;
  border: 1px solid rgba(226, 232, 240, 0.95);
  background: #ffffff;
}

/* SIDEBAR */

.info-list {
  display: grid;
  gap: 10px;
}

.info-list div {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  display: grid;
  gap: 5px;
  background: rgba(248, 250, 252, 0.85);
}

.info-list span {
  color: var(--muted);
  font-size: 13px;
}

.info-list b {
  font-size: 15px;
  color: var(--text);
  overflow-wrap: anywhere;
}

pre {
  margin: 0;
  max-height: 360px;
  overflow: auto;
  padding: 14px;
  border-radius: 16px;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  resize: vertical;
  min-height: 150px;
  font-size: 14px;
  outline: none;
  color: var(--text);
  background: #ffffff;
}

textarea:focus,
input:focus {
  border-color: rgba(2, 132, 199, 0.7);
  box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.12);
}

.button-row,
.pin-actions {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.button-row {
  margin-bottom: 4px;
}

.btn {
  border: none;
  cursor: pointer;
  border-radius: 14px;
  padding: 12px 15px;
  font-weight: 800;
  transition: 0.18s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn.primary {
  background: var(--primary);
  color: #ffffff;
}

.btn.primary:hover {
  background: var(--primary-dark);
}

.btn.secondary {
  background: #e2e8f0;
  color: #0f172a;
}

.btn.danger {
  background: var(--danger);
  color: #ffffff;
}

/* PIN CONFIG */

.pin-config-panel {
  margin-top: 0;
}

.pin-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.pin-form label {
  display: grid;
  gap: 7px;
}

.pin-form label span {
  font-size: 13px;
  color: var(--muted);
  font-weight: 800;
}

.pin-form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  outline: none;
  font-size: 15px;
  background: #ffffff;
  color: var(--text);
}

.pin-table {
  width: 100%;
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.pin-row {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 0.9fr 1.5fr;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.04);
  border: 1px solid rgba(148, 163, 184, 0.22);
  font-size: 14px;
}

.pin-head {
  font-weight: 900;
  color: #0f172a;
  background: rgba(14, 165, 233, 0.12);
}

.pin-row span:nth-child(3) {
  font-weight: 900;
  color: #0369a1;
}

.config-status {
  margin-top: 14px;
  padding: 14px;
  border-radius: 16px;
  background: rgba(248, 250, 252, 0.9);
  border: 1px solid var(--line);
}

.config-status p {
  margin: 0;
  line-height: 1.7;
}

#httpResponse {
  margin-top: 18px;
}

#systemNote {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

/* RESPONSIVE */

@media (max-width: 1160px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pin-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .page {
    width: min(100% - 18px, 1500px);
    padding-top: 12px;
  }

  .hero {
    flex-direction: column;
    align-items: flex-start;
    border-radius: 22px;
  }

  .brand {
    align-items: flex-start;
  }

  .logo-box {
    width: 64px;
    height: 64px;
    border-radius: 18px;
  }

  .school-logo {
    width: 58px;
    height: 58px;
  }

  .hero-status {
    min-width: auto;
    justify-content: flex-start;
  }

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

  .metric-card {
    min-height: auto;
  }

  .chart-section-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .pin-form {
    grid-template-columns: 1fr;
  }

  .pin-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .pin-head {
    display: none;
  }

  .pin-row span {
    display: block;
  }

  h1 {
    font-size: 25px;
  }
}