/* ============================================
   JCPT — 火箭转运贮箱压力监测平台
   蓝白渐变 + 毛玻璃 (Glassmorphism) 浅色主题
   ============================================ */

/* ---------- Reset & Base ---------- */
* {
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Segoe UI",
    Roboto, Arial, sans-serif;
  color: #1e293b;
  background:
    radial-gradient(ellipse 1100px 640px at 10% -8%, rgba(59, 130, 246, 0.16) 0%, transparent 50%),
    radial-gradient(ellipse 900px 540px at 88% 15%, rgba(147, 197, 253, 0.14) 0%, transparent 48%),
    radial-gradient(ellipse 800px 460px at 55% 75%, rgba(191, 219, 254, 0.12) 0%, transparent 50%),
    linear-gradient(175deg, #f8fafc 0%, #eff6ff 35%, #f0f9ff 65%, #f8fafc 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Animated Ambient Light Blobs ---------- */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle 280px at 18% 12%, rgba(59, 130, 246, 0.07) 0%, transparent 100%),
    radial-gradient(circle 240px at 82% 68%, rgba(147, 197, 253, 0.06) 0%, transparent 100%),
    radial-gradient(circle 320px at 55% 32%, rgba(191, 219, 254, 0.05) 0%, transparent 100%);
  animation: blobDrift 20s ease-in-out infinite;
}

@keyframes blobDrift {
  0%, 100% { opacity: 1; }
  25%      { opacity: 0.6; }
  50%      { opacity: 0.9; }
  75%      { opacity: 0.5; }
}

/* ---------- Layout ---------- */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px;
  position: relative;
  z-index: 1;
}

.dashboard-page {
  display: grid;
  gap: 24px;
  padding-bottom: 84px;
}

/* ---------- Topbar (Frosted Glass) ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(255, 255, 255, 0.58);
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
}

.topbar .container {
  padding: 0 16px;
}

.topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  letter-spacing: 0.2px;
  color: #0f172a;
  text-decoration: none;
}

.brand__logo {
  width: 260px;
  height: 76px;
  object-fit: contain;
  background: transparent;
  border-radius: 0;
  border: 0;
  filter: drop-shadow(0 1px 3px rgba(15, 23, 42, 0.06));
}

.brand__name {
  font-size: 16px;
}

.topbar__right {
  color: #64748b;
  font-size: 14px;
  font-weight: 500;
}

/* Dashboard topbar: 3-column grid */
.topbar--dashboard .topbar__inner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.topbar__spacer {
  width: 260px;
  height: 1px;
}

/* ---------- Title — Flowing Gradient (left → right, 10s) ---------- */
.topbar__title {
  margin: 0;
  min-width: 0;
  justify-self: center;
  text-align: center;
  font-size: 26px;
  line-height: 1.2;
  font-weight: 850;
  background: linear-gradient(to right,
    /* cycle 1 */
    #1d4ed8 0%, #2563eb 6.25%, #6366f1 12.5%, #8b5cf6 18.75%, #a78bfa 25%,
    #8b5cf6 31.25%, #6366f1 37.5%, #2563eb 43.75%, #1d4ed8 50%,
    /* cycle 2 (identical to cycle 1) */
    #1d4ed8 50%, #2563eb 56.25%, #6366f1 62.5%, #8b5cf6 68.75%, #a78bfa 75%,
    #8b5cf6 81.25%, #6366f1 87.5%, #2563eb 93.75%, #1d4ed8 100%);
  background-size: 200% 100%;
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: titleFlow 10s linear infinite;
}

@keyframes titleFlow {
  0%   { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* ---------- Bottombar (Frosted Glass) ---------- */
.bottombar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 35;
  border-top: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(255, 255, 255, 0.58);
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
}

.bottombar .container {
  padding: 10px 16px;
}

.bottombar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.bottombar__btn {
  height: 38px;
  border: 1px solid rgba(148, 163, 184, 0.20);
  border-radius: 12px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.65);
  color: #334155;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.16s ease, box-shadow 0.2s ease;
  white-space: nowrap;
  backdrop-filter: blur(6px);
}

.bottombar__btn:hover {
  background: rgba(59, 130, 246, 0.06);
  border-color: rgba(59, 130, 246, 0.35);
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.10);
}

.bottombar__btn:active {
  transform: translateY(1px);
}

.bottombar__btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.20);
  border-color: rgba(59, 130, 246, 0.45);
}

/* ---------- Topbar Dashboard Controls ---------- */
.topbar__dashboard-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  justify-self: end;
  flex-wrap: wrap;
  gap: 10px;
  min-width: 0;
}

.topbar__field {
  flex-wrap: nowrap;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 6px 12px;
  border: 1px solid rgba(148, 163, 184, 0.20);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(6px);
}

.topbar__field > span {
  white-space: nowrap;
  font-size: 13px;
  color: #64748b;
}

.topbar__field select {
  min-width: 112px;
  max-width: 132px;
  height: 36px;
  padding: 0 10px;
  border-radius: 10px;
}

.range-trigger {
  height: 36px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 10px;
  padding: 0 10px;
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(6px);
  color: #334155;
  font-size: 13px;
  cursor: pointer;
  min-width: 112px;
  max-width: 152px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.range-trigger:focus {
  outline: none;
  border-color: rgba(59, 130, 246, 0.55);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.14);
}

.range-trigger:hover {
  background: rgba(255, 255, 255, 0.82);
  border-color: rgba(148, 163, 184, 0.38);
}

.topbar__status {
  flex: 0 1 auto;
  text-align: right;
  font-size: 13px;
  color: #64748b;
}

.topbar__status[hidden] {
  display: none !important;
}

/* ---------- Sensor Grid ---------- */
.sensor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}

/* ---------- Sensor Card (Glassmorphism) ---------- */
.sensor-card {
  display: flex;
  flex-direction: column;
  min-height: 400px;
  border-radius: 22px;
  padding: 22px 22px 18px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(255, 255, 255, 0.52);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  box-shadow:
    0 2px 12px rgba(15, 23, 42, 0.06),
    0 8px 28px rgba(15, 23, 42, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.65);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
  position: relative;
  overflow: hidden;
}

/* Card top highlight bar */
.sensor-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 20px;
  right: 20px;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.60) 25%, rgba(255, 255, 255, 0.80) 50%, rgba(255, 255, 255, 0.60) 75%, transparent 100%);
  pointer-events: none;
}

/* Card gradient border ring */
.sensor-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 22px;
  padding: 1px;
  background: linear-gradient(155deg, rgba(59, 130, 246, 0.14) 0%, rgba(147, 197, 253, 0.08) 40%, rgba(59, 130, 246, 0.10) 100%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.sensor-card--collapsed {
  min-height: 0;
}

.sensor-card:hover {
  transform: translateY(-4px);
  border-color: rgba(59, 130, 246, 0.28);
  box-shadow:
    0 4px 20px rgba(59, 130, 246, 0.10),
    0 12px 36px rgba(15, 23, 42, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.70),
    0 0 80px -20px rgba(59, 130, 246, 0.12);
}

/* Collapsed card chart area */
.sensor-card--collapsed .sensor-card__chart {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 56px;
  min-height: 56px;
  height: 36px;
  border-radius: 14px;
  border: 1px dashed rgba(148, 163, 184, 0.30);
  background: rgba(248, 250, 252, 0.60);
  color: #94a3b8;
  font-size: 13px;
  margin-top: 10px;
}

/* ---------- Card Internals ---------- */
.sensor-card__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.sensor-card__title {
  margin: 0;
  font-size: 19px;
  font-weight: 800;
  color: #94a3b8;
  transition: color 0.2s ease;
}

.sensor-card__title--online {
  color: #1e3a8a;
}

.sensor-card__title--offline {
  color: #94a3b8;
}

.sensor-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  align-items: center;
}

/* Chips */
.chip {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  font-size: 12px;
  color: #475569;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 999px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(4px);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.chip-period--synced {
  border-color: rgba(16, 185, 129, 0.45);
  color: #059669;
  background: rgba(209, 250, 229, 0.35);
}

.chip-period--pending {
  border-color: rgba(245, 158, 11, 0.55);
  color: #d97706;
  background: rgba(252, 211, 77, 0.16);
  animation: chip-period-pulse 1.8s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .chip-period--pending {
    animation: none;
  }
}

@keyframes chip-period-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.0); }
  50%      { box-shadow: 0 0 0 8px rgba(245, 158, 11, 0.12); }
}

/* Card value display */
.sensor-card__value {
  text-align: right;
  min-width: 140px;
}

.sensor-card__value-num {
  font-size: 28px;
  line-height: 1.15;
  font-weight: 900;
  color: #1e3a8a;
}

.sensor-card__value-time {
  margin-top: 8px;
  font-size: 12px;
  color: #94a3b8;
}

.sensor-card__chart {
  flex: 1;
  min-height: 250px;
}

/* ---------- Buttons ---------- */
.btn {
  height: 42px;
  border: 0;
  border-radius: 12px;
  padding: 0 18px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #2563eb 0%, #3b82f6 40%, #6366f1 100%);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
  font-size: 14px;
  position: relative;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.25) 0%, rgba(255, 255, 255, 0.04) 100%);
  pointer-events: none;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.32), 0 0 0 1px rgba(59, 130, 246, 0.25);
}

.btn:active {
  transform: translateY(0);
}

.btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.28), 0 8px 24px rgba(37, 99, 235, 0.20);
}

.btn:disabled {
  opacity: 0.45;
  pointer-events: none;
  transform: none;
}

.btn-secondary {
  color: #334155;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.28);
  backdrop-filter: blur(8px);
}

.btn-secondary::after {
  background: none;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.88);
  border-color: rgba(148, 163, 184, 0.38);
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
  color: #0f172a;
}

.btn-mini {
  height: 32px;
  border-radius: 10px;
  padding: 0 12px;
  font-size: 13px;
}

/* ---------- Form Controls ---------- */
select,
input[type="text"],
input[type="number"],
input[type="date"] {
  height: 42px;
  min-width: 100px;
  max-width: 220px;
  width: auto;
  border: 1px solid rgba(148, 163, 184, 0.32);
  border-radius: 12px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.70);
  backdrop-filter: blur(6px);
  color: #0f172a;
  outline: none;
  font-size: 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

select {
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

select:focus,
input[type="text"]:focus,
input[type="number"]:focus,
input[type="date"]:focus {
  border-color: rgba(59, 130, 246, 0.55);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12), inset 0 0 0 1px rgba(59, 130, 246, 0.08);
  background: rgba(255, 255, 255, 0.88);
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748b'%3E%3Cpath d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  -webkit-appearance: none;
  appearance: none;
}

select option {
  background: #fff;
  color: #0f172a;
}

input::placeholder {
  color: #94a3b8;
}

/* ---------- Field Labels ---------- */
.field {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  color: #475569;
  font-size: 14px;
  min-width: 0;
}

.status {
  color: #64748b;
  font-size: 13px;
}

.muted {
  color: #64748b;
  font-size: 13px;
}

/* ---------- Toast (Frosted Glass) ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 220;
  width: min(420px, calc(100vw - 24px));
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.20);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  color: #0f172a;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.14);
  transform: translate(-50%, 12px);
  opacity: 0;
  transition: opacity 0.22s ease, transform 0.22s ease;
  pointer-events: none;
}

.toast.toast--show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast[data-type="success"] {
  border-color: rgba(16, 185, 129, 0.35);
  background: rgba(240, 253, 244, 0.78);
  color: #065f46;
}

.toast[data-type="error"] {
  border-color: rgba(239, 68, 68, 0.30);
  background: rgba(254, 242, 242, 0.78);
  color: #991b1b;
}

.toast[data-type="info"] {
  border-color: rgba(59, 130, 246, 0.30);
  background: rgba(239, 246, 255, 0.78);
  color: #1e40af;
}

/* ---------- Modals (Frosted Glass) ---------- */
.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.18);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.modal__panel {
  position: relative;
  z-index: 1;
  width: min(520px, calc(100vw - 32px));
  border-radius: 24px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  padding: 18px;
  box-shadow:
    0 20px 52px rgba(15, 23, 42, 0.12),
    0 2px 8px rgba(15, 23, 42, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.70);
}

.modal__panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 24px;
  right: 24px;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.55) 50%, transparent 100%);
  pointer-events: none;
}

.modal__panel--wide {
  width: min(960px, calc(100vw - 32px));
}

.modal__head {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.modal__head .modal__title {
  justify-self: start;
}

.modal__head .history-pager {
  justify-self: center;
}

.modal__head .modal__actions {
  justify-self: end;
  margin-top: 0;
}

.modal__sub {
  color: #64748b;
  font-size: 14px;
  margin-bottom: 14px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
}

.modal__title {
  font-size: 20px;
  font-weight: 800;
  color: #0f172a;
}

.modal__form {
  display: grid;
  gap: 14px;
}

.modal__form .field {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
}

.modal__form .field > span {
  color: #334155;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
}

.modal__form .field--period {
  align-items: start;
}

.period-field {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.period-field__value {
  flex: 1 1 auto;
  min-width: 0;
}

.period-field__unit {
  flex: 0 0 110px;
  min-width: 0;
}

.modal__form input[type="text"],
.modal__form input[type="number"],
.modal__form input[type="date"],
.modal__form select {
  width: 100%;
  max-width: none;
  min-width: 0;
  height: 48px;
  border-radius: 16px;
  padding: 0 16px;
  background: rgba(255, 255, 255, 0.80);
  border: 1px solid rgba(148, 163, 184, 0.28);
  color: #0f172a;
}

.modal__form input::placeholder {
  color: #94a3b8;
}

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 6px;
}

.modal__actions .btn {
  min-width: 100px;
  height: 48px;
  border-radius: 16px;
}

.modal__form .status {
  display: block;
  min-height: 20px;
  padding-left: 126px;
  font-size: 13px;
}

/* ---------- Edit Modal ---------- */
#editModal .modal__panel {
  width: min(400px, calc(100vw - 32px));
}

#editModal .modal__title {
  margin-bottom: 24px;
  text-align: center;
}

#editModal .modal__form {
  --edit-control-width: 300px;
  justify-items: center;
  gap: 16px;
}

#editModal .modal__form .field {
  width: 100%;
  grid-template-columns: 88px minmax(0, var(--edit-control-width));
  justify-content: center;
  gap: 12px;
}

#editModal .modal__form .field > span {
  align-self: center;
}

#editModal .period-field {
  width: 100%;
  justify-content: stretch;
}

#editModal .period-field > select,
#editModal .modal__form input[type="text"],
#editModal .modal__form input[type="number"] {
  width: 100%;
  max-width: none;
}

#editModal .modal__actions {
  justify-content: center;
  width: 100%;
  margin-top: 12px;
}

#editModal .modal__actions .btn {
  min-width: 140px;
}

#editModal .modal__form .status {
  width: 100%;
  padding-left: 0;
  text-align: center;
}

/* ---------- Device Filter ---------- */
.device-filter {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: min(52vh, 420px);
  overflow: auto;
  padding: 6px 2px;
}

.device-filter__row {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 16px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(6px);
  transition: border-color 0.2s ease, background 0.2s ease;
}

.device-filter__row:hover {
  border-color: rgba(59, 130, 246, 0.28);
  background: rgba(255, 255, 255, 0.72);
}

.device-filter__check {
  width: 18px;
  height: 18px;
  accent-color: #2563eb;
}

.device-filter__name {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 800;
  color: #0f172a;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.device-filter__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- Device Filter DnD ---------- */
.device-filter__drag {
  cursor: grab;
  color: #94a3b8;
  font-size: 18px;
  line-height: 1;
  padding: 0 2px;
  user-select: none;
  flex-shrink: 0;
  transition: color 0.15s ease;
}

.device-filter__drag:active {
  cursor: grabbing;
}

.device-filter__row:hover .device-filter__drag {
  color: #64748b;
}

.device-filter__row--dragging {
  opacity: 0.35;
  border-style: dashed;
  border-color: rgba(59, 130, 246, 0.35);
  background: rgba(59, 130, 246, 0.06);
}

.device-filter__row--drag-over {
  border-color: rgba(59, 130, 246, 0.55);
  background: rgba(59, 130, 246, 0.08);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.20);
}

.device-filter__row {
  user-select: none;
}

/* ---------- Table (Glass) ---------- */
.table-wrap {
  max-height: min(60vh, 560px);
  overflow: auto;
  border: 1px solid rgba(148, 163, 184, 0.20);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.50);
  backdrop-filter: blur(8px);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  color: #334155;
}

.table th,
.table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
  white-space: nowrap;
  text-align: center;
}

.table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(248, 250, 252, 0.92);
  backdrop-filter: blur(10px);
  text-align: center;
  color: #475569;
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.table tbody tr:nth-child(even) {
  background: rgba(241, 245, 249, 0.40);
}

.table tbody tr:hover {
  background: rgba(59, 130, 246, 0.06);
}

.history-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.history-pager__info {
  font-size: 14px;
  color: #475569;
  font-weight: 600;
  min-width: 80px;
  text-align: center;
}

.history-pager {
  display: flex;
  align-items: center;
  gap: 6px;
}

.history-pager .btn-mini {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.history-pager .btn-mini svg {
  display: block;
}

.history-pager .history-pager__input {
  width: 52px;
  min-width: 0;
  max-width: none;
  height: 30px;
  text-align: center;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
  background: rgba(255, 255, 255, 0.70);
  outline: none;
  padding: 0 4px;
  -moz-appearance: textfield;
}

.history-pager .history-pager__input::-webkit-outer-spin-button,
.history-pager .history-pager__input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.history-pager__total {
  font-size: 13px;
  color: #64748b;
  font-weight: 500;
}

.table tbody tr:hover td {
  background: rgba(59, 130, 246, 0.04);
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

/* ---------- Chart Placeholder ---------- */
#chart {
  height: 480px !important;
}

/* ---------- Footer ---------- */
.footer {
  margin-top: 34px;
  border-top: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(14px);
}

.footer__inner {
  min-height: 56px;
  display: flex;
  align-items: center;
  color: #64748b;
  font-size: 13px;
}

/* ---------- Legacy Card / Toolbar (pressure page) ---------- */
.card {
  border-radius: 22px;
  padding: 24px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(255, 255, 255, 0.52);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  box-shadow:
    0 2px 12px rgba(15, 23, 42, 0.05),
    0 8px 28px rgba(15, 23, 42, 0.03),
    inset 0 1px 0 rgba(255, 255, 255, 0.60);
  margin-bottom: 24px;
  position: relative;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 24px;
  right: 24px;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.55) 50%, transparent 100%);
  pointer-events: none;
}

.toolbar {
  display: flex;
  gap: 20px;
  align-items: center;
  flex-wrap: wrap;
}

.toolbar label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: #475569;
  font-size: 13px;
}

.toolbar button {
  height: 40px;
  border: 0;
  border-radius: 12px;
  padding: 0 18px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #2563eb 0%, #3b82f6 40%, #6366f1 100%);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  font-size: 14px;
}

.toolbar button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.32);
}

/* Pill */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.26);
  background: rgba(255, 255, 255, 0.60);
  backdrop-filter: blur(6px);
  color: #334155;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.pill:hover {
  border-color: rgba(148, 163, 184, 0.38);
  background: rgba(255, 255, 255, 0.78);
}

.pill input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #2563eb;
}

/* ---------- KPI (Index Page) ---------- */
.kpi__value {
  font-size: 32px;
  font-weight: 900;
  background: linear-gradient(135deg, #1d4ed8 0%, #3b82f6 40%, #6366f1 100%);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.kpi__label {
  font-size: 14px;
  color: #64748b;
  margin-top: 4px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.28);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.45);
}

/* ============================================
   Responsive — Tablet (< 920px)
   ============================================ */
@media (max-width: 920px) {
  .topbar__spacer {
    width: 0;
  }
}

/* ============================================
   Responsive — Mobile (< 900px)
   ============================================ */
@media (max-width: 899px) {
  .container {
    padding: 10px;
  }

  .topbar .container {
    padding: 0 12px;
  }

  .topbar__inner {
    min-height: 52px;
  }

  .brand__logo {
    width: 180px;
    height: 52px;
  }

  .topbar__right {
    font-size: 11px;
  }

  .topbar--dashboard .topbar__inner {
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    justify-items: stretch;
    gap: 12px;
    padding: 4px 0;
  }

  .topbar__dashboard-controls {
    justify-content: flex-end;
    justify-self: end;
    flex-wrap: nowrap;
    gap: 8px;
    width: auto;
  }

  .topbar__title {
    font-size: 20px;
    justify-self: center;
    text-align: center;
  }

  .field {
    width: auto;
  }

  .topbar__field {
    width: auto;
    padding: 4px 8px 4px 10px;
  }

  .topbar__status {
    width: auto;
    text-align: left;
  }

  select,
  input[type="text"],
  input[type="number"],
  input[type="date"] {
    min-width: 100px;
    max-width: 140px;
    width: auto;
    font-size: 13px;
  }

  .btn {
    width: auto;
  }

  .sensor-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .sensor-card {
    min-height: 300px;
    padding: 10px;
    border-radius: 12px;
  }

  .sensor-card::before {
    left: 12px;
    right: 12px;
  }

  .sensor-card::after {
    border-radius: 12px;
  }

  .sensor-card__head {
    align-items: flex-start;
    gap: 8px;
  }

  .sensor-card__value {
    min-width: 96px;
    width: auto;
    margin-left: auto;
    text-align: right;
  }

  .sensor-card__title {
    font-size: 14px;
  }

  .sensor-card__value-num {
    font-size: 18px;
  }

  .sensor-card__meta {
    gap: 5px;
    flex-wrap: wrap;
  }

  .chip {
    font-size: 10px;
    padding: 2px 6px;
  }

  .sensor-card__chart {
    flex: 0 0 200px;
    min-height: 200px;
    height: 200px;
  }

  .footer {
    margin-top: 14px;
  }

  .modal__panel {
    padding: 12px;
    border-radius: 14px;
  }

  .modal__form .field {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .modal__form .field > span {
    font-size: 14px;
  }

  .period-field {
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }

  .period-field__unit {
    flex: 0 0 90px;
  }

  .modal__form input[type="text"],
  .modal__form input[type="number"],
  .modal__form input[type="date"],
  .modal__form select {
    height: 44px;
    border-radius: 14px;
  }

  .modal__actions {
    justify-content: stretch;
  }

  .modal__actions .btn {
    flex: 1 1 0;
    min-width: 0;
    height: 44px;
  }

  .modal__form .status {
    padding-left: 0;
  }

  #editModal .modal__panel {
    width: min(440px, calc(100vw - 24px));
  }

  #editModal .modal__form .field {
    grid-template-columns: 1fr;
    justify-content: stretch;
  }

  #editModal .period-field {
    justify-content: stretch;
  }

  #editModal .period-field > select,
  #editModal .modal__form input[type="text"],
  #editModal .modal__form input[type="number"] {
    max-width: none;
  }

  .table th,
  .table td {
    padding: 6px 8px;
    font-size: 11px;
  }

  .modal__head {
    gap: 4px;
  }

  .modal__title {
    font-size: 16px;
  }

  .history-pager {
    gap: 3px;
  }

  .history-pager .btn-mini {
    height: 28px;
    padding: 0 6px;
    font-size: 11px;
    border-radius: 6px;
    min-width: 0;
  }

  .history-pager .history-pager__input {
    width: 30px;
    min-width: 0;
    max-width: none;
    height: 26px;
    font-size: 11px;
    border-radius: 6px;
    padding: 0 4px;
  }

  .history-pager__total {
    font-size: 11px;
  }

  .modal__actions .btn-mini {
    height: 28px;
    padding: 0 8px;
    font-size: 11px;
    border-radius: 6px;
  }

  .card {
    padding: 16px;
    border-radius: 16px;
    margin-bottom: 16px;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .toolbar label,
  .toolbar button,
  .toolbar .pill {
    width: 100%;
  }

  .toolbar button {
    padding: 0;
  }

  #chart {
    height: 360px !important;
  }
}

/* ============================================
   Responsive — Small Mobile (< 600px)
   ============================================ */
@media (max-width: 599px) {
  .container {
    padding: 8px;
  }

  .topbar .container {
    padding: 0 8px;
  }

  .topbar--dashboard .brand {
    display: none;
  }

  .topbar--dashboard .topbar__inner {
    grid-template-columns: 1fr;
    align-items: center;
    justify-items: center;
    gap: 6px;
    padding: 6px 0;
    min-height: auto;
  }

  .topbar__title {
    justify-self: stretch;
    font-size: 17px;
    text-align: center;
  }

  .topbar__dashboard-controls {
    align-items: stretch;
    justify-content: stretch;
    justify-self: stretch;
    gap: 8px;
    width: 100%;
  }

  .topbar__field {
    width: 100%;
    justify-content: space-between;
    padding: 6px 8px 6px 10px;
    gap: 8px;
  }

  .topbar__field > span {
    font-size: 12px;
  }

  .topbar__field select {
    max-width: 116px;
    min-width: 88px;
    height: 34px;
    font-size: 12px;
  }

  .range-trigger {
    height: 34px;
    font-size: 12px;
  }

  .topbar__status {
    width: 100%;
    font-size: 12px;
  }

  .sensor-grid {
    gap: 8px;
  }

  .sensor-card {
    min-height: 0;
    padding: 10px;
  }

  .sensor-card__head {
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 8px;
  }

  .sensor-card__head > :first-child {
    min-width: 0;
    flex: 1 1 auto;
  }

  .sensor-card__title {
    font-size: 14px;
    line-height: 1.3;
  }

  .sensor-card__meta {
    gap: 4px;
    margin-top: 4px;
  }

  .chip {
    font-size: 9px;
    line-height: 1.15;
    padding: 2px 5px;
  }

  .sensor-card__value {
    min-width: 88px;
    margin-left: auto;
    text-align: right;
  }

  .sensor-card__value-num {
    font-size: 16px;
  }

  .sensor-card__value-time {
    font-size: 11px;
  }

  .sensor-card__chart {
    flex: 0 0 190px;
    min-height: 190px;
    height: 190px;
  }
}

/* ============================================
   Responsive — Tiny Mobile (< 380px)
   ============================================ */
@media (max-width: 380px) {
  .topbar__title {
    font-size: 16px;
  }

  .topbar--dashboard .topbar__inner {
    min-height: auto;
  }

  .topbar__field {
    padding: 5px 7px 5px 8px;
  }

  .topbar__field > span {
    font-size: 11px;
  }

  .topbar__field select {
    max-width: 108px;
    min-width: 82px;
    padding: 0 8px;
    font-size: 11px;
  }

  .sensor-card {
    padding: 8px;
  }

  .sensor-card__chart {
    flex-basis: 156px;
    min-height: 156px;
    height: 156px;
  }

  .chip {
    font-size: 8.5px;
    padding: 2px 4px;
  }
}

/* ============================================
   Reduced Motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  .btn,
  .sensor-card,
  .toolbar button,
  .bottombar__btn,
  .modal__backdrop,
  .toast {
    transition: none;
  }

  .chip-period--pending {
    animation: none;
  }

  .topbar__title {
    animation: none;
  }
}
