/* =====================================================
   Korea Seismicity Map — 모바일 최적화 + 가독성 개선
   ===================================================== */

:root {
  --bg:     #0d1b2a;
  --surf:   #112236;
  --card:   #16293d;
  --card2:  #1a3048;
  --bdr:    #2a4a66;
  --bdr2:   #3a5f80;
  --txt:    #f0f6ff;
  --sub:    #b0cde6;
  --dim:    #7aa0be;
  --gold:   #ffc300;
  --gold2:  #d9a600;
  --grn:    #4dd6a0;
  --red:    #e05060;
  --sans:   "IBM Plex Sans", system-ui, sans-serif;
  --mono:   "IBM Plex Mono", monospace;
  --r: 10px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--txt);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ════════════════════════════════
   HEADER — sticky, 내부 900px 중앙
   ════════════════════════════════ */
.hdr {
  background: linear-gradient(90deg, #040e1c 0%, #0b1f35 60%, #07172a 100%);
  border-bottom: 1px solid rgba(255,195,0,0.25);
  position: sticky;
  top: 0;
  z-index: 200;
  flex-shrink: 0;
}

/* 900px 중앙 컨테이너 */
.hdr-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 16px;
}

/* 행 1: 로고 + 타이틀 */
.hdr-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0 8px;
}

.logo {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 2.5px;
  border: 1.5px solid rgba(255,195,0,0.55);
  padding: 4px 10px;
  border-radius: 5px;
  background: rgba(255,195,0,0.07);
  white-space: nowrap;
  flex-shrink: 0;
}

.htitle {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.hname {
  font-size: 14px;
  font-weight: 700;
  color: var(--txt);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hcredit {
  font-size: 11px;
  color: var(--sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hcredit a { color: var(--gold); text-decoration: none; }

/* 행 2: 탭 네비게이션 */
.top-nav {
  display: flex;
  border-top: 1px solid rgba(255,255,255,0.07);
  /* hdr-inner 패딩 상쇄 → 탭 배경 full-bleed */
  margin: 0 -16px;
  padding: 0 16px;
}

.tb {
  flex: 1;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: transparent;
  border: none;
  color: var(--dim);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2.5px solid transparent;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  padding: 9px 0 7px;
  -webkit-tap-highlight-color: transparent;
}

.tb.a {
  color: var(--gold);
  border-bottom-color: var(--gold);
  background: rgba(255,195,0,0.05);
}

.tb:active { background: rgba(255,195,0,0.10); }

.ti {
  font-size: 16px;
  line-height: 1;
}

/* ════════════════════════════════
   STATUS BAR — 헤더 바로 아래, Multiple 전용
   ════════════════════════════════ */
.status-bar {
  background: var(--bg);
  border-bottom: 1px solid var(--bdr);
}

.status-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 16px;
}

#status {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--sub);
  line-height: 1.4;
  padding: 7px 12px;
  border-radius: 6px;
  margin: 6px 0;
  background: transparent;
  border: 1.5px solid transparent;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#status.ok {
  color: var(--grn);
  border-color: rgba(77,214,160,0.30);
  background: rgba(77,214,160,0.07);
}
#status.err {
  color: var(--red);
  border-color: rgba(224,80,96,0.30);
  background: rgba(224,80,96,0.07);
}

/* ════════════════════════════════
   MAIN SCROLL AREA
   ════════════════════════════════ */
.main {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 32px;
}

.pnl { display: none; padding: 16px 16px 24px; max-width: 900px; margin: 0 auto; }
.pnl.a { display: block; }

/* ── 패널 헤더 ── */
.ph {
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--bdr);
}

.ph h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: -0.3px;
}

.ph p {
  font-size: 14px;
  color: var(--sub);
  margin-top: 6px;
  line-height: 1.65;
}

.ph p strong { color: var(--txt); font-weight: 700; }

.ph code {
  font-family: var(--mono);
  font-size: 12px;
  background: rgba(255,195,0,0.1);
  color: var(--gold);
  padding: 2px 6px;
  border-radius: 4px;
}

/* ════════════════════════════════
   CARDS
   ════════════════════════════════ */
.card {
  background: var(--card2);
  border: 1px solid var(--bdr);
  border-radius: var(--r);
  padding: 16px;
  margin-bottom: 14px;
}

.ct {
  font-size: 11px;
  font-weight: 700;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 1.4px;
  margin-bottom: 14px;
}

/* ════════════════════════════════
   FORM ELEMENTS
   ════════════════════════════════ */
.f { display: flex; flex-direction: column; gap: 7px; }
.f.gf { grid-column: 1 / -1; }

.f label {
  font-size: 12px;
  font-weight: 700;
  color: var(--sub);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  line-height: 1;
}

.f input,
.f select,
.f input[type="file"] {
  background: var(--surf);
  border: 1.5px solid var(--bdr);
  border-radius: 8px;
  color: var(--txt);
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 500;
  padding: 11px 14px;
  width: 100%;
  min-height: 48px;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.15s, background 0.15s;
}

.f input::placeholder { color: var(--dim); font-size: 14px; }

.f input:focus,
.f select:focus {
  outline: none;
  border-color: var(--gold);
  background: rgba(255,195,0,0.04);
  box-shadow: 0 0 0 3px rgba(255,195,0,0.08);
}

select.sel-period {
  background-color: var(--surf);
  color: var(--txt);
  color-scheme: dark;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath d='M1 1l6 6 6-6' stroke='%23b0cde6' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

select.sel-period option {
  background-color: #1a3048;
  color: #f0f6ff;
}

.f .h {
  font-size: 12px;
  color: var(--sub);
  line-height: 1.45;
}

.coord-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.pga-row { margin-top: 4px; }

.pga-box {
  min-height: 56px;
  display: flex;
  align-items: center;
  padding: 10px 14px;
  background: #080f1c;
  border: 1.5px solid var(--bdr2);
  border-radius: 8px;
}

.pga-out {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 1px;
}

/* ════════════════════════════════
   MAP
   ════════════════════════════════ */
.map-stack {
  position: relative;
  display: block;
  width: 100%;
  line-height: 0;
  border-radius: var(--r);
  overflow: hidden;
  margin-top: 4px;
}

.map-stack img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--r);
  border: 1.5px solid var(--bdr);
  cursor: crosshair;
  touch-action: none;
}

.map-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: var(--r);
}

.hint {
  font-size: 13px;
  color: var(--sub);
  margin-top: 10px;
  line-height: 1.5;
}

/* ════════════════════════════════
   BUTTONS
   ════════════════════════════════ */
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.btnpri {
  cursor: pointer;
  background: linear-gradient(135deg, #ffd000, #d9a600);
  border: none;
  border-radius: var(--r);
  color: #05111f;
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 800;
  padding: 14px 22px;
  min-height: 52px;
  flex: 1;
  min-width: 140px;
  letter-spacing: 0.2px;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.1s, box-shadow 0.12s;
}

.btnpri:active {
  transform: scale(0.97);
  box-shadow: 0 3px 12px rgba(255,195,0,0.3);
}

.btnsec {
  cursor: pointer;
  background: var(--card);
  border: 1.5px solid var(--bdr2);
  border-radius: var(--r);
  color: var(--txt);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  padding: 13px 18px;
  min-height: 52px;
  flex: 1;
  min-width: 110px;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.12s, color 0.12s;
}

.btnsec:active {
  border-color: var(--gold);
  color: var(--gold);
}

/* ════════════════════════════════
   BATCH TABLE
   ════════════════════════════════ */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 6px;
}

.batch-tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.batch-tbl th,
.batch-tbl td {
  border: 1px solid var(--bdr);
  padding: 11px 14px;
  text-align: left;
}

.batch-tbl th {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--gold);
  background: rgba(255,195,0,0.07);
  white-space: nowrap;
}

.batch-tbl td {
  font-family: var(--mono);
  color: var(--txt);
}

.batch-tbl tbody tr:nth-child(even) td {
  background: rgba(0,0,0,0.15);
}

.batch-tbl .col-pga {
  text-align: right;
  font-weight: 700;
  color: var(--gold);
}

.batch-tbl td.err {
  color: var(--red);
  font-size: 12px;
}

/* ════════════════════════════════
   HAZARD SITE ROWS
   ════════════════════════════════ */
.site-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--bdr);
}

.site-row .f { margin: 0; }
.site-row .f:first-child { grid-column: 1 / -1; }
.site-row button.remove {
  grid-column: 1 / -1;
  min-height: 44px;
  font-size: 13px;
}

/* ════════════════════════════════
   HAZARD CHART
   ════════════════════════════════ */
.chart-wrap {
  min-height: 300px;
  background: #080f1c;
  border-radius: var(--r);
  padding: 12px;
  border: 1px solid var(--bdr);
}

/* ════════════════════════════════
   SCROLLBAR
   ════════════════════════════════ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--bdr2); border-radius: 3px; }

/* ════════════════════════════════
   TABLET / DESKTOP
   ════════════════════════════════ */
@media (min-width: 600px) {
  .pnl { padding: 20px 28px 28px; }
  .hdr-inner { padding: 0 28px; }
  .status-inner { padding: 0 28px; }
  .top-nav { margin: 0 -28px; padding: 0 28px; }

  .map-stack { width: 75%; margin: 10px auto 0; }

  .site-row {
    grid-template-columns: minmax(5rem, 0.8fr) 1fr 1fr auto;
  }
  .site-row .f:first-child { grid-column: auto; }
  .site-row button.remove  { grid-column: auto; }

  .btnpri, .btnsec { flex: unset; min-width: unset; }

  #status { font-size: 13px; white-space: normal; }

  .tb { font-size: 14px; gap: 8px; }
  .ti { font-size: 17px; }
}

@media (min-width: 900px) {
  .map-stack { width: 55%; }
}
