/* ================================
   Base Layout
================================ */

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background: #0b0c10;
  color: #ffffff;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.header {
  gap: 12px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
  opacity: .85;
}

.header-brand .pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #00d084;
  box-shadow: 0 0 0 0 rgba(0, 208, 132, 0.6);
  animation: pulse 1.2s infinite ease-out;
}


.brand-text {
  font-weight: 700;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 10px;
  color: #fff;
  text-decoration: none;
  background: rgba(255,255,255,.06);
}

.icon-btn:hover {
  background: rgba(255,255,255,.12);
  color: #fff;
}

.icon-btn.active {
  border-color: rgba(80, 255, 170, .85);
  background: rgba(80, 255, 170, .2);
}

.icon-btn.dropdown-toggle::after {
  display: none;
}

h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

h2 {
  margin: 16px 0 10px;
  font-size: 18px;
  font-weight: 600;
}


/* ================================
   Dashboard Grid
================================ */

.slider {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
}

.screen {
  width: 100%;
}

.grid {
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

/* 7-inch screen optimisation */
@media (min-width: 800px) {
  .grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.tile {
  background: #11141a;
  border: 5px solid rgba(255,255,255,.10);
  border-radius: 20px;
  padding: 18px;
  text-align: left;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  font-size: 18px;
  transition: 0.15s ease;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.tile:active {
  transform: scale(0.98);
}

.tile.on {
  border: 5px solid rgba(80, 255, 170, .6);
  background: linear-gradient(180deg, rgba(80, 255, 170, 0.6), #11141a);
}

.grid.reorder-active .tile {
  cursor: grab;
  touch-action: none;
}

.grid.reorder-active .tile.dragging {
  opacity: .72;
  transform: scale(0.98);
  border-color: rgba(80, 255, 170, .9);
}

.icon {
  height: 50px;
  display: flex;
  align-items: center;
  color: #fff;
}

.icon img {
  height: 64px;
  width: 64px;
  object-fit: contain;
}

.placeholder {
  font-size: 40px;
}

.label {
  font-weight: 600;
  font-size: 14px;
  color: #fff;
  -webkit-user-select: none;
  user-select: none;
}

.status {
  font-size: 14px;
  opacity: .7;
  color: #fff;
  -webkit-user-select: none;
  user-select: none;
}

.icon,
.icon i,
.placeholder,
.icon-choice,
.icon-btn,
.btn {
  -webkit-user-select: none;
  user-select: none;
}

.icon-picker {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.icon-choice {
  height: 44px;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 10px;
  background: rgba(255,255,255,.05);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.icon-choice.selected {
  border-color: rgba(80, 255, 170, .85);
  background: rgba(80, 255, 170, .2);
}

.icon-none {
  font-size: 12px;
  opacity: .9;
}

/* Info screen */
.info-screen {
  padding: 16px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.info-card {
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 18px;
  padding: 16px;
  background: #0f1218;
  width: 100%;
  margin-bottom: 10px;
}

.info-title {
  font-size: 14px;
  opacity: .7;
  margin-bottom: 6px;
}

.info-time {
  font-size: 48px;
  font-weight: 700;
}

.info-date {
  font-size: 18px;
  opacity: .85;
  margin-top: 6px;
}

.info-temp {
  font-size: 42px;
  font-weight: 700;
}

.info-sub {
  font-size: 14px;
  opacity: .7;
  margin-top: 6px;
}

.info-hint {
  opacity: .5;
  font-size: 12px;
  text-align: center;
}

.welcome-card {
  margin-bottom: 0;
}

.welcome-title {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

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

/* ================================
   Virtual Keyboard
================================ */
.vk-root {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5000;
  padding: 8px 8px max(8px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(10, 12, 16, 0.88), rgba(10, 12, 16, 0.98));
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.vk-root.hidden {
  display: none;
}

.vk-card {
  max-width: 980px;
  margin: 0 auto;
}

.vk-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.vk-title {
  font-size: 12px;
  opacity: 0.75;
}

.vk-close {
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12px;
}

.vk-rows {
  display: grid;
  gap: 6px;
}

.vk-row {
  display: flex;
  gap: 6px;
}

.vk-key {
  flex: 1;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 18px;
  font-weight: 600;
  min-height: 44px;
}

.vk-key.wide {
  flex: 3;
}

.vk-key.active {
  background: rgba(80, 255, 170, 0.3);
  border-color: rgba(80, 255, 170, 0.7);
}

.vk-key:active {
  transform: scale(0.98);
}

.heater-status {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.heater-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.heater-control {
  margin-bottom: 10px;
}

.heater-label {
  font-size: 13px;
  opacity: .75;
  margin-bottom: 6px;
}

.dimmer-grid {
  display: grid;
  gap: 12px;
  margin-top: 10px;
}

.dimmer-row {
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 14px;
  padding: 10px;
  background: rgba(255,255,255,.03);
}

.dimmer-value {
  opacity: .75;
  margin-left: 4px;
}

.dimmer-modal {
  position: fixed;
  inset: 0;
  z-index: 7000;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}

.dimmer-modal.hidden {
  display: none;
}

.dimmer-modal-card {
  width: min(560px, 96vw);
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 18px;
  padding: 14px;
  background: #0f1218;
}

.dimmer-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.dimmer-modal-title {
  font-size: 16px;
  font-weight: 700;
}

.dimmer-modal-value {
  font-size: 34px;
  font-weight: 700;
  margin-bottom: 6px;
}

.dimmer-modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.tilt-card {
  background: linear-gradient(160deg, #171a21, #11141a);
}

.tilt-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 18px;
}

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

.tilt-pane {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.tilt-van-wrap {
  width: 100%;
  min-height: 130px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tilt-van {
  font-size: 76px;
  color: #eceff4;
  transition: transform 0.25s ease;
  transform-origin: center center;
}

.tilt-side {
  font-size: 56px;
}

.tilt-rear {
  font-size: 56px;
}

.tilt-divider {
  width: 100%;
  height: 2px;
  background: rgba(255,255,255,.85);
}

.tilt-value {
  font-size: 64px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

@media (max-width: 700px) {
  .info-row {
    grid-template-columns: 1fr;
  }
  .tilt-title {
    font-size: 34px;
  }
  .tilt-van,
  .tilt-side,
  .tilt-rear {
    font-size: 58px;
  }
  .tilt-value {
    font-size: 42px;
  }
}

.swiper {
    padding-bottom: 30px;
}

/* Swiper pagination */
.swiper-pagination {
  position: static;
  margin-top: 6px;
}

.swiper-pagination-bullet {
  background: rgba(255,255,255,.5);
  opacity: 1;
}

.swiper-pagination-bullet-active {
  background: #ffffff;
}

/* ================================
   Forms / Edit Panel
================================ */

.panel {
  padding: 16px;
}

.form {
  display: grid;
  gap: 12px;
  margin-bottom: 10px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 14px;
}

input,
select {
  background: #0f1218;
  border: 1px solid rgba(255,255,255,.12);
  color: #fff;
  padding: 14px;
  border-radius: 14px;
  font-size: 16px;
}

.card {
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 18px;
  padding: 14px;
  margin: 14px 0;
  background: #0f1218;
  color: #fff;
}

.row {
  /* display: grid; */
  grid-template-columns: 28px 1fr auto auto;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 14px;
  padding: 10px 12px;
  margin: 10px 0;
  background: #0f1218;
}

.row-title {
  font-weight: 600;
  font-size: 16px;
}

.row-meta {
  opacity: .7;
  font-size: 13px;
}

.drag-handle {
  font-size: 22px;
  opacity: .8;
  margin-bottom: 10px;
  cursor: grab;
  user-select: none;
}

.hint {
  opacity: .7;
  font-size: 13px;
}

hr {
  border: none;
  border-top: 1px solid rgba(255,255,255,.10);
  margin: 20px 0;
}

.empty {
  opacity: .8;
  padding: 20px;
  border: 1px dashed rgba(255,255,255,.2);
  border-radius: 16px;
}

/* ================================
   PIN Modal
================================ */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 9999;
}

.modal-card {
  width: min(520px, 100%);
  background: #0f1218;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 20px;
  padding: 20px;
}

.unlock-card {
  max-height: 460px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 14px;
}

.unlock-panel {
  padding: 10px;
}

.unlock-card .modal-title {
  font-size: 18px;
  margin-bottom: 6px;
}

.unlock-card .pin-display {
  font-size: 20px;
  padding: 10px;
  margin-bottom: 10px;
  letter-spacing: 6px;
}

.unlock-card .keypad {
  gap: 8px;
}

.unlock-card .key {
  padding: 11px 0;
  border-radius: 12px;
  font-size: 18px;
}

.unlock-card .key.secondary {
  font-size: 14px;
}

.unlock-card .modal-actions {
  margin-top: 8px;
}

.unlock-card .modal-actions .btn {
  padding: 10px 12px;
  font-size: 14px;
}

.unlock-card .modal-hint {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.2;
}

.modal-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 10px;
}

.pin-dots {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 10px 0 8px;
}

.pin-dots .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.25);
  opacity: .7;
}

.pin-dots .dot.filled {
  background: rgba(255,255,255,.9);
  opacity: 1;
}

.pin-display {
  font-size: 24px;
  letter-spacing: 8px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.12);
  background: #0b0c10;
  text-align: center;
  margin-bottom: 16px;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

/* Compact keypad for 800x480 */
@media (max-height: 520px) {
  .modal-card {
    padding: 16px;
    border-radius: 16px;
  }

  .modal-title {
    font-size: 18px;
    margin-bottom: 6px;
  }

  .pin-display {
    font-size: 20px;
    padding: 10px;
    margin-bottom: 10px;
  }

  .keypad {
    gap: 8px;
  }

  .key {
    padding: 12px 0;
    border-radius: 14px;
    font-size: 18px;
  }

  .modal-actions {
    margin-top: 12px;
  }
}

/* Extra compact for 480px height */
@media (max-height: 480px) {
  .panel {
    padding: 10px;
  }

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

  .modal-title {
    font-size: 16px;
    margin-bottom: 4px;
  }

  .pin-display {
    font-size: 18px;
    padding: 8px;
    margin-bottom: 8px;
    letter-spacing: 6px;
  }

  .keypad {
    gap: 6px;
  }

  .key {
    padding: 10px 0;
    border-radius: 12px;
    font-size: 16px;
  }

  .key.secondary {
    font-size: 14px;
  }

  .modal-actions {
    margin-top: 10px;
  }

  .modal-actions .btn {
    padding: 10px 12px;
    border-radius: 12px;
    font-size: 14px;
  }

  .modal-hint {
    margin-top: 8px;
    font-size: 12px;
  }
}

.key {
  padding: 18px 0;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.12);
  background: #11141a;
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  touch-action: manipulation;
}

.key:active {
  background: #1f2833;
}

.key.secondary {
  background: #1a1f28;
  font-size: 18px;
  font-weight: 600;
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.modal-actions .btn {
  width: 100%;
  text-align: center;
}

.modal-hint {
  margin-top: 12px;
  opacity: .75;
  font-size: 14px;
}

.hidden {
  display: none !important;
}

/* ================================
   Splash Screen
================================ */

.splash {
  position: fixed;
  inset: 0;
  background: radial-gradient(1200px 600px at 50% -10%, #1c2430, #0b0c10 60%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 1;
  transition: opacity 400ms ease;
}

.splash.hide {
  opacity: 0;
  pointer-events: none;
}

.splash .logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 26px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.splash .pulse {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #00d084;
  box-shadow: 0 0 0 0 rgba(0, 208, 132, 0.6);
  animation: pulse 1.2s infinite ease-out;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(0, 208, 132, 0.6); }
  100% { box-shadow: 0 0 0 18px rgba(0, 208, 132, 0); }
}
