:root {
  --bg: #f0f3f6;
  --surface: #ffffff;
  --text: #1a2332;
  --muted: #5c6b7a;
  --line: #d8e0e8;
  --brand: #0b3d5c;
  --brand-2: #0e7490;
  --accent: #0f766e;
  --danger: #b91c1c;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(15, 39, 68, 0.08);
  --max: 1100px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Noto Sans KR", "Malgun Gothic", sans-serif;
  background:
    linear-gradient(180deg, #e8eef3 0%, var(--bg) 220px),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }

.site-header {
  background: var(--brand);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.header-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  color: #fff;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  text-decoration: none;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; color: #fff; }
.brand span { color: #5eead4; font-weight: 500; margin-left: 0.35rem; font-size: 0.85rem; }

.nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.35);
  color: #fff;
  border-radius: 6px;
  padding: 0.4rem 0.65rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  align-items: center;
}

.site-nav a {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  font-size: 0.92rem;
  padding: 0.35rem 0;
  border-bottom: 2px solid transparent;
}
.site-nav a:hover { color: #fff; text-decoration: none; }
.site-nav a.is-active {
  color: #fff;
  border-bottom-color: #5eead4;
}

.site-main {
  max-width: var(--max);
  margin: 0 auto;
  padding: 1.25rem 1rem 2.5rem;
  min-height: calc(100vh - 140px);
}

.page-title {
  margin: 0 0 0.35rem;
  font-size: 1.5rem;
  color: var(--brand);
}

.page-desc {
  margin: 0 0 1.25rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
  box-shadow: var(--shadow);
}

.card h3 {
  margin: 0 0 0.4rem;
  font-size: 1.05rem;
  color: var(--brand);
}

.card p {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.btn {
  display: inline-block;
  padding: 0.5rem 0.9rem;
  border-radius: 6px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { filter: brightness(1.05); text-decoration: none; color: #fff; }
.btn-outline {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--brand);
}
.btn-outline:hover { border-color: var(--brand-2); color: var(--brand-2); }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.table th, .table td {
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
.table th { color: var(--muted); font-weight: 600; background: #f7fafc; }

.form-row { margin-bottom: 0.85rem; }
.form-row label { display: block; margin-bottom: 0.3rem; font-size: 0.9rem; color: var(--muted); }
.form-row input, .form-row select, .form-row textarea {
  width: 100%;
  max-width: 520px;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}

.badge { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px; font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
.badge-pending    { background: #eef2f6; color: var(--muted); }
.badge-queued     { background: #fef9c3; color: #854d0e; }
.badge-processing { background: #dbeafe; color: #1e40af; }
.badge-completed  { background: #dcfce7; color: #166534; }
.badge-failed     { background: #fee2e2; color: var(--danger); }

.alert { padding: 0.6rem 0.8rem; border-radius: 6px; font-size: 0.9rem; }
.alert-error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.btn-block { display: block; width: 100%; text-align: center; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.login-body { display: flex; align-items: center; justify-content: center; padding: 1rem; }
.login-box {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.75rem 1.5rem;
}
.login-box .form-row input { max-width: 100%; }
.brand-mark { font-size: 1.4rem; font-weight: 700; color: var(--brand); margin-bottom: 1.25rem; text-align: center; }
.brand-mark span { color: var(--accent); font-size: 0.9rem; font-weight: 500; margin-left: 0.35rem; }

.site-nav .nav-logout { color: rgba(255,255,255,0.6); }

.site-footer {
  text-align: center;
  padding: 1.25rem 1rem 1.75rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.dropzone {
  display: block;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 1.75rem 1rem;
  text-align: center;
  color: var(--muted);
  background: var(--bg);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover,
.dropzone.is-over { border-color: var(--accent); background: #e6f4f2; color: var(--text); }
.dropzone input[type="file"] { display: none; }
.dropzone .dz-file { display: block; margin-top: 0.5rem; font-weight: 600; color: var(--text); word-break: break-all; }

.progress { height: 10px; background: var(--line); border-radius: 5px; overflow: hidden; margin-top: 0.5rem; }
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }

.report-body { line-height: 1.7; word-break: break-word; }
.report-body h2, .report-body h3, .report-body h4 { margin: 1.25rem 0 0.5rem; color: var(--brand); }
.report-body > :first-child { margin-top: 0; }
.report-body p { margin: 0 0 0.6rem; }
.report-body ul, .report-body ol { margin: 0 0 0.75rem; padding-left: 1.3rem; }
.bulk-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 0.6rem; margin-bottom: 0.75rem; }
.bulk-action { padding: 0.5rem 0.6rem; border: 1px solid var(--line); border-radius: 6px; font: inherit; background: #fff; }
.bulk-count { font-size: 0.85rem; color: var(--muted); }
.bulk-box { width: 18px; height: 18px; vertical-align: middle; cursor: pointer; }
.guide-star { border: 0; background: none; padding: 0.1rem 0.4rem; font-size: 1.25rem; line-height: 1; color: #cbd5e1; cursor: pointer; }
.guide-star:hover { color: #f59e0b; }
.guide-star.is-on { color: #d97706; }

.cmp-tabs { display: none; }
.cmp-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; align-items: start; }
.cmp-head { padding-bottom: 0.6rem; margin-bottom: 0.75rem; border-bottom: 1px solid var(--line); }
.cmp-label { display: inline-block; padding: 0.1rem 0.5rem; margin-right: 0.35rem; border-radius: 999px; font-size: 0.75rem; font-weight: 700; }
.cmp-label-0 { background: #eef2f6; color: var(--muted); }
.cmp-label-1 { background: #dcfce7; color: #166534; }
.cmp-meta { margin-top: 0.3rem; font-size: 0.8rem; color: var(--muted); }

.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.dash-panel { overflow: visible; }
.dash-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; margin-bottom: 0.5rem; }
.dash-head h3 { margin: 0; font-size: 1rem; }
.dash-head a { font-size: 0.85rem; white-space: nowrap; }
.dash-empty { margin: 0; color: var(--muted); font-size: 0.9rem; }
.dash-list { list-style: none; margin: 0; padding: 0; }
.dash-list li + li { border-top: 1px solid var(--line); }
.dash-row { display: flex; align-items: center; gap: 0.6rem; padding: 0.55rem 0.2rem; color: inherit; }
.dash-row:hover { text-decoration: none; background: #f7fafc; }
.dash-main { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.dash-main strong { font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-main small, .dash-num small { color: var(--muted); font-size: 0.78rem; }
.dash-num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.dash-chg { min-width: 4.2rem; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.dash-chg.is-up { color: #dc2626; }
.dash-chg.is-down { color: #2563eb; }
.dash-stat { display: block; padding: 0.6rem 0.2rem; border-bottom: 1px solid var(--line); color: inherit; }
.dash-stat:hover { text-decoration: none; background: #f7fafc; }
.dash-stat-label { display: block; font-weight: 600; font-size: 0.92rem; margin-bottom: 0.25rem; }
.dash-stat-nums { display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; font-size: 0.85rem; color: var(--muted); }
.dash-stat-nums b { color: var(--text); font-size: 1rem; font-variant-numeric: tabular-nums; }
.dash-stat-nums .is-fail b, .dash-stat-nums .is-fail { color: var(--danger); }
.dash-cron { margin: 0.75rem 0 0; font-size: 0.82rem; color: var(--muted); }
.dash-cron.is-warn { color: var(--danger); }

.ac-list {
  position: absolute; left: 0; top: calc(100% + 4px); z-index: 30;
  width: max(100%, 320px); max-width: calc(100vw - 2rem); max-height: 340px; overflow-y: auto;
  padding: 0.3rem; background: #fff;
  border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.14);
}
.ac-item {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.55rem 0.65rem; border-radius: 7px; cursor: pointer;
}
.ac-item:hover, .ac-item.is-active { background: #eef7f6; }
.ac-main { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.ac-name { font-size: 0.95rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ac-name mark { background: none; color: var(--accent); }
.ac-sub { font-size: 0.78rem; color: var(--muted); }
.ac-code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85rem; color: var(--text); }
.ac-mkt { flex-shrink: 0; padding: 0.12rem 0.45rem; border-radius: 999px; font-size: 0.72rem; font-weight: 600; }
.ac-mkt-KR { background: #fee2e2; color: #b91c1c; }
.ac-mkt-US { background: #dbeafe; color: #1d4ed8; }
.ac-mkt-OTHER { background: #eef2f6; color: var(--muted); }
.ac-empty { padding: 0.75rem 0.7rem; color: var(--muted); font-size: 0.85rem; text-align: center; }
.stock-chart + .stock-chart { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.report-body hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }

@media (max-width: 768px) {
  .nav-toggle { display: inline-block; }

  .site-nav {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding-bottom: 0.75rem;
  }
  .site-nav.is-open { display: flex; }
  .site-nav a {
    padding: 0.7rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.12);
  }
  .site-nav a.is-active { border-bottom-color: #5eead4; }

  .header-inner { flex-wrap: wrap; }
  .page-title { font-size: 1.25rem; }
  .dash-grid { grid-template-columns: 1fr; }
  .cmp-tabs { display: flex; gap: 0.4rem; margin-bottom: 0.6rem; }
  .cmp-tab { flex: 1; padding: 0.55rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; font: inherit; color: var(--muted); }
  .cmp-tab.is-active { border-color: var(--accent); color: var(--accent); font-weight: 700; }
  .cmp-grid { grid-template-columns: 1fr; }
  .cmp-col { display: none; }
  .cmp-col.is-active { display: block; }
}
