  :root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --border: #e4e7eb;
    --text: #1f2937;
    --text-muted: #6b7280;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --danger: #dc2626;
    --warn-30: #0ea5e9;
    --warn-14: #f59e0b;
    --warn-7:  #f97316;
    --warn-1:  #dc2626;
    --success: #16a34a;
    --chip-bg: #eef2ff;
    --chip-text: #3730a3;
    --y1-bg: #fee2e2;
    --y1-border: #fca5a5;
    --y1-text: #991b1b;
  }
  * { box-sizing: border-box; }
  html, body {
    margin: 0; padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
  }
  header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
    position: sticky;
    top: 0;
    z-index: 50;
  }
  header h1 { font-size: 18px; margin: 0; font-weight: 700; }
  .logo-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); display: inline-block; margin-right: 6px; }
  nav { display: flex; gap: 4px; margin-left: 20px; flex: 1; flex-wrap: wrap; }
  nav button { background: transparent; border: none; padding: 8px 14px; font-size: 14px; cursor: pointer; border-radius: 6px; color: var(--text-muted); }
  nav button:hover { background: var(--bg); }
  nav button.active { background: var(--primary); color: #fff; font-weight: 600; }
  .header-brand {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
  }
  .header-brand img { height: 32px; max-width: 240px; object-fit: contain; display: block; }
  .header-brand img:not([src]), .header-brand img[src=""] { display: none; }
  .header-actions { display: flex; gap: 8px; align-items: center; }
  .user-chip { font-size: 12px; background: var(--chip-bg); color: var(--chip-text); padding: 4px 10px; border-radius: 999px; }
  .btn { background: var(--primary); color: #fff; border: none; padding: 8px 14px; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 500; transition: background .15s; }
  .btn:hover { background: var(--primary-hover); }
  .btn.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
  .btn.secondary:hover { background: var(--bg); }
  .btn.danger { background: var(--danger); }
  .btn.danger:hover { background: #b91c1c; }
  .btn.small { padding: 4px 10px; font-size: 12px; }
  .btn.ghost { background: transparent; color: var(--text-muted); border: 1px solid transparent; }
  .btn.ghost:hover { color: var(--text); background: var(--bg); }

  main { padding: 20px; max-width: 1400px; margin: 0 auto; }
  .view { display: none; }
  .view.active { display: block; }

  .card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
  .card h2 { font-size: 15px; margin: 0 0 12px 0; font-weight: 600; display: flex; align-items: center; justify-content: space-between; }
  .card h2 .badge { background: var(--chip-bg); color: var(--chip-text); font-size: 12px; padding: 2px 8px; border-radius: 999px; font-weight: 500; }

  .summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
  .stat { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
  .stat .label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
  .stat .value { font-size: 22px; font-weight: 700; }
  .stat .sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

  table { width: 100%; border-collapse: collapse; font-size: 13px; }
  th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
  th { font-size: 12px; font-weight: 600; color: var(--text-muted); background: var(--bg); position: sticky; top: 0; }
  tr:hover td { background: #fafbfc; }
  td.nowrap, th.nowrap { white-space: nowrap; }
  td.num { text-align: right; font-variant-numeric: tabular-nums; }
  td.tc, th.tc { text-align: center; vertical-align: middle; }

  .dl-chip { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; color: #fff; margin-right: 4px; }
  .dl-30 { background: var(--warn-30); }
  .dl-14 { background: var(--warn-14); }
  .dl-7  { background: var(--warn-7); }
  .dl-1  { background: var(--warn-1); }
  .dl-overdue { background: #991b1b; color: #fff; font-weight: 700; }
  .dl-done    { background: var(--success); }
  /* 신청 가능 시작 전 (대기) */
  .dl-pending { background: #6b7280; color: #fff; }
  /* 신청 가능 (시작됨, 마감 전) */
  .dl-open-7  { background: #f97316; color:#fff; }
  .dl-open-14 { background: #f59e0b; color:#fff; }
  .dl-open-30 { background: #0ea5e9; color:#fff; }
  .dl-open-90 { background: #2563eb; color:#fff; }
  .dl-chip.wide { padding:2px 10px; font-weight:600; }
  .y1-badge { display: none; }

  .status-pill { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); background: #fff; }
  .status-진행중 { background: #e0f2fe; color: #075985; border-color: #bae6fd; }
  .status-완료   { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
  .status-탈락   { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
  .status-퇴사   { background: #f3f4f6; color: #6b7280; border-color: #e5e7eb; }
  .status-보류   { background: #fef3c7; color: #92400e; border-color: #fde68a; }

  .input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; font-family: inherit; background: #fff; color: var(--text); }
  .input:focus, select:focus, textarea:focus { outline: 2px solid rgba(37,99,235,.25); border-color: var(--primary); }
  label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
  .form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
  .form-grid > .full { grid-column: 1 / -1; }
  .row { display: flex; gap: 8px; align-items: center; }
  .row.between { justify-content: space-between; }
  .toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
  .toolbar .grow { flex: 1; }

  .modal-backdrop { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(17, 24, 39, 0.5); display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
  .modal-backdrop.open { display: flex; }
  /* 바깥 클릭 시 닫히지 않는 입력 모달의 '흔들림' 효과 — 사용자에게 "실수 방지 중"임을 알림 */
  @keyframes modalShake {
    0%,100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
  }
  .modal-shake { animation: modalShake .28s ease-in-out; }
  .modal { background: var(--surface); border-radius: 12px; padding: 20px; width: 100%; max-width: 760px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 40px rgba(0,0,0,.25); }
  .modal h3 { margin: 0 0 12px 0; font-size: 16px; font-weight: 600; }
  .modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }

  .empty { text-align: center; padding: 40px 20px; color: var(--text-muted); }
  .empty h3 { margin: 0 0 8px 0; font-size: 16px; color: var(--text); }

  .secret { display: inline-flex; align-items: center; gap: 6px; }
  .secret code { background: var(--bg); padding: 1px 6px; border-radius: 4px; font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px; }
  .secret .mask-toggle { font-size: 11px; background: transparent; border: 1px solid var(--border); padding: 2px 6px; border-radius: 4px; cursor: pointer; color: var(--text-muted); }
  .secret .mask-toggle:hover { background: var(--bg); }

  .deadline-row td { border-left: 3px solid transparent; }
  .deadline-row.dl-row-30 td:first-child { border-left-color: var(--warn-30); }
  .deadline-row.dl-row-14 td:first-child { border-left-color: var(--warn-14); }
  .deadline-row.dl-row-7  td:first-child { border-left-color: var(--warn-7); }
  .deadline-row.dl-row-1  td:first-child { border-left-color: var(--warn-1); }
  .deadline-row.dl-row-overdue td:first-child { border-left-color: #111827; }
  .deadline-row.dl-row-pending td:first-child { border-left-color: #6b7280; }
  .deadline-row.dl-row-open td:first-child { border-left-color: var(--primary); }

  .small-muted { font-size: 11px; color: var(--text-muted); }
  .linklike { background: none; border: none; color: var(--primary); cursor: pointer; padding: 0; font-size: inherit; text-decoration: underline; }
  .linklike:hover { color: var(--primary-hover); }

  details.company { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 10px; background: var(--surface); }
  details.company > summary { padding: 12px 14px; cursor: pointer; display: flex; align-items: center; gap: 12px; font-weight: 600; list-style: none; }
  details.company > summary::-webkit-details-marker { display: none; }
  details.company > summary::before { content: "▶"; font-size: 10px; color: var(--text-muted); transition: transform .15s; }
  details.company[open] > summary::before { transform: rotate(90deg); }
  details.company .body { padding: 0 14px 14px; }

  .tag { display: inline-block; font-size: 11px; background: var(--chip-bg); color: var(--chip-text); padding: 1px 8px; border-radius: 4px; margin-left: 6px; }
  .tag.deleted { background: #fee2e2; color: #991b1b; }
  .tag.dropped { background: #fee2e2; color: #991b1b; }
  .tag.converted { background: #ecfdf5; color: #065f46; }

  .apps-table th, .apps-table td { padding: 6px 6px; font-size: 12px; }
  .apps-table input[type="date"], .apps-table select, .apps-table input[type="text"], .apps-table input[type="month"] { padding: 4px 6px; font-size: 12px; }
  .apps-table select { min-width: 70px; }

  .app-row-done td { background: #e5e7eb !important; color: #6b7280; }
  .app-row-done input, .app-row-done select { opacity: .7; }

  /* 퇴사 자동반영 — 신청불가(빨간) / 부분지급(노란) */
  .app-row-blocked td { background: #fee2e2 !important; color: #991b1b; }
  .app-row-blocked input, .app-row-blocked select { opacity: .65; }
  .app-row-partial td { background: #fef3c7 !important; }
  .app-badge { display:inline-block; font-size:10px; font-weight:600; padding:1px 6px; border-radius:10px; margin-left:6px; vertical-align: middle; }
  .app-badge-blocked { background:#dc2626; color:#fff; }
  .app-badge-partial { background:#f59e0b; color:#fff; }
  .app-amount-orig { font-size:11px; color:#9ca3af; text-decoration: line-through; margin-right:4px; }

  .status-pill.s-완료   { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
  .status-pill.s-진행중 { background: #e0f2fe; color: #075985; border-color: #bae6fd; }

  .warn-banner { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 13px; }

  /* Auth overlay */
  .auth-overlay { position: fixed; inset: 0; background: linear-gradient(135deg, #0f172a, #1e293b); color: #f1f5f9; display: none; align-items: center; justify-content: center; z-index: 9999; padding: 20px; }
  .auth-overlay.open { display: flex; }
  .auth-box { background: #fff; color: var(--text); border-radius: 14px; padding: 28px; width: 100%; max-width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,.4); }
  .auth-box h2 { margin: 0 0 6px 0; font-size: 16px; display: flex; align-items: center; gap: 6px; white-space: nowrap; letter-spacing: -0.3px; }
  .auth-box .sub { color: var(--text-muted); font-size: 13px; margin-bottom: 16px; }
  .auth-box .err { color: var(--danger); font-size: 12px; min-height: 16px; margin-top: 8px; }
  .auth-box .btn { width: 100%; padding: 10px; margin-top: 12px; }
  .auth-box .hint { font-size: 11px; color: var(--text-muted); margin-top: 10px; line-height: 1.5; }
  .auth-box .field + .field { margin-top: 10px; }
  .auth-box .switch-mode { text-align: center; margin-top: 10px; font-size: 12px; color: var(--text-muted); }
  .auth-box .switch-mode button { background: none; border: none; color: var(--primary); cursor: pointer; font-size: 12px; text-decoration: underline; }

  @media print { header, nav, .btn, .header-actions { display: none; } }

  /* ----- 서버판 추가: 좁은 화면(노트북·휴대폰) 대응 ----- */
  @media (max-width: 1640px) { .header-brand { display: none; } }
  @media (max-width: 860px) {
    header { flex-wrap: wrap; gap: 8px; padding: 10px 12px; position: static; height: auto; }
    header h1 { font-size: 16px; flex: 1 1 100%; }
    nav { order: 3; margin-left: 0; flex: 1 1 100%; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    nav button { white-space: nowrap; padding: 8px 12px; flex: 0 0 auto; }
    .header-actions { order: 2; flex: 1 1 100%; flex-wrap: wrap; }
    .header-actions .btn, .user-chip { white-space: nowrap; }
    main { padding: 12px; }
    .card { overflow-x: auto; }
    .card table { min-width: 620px; }
    .modal { padding: 14px; max-height: 94vh; }
    .auth-box { padding: 22px 18px; }
  }
