* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  font-family: 'Nanum Square Neo', -apple-system, BlinkMacSystemFont, 'Segoe UI',
    sans-serif;
  -webkit-font-smoothing: antialiased;
  background: linear-gradient(135deg, #1e3a5f 0%, #2d6a9f 50%, #4a90c2 100%);
  min-height: 100vh;
  color: #1a1a2e;
}

/* ---- 로그인 ---- */
.auth-page {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
}

.auth-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
  padding: 36px 28px;
  width: 100%;
  max-width: 420px;
  animation: slideUp 0.35s ease-out;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.brand {
  text-align: center;
  margin-bottom: 24px;
}

.brand h1 {
  font-size: 1.5rem;
  font-weight: 800;
  color: #1e3a5f;
}

.brand p {
  font-size: 0.85rem;
  color: #666;
  margin-top: 4px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.tab {
  flex: 1;
  padding: 10px;
  border: 2px solid #e0e8ef;
  background: #f8fafc;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  color: #555;
}

.tab.active {
  border-color: #2d6a9f;
  background: #2d6a9f;
  color: #fff;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #444;
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid #e0e8ef;
  border-radius: 8px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: #2d6a9f;
}

.hint {
  font-size: 0.75rem;
  color: #888;
  margin-top: 4px;
}

.btn-primary {
  width: 100%;
  padding: 14px;
  margin-top: 8px;
  background: linear-gradient(135deg, #1e3a5f, #2d6a9f);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-primary:hover {
  opacity: 0.92;
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.alert {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 12px;
  display: none;
}

.alert.error {
  display: block;
  background: #fee2e2;
  color: #b91c1c;
}

.alert.success {
  display: block;
  background: #dcfce7;
  color: #166534;
}

.hidden {
  display: none !important;
}

.auth-link-wrap {
  text-align: center;
  margin-top: 12px;
}

.auth-link {
  background: none;
  border: none;
  color: #2d6a9f;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

.auth-link:hover {
  color: #1e3a5f;
}

/* ---- 대시보드 ---- */
.dashboard-page {
  min-height: 100vh;
  background: #f0f4f8;
}

.header {
  background: linear-gradient(135deg, #1e3a5f, #2d6a9f);
  color: #fff;
  padding: 16px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

.header h1 {
  font-size: 1.15rem;
  font-weight: 800;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.year-select {
  padding: 8px 12px;
  border-radius: 8px;
  border: none;
  font-size: 0.9rem;
  font-weight: 600;
}

.user-info {
  font-size: 0.8rem;
  opacity: 0.9;
}

.btn-outline {
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: #fff;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.25);
}

.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.summary-card {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.summary-card .label {
  font-size: 0.75rem;
  color: #666;
  font-weight: 600;
}

.summary-card .value {
  font-size: 1.25rem;
  font-weight: 800;
  color: #1e3a5f;
  margin-top: 4px;
  word-break: break-all;
}

.summary-card .sub {
  font-size: 0.7rem;
  color: #2d6a9f;
  margin-top: 4px;
}

.charts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

@media (min-width: 768px) {
  .charts-grid {
    grid-template-columns: 1fr 1fr;
  }

  .chart-wide {
    grid-column: 1 / -1;
  }
}

.chart-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.chart-card h2 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #333;
  margin-bottom: 16px;
}

.chart-wrap {
  position: relative;
  height: 260px;
}

.chart-wrap.tall {
  height: 300px;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(240, 244, 248, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: #2d6a9f;
  z-index: 100;
}

.dash-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 12px 16px 0;
  max-width: 1200px;
  margin: 0 auto;
  -webkit-overflow-scrolling: touch;
}

.dash-tab {
  flex-shrink: 0;
  padding: 8px 14px;
  border: none;
  border-radius: 8px 8px 0 0;
  background: #dce6ef;
  color: #444;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.dash-tab.active {
  background: #fff;
  color: #1e3a5f;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
}

.dash-panel.hidden {
  display: none;
}

.table-card {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.table-card h2 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.table-meta {
  font-size: 0.8rem;
  color: #666;
  margin-bottom: 12px;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.data-table th,
.data-table td {
  padding: 10px 8px;
  border-bottom: 1px solid #eef2f6;
  text-align: left;
}

.data-table th {
  background: #f8fafc;
  font-weight: 700;
  color: #444;
  white-space: nowrap;
}

.data-table td.num {
  text-align: right;
  white-space: nowrap;
}

.data-table td.name {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-table tr:hover td {
  background: #f8fbff;
}

.data-table .empty {
  text-align: center;
  color: #888;
  padding: 24px;
}

.data-table .up {
  color: #166534;
  font-weight: 700;
}

.data-table .down {
  color: #b91c1c;
  font-weight: 700;
}

.sub.up {
  color: #166534;
  font-weight: 700;
}

.sub.down {
  color: #b91c1c;
  font-weight: 700;
}

@media (min-width: 768px) {
  .dash-tab {
    font-size: 0.9rem;
    padding: 10px 18px;
  }

  .data-table {
    font-size: 0.85rem;
  }

  .data-table td.name {
    max-width: 280px;
  }
}
