* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; font-family: 'Malgun Gothic', '맑은 고딕', sans-serif; }
.hidden { display: none !important; }

/* 로그인 */
.login { position: fixed; inset: 0; background: #f2f4f7; display: flex; align-items: center; justify-content: center; z-index: 100; }
.login-box { background: #fff; padding: 36px 44px; border-radius: 10px; box-shadow: 0 4px 20px rgba(0,0,0,.1); text-align: center; }
.login-box h2 { margin: 0 0 18px; }
.login-box input { display: block; width: 220px; padding: 10px; font-size: 16px; border: 1px solid #ccc; border-radius: 6px; margin-bottom: 12px; }
.login-box button { width: 220px; padding: 10px; font-size: 15px; border: 0; border-radius: 6px; background: #2b6cb0; color: #fff; cursor: pointer; }
.login-msg { color: #d33; margin-top: 10px; min-height: 1.2em; font-size: 13px; }

/* 상단 */
#main { display: flex; flex-direction: column; height: 100vh; }
header { display: flex; align-items: center; gap: 16px; padding: 6px 10px; background: #1f2937; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; }
.tabs button { padding: 7px 16px; font-size: 14px; border: 0; border-radius: 6px 6px 0 0; background: #4b5563; color: #e5e7eb; cursor: pointer; }
.tabs button.active { background: #217346; color: #fff; font-weight: bold; }
.toolbar { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.toolbar input { padding: 6px 10px; border: 1px solid #9ca3af; border-radius: 6px; width: 130px; }
.toolbar button { padding: 6px 12px; border: 0; border-radius: 6px; background: #374151; color: #fff; cursor: pointer; }
.toolbar button:hover { background: #4b5563; }
.save-state { color: #9ae6b4; font-size: 12px; min-width: 60px; }

#sheetTitleWrap { padding: 4px 10px; background: #e8f0e8; border-bottom: 1px solid #c6d8c6; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.legend { font-size: 12px; color: #3a5a3a; }
.legend b { color: #1a4a1a; }
.toolbar button.on { background: #217346; }
#sheetTitle { font-size: 15px; font-weight: bold; border: 1px solid transparent; background: transparent; padding: 3px 6px; width: 300px; }
#sheetTitle:focus { border-color: #217346; background: #fff; outline: none; }

/* 그리드 — 엑셀 모양 */
.grid-wrap { flex: 1; overflow: auto; background: #e6e6e6; }
table.grid { border-collapse: separate; border-spacing: 0; background: #fff; }
table.grid th, table.grid td {
  border-right: 1px solid #c0c0c0; border-bottom: 1px solid #c0c0c0;
  padding: 2px 4px; font-size: 12px; vertical-align: top;
  white-space: pre-wrap; word-break: break-all; line-height: 1.35;
}
table.grid th {
  background: #217346; color: #fff; font-weight: normal; text-align: center;
  position: sticky; top: 0; z-index: 5; white-space: nowrap;
}
table.grid td.rowhead { text-align: center; vertical-align: middle; background: #f3f3f3; font-weight: bold; }
/* 학생 구분: 짝 아래쪽 진한 선 */
tr.pair-bottom td { border-bottom: 2px solid #666; }
/* 고정: No, 성명 */
table.grid th.sticky1, table.grid td.sticky1 { position: sticky; left: 0; z-index: 6; }
table.grid th.sticky2, table.grid td.sticky2 { position: sticky; z-index: 6; }
table.grid td.sticky1, table.grid td.sticky2 { background: #f8f8f8; }
table.grid th.sticky1, table.grid th.sticky2 { z-index: 7; }
/* 이번 달 강조 */
table.grid th.curmonth { background: #f0a500; color: #222; font-weight: bold; }
table.grid td.curcol { background: #fffbe6; }
table.grid td.editable { cursor: cell; }
table.grid td.editable:hover { outline: 2px solid #21734688; outline-offset: -2px; }
td .delbtn { display: none; border: 0; background: #fee; color: #c00; border-radius: 4px; cursor: pointer; font-size: 10px; margin-top: 2px; }
td.rowhead:hover .delbtn { display: inline-block; }

/* 셀 편집 팝업 */
.editor-pop { position: absolute; z-index: 50; background: #fff; border: 2px solid #217346; border-radius: 6px; box-shadow: 0 6px 24px rgba(0,0,0,.25); padding: 6px; width: 280px; }
.editor-pop textarea { width: 100%; font-size: 13px; font-family: inherit; border: 1px solid #ccc; border-radius: 4px; padding: 4px; resize: vertical; }
.editor-tools { display: flex; align-items: center; gap: 3px; margin-top: 4px; flex-wrap: wrap; }
.editor-tools .lbl { font-size: 11px; color: #555; margin: 0 2px; }
.editor-tools button { width: 26px; height: 24px; border: 1px solid #bbb; border-radius: 4px; background: #fff; cursor: pointer; font-size: 12px; }
.editor-tools button.sel { border: 2px solid #217346; }
.editor-tools .spacer { flex: 1; }
.editor-tools #editorSave { width: auto; padding: 0 10px; background: #217346; color: #fff; border: 0; }
.editor-tools #editorCancel { width: auto; padding: 0 8px; }
.editor-hint { font-size: 10px; color: #888; margin-top: 3px; }
