/* =========================================================
   반응형 (완성형)
   → style.css 맨 아래의 기존 "반응형" @media (max-width: 768px) 블록을
     이 파일 내용 전체로 교체하세요.
   ========================================================= */

/* ---------- 터치 기기: hover 확대/흔들림 최소화 ---------- */
@media (hover: none) {
  .card:hover {
    transform: none;
    box-shadow: none;
  }
  .tab:hover {
    background: #001018;
    box-shadow: none;
  }
  .tab.active:hover {
    background: #00eaff;
    box-shadow: 0 0 12px #00eaff;
  }
}

/* ---------- 모션 줄이기 설정 존중 ---------- */
@media (prefers-reduced-motion: reduce) {
  .card.danger,
  .card.danger::after,
  .card.danger .donut-wrap,
  .card.danger .center-badge,
  .donut.energy,
  .donut.value,
  .ticker-track {
    animation: none !important;
  }
}

/* =========================================================
     태블릿 (769px ~ 1024px) : 2단 유지, 카드 5열
     ========================================================= */
@media (max-width: 1024px) {
  .layout {
    grid-template-columns: minmax(0, 6.3fr) minmax(0, 3.7fr);
  }

  .cards {
    grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  }

  .donut-wrap {
    width: 100%;
    max-width: 84px;
    height: auto;
    aspect-ratio: 1 / 1;
  }

  .center-badge {
    font-size: 13px;
  }

  .title {
    font-size: 16px;
    letter-spacing: 1px;
  }
}

/* =========================================================
     모바일 / 소형 태블릿 (~768px) : 1단 세로 배치
     ========================================================= */
@media (max-width: 768px) {
  /* ----- 헤더 ----- */
  .header {
    padding: 10px 14px;
    gap: 10px;
  }

  .header-left {
    gap: 8px;
    min-width: 0; /* 말줄임 동작에 필요 */
    flex: 1;
  }

  .logo {
    height: 24px;
    flex-shrink: 0;
  }

  .title {
    display: none;
  }

  .header-right {
    gap: 8px;
    flex-shrink: 0;
  }

  .user-info {
    font-size: 11px;
    max-width: 90px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .logout-btn {
    padding: 6px 10px;
    font-size: 11px;
  }

  /* ----- 전체 레이아웃: 단일 컬럼 ----- */
  .layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto auto; /* 탭 / 카드 / 점검현황 / 티커 */
    height: auto;
    min-height: calc(100vh - 50px);
    min-height: calc(100dvh - 50px);
    align-content: start; /* auto 행이 남는 높이만큼 늘어나는 것 방지 */
    overflow: visible;
  }

  .left-panel {
    min-width: 0;
    grid-template-rows: auto;
    height: auto;
    overflow: visible;
  }

  .left-top {
    padding: 12px;
  }

  /* ----- 탭: 가로 스와이프 ----- */
  .tabs {
    grid-column: 1 / -1;
    min-width: 0; /* 내용 폭만큼 늘어나지 않게 */
    display: flex;
    flex-wrap: nowrap; /* 줄바꿈 금지 */
    gap: 10px;
    padding: 10px 20px;
    overflow-x: auto; /* 넘치면 가로 스크롤 */
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #00eaff55 transparent;

    background: #02070f;
    border-bottom: 1px solid #00eaff22;
  }

  .tabs::-webkit-scrollbar {
    display: none; /* Chrome, Safari */
  }

  .tab {
    flex: 0 0 auto; /* 탭이 찌그러지지 않게 */
    white-space: nowrap;
    padding: 6px 14px;
    font-size: 13px;
    cursor: pointer;
    border: 1px solid #00eaff33;
    border-radius: 6px;
    color: #7ddcff;
    background: #001018;
    transition: all 0.2s ease;
  }

  /* ----- 선박 카드: 4열 ----- */
  .cards {
    grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
    gap: 8px;
  }

  .card {
    min-width: 0; /* 내용 때문에 열이 넓어지지 않게 */
    padding: 8px 4px 6px;
    border-radius: 8px;
    text-align: center;
  }

  .card h3 {
    margin: 0 0 6px;
    font-size: 13px;
    letter-spacing: 0.5px;
  }

  .donut-wrap {
    width: 100%;
    max-width: 72px;
    height: auto;
    aspect-ratio: 1 / 1;
  }

  .donut {
    border-width: 2px;
  }

  .donut.value {
    inset: 6px;
    border-width: 2px;
  }

  .center-badge {
    font-size: 11px;
    letter-spacing: 0;
  }

  /* ----- 점검현황 (우측 패널 → 아래로) ----- */
  .right-panel {
    border-left: none;
    border-top: 1px solid #00eaff22;
    padding: 4px 12px 20px;
    min-width: 0;
    min-height: 160px;
  }

  #detailTitle {
    margin: 12px 0 8px;
    font-size: 15px;
  }

  #detailTemps {
    min-width: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .detail-table {
    font-size: 13px;
  }

  .detail-table th,
  .detail-table td {
    padding: 10px 8px;
  }

  .detail-table th:first-child,
  .detail-table td:first-child {
    width: 62px;
  }

  .detail-table th:last-child,
  .detail-table td:last-child {
    padding: 8px 10px;
    word-break: keep-all;
    overflow-wrap: anywhere;
  }

  /* ----- 하단 정비만료 티커: 화면 하단 고정 ----- */
  .bottom-ticker {
    position: sticky;
    bottom: 0;
    z-index: 20;
    height: 44px;
    padding: 0 12px;
    gap: 10px;
  }

  .ticker-title {
    min-width: auto;
    font-size: 12px;
    letter-spacing: 0;
    white-space: nowrap;
  }

  .ticker-track {
    gap: 24px;
    animation-duration: 5s; /* 숫자가 작을수록 빠름 */
  }

  .ticker-item {
    font-size: 12px;
  }

  /* ----- 점검 입력 모달: 화면에 맞게 ----- */
  .modal-overlay {
    padding: 12px;
    box-sizing: border-box;
  }

  .modal-box {
    width: 100%;
    max-width: 480px;
    max-height: 88vh;
    max-height: 88dvh;
    padding: 16px;
    box-sizing: border-box;
  }

  .modal-header h3 {
    font-size: 14px;
  }

  .modal-close-x {
    font-size: 26px;
    padding: 0 8px;
  }

  .modal-checklist {
    gap: 8px;
  }

  .modal-checklist label,
  .checklist-done {
    padding: 10px;
    font-size: 13px;
  }

  .modal-checklist input[type="checkbox"] {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
  }

  .modal-actions {
    position: sticky;
    bottom: -16px; /* modal-box padding 만큼 */
    padding: 10px 0 0;
    background: linear-gradient(to top, #02070f 70%, transparent);
  }

  .btn-cancel,
  .btn-save {
    flex: 1;
    padding: 11px 0;
  }

  /* ----- 로그인 화면 ----- */
  .login-bg-logo {
    width: 130vw;
    height: 130vw;
  }

  .login-box {
    width: 88%;
    max-width: 320px;
    padding: 32px 22px;
    box-sizing: border-box;
  }
  .login-box h2 {
    font-size: 18px;
  }

  .login-box input {
    font-size: 16px; /* iOS 입력창 자동 확대 방지 */
    padding: 12px;
  }

  .login-box button {
    padding: 12px;
    font-size: 14px;
  }
}

/* =========================================================
     소형 모바일 (~480px) : 카드 3열
     ========================================================= */
@media (max-width: 480px) {
  .cards {
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  }

  .donut-wrap {
    max-width: 78px;
  }

  .title {
    font-size: 13px;
  }

  .user-info {
    max-width: 64px;
  }

  .detail-table {
    font-size: 12px;
  }

  .detail-table th:first-child,
  .detail-table td:first-child {
    width: 54px;
  }

  .ticker-title {
    font-size: 11px;
  }
}
