:root {
  color-scheme: light;
  --navy: #123a6d;
  --navy-strong: #0c2d57;
  --blue: #2d6fb6;
  --blue-pale: #eaf3fd;
  --ink: #15263b;
  --muted: #64748b;
  --line: #dbe4ef;
  --surface: #ffffff;
  --canvas: #f3f6fa;
  --green: #27865c;
  --orange: #d97a20;
  --red: #b64848;
  --purple: #7250a5;
  --shadow: 0 14px 40px rgba(18, 58, 109, .09);
  font-family: "Pretendard", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--canvas); color: var(--ink); }
button, input, select { font: inherit; }
button, select { cursor: pointer; }

.language-switch { display: inline-flex; align-items: center; gap: 2px; padding: 3px; border: 1px solid #cbd7e5; border-radius: 9px; background: #eef3f8; }
.language-button { display: grid; place-items: center; min-width: 34px; height: 27px; padding: 0 7px; border-radius: 6px; color: #5d6f83; font-size: 11px; font-weight: 850; line-height: 1; text-decoration: none; }
.language-button:hover { color: var(--navy); background: rgba(255,255,255,.72); }
.language-button.active { color: #fff; background: var(--navy); box-shadow: 0 2px 5px rgba(12,45,87,.18); }
.login-language-switch { position: fixed; top: 22px; right: 24px; z-index: 20; border-color: rgba(255,255,255,.36); background: rgba(7,35,69,.34); backdrop-filter: blur(9px); }
.login-language-switch .language-button { color: #dceaf7; }
.login-language-switch .language-button:hover { color: #fff; background: rgba(255,255,255,.13); }
.login-language-switch .language-button.active { color: var(--navy-strong); background: #fff; }

.login-page {
  background:
    radial-gradient(circle at 10% 10%, rgba(63, 126, 188, .24), transparent 32rem),
    linear-gradient(140deg, #0c2d57 0%, #184b80 48%, #eef4fa 48%, #eef4fa 100%);
  display: grid;
  place-items: center;
  padding: 32px 20px;
}
.login-shell {
  width: min(980px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 430px);
  align-items: center;
  gap: 70px;
}
.login-brand { color: #fff; }
.brand-mark, .logo-mark {
  display: inline-grid;
  place-items: center;
  min-width: 54px;
  height: 34px;
  padding: 0 10px;
  border-radius: 10px;
  background: #fff;
  color: var(--navy);
  font-weight: 900;
  letter-spacing: .04em;
}
.login-brand .eyebrow { color: #cfe2f6; margin: 24px 0 8px; }
.login-brand h1 { font-size: clamp(34px, 5vw, 54px); line-height: 1.1; margin: 0 0 16px; }
.login-brand > p:not(.eyebrow) { max-width: 480px; color: #e7f0f9; font-size: 17px; line-height: 1.7; }
.login-points { display: grid; gap: 10px; padding: 0; margin: 28px 0 0; list-style: none; color: #dceaf7; }
.login-points li::before { content: "✓"; color: #8de2bb; font-weight: 800; margin-right: 10px; }
.login-card { background: rgba(255, 255, 255, .98); border: 1px solid rgba(255,255,255,.65); border-radius: 22px; padding: 34px; box-shadow: 0 26px 70px rgba(2, 24, 52, .23); }
.login-card h2 { margin: 4px 0 24px; font-size: 24px; color: var(--navy-strong); }
.environment-chip { display: inline-flex; align-items: center; min-height: 25px; padding: 3px 9px; border-radius: 999px; background: #e7f5ec; color: #17633f; font-size: 12px; font-weight: 700; }
.auth-kicker { margin: 14px 0 0; color: var(--blue); font-size: 12px; font-weight: 800; letter-spacing: .03em; }
.login-form, .preview-form { display: grid; gap: 9px; }
.login-form label, .preview-form label { font-size: 13px; font-weight: 700; color: #41546b; }
.label-note { color: var(--muted); font-size: 11px; font-weight: 500; }
.login-form input, .preview-form select, .year-picker select {
  width: 100%; border: 1px solid #cbd7e5; border-radius: 10px; background: #fff; color: var(--ink); outline: none;
}
.login-form input { height: 48px; padding: 0 14px; }
.login-form input:focus, .preview-form select:focus, .year-picker select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(45,111,182,.12); }
.login-form .pin-input, .login-form .numeric-code-input { text-align: center; font-size: 20px; font-weight: 800; letter-spacing: .45em; padding-left: calc(14px + .45em); font-variant-numeric: tabular-nums; }
.primary-button, .secondary-button { border: 0; border-radius: 10px; min-height: 46px; padding: 0 18px; font-weight: 800; }
.primary-button { margin-top: 8px; background: var(--navy); color: #fff; }
.primary-button:hover { background: var(--navy-strong); }
.secondary-button { background: #e6edf6; color: var(--navy); }
.form-help { margin: 12px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.field-help { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.text-link { display: inline-block; margin-top: 15px; color: var(--blue); font-size: 13px; }
.first-login-link { display: grid; gap: 3px; margin-top: 18px; padding: 13px 14px; border: 1px solid #d4e0ed; border-radius: 10px; background: #f6f9fc; color: var(--navy); text-decoration: none; }
.first-login-link:hover { border-color: #a9c3df; background: #eef5fc; }
.first-login-link strong { font-size: 13px; }
.first-login-link span { color: var(--muted); font-size: 11px; }
.login-form .verified-email-input { height: 44px; margin-bottom: 7px; border-color: #d8eadf; background: #eef8f2; color: #226a48; font-size: 13px; font-weight: 700; }
.remembered-account { display: flex; align-items: center; gap: 10px; margin: 0 0 8px; padding: 11px 12px; border: 1px solid #dce5ef; border-radius: 10px; background: #f7f9fc; color: var(--navy-strong); }
.remembered-account span { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--navy); color: #fff; font-size: 13px; font-weight: 900; }
.remembered-account strong { font-size: 14px; }
.notice { border-radius: 10px; padding: 11px 13px; font-size: 13px; line-height: 1.5; }
.notice.error { background: #fff0f0; color: #9f2f36; }
.notice.success { background: #eef8f2; color: #226a48; }
.preview-divider { display: flex; align-items: center; gap: 12px; margin: 26px 0 17px; color: #8190a2; font-size: 11px; }
.preview-divider::before, .preview-divider::after { content: ""; height: 1px; background: var(--line); flex: 1; }
.preview-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.preview-row select { min-width: 0; height: 44px; padding: 0 10px; }

.portal-header { position: sticky; top: 0; z-index: 10; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); backdrop-filter: blur(10px); }
.header-inner { width: min(1180px, calc(100% - 40px)); height: 68px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.portal-logo { display: flex; align-items: center; gap: 12px; color: var(--navy-strong); text-decoration: none; font-size: 18px; font-weight: 850; }
.portal-logo .logo-mark { background: var(--navy); color: #fff; font-size: 12px; }
.header-account { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.header-account form { margin: 0; }
.logout-button { border: 1px solid #cbd7e5; background: #fff; color: #42556d; border-radius: 8px; padding: 7px 10px; }

.portal-main { width: min(1180px, calc(100% - 40px)); margin: 26px auto 60px; }
.portal-main.personnel-wide { width: min(1560px, calc(100% - 32px)); }
.welcome-panel { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; padding: 27px 30px; border-radius: 18px; background: linear-gradient(120deg, var(--navy-strong), #245b93); color: #fff; box-shadow: var(--shadow); }
.eyebrow { margin: 0 0 6px; font-size: 11px; font-weight: 800; letter-spacing: .12em; color: #9fb7cf; }
.welcome-panel h1 { margin: 0 0 7px; font-size: 27px; }
.welcome-panel p:not(.eyebrow) { margin: 0; color: #d9e6f3; font-size: 13px; }
.sync-status { flex: 0 0 auto; color: #dbe9f6; font-size: 12px; }
.dashboard-tabs { display: flex; gap: 7px; margin: 22px 0 14px; padding: 5px; border-radius: 12px; background: #e5ebf3; width: fit-content; }
.dashboard-tab { min-width: 120px; padding: 10px 16px; border: 0; border-radius: 8px; background: transparent; color: #55667a; font-weight: 800; }
.dashboard-tab.active { background: #fff; color: var(--navy); box-shadow: 0 3px 10px rgba(26,55,90,.1); }
.tab-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 17px; padding: 24px; box-shadow: 0 8px 24px rgba(18, 58, 109, .05); }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.section-heading h2 { margin: 0 0 5px; color: var(--navy-strong); font-size: 20px; }
.section-heading p { margin: 0; color: var(--muted); font-size: 13px; }
.summary-chips { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.summary-chip { padding: 6px 10px; border-radius: 999px; background: var(--blue-pale); color: #285c94; font-size: 12px; font-weight: 700; }
.loading-state, .empty-state { display: grid; place-items: center; min-height: 220px; color: var(--muted); text-align: center; }
.empty-state strong { display: block; color: #3e536b; margin-bottom: 7px; }

.research-section + .research-section { margin-top: 25px; }
.research-section-title { display: flex; align-items: center; gap: 9px; margin: 0 0 11px; font-size: 14px; color: #304a68; }
.research-section-title::before { content: ""; width: 4px; height: 17px; border-radius: 4px; background: var(--blue); }
.research-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
.research-card { min-width: 0; min-height: 245px; display: flex; flex-direction: column; padding: 18px; border: 1px solid #d6e1ec; border-top: 4px solid var(--blue); border-radius: 13px; background: #fff; box-shadow: 0 7px 18px rgba(19,58,102,.055); }
.research-card.kind-research { border-top-color: var(--purple); }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card-kind { margin: 0 0 5px; color: var(--muted); font-size: 11px; font-weight: 800; }
.research-card h3 { margin: 0; color: var(--navy-strong); font-size: 16px; line-height: 1.45; overflow-wrap: anywhere; }
.badge { flex: 0 0 auto; min-width: 44px; padding: 5px 9px; border-radius: 999px; color: #fff; text-align: center; font-size: 11px; font-weight: 800; }
.badge-government { background: var(--green); }
.badge-industry { background: var(--orange); }
.badge-service { background: var(--red); }
.latest-note { appearance: none; width: 100%; flex: 1; margin: 16px 0; padding: 13px; border: 0; border-radius: 10px; background: #f5f8fb; color: #344a62; font-family: inherit; font-size: 13px; line-height: 1.65; text-align: left; white-space: pre-wrap; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; cursor: pointer; }
.latest-note:hover { background: #edf3f8; }
.latest-note:focus-visible { outline: 3px solid rgba(45,111,182,.28); outline-offset: 2px; }
.latest-note.empty { color: #94a0ae; }
.progress-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; }
.progress-track { height: 8px; border-radius: 999px; background: #e6edf5; overflow: hidden; }
.progress-fill { height: 100%; border-radius: inherit; background: var(--blue); }
.kind-research .progress-fill { background: var(--purple); }
.progress-value { font-size: 12px; font-weight: 800; color: #304861; }
.history-button { width: 100%; margin-top: 13px; min-height: 35px; border: 1px solid #cbd9e7; border-radius: 8px; background: #fff; color: var(--navy); font-size: 12px; font-weight: 800; }

.year-picker { display: grid; grid-template-columns: auto 110px; align-items: center; gap: 8px; color: #52647a; font-size: 12px; font-weight: 700; }
.year-picker select { height: 38px; padding: 0 10px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.personnel-sheet { border: 1px solid #c8d3df; border-radius: 12px 12px 0 0; overflow: hidden; background: #fff; }
.personnel-sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 54px; padding: 10px 15px; background: #dfe7f1; color: var(--navy-strong); }
.personnel-sheet-head h3 { margin: 0; font-size: 15px; }
.personnel-sheet-head p { margin: 3px 0 0; color: #64758a; font-size: 11px; }
.sheet-annual { display: flex; align-items: baseline; gap: 8px; flex: 0 0 auto; font-size: 12px; }
.sheet-annual strong { color: var(--navy); font-size: 15px; }
.table-scroll-hint { display: none; }
.personnel-table-scroll { max-width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; }
.personnel-table-scroll:focus-visible { outline: 3px solid rgba(45,111,182,.28); outline-offset: -3px; }
.personnel-summary-table { width: 100%; min-width: 1380px; border-collapse: separate; border-spacing: 0; table-layout: fixed; font-size: 11px; }
.personnel-summary-table th, .personnel-summary-table td { height: 34px; padding: 6px 8px; border-right: 1px solid #edf1f5; border-bottom: 1px solid #e6ebf1; white-space: nowrap; }
.personnel-summary-table thead th { background: #f3f6fa; color: #3d4f64; text-align: center; font-weight: 800; }
.personnel-summary-table .project-column { position: sticky; left: 0; z-index: 2; width: 230px; text-align: left; overflow: hidden; text-overflow: ellipsis; background: #fff; box-shadow: 1px 0 0 #dfe6ee; }
.personnel-summary-table thead .project-column { z-index: 3; text-align: center; background: #e9eef5; }
.personnel-summary-table .rate-column { width: 76px; text-align: right; }
.personnel-summary-table .money-column { width: 89px; text-align: right; }
.personnel-summary-table .project-pay-row:nth-child(even) td,
.personnel-summary-table .project-pay-row:nth-child(even) .project-column { background: #fbfcfe; }
.project-year { color: #8290a1; font-size: 10px; font-weight: 500; }
.personnel-total-row { font-weight: 800; }
.personnel-total-row.all-total td, .personnel-total-row.all-total .project-column { background: #edf2f8; }
.personnel-total-row.without-bk-total td, .personnel-total-row.without-bk-total .project-column { background: #e8f3ec; }
.settlement-box { border: 1px solid #c8d3df; border-top: 0; border-radius: 0 0 12px 12px; overflow: hidden; background: #fff; font-size: 12px; }
.settlement-row { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; align-items: center; gap: 9px 14px; padding: 10px 15px; border-top: 1px solid #edf1f5; }
.settlement-row:first-child { border-top: 0; }
.settlement-label { margin: 0; color: var(--navy); font-size: 13px; }
.settlement-items { display: flex; flex-wrap: wrap; gap: 7px 18px; min-width: 0; margin: 0; }
.settlement-item { display: inline-flex; align-items: baseline; gap: 5px; margin: 0; }
.settlement-item dt { color: #68798c; }
.settlement-item dd { margin: 0; color: #263e59; font-weight: 800; }
.settlement-item.unused dd { color: #9ca8b5; text-decoration: line-through; }
.settlement-item.applied dd { color: var(--navy); }
.settlement-subtotal { display: flex; align-items: baseline; gap: 7px; min-width: 142px; justify-content: flex-end; color: #586b81; white-space: nowrap; }
.settlement-subtotal strong { color: var(--navy); font-size: 14px; }
.salary-note { grid-column: 2 / -1; margin: -2px 0 0; color: #8491a0; font-size: 11px; }
.settlement-footer { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 10px 15px; border-top: 1px dashed #d9e1e9; background: #fbfcfe; }
.settlement-comment { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 8px; min-width: 0; }
.settlement-comment > span { color: #68798c; font-weight: 700; }
.settlement-comment p { margin: 0; color: #3f5165; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.settlement-comment p.empty { color: #9da8b4; }
.settlement-balance { display: flex; align-items: baseline; gap: 9px; white-space: nowrap; color: #53667b; }
.settlement-balance strong { font-size: 14px; }
.settlement-balance.negative strong { color: #a23030; }
.settlement-balance.positive strong { color: #1f5a9e; }
.settlement-balance.zero strong { color: #68798c; }
.settlement-missing { padding: 14px; border: 1px solid #dbe4ef; border-top: 0; color: #7b8998; font-size: 12px; }
.data-note { margin: 15px 0 0; color: #75869a; font-size: 11px; }

.history-dialog { width: min(720px, calc(100% - 28px)); max-height: min(720px, calc(100vh - 28px)); padding: 0; border: 0; border-radius: 16px; color: var(--ink); box-shadow: 0 30px 90px rgba(10,34,65,.3); }
.history-dialog::backdrop { background: rgba(12, 31, 53, .54); }
.dialog-header { position: sticky; top: 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 20px 22px; border-bottom: 1px solid var(--line); background: #fff; }
.dialog-header h2 { margin: 5px 0 0; font-size: 19px; color: var(--navy-strong); }
.kind-label { font-size: 11px; color: var(--muted); font-weight: 800; }
.dialog-close { width: 34px; height: 34px; border: 0; border-radius: 50%; background: #edf2f7; color: #4e6075; font-size: 24px; line-height: 1; }
.dialog-notes { padding: 18px 22px 24px; overflow-y: auto; }
.history-entry { padding: 15px 0; border-bottom: 1px solid #e7edf3; }
.history-entry:last-child { border-bottom: 0; }
.history-date { display: block; margin-bottom: 7px; color: var(--blue); font-size: 12px; font-weight: 800; }
.history-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; color: #30465d; font-size: 13px; line-height: 1.7; }
.fatal-error { padding: 18px; border-radius: 10px; background: #fff0f0; color: #9f2f36; }

@media (max-width: 900px) {
  .login-shell { grid-template-columns: 1fr; gap: 28px; max-width: 520px; }
  .login-brand { text-align: center; }
  .login-brand > p:not(.eyebrow) { margin-left: auto; margin-right: auto; }
  .login-points { display: none; }
  .research-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settlement-row { grid-template-columns: 44px minmax(0, 1fr); }
  .settlement-subtotal { grid-column: 2; justify-content: flex-start; }
  .salary-note { grid-column: 2; }
}

@media (max-width: 620px) {
  .login-page { display: block; background: linear-gradient(180deg, var(--navy-strong) 0, #174c82 290px, #eef4fa 290px); }
  .login-brand h1 { font-size: 34px; }
  .login-card { padding: 24px 20px; border-radius: 17px; }
  .header-inner, .portal-main, .portal-main.personnel-wide { width: min(100% - 24px, 1180px); }
  .header-inner { height: 62px; }
  .portal-logo > span:last-child { display: none; }
  .header-account { gap: 7px; }
  .language-button { min-width: 31px; padding-inline: 5px; }
  .login-language-switch { top: 12px; right: 12px; }
  .welcome-panel { display: block; padding: 22px; }
  .sync-status { margin-top: 15px; }
  .dashboard-tabs { width: 100%; }
  .dashboard-tab { flex: 1; min-width: 0; }
  .tab-panel { padding: 18px 14px; border-radius: 14px; }
  .section-heading { display: block; }
  .summary-chips { justify-content: flex-start; margin-top: 12px; }
  .personnel-heading { display: flex; align-items: flex-end; }
  .year-picker { margin-left: auto; grid-template-columns: 1fr; gap: 3px; }
  .research-grid { grid-template-columns: 1fr; }
  .research-card { min-height: 225px; }
  .personnel-sheet-head { align-items: flex-start; }
  .table-scroll-hint { display: block; margin: 0; padding: 7px 12px; background: #f6f8fb; color: #6d7e92; font-size: 11px; text-align: right; }
  .personnel-summary-table { min-width: 1280px; }
  .personnel-summary-table .project-column { width: 180px; }
  .settlement-row { display: block; padding: 12px; }
  .settlement-label { margin-bottom: 8px; }
  .settlement-items { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
  .settlement-item { display: grid; gap: 2px; }
  .settlement-subtotal { margin-top: 11px; justify-content: flex-end; }
  .salary-note { margin-top: 8px; }
  .settlement-footer { display: block; padding: 12px; }
  .settlement-comment { display: block; }
  .settlement-comment > span { display: block; margin-bottom: 4px; }
  .settlement-balance { justify-content: space-between; margin-top: 12px; padding-top: 9px; border-top: 1px solid #e5eaf0; }
}
