:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --eng: #1d4ed8;
  --eng-bg: #eff6ff;
  --chn: #b91c1c;
  --chn-bg: #fef2f2;
  --sat: #2563eb;
  --sun: #dc2626;
  --shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.05), 0 8px 10px -6px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 20px 25px -5px rgba(15, 23, 42, 0.1), 0 8px 10px -6px rgba(15, 23, 42, 0.1);
  --radius: 18px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Noto Sans KR", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

/* Hero Section */
.hero {
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 60%, #312e81 100%);
  color: white;
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  top: -50%;
  right: -20%;
  width: 380px;
  height: 380px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.25) 0%, transparent 70%);
  pointer-events: none;
}

.hero-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}

.hero-badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #e0e7ff;
}

.source-status {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.6);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}

.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(28px, 4.5vw, 40px);
  font-weight: 800;
  letter-spacing: -0.5px;
}

.hero p {
  margin: 0;
  color: #cbd5e1;
  font-size: 16px;
  line-height: 1.6;
  max-width: 680px;
}

/* Search Box */
.searchbox {
  display: flex;
  gap: 10px;
  margin-top: 24px;
  flex-wrap: wrap;
}

.searchbox input {
  flex: 1;
  min-width: 240px;
  padding: 14px 18px;
  border: 0;
  border-radius: 14px;
  font-size: 16px;
  outline: none;
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.searchbox input:focus {
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.5);
}

button {
  border: 0;
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.primary {
  background: #ffffff;
  color: #312e81;
}
.primary:hover {
  background: #f1f5f9;
  transform: translateY(-1px);
}

.btn-excel-open {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(8px);
}
.btn-excel-open:hover {
  background: rgba(255, 255, 255, 0.28);
}

/* Toolbar & Navs */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 24px 0 12px;
  flex-wrap: wrap;
  gap: 14px;
}

.navs, .filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.ghost {
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.ghost:hover {
  background: #f8fafc;
  border-color: var(--line-strong);
}
.ghost.active {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.period {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #0f172a;
}

.filter-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}

/* Panels */
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 24px;
}

.panel-head {
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  background: #ffffff;
}

.panel-head h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.small {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

.panel-legend {
  display: flex;
  gap: 14px;
  font-size: 13px;
  color: var(--muted);
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Table */
.table-container {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th, td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  background: #f8fafc;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

tr:last-child td {
  border-bottom: 0;
}

tr.row-sat {
  background: rgba(239, 246, 255, 0.25);
}
tr.row-sun {
  background: rgba(254, 242, 242, 0.25);
}

tr:hover {
  background: #f1f5f9;
}

.datecell {
  white-space: nowrap;
  font-weight: 800;
  font-size: 16px;
  color: #1e293b;
}

.daycell {
  font-weight: 800;
  font-size: 14px;
}
.daycell.sat { color: var(--sat); }
.daycell.sun { color: var(--sun); }

.engtxt {
  color: var(--eng);
  font-weight: 700;
  font-size: 15px;
}
.chntxt {
  color: var(--chn);
  font-weight: 700;
  font-size: 15px;
}

.notecell {
  font-size: 13px;
  color: var(--muted);
}
.notebadge {
  display: inline-block;
  background: #f1f5f9;
  border: 1px solid var(--line);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  color: #475569;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
}
.badge.eng { background: #dbeafe; color: #1e40af; }
.badge.chn { background: #fee2e2; color: #991b1b; }

/* Search Results Grid */
.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  padding: 20px;
}

.result-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  background: #ffffff;
  box-shadow: 0 2px 5px rgba(0,0,0,0.03);
  transition: transform 0.15s ease;
}
.result-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.result-card .date {
  font-weight: 800;
  font-size: 16px;
  margin-bottom: 8px;
  color: #0f172a;
}

.result-card .who {
  margin-top: 8px;
  font-size: 15px;
  font-weight: 600;
  color: #334155;
  line-height: 1.5;
}

.result-card.card-eng { border-left: 4px solid var(--eng); }
.result-card.card-chn { border-left: 4px solid var(--chn); }

.result-empty {
  padding: 32px;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 20px;
}

.modal-card {
  background: #ffffff;
  width: 100%;
  max-width: 580px;
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modalIn 0.2s ease-out;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
}

.modal-close {
  background: transparent;
  border: 0;
  font-size: 26px;
  line-height: 1;
  color: var(--muted);
  padding: 4px 8px;
}
.modal-close:hover { color: #000; }

.modal-body {
  padding: 24px;
}

.modal-desc {
  margin: 0 0 16px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
}

.dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: 14px;
  padding: 28px 20px;
  text-align: center;
  background: #f8fafc;
  cursor: pointer;
  transition: all 0.2s ease;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dropzone-icon {
  font-size: 38px;
  margin-bottom: 8px;
}

.dropzone-text {
  font-size: 15px;
  color: #334155;
}

.dropzone-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.btn-secondary {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid var(--line);
}
.btn-secondary:hover { background: #e2e8f0; }

.btn-danger {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}
.btn-danger:hover { background: #fecaca; }

.excel-info-box {
  margin-top: 18px;
  padding: 14px 16px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  font-size: 13px;
  color: #166534;
}
.excel-info-detail {
  margin-top: 4px;
  color: #15803d;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #0f172a;
  color: #ffffff;
  padding: 14px 20px;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  font-weight: 600;
  z-index: 1000;
  animation: toastIn 0.25s ease-out;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(15px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Note Section */
.note {
  margin-top: 20px;
  padding: 20px 24px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: #475569;
  box-shadow: var(--shadow);
}
.note-title {
  font-weight: 800;
  color: #1e293b;
  margin-bottom: 10px;
  font-size: 15px;
}
.note ul {
  margin: 0;
  padding-left: 20px;
  font-size: 14px;
  line-height: 1.7;
}
.note li { margin-bottom: 6px; }

/* Footer */
.footer {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin-top: 36px;
  line-height: 1.6;
}

/* Responsive */
@media (max-width: 768px) {
  .wrap { padding: 16px 12px 48px; }
  .hero { padding: 22px 18px; border-radius: 16px; }
  .hero h1 { font-size: 26px; }
  .searchbox { flex-direction: column; }
  .searchbox input { width: 100%; }
  th:nth-child(5), td:nth-child(5) { display: none; } /* hide note column on small screens */
  th, td { padding: 12px 10px; font-size: 14px; }
  .datecell { font-size: 14px; }
  .period { font-size: 18px; }
  .panel-legend { display: none; }
}
