:root {
  --primary: #1F3864;
  --primary-light: #DEEAF6;
  --accent: #C00000;
  --gray: #666;
  --light: #F7F9FC;
  --border: #DDD;
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, "Malgun Gothic", "맑은 고딕", "Segoe UI", sans-serif;
  margin: 0; padding: 0;
  background: var(--light);
  color: #222;
  font-size: 14px;
}

.topbar {
  background: var(--primary);
  color: white;
  padding: 12px 20px;
  display: flex; gap: 16px; align-items: center;
}
.brand { color: white; text-decoration: none; font-weight: 700; font-size: 16px; }
.brand-co { color: #cfe; font-weight: 400; font-size: 12px; margin-left: 4px; }
.crumbs a { color: #cfe; text-decoration: none; margin-right: 8px; }

.container { max-width: 1100px; margin: 20px auto; padding: 0 16px; }
.card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px 24px;
  margin-bottom: 20px;
}
.card.wide { max-width: none; }

h1 { margin: 0 0 16px; font-size: 22px; color: var(--primary); }
h1 small { color: var(--gray); font-weight: 400; font-size: 14px; }
h3 { margin-top: 24px; color: var(--primary); border-bottom: 1px solid var(--primary-light); padding-bottom: 6px; }
h4 { margin: 12px 0 4px; }

.actions { display: flex; gap: 10px; margin: 12px 0; flex-wrap: wrap; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
input[type=text], input[type=number], input[type=date] {
  padding: 6px 8px; border: 1px solid var(--border); border-radius: 4px;
  font-size: 13px; font-family: inherit;
  min-width: 90px;
}
input:focus { outline: 2px solid var(--primary); border-color: var(--primary); }

.btn {
  display: inline-block; padding: 6px 12px;
  background: white; color: var(--primary);
  border: 1px solid var(--primary); border-radius: 4px;
  text-decoration: none; cursor: pointer; font-family: inherit; font-size: 13px;
}
.btn:hover { background: var(--primary-light); }
.btn.primary { background: var(--primary); color: white; }
.btn.primary:hover { background: #15294a; }
.btn.danger { color: var(--accent); border-color: var(--accent); }
.btn.danger:hover { background: #fee; }
.btn.small { padding: 3px 8px; font-size: 12px; }

fieldset {
  border: 1px solid var(--border);
  border-radius: 6px;
  margin: 16px 0; padding: 12px 16px;
}
legend { padding: 0 6px; color: var(--primary); font-weight: 600; }

.table-wrap { overflow-x: auto; }
table.data {
  border-collapse: collapse; width: 100%;
  font-size: 13px;
}
table.data th, table.data td {
  border: 1px solid var(--border);
  padding: 6px 8px;
  text-align: left;
}
table.data th {
  background: var(--primary); color: white;
  text-align: center; font-weight: 600;
}
table.data tbody tr:nth-child(even) { background: #fafafa; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data.compact th, table.data.compact td { padding: 4px 6px; font-size: 12px; text-align: center; }

/* ===== 엑셀 스타일 입력 표 ===== */
table.input-table {
  border-collapse: separate;
  border-spacing: 0;
  background: #fff;
  font-family: 'Apple SD Gothic Neo', 'Malgun Gothic', 'Segoe UI', system-ui, sans-serif;
}
/* 헤더 — 엑셀의 열 머리글처럼 회색 */
table.input-table thead th {
  background: #f0f0f0;
  color: #333;
  font-weight: 600;
  font-size: 12px;
  text-align: center;
  border: 1px solid #b0b0b0;
  padding: 6px 8px;
  position: sticky;
  top: 0;
  z-index: 2;
}
/* 셀 — 얇은 회색 격자 */
table.input-table tbody td {
  border: 1px solid #d4d4d4;
  padding: 0;
  position: relative;
  background: #fff;
  vertical-align: middle;
}
table.input-table tbody tr {
  background: #fff;
}
table.input-table tbody tr:nth-child(even) {
  background: #fff;  /* 엑셀 기본은 줄무늬 없음 */
}
/* 행 번호 셀 (왼쪽 첫 열) — 엑셀의 행 머리글 */
table.input-table tbody td:first-child {
  background: #f0f0f0;
  color: #777;
  text-align: center;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 8px;
  width: 32px;
  border-right: 1px solid #b0b0b0;
}
/* 마지막 열 (삭제 버튼) */
table.input-table tbody td:last-child {
  background: #f0f0f0;
  text-align: center;
  padding: 2px;
  border-left: 1px solid #b0b0b0;
}
/* input — 셀 내부에 꽉 차게, 테두리 제거해서 셀 자체가 입력되는 느낌 */
table.input-table tbody input {
  border: none;
  outline: none;
  width: 100%;
  min-width: 80px;
  padding: 6px 8px;
  background: transparent;
  font-size: 13px;
  font-family: inherit;
  box-sizing: border-box;
}
table.input-table tbody input[type="number"] {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
/* 포커스 — 엑셀의 활성 셀처럼 진한 초록 박스 */
table.input-table tbody input:focus {
  outline: 2px solid #107c41;
  outline-offset: -2px;
  background: #fff;
  position: relative;
  z-index: 1;
}
/* hover */
table.input-table tbody tr:hover td:not(:first-child):not(:last-child) {
  background: #f5fafd;
}
table.input-table tbody tr:hover input {
  background: transparent;
}
/* 삭제 버튼 톤다운 */
table.input-table tbody .remove-row {
  font-size: 11px;
  padding: 2px 6px;
  background: transparent;
  color: #999;
  border: 1px solid transparent;
}
table.input-table tbody .remove-row:hover {
  color: #c33;
  border-color: #c33;
  background: #fff;
}

.flash-zone { max-width: 1100px; margin: 12px auto 0; padding: 0 16px; }
.flash {
  padding: 10px 14px; border-radius: 4px; margin-bottom: 8px;
  border-left: 4px solid;
}
.flash-ok { background: #eaf5ea; border-color: #4a4; }
.flash-error { background: #fde9e9; border-color: #c33; }

.muted { color: var(--gray); font-size: 13px; }
.chart { max-width: 100%; height: auto; border: 1px solid var(--border); border-radius: 6px; background: white; }

.month-list, .doctor-list { list-style: none; padding: 0; display: flex; gap: 8px; flex-wrap: wrap; }
.month-list li a, .doctor-list li a {
  display: block; padding: 8px 16px;
  background: var(--primary-light); color: var(--primary);
  border-radius: 4px; text-decoration: none;
}
.month-list li a:hover, .doctor-list li a:hover { background: var(--primary); color: white; }

.comments { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 700px) { .comments { grid-template-columns: 1fr; } }
.comments h4 { color: var(--primary); }

.footer {
  text-align: center; color: var(--gray); font-size: 12px;
  padding: 20px 0;
}

.paste-box {
  background: var(--primary-light);
  border: 1px dashed var(--primary);
  border-radius: 6px;
  padding: 10px 14px;
  margin: 0 0 14px;
}
.paste-box summary {
  cursor: pointer; font-weight: 600; color: var(--primary);
  user-select: none;
}
.paste-box textarea {
  width: 100%; min-height: 80px;
  padding: 8px;
  border: 1px solid var(--border); border-radius: 4px;
  font-family: Consolas, "맑은 고딕", monospace; font-size: 13px;
}

.sortable th { cursor: pointer; }
.sortable th:hover { background: #15294a; }
.sortable th.sort-asc::after  { content: " ▲"; font-size: 10px; }
.sortable th.sort-desc::after { content: " ▼"; font-size: 10px; }

.swot-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 10px 0 20px;
}
@media (max-width: 800px) { .swot-grid { grid-template-columns: 1fr; } }
.swot-cell {
  border-radius: 8px;
  padding: 12px 16px;
  border: 1px solid var(--border);
}
.swot-cell h4 { margin: 0 0 8px; }
.swot-cell ul { margin: 0; padding-left: 18px; }
.swot-cell li { margin: 4px 0; line-height: 1.5; }
.swot-s { background: #eaf5ea; border-color: #4a4; }
.swot-w { background: #fde9e9; border-color: #c33; }
.swot-o { background: #eaf0fa; border-color: #58a; }
.swot-t { background: #fff7e6; border-color: #d88; }

.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
  margin: 10px 0 20px;
}
.status-cell {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: white;
}
.status-cell.done    { background: #eaf5ea; border-color: #4a4; }
.status-cell.pending { background: #fff7e6; border-color: #d88; }
.status-cell.self    { box-shadow: 0 0 0 2px var(--primary); }
.status-cell .mark { font-size: 18px; }
.status-cell .name { font-weight: 600; }

.admin-nav { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 16px; }
.admin-nav a {
  padding: 6px 12px;
  border: 1px solid var(--primary);
  border-radius: 4px;
  text-decoration: none;
  color: var(--primary);
  background: white;
}
.admin-nav a.active { background: var(--primary); color: white; }
.admin-nav a:hover  { background: var(--primary-light); }
