/* ============================================================
   SEcMS · HK2401 Cable List · Enhance Layer
   - Excel-like 다중셀 선택 시각화
   - 작업 이력(Audit Log) 모달
   - secms.tech 통합 톤 보정
   ============================================================ */

/* ──────────────── 다중셀 선택 ──────────────── */

.excel-table.cable-data-table td.excel-cell-selected {
  /* Excel 선택 영역 톤: 하늘빛 + 인셋 보더 */
  background: rgba(33, 115, 224, 0.18) !important;
  box-shadow: inset 0 0 0 1px rgba(33, 115, 224, 0.55);
  position: relative;
  z-index: 1;
}

.excel-table.cable-data-table tbody tr:nth-child(even) td.excel-cell-selected {
  background: rgba(33, 115, 224, 0.22) !important;
}

.excel-table.cable-data-table td.excel-cell-anchor {
  outline: 2px solid #137333;
  outline-offset: -2px;
  z-index: 2;
}

/* 드래그 중 사용자 텍스트 선택 차단 */
.excel-table.cable-data-table.dragging,
.excel-table.cable-data-table.dragging * {
  user-select: none !important;
  -webkit-user-select: none !important;
}

/* 떠 있는 선택 카운트 배지 */
.excel-select-badge {
  position: fixed;
  right: 18px;
  bottom: 60px;
  z-index: 50;
  display: none;
  padding: 8px 14px;
  border: 1px solid #1f4e79;
  border-radius: 4px;
  background: linear-gradient(180deg, #305496, #1f4e79);
  color: #fff;
  font-family: var(--mono, "Consolas", monospace);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.32);
}

.excel-select-badge.show { display: inline-flex; align-items: center; gap: 8px; }

.excel-select-badge strong {
  color: #ffd428;
  font-size: 14px;
  font-family: var(--mono, "Consolas", monospace);
}

.excel-select-badge .excel-select-hint {
  color: #cfe1ff;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0;
}

/* ──────────────── 헤더 audit 버튼 ──────────────── */

.topbar-btn.audit-symbol {
  background: rgba(255, 212, 40, 0.12);
  border-color: rgba(255, 212, 40, 0.28);
  color: #ffd428;
}

.topbar-btn.audit-symbol:hover {
  background: rgba(255, 212, 40, 0.22);
  border-color: rgba(255, 212, 40, 0.45);
}

/* ──────────────── 작업 이력 모달 ──────────────── */

.audit-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
}

.audit-modal.show { display: block; }

.audit-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 14, 28, 0.62);
  backdrop-filter: blur(2px);
}

.audit-modal-card {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(1300px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #1f4e79;
  border-radius: 6px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.audit-modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: linear-gradient(180deg, #102142, #1a315d);
  color: #fff;
  border-bottom: 1px solid #0a1430;
}

.audit-modal-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 900;
  color: #ffd428;
  letter-spacing: 0.04em;
}

.audit-modal-actions {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.audit-modal-actions select,
.audit-modal-actions input[type="search"] {
  height: 30px;
  padding: 0 10px;
  border: 1px solid #1f4e79;
  border-radius: 3px;
  background: #fff;
  color: #1a2233;
  font-size: 12px;
  min-width: 160px;
}

.audit-modal-actions input[type="search"] {
  min-width: 220px;
}

.audit-modal-close {
  width: 32px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
  font-size: 18px;
  font-weight: 700;
}

.audit-modal-close:hover {
  background: rgba(255, 255, 255, 0.16);
}

.audit-modal-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  background: #f4f7fc;
  overflow: hidden;
}

.audit-summary {
  padding: 6px 10px;
  background: #fff;
  border: 1px solid #d8dee8;
  border-radius: 3px;
  color: #475569;
  font-size: 12px;
}

.audit-summary strong {
  color: #102142;
  font-weight: 800;
}

.audit-table-wrap {
  flex: 1;
  overflow: auto;
  border: 1px solid #d8dee8;
  border-radius: 3px;
  background: #fff;
}

.audit-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.audit-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  height: 32px;
  padding: 0 10px;
  background: #305496;
  color: #fff;
  text-align: left;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.02em;
  border-right: 1px solid #1f4e79;
}

.audit-table tbody td {
  padding: 6px 10px;
  border-bottom: 1px solid #e6ebf2;
  vertical-align: top;
  color: #1a2233;
}

.audit-table tbody tr:nth-child(even) td { background: #f8fafd; }
.audit-table tbody tr:hover td { background: #fff8d6; }

.audit-table .col-time { width: 152px; white-space: nowrap; color: #334155; }
.audit-table .col-cat { width: 130px; }
.audit-table .col-actor { width: 100px; }
.audit-table .col-vessel { width: 80px; }
.audit-table .col-action { min-width: 280px; }
.audit-table .col-detail {
  width: 38%;
  max-width: 480px;
}

.audit-table .col-detail pre {
  margin: 0;
  padding: 4px 6px;
  border-radius: 2px;
  background: #f0f4fa;
  color: #475569;
  font-family: var(--mono, "Consolas", monospace);
  font-size: 11px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 6.4em;
  overflow: auto;
}

.audit-empty {
  padding: 38px 12px !important;
  text-align: center;
  color: #94a3b8;
  font-size: 13px;
}

/* mono helper (이미 main.css에 있을 가능성) */
.audit-table .mono { font-family: var(--mono, "Consolas", monospace); }

/* ──────────────── 반응형 ──────────────── */
@media (max-width: 900px) {
  .audit-modal-actions {
    justify-content: flex-start;
    margin-top: 6px;
  }
  .audit-modal-actions input[type="search"] { min-width: 140px; }
  .audit-table .col-detail { display: none; }
}

/* ──────────────── 페이저 숨김 (무한 스크롤) ──────────────── */
.pager { display: none !important; }

/* 테이블 컨테이너의 max-height 제거하여 자연 스크롤 (페이지 스크롤만) */
.excel-shell.cable-data-wrap {
  max-height: none !important;
  min-height: 520px;
  overflow: visible !important;
}

/* ──────────────── 성능 최적화 ──────────────── */



/* 스크롤 컨테이너 GPU 합성 레이어 */
.excel-shell.cable-data-wrap,
main#main-content {
  will-change: scroll-position;
}

/* sticky 헤더는 페이지 스크롤 기준으로 동작하도록 */
.excel-table.cable-data-table thead tr.excel-letters th,
.excel-table.cable-data-table thead tr.excel-headline th {
  position: sticky;
}

/* 워터마크의 PAGE 숫자가 1로만 보이도록 (배경 단순화) */
.excel-watermark { opacity: 0.6; }

/* ──────────────── 헤더 클릭 정렬 ──────────────── */

.excel-table.cable-data-table thead tr.excel-headline th.sortable-th {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 18px !important;
}

.excel-table.cable-data-table thead tr.excel-headline th.sortable-th:hover {
  background: linear-gradient(180deg, #4472c4 0%, #2e5b9a 100%);
}

.excel-table.cable-data-table thead tr.excel-headline th.sortable-th .sort-indicator {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  color: #ffd428;
  font-size: 9.5px;
  font-weight: 700;
  text-shadow: 0 1px 0 rgba(0, 0, 0, .35);
  pointer-events: none;
}

.excel-table.cable-data-table thead tr.excel-headline th.sort-asc,
.excel-table.cable-data-table thead tr.excel-headline th.sort-desc {
  background: linear-gradient(180deg, #305496 0%, #1f4e79 100%) !important;
  color: #ffd428;
}

/* ──────────────── secms.tech 통합 톤 미세 보정 ──────────────── */

/* topbar 좌측 상단 여백 정리 */
.topbar .brand-link {
  padding: 2px 4px;
}

/* nav-tab의 active 색상을 SEcMS 골드와 명확히 동기화 */
.nav-bar .nav-tab.active {
  color: #ffd428;
  border-bottom-color: #ffd428;
}

/* 푸터 위에 살짝 그림자로 깊이 추가 */
.app-footer {
  box-shadow: 0 -1px 0 rgba(255, 212, 40, 0.18);
}

/* ══════════════════════════════════════════════════════════
   로그인 화면 프리미엄 리디자인 (enhance layer override)
   ══════════════════════════════════════════════════════════ */

/* ── 배경: 깊은 우주 네이비 + 방사형 광원 ── */
.secms-auth-shell {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(48, 84, 150, 0.38) 0%, transparent 70%),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(255, 212, 40, 0.06) 0%, transparent 60%),
    #060d1a !important;
  position: relative;
  overflow: hidden;
}

/* 배경 격자 패턴 */
.secms-auth-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(48, 84, 150, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(48, 84, 150, 0.06) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
}

/* ── 카드: 더블 베젤 + 골드 테두리 글로우 ── */
.secms-auth-device {
  position: relative;
  width: min(420px, 100%);
  padding: 0;
  border: 1px solid rgba(255, 212, 40, 0.22) !important;
  border-radius: 16px !important;
  background: linear-gradient(145deg, #0e1a2e 0%, #091422 100%) !important;
  box-shadow:
    0 0 0 1px rgba(255, 212, 40, 0.08),
    0 0 40px rgba(255, 212, 40, 0.06),
    0 32px 80px rgba(0, 0, 0, 0.65),
    inset 0 1px 0 rgba(255, 255, 255, 0.06) !important;
  animation: loginSlideUp 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
  overflow: hidden;
}

@keyframes loginSlideUp {
  from { opacity: 0; transform: translateY(22px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}

/* 카드 상단 골드 라인 */
.secms-auth-device::before {
  content: "";
  position: absolute;
  top: 0; left: 10%; right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 212, 40, 0.6), transparent);
}

/* ── 내부 패딩 래퍼 ── */
.secms-auth-device > .secms-login-logo-wrap,
.secms-auth-device > .secms-kicker,
.secms-auth-device > .secms-login-title,
.secms-auth-device > .secms-login-sub,
.secms-auth-device > .name-gate-field,
.secms-auth-device > .name-gate-actions,
.secms-auth-device > .secms-footer-note {
  padding-left: 32px;
  padding-right: 32px;
}

.secms-auth-device > .secms-login-logo-wrap { padding-top: 32px; }
.secms-auth-device > .secms-footer-note { padding-bottom: 28px; }

/* ── 로고 ── */
.secms-login-logo {
  max-width: 160px !important;
  max-height: 64px !important;
  filter: drop-shadow(0 0 12px rgba(255, 212, 40, 0.25));
}

/* ── KICKER ── */
.secms-kicker {
  font-size: 9.5px !important;
  letter-spacing: 0.18em !important;
  color: rgba(255, 212, 40, 0.55) !important;
  margin-top: 8px;
  margin-bottom: 0;
}

/* ── 타이틀 ── */
.secms-login-title {
  font-size: 28px !important;
  font-weight: 900 !important;
  color: #fff !important;
  letter-spacing: -0.01em;
  margin: 10px 0 4px !important;
}

/* ── 서브텍스트 ── */
.secms-login-sub {
  font-size: 12px !important;
  color: rgba(148, 170, 210, 0.75) !important;
  margin-bottom: 22px !important;
}

/* ── 구분선 ── */
.secms-auth-device .login-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(48, 84, 150, 0.4), transparent);
  margin: 4px 0 18px;
}

/* ── 라벨 ── */
.name-gate-field {
  margin-bottom: 14px !important;
  gap: 5px !important;
}

.name-gate-field span {
  font-size: 10.5px !important;
  font-weight: 800 !important;
  letter-spacing: 0.12em !important;
  color: rgba(148, 185, 240, 0.7) !important;
  text-transform: uppercase;
}

/* ── 입력창 — 핵심 리디자인 ── */
.name-gate-field input {
  height: 48px !important;
  padding: 0 16px !important;
  border: 1px solid rgba(48, 84, 150, 0.45) !important;
  border-radius: 10px !important;
  background: rgba(6, 13, 26, 0.85) !important;
  color: #e8f0fe !important;
  font-size: 15px !important;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  outline: none !important;
}

.name-gate-field input::placeholder {
  color: rgba(148, 163, 184, 0.4);
  font-weight: 400;
}

.name-gate-field input:focus {
  border-color: rgba(255, 212, 40, 0.55) !important;
  background: rgba(10, 20, 38, 0.95) !important;
  box-shadow:
    0 0 0 3px rgba(255, 212, 40, 0.08),
    0 0 20px rgba(255, 212, 40, 0.06) !important;
}

/* ── 버튼 그룹 ── */
.name-gate-actions {
  gap: 10px !important;
  margin-top: 4px;
}

/* ── 입장 버튼 — 골드 그라디언트 ── */
.secms-primary-btn {
  height: 48px !important;
  border: none !important;
  border-radius: 10px !important;
  background: linear-gradient(135deg, #e6a800 0%, #ffd428 50%, #f0b800 100%) !important;
  color: #0a1428 !important;
  font-size: 14px !important;
  font-weight: 900 !important;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
  box-shadow: 0 4px 20px rgba(255, 212, 40, 0.3), 0 2px 6px rgba(0,0,0,0.4);
}

.secms-primary-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 28px rgba(255, 212, 40, 0.4), 0 2px 8px rgba(0,0,0,0.4);
  filter: brightness(1.06);
}

.secms-primary-btn:active {
  transform: translateY(0);
  filter: brightness(0.95);
}

/* ── 관리자 ⚙ 버튼 ── */
.name-gate-admin {
  height: 48px !important;
  border: 1px solid rgba(255, 212, 40, 0.2) !important;
  border-radius: 10px !important;
  background: rgba(255, 212, 40, 0.06) !important;
  color: rgba(255, 212, 40, 0.6) !important;
  font-size: 20px !important;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, color 0.18s, transform 0.18s;
}

.name-gate-admin:hover {
  background: rgba(255, 212, 40, 0.14) !important;
  border-color: rgba(255, 212, 40, 0.45) !important;
  color: #ffd428 !important;
  transform: rotate(20deg);
}

/* ── 문의 링크 ── */
.secms-contact-link {
  display: block !important;
  text-align: center !important;
  font-size: 11.5px !important;
  color: rgba(100, 150, 220, 0.75) !important;
  text-decoration: none !important;
  padding: 8px 32px 0 !important;
  transition: color 0.2s;
}
.secms-contact-link:hover {
  color: #ffd428 !important;
}

/* ── 푸터 노트 ── */
.secms-footer-note {
  color: rgba(100, 120, 160, 0.6) !important;
  font-size: 11px !important;
  margin-top: 10px !important;
  border-top: 1px solid rgba(48, 84, 150, 0.15);
  padding-top: 16px !important;
}

/* ──────────────── 컬럼 너비 리사이즈 ──────────────── */

.col-resize-handle {
  position: absolute;
  right: 0;
  top: 0;
  width: 5px;
  height: 100%;
  cursor: col-resize;
  z-index: 3;
  background: transparent;
  transition: background 0.15s;
}

.col-resize-handle:hover,
body.col-resizing .col-resize-handle {
  background: rgba(255, 212, 40, 0.55);
}

body.col-resizing {
  cursor: col-resize !important;
  user-select: none !important;
}

body.col-resizing * {
  cursor: col-resize !important;
}

/* ──────────────── 날짜 다중셀 팝업 ──────────────── */

.date-multi-popup {
  display: none;
  position: fixed;
  z-index: 200;
  min-width: 168px;
  background: #fff;
  border: 1px solid #1f4e79;
  border-radius: 6px;
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.28);
  padding: 10px;
  flex-direction: column;
  gap: 6px;
}

.date-multi-popup.show {
  display: flex;
}

.dmp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.dmp-title {
  font-size: 11.5px;
  font-weight: 800;
  color: #102142;
  letter-spacing: 0.01em;
}

.dmp-title em {
  font-style: normal;
  color: #305496;
  font-weight: 700;
  margin-left: 4px;
}

.dmp-close {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: #94a3b8;
  font-size: 16px;
  font-weight: 700;
  border-radius: 3px;
  padding: 0;
}

.dmp-close:hover { background: #f1f5f9; color: #1a2233; }

.dmp-btn {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #d8dee8;
  border-radius: 4px;
  background: #f4f7fc;
  color: #1a2233;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: background 0.12s, border-color 0.12s;
  line-height: 1.4;
}

.dmp-btn small {
  display: block;
  font-weight: 400;
  font-size: 10.5px;
  color: #475569;
  font-family: var(--mono, "Consolas", monospace);
  margin-top: 2px;
}

.dmp-btn.today {
  background: linear-gradient(180deg, #305496, #1f4e79);
  border-color: #1f4e79;
  color: #fff;
}

.dmp-btn.today small { color: #cfe1ff; }

.dmp-btn.today:hover {
  background: linear-gradient(180deg, #4472c4, #305496);
}

.dmp-btn.clear {
  background: #fff;
  border-color: #f59e0b;
  color: #b45309;
}

.dmp-btn.clear:hover { background: #fef3c7; }

/* ──────────────── 공통 모달 오버레이 ──────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 9000;
  align-items: center;
  justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal-box {
  background: #fff;
  border-radius: 10px;
  padding: 24px;
  width: 90%;
  max-width: 440px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.22);
}
.modal-title { font-size: 16px; font-weight: 700; margin: 0 0 6px; }
.modal-desc { font-size: 12px; color: #888; margin: 0 0 12px; }
