* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #f5f7fb;
  color: #111827;
  font-family: Arial, "Malgun Gothic", "맑은 고딕", sans-serif;
}

.app {
  display: flex;
  gap: 16px;
  padding: 16px;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: 460px;
  min-width: 460px;
  height: calc(100vh - 32px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-right: 4px;
}

.main {
  flex: 1;
  min-width: 0;
  height: calc(100vh - 32px);
  overflow-y: auto;
  padding-right: 4px;
}
.panel {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(15,23,42,.05);
  padding: 16px;
}
h1, h2 { margin: 0; }

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 12px 0;
}
#monthTitle {
  font-size: 18px;
  font-weight: 700;
}

#calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.cal-head, .cal-cell {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  min-height: 56px;
  padding: 6px;
  background: #fff;
}
.cal-head {
  min-height: auto;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  background: #f9fafb;
}
.cal-cell {
  cursor: pointer;
  position: relative;
}
.cal-cell.disabled {
  background: #f9fafb;
  color: #9ca3af;
  cursor: default;
}
.cal-cell.selected {
  outline: 2px solid #111827;
}
.cal-date {
  font-size: 13px;
  font-weight: 700;
}
.cal-marks {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.cal-mark-row {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
}
.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}
.dot-a { background: #16a34a; }
.dot-b { background: #d97706; }
.dot-c { background: #dc2626; }

.legend {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  font-size: 13px;
}

.filter-row {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 0.8fr;
  gap: 10px;
}
.filter-row label, .chart-controls label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.filter-row label span, .chart-controls label span {
  font-size: 12px;
  color: #6b7280;
}

input, select, button {
  border: 1px solid #d1d5db;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  background: #fff;
}
button { cursor: pointer; }
button.primary {
  background: #111827;
  color: #fff;
  border-color: #111827;
}
.btn-row { margin: 12px 0; }

.stats-wrap {
  margin-bottom: 12px;
}
.stats-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.help-tip {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #111827;
  color: #fff;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: help;
}
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.stats-card {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 10px;
  background: #fafafa;
}
.stats-head {
  font-weight: 700;
  margin-bottom: 6px;
}
.stats-body {
  font-size: 13px;
  line-height: 1.6;
}

.list-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 10px 0;
}
.table-wrap {
  max-height: 520px;
  overflow: auto;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
}
.scan-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
}
.scan-table th, .scan-table td {
  padding: 8px;
  border-bottom: 1px solid #eef2f7;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.scan-table thead th {
  position: sticky;
  top: 0;
  background: #f9fafb;
}
.scan-table tbody tr {
  cursor: pointer;
}
.scan-table tbody tr:hover { background: #f3f7ff; }
.scan-table tbody tr.active { background: #eaf2ff; }

.col-case {
  width: 56px;
}

.col-code {
  width: 58px;
}

.col-name {
  width: 96px;
}

.col-market {
  width: 62px;
}

.col-gap {
  width: 62px;
}
.td-name {
  max-width: 96px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  min-width: 28px;
  height: 24px;
  border-radius: 999px;
  justify-content: center;
  align-items: center;
  font-weight: 700;
  font-size: 12px;
}
.badge-a { background: #dcfce7; color: #166534; }
.badge-b { background: #fef3c7; color: #92400e; }
.badge-c { background: #fee2e2; color: #991b1b; }

.top-bar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 10px;
}
.subinfo {
  margin-top: 6px;
  font-size: 13px;
  color: #4b5563;
  line-height: 1.7;
}
.chart-controls {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.legend-note {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 8px;
}
#chart {
  width: 100%;
  height: 860px;
}
@media (max-width: 1200px) {
  html, body {
    height: auto;
    overflow: auto;
  }

  .app {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .sidebar {
    width: 100%;
    min-width: 0;
    height: auto;
    overflow: visible;
    padding-right: 0;
  }

  .main {
    width: 100%;
    height: auto;
    overflow: visible;
    padding-right: 0;
  }

  #chart {
    height: 760px;
  }

  .info-table {
    font-size: 12px;
  }
}

/* 돌파 / 미돌파 */
.break {
  color: #16a34a;
  font-weight: 600;
  margin-left: 4px;
}

.fail {
  color: #dc2626;
  font-weight: 600;
  margin-left: 4px;
}

/* 케이스 뱃지 */
.case-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 12px;
  margin-left: 4px;
  color: #fff;
}

.case-A {
  background: #16a34a; /* 초록 */
}

.case-B {
  background: #f59e0b; /* 주황 */
}

.case-C {
  background: #dc2626; /* 빨강 */
}

.filter-extra {
  margin-top: 8px;
  margin-bottom: 10px;
}

.check-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #374151;
}

.check-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

.check-label {
  position: relative;
}

.help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #111827;
  color: #fff;
  font-size: 11px;
  margin-left: 4px;
  cursor: pointer;
}

.tooltip-text {
  position: absolute;
  left: 0;
  bottom: 120%;
  background: #111827;
  color: #fff;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s;
}

.check-label:hover .tooltip-text {
  opacity: 1;
}

.bottom-sections {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sub-panel {
  padding: 14px 16px;
}

.sub-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.sub-panel-head h3 {
  margin: 0;
  font-size: 18px;
}

.fin-tabs {
  display: flex;
  gap: 8px;
}

.fin-tab {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: #fff;
  cursor: pointer;
}

.fin-tab.active {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
  font-weight: 700;
}

.info-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
}

.info-table th,
.info-table td {
  padding: 9px 10px;
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.info-table thead th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  z-index: 1;
}

.pos {
  color: #dc2626;
  font-weight: 700;
}

.neg {
  color: #2563eb;
  font-weight: 700;
}

.neutral {
  color: #6b7280;
}

@media (max-width: 1200px) {
  .info-table {
    font-size: 12px;
  }
}

.top-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #fff;
  padding-bottom: 8px;
}

.legend-note {
  position: sticky;
  top: 64px;
  z-index: 19;
  background: #fff;
  padding-bottom: 8px;
}

.table-wrap.no-scroll {
  max-height: none;
  overflow: visible;
}

.material-open-btn {
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #111827;
  border-radius: 10px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.material-open-btn:hover {
  background: #f8fafc;
}

.material-modal-card {
  width: min(980px, calc(100vw - 32px));
  max-height: calc(100vh - 60px);
}

.material-meta {
  margin-bottom: 12px;
  font-size: 13px;
  color: #6b7280;
}

.material-content {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.material-content .material-item {
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  background: #f8fafc;
  padding: 14px 16px;
}

.material-content .material-item > b {
  display: inline-block;
  font-size: 17px;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 10px;
}

.material-content .material-lines {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.material-content .material-line {
  color: #374151;
  line-height: 1.65;
  font-size: 14px;
}

.material-content .material-time {
  color: #6b7280;
  font-size: 12px;
  margin-right: 6px;
}

.material-empty {
  color: #6b7280;
  font-size: 14px;
}

.hidden {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}

.modal-card {
  position: relative;
  width: min(980px, calc(100vw - 32px));
  max-height: calc(100vh - 60px);
  margin: 30px auto;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  z-index: 1;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid #e5e7eb;
}

.modal-head h3 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  color: #0f172a;
}

.modal-close {
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #111827;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 15px;
  cursor: pointer;
}

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  max-height: calc(100vh - 140px);
}

.pwa-nav {
  display: none;
  position: sticky;
  top: 0;
  z-index: 1000;
  gap: 8px;
  padding: 8px 12px;
  background: #0b1220;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.pwa-nav button {
  border: 0;
  border-radius: 10px;
  padding: 8px 12px;
  background: #1f2a44;
  color: #fff;
  cursor: pointer;
}

/* Adsense/content friendly additions */
html, body { overflow-x: hidden !important; overflow-y: auto !important; height: auto !important; min-height: 100% !important; }
.adsense-content { background:#0f172a; color:#e5e7eb; padding:24px 16px; }
.adsense-inner { max-width:1180px; margin:0 auto; background:rgba(255,255,255,.06); border:1px solid rgba(255,255,255,.12); border-radius:18px; padding:24px; box-shadow:0 16px 36px rgba(15,23,42,.16); }
.adsense-inner h2 { margin:0 0 10px; color:#fff; font-size:26px; }
.adsense-inner p { color:#cbd5e1; line-height:1.75; }
.content-label { color:#93c5fd !important; font-weight:800; font-size:13px; letter-spacing:.08em; text-transform:uppercase; margin:0 0 8px; }
.guide-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:14px; margin-top:18px; }
.guide-grid article { background:rgba(255,255,255,.06); border:1px solid rgba(255,255,255,.1); border-radius:14px; padding:16px; }
.guide-grid h3 { margin:0 0 8px; color:#fff; font-size:17px; }
.ad-slot-inline { min-height:90px; border:1px dashed rgba(255,255,255,.22); border-radius:14px; margin-top:18px; display:flex; align-items:center; justify-content:center; color:#64748b; }
.legal-footer { background:#0f172a; color:#94a3b8; text-align:center; padding:24px 16px 40px; }
.legal-footer a { color:#cbd5e1; margin:0 8px; text-decoration:none; }
@media(max-width:900px){ .guide-grid{grid-template-columns:1fr}.adsense-inner{padding:18px}.adsense-inner h2{font-size:22px} }
