/* ===== 기본 ===== */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1f2937;
  --text-soft: #6b7280;
  --border: #e5e7eb;
  --danger: #ef4444;
  --success: #16a34a;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Noto Sans KR', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; }

.hidden { display: none !important; }

/* ===== 최상단 유틸리티 바 ===== */
.top-bar { background: #1f2a44; }
.top-bar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 7px 28px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
}
.top-link {
  color: #e2e8f0;
  font-size: 13px;
  font-weight: 500;
  padding: 2px 4px;
}
.top-link:hover { color: #fff; text-decoration: underline; }
.top-user { color: #fff; font-size: 13px; font-weight: 700; }

/* ===== 헤더 ===== */
.app-header {
  background: var(--card);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 28px;
  display: flex;
  align-items: center;
  gap: 18px;
}
/* 로고: 왼쪽 위(11시 방향) */
.brand { display: flex; align-items: center; flex: 1; text-decoration: none; }
.brand-logo-img { height: 46px; width: auto; display: block; }
.header-spacer { flex: 1; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

.admin-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-soft);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}
.admin-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* 상단 가로 메뉴 */
.tabs {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  gap: 8px;
}
.tab {
  padding: 10px 22px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  border-radius: 8px;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.tab:hover { background: var(--primary-light); color: var(--primary-dark); }
.tab.active { color: var(--primary); }
.tab.active::after {
  content: '';
  display: block;
  height: 3px;
  background: var(--primary);
  border-radius: 999px;
  margin-top: 6px;
}

/* ===== 관리자 배너 ===== */
.admin-banner {
  background: #fef3c7;
  color: #92400e;
  text-align: center;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.admin-banner button {
  background: #92400e;
  color: #fff;
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 13px;
}

/* ===== 본문 ===== */
.container { max-width: 1000px; width: 100%; margin: 0 auto; padding: 18px; flex: 1 0 auto; }
.view { display: none; animation: fade .25s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.view-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.section-title {
  font-size: 18px; font-weight: 800; margin: 26px 0 14px;
  padding-left: 12px; border-left: 4px solid var(--primary); line-height: 1.15;
}
.section-title:first-child { margin-top: 0; }
.view-head .section-title { margin: 0; }

/* 메인 환영 배너 (학교 홈페이지 스타일) */
.hero {
  background: linear-gradient(120deg, #1b2440 0%, #28365f 55%, var(--primary) 130%);
  color: #fff; border-radius: 16px; padding: 36px 32px; margin-bottom: 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 26px;
  box-shadow: 0 10px 30px rgba(27, 36, 64, .25);
}
.hero-eyebrow { font-size: 14px; font-weight: 600; opacity: .85; letter-spacing: .3px; }
.hero-title { font-size: 28px; font-weight: 900; margin: 8px 0 6px; line-height: 1.25; }
.hero-sub { font-size: 15px; opacity: .9; }
.hero-today {
  flex-shrink: 0; text-align: center; background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .2); border-radius: 14px; padding: 18px 26px;
}
.hero-date { font-size: 26px; font-weight: 900; white-space: nowrap; }
.hero-weekday { font-size: 13px; opacity: .9; margin-top: 3px; }

.add-btn {
  background: var(--primary);
  color: #fff;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
}

/* 오늘 카드 */
.today-card {
  background: linear-gradient(135deg, var(--primary), #3b82f6);
  color: #fff;
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
}
.today-date { font-size: 30px; font-weight: 900; }
.today-weekday { font-size: 16px; opacity: .9; margin-top: 2px; }

/* 카드 리스트 */
.card-list { display: flex; flex-direction: column; gap: 10px; }
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.card-accent { width: 5px; align-self: stretch; border-radius: 999px; background: var(--primary); flex-shrink: 0; }
.card-main { flex: 1; min-width: 0; }
.card-title { font-weight: 700; font-size: 15px; }
.card-sub { font-size: 13px; color: var(--text-soft); margin-top: 3px; }
.card-date-badge {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 8px;
  white-space: nowrap;
  flex-shrink: 0;
}
.card-actions { display: flex; gap: 6px; flex-shrink: 0; }
.icon-btn { font-size: 16px; padding: 4px 6px; border-radius: 8px; }
.icon-btn:hover { background: var(--bg); }

.empty {
  text-align: center;
  color: var(--text-soft);
  padding: 30px 16px;
  background: var(--card);
  border-radius: var(--radius);
  font-size: 14px;
  border: 1px dashed var(--border);
}

/* ===== 월간 달력 (일정표) ===== */
.cal-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.cal-nav {
  width: 38px; height: 38px; border-radius: 9px;
  background: var(--card); box-shadow: var(--shadow);
  font-size: 22px; color: var(--primary); font-weight: 700; line-height: 1;
}
.cal-nav:hover { background: var(--primary-light); }
.cal-title { font-size: 18px; font-weight: 800; min-width: 130px; text-align: center; }
.cal-today-btn {
  margin-left: auto; background: var(--primary-light); color: var(--primary-dark);
  font-weight: 700; padding: 9px 16px; border-radius: 9px; font-size: 14px;
}
.cal-hint { font-size: 13px; color: var(--text-soft); margin: 0 0 10px; }

.calendar { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.cal-head, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-dow {
  text-align: center; padding: 10px 0; font-weight: 700; font-size: 13px;
  color: var(--text-soft); background: #f9fafb; border-bottom: 1px solid var(--border);
}
.cal-dow.sun { color: #dc2626; }
.cal-dow.sat { color: #2563eb; }

.cal-cell {
  min-height: 98px;
  min-width: 0;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 6px; display: flex; flex-direction: column; gap: 4px;
}
.cal-cell:nth-child(7n) { border-right: none; }
.cal-cell.other { background: #fafbfc; cursor: pointer; }
.cal-cell.other .cal-date { color: #c4c9d2 !important; }
.cal-cell.other .cal-ev { opacity: .45; }
.cal-cell.other .cal-holiday { opacity: .5; }
.cal-cell.other:hover { background: #f1f3f8; }
.cal-holiday { font-size: 10px; font-weight: 700; color: #dc2626; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-date {
  align-self: flex-start; font-size: 13px; font-weight: 700;
  min-width: 22px; height: 22px; display: inline-flex;
  align-items: center; justify-content: center; border-radius: 50%;
}
.cal-date.sun { color: #dc2626; }
.cal-date.sat { color: #2563eb; }
.cal-cell.today { background: var(--primary-light); }
.cal-cell.today .cal-date { background: var(--primary); color: #fff; }
.admin-mode .cal-cell[data-day]:hover { outline: 2px solid var(--primary); outline-offset: -2px; cursor: pointer; }

.cal-events { display: flex; flex-direction: column; gap: 3px; overflow: hidden; min-width: 0; }
.cal-ev {
  background: var(--primary); color: #fff; font-size: 11px; font-weight: 600;
  padding: 2px 5px; border-radius: 4px; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-ev:hover { background: var(--primary-dark); }

/* ===== 프로그램 시간표 ===== */
.pt-subtitle {
  text-align: center; font-weight: 700; color: var(--primary-dark);
  background: var(--primary-light); padding: 11px; border-radius: 10px;
  margin: 0 0 14px; font-size: 15px;
}
.pt-table { width: 100%; border-collapse: collapse; min-width: 580px; table-layout: fixed; }
.pt-table th, .pt-table td {
  border: 1px solid #d6dae2; padding: 14px 8px;
  text-align: center; font-size: 14px; vertical-align: middle;
}
.pt-head th { background: #dde2ee; color: #2b3550; font-weight: 700; height: 44px; }
.pt-timecol { width: 132px; }
.pt-time { width: 132px; background: #f1f3f7; font-weight: 700; font-size: 13px; white-space: normal; word-break: keep-all; line-height: 1.35; }
.pt-delcol, .pt-delcell { width: 46px; }
.pt-delcell { background: #fff; }
/* 가로 스크롤 시 시간 열을 왼쪽에 고정 */
.pt-timecol, .pt-time { position: sticky; left: 0; z-index: 1; }
.pt-cell { height: 58px; font-weight: 600; word-break: break-all; position: relative; }
.pt-cell.cream { background: #fdf6d3; }
.pt-cell.purple { background: #e7e1f0; }
.pt-seg-text { line-height: 1.5; white-space: normal; }
.pt-empty { color: #9aa2b1; font-weight: 500; font-size: 12px; }
.admin-mode .pt-cell { cursor: pointer; }
.admin-mode .pt-cell:hover { outline: 2px solid var(--primary); outline-offset: -2px; }
.pt-seg-tools { display: flex; gap: 5px; justify-content: center; margin-top: 7px; }
.pt-seg-btn {
  font-size: 10px; font-weight: 700; background: rgba(0, 0, 0, .07);
  color: #4b5563; border-radius: 5px; padding: 3px 7px; white-space: nowrap;
}
.pt-seg-btn:hover { background: var(--primary); color: #fff; }

/* ===== 담당 업무 (구분별 표) ===== */
.view-head-btns { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.add-btn-alt { background: #5b21b6; }
.rot-badge { font-size: 12px; font-weight: 700; background: var(--primary); color: #fff; padding: 2px 9px; border-radius: 999px; margin-left: 6px; vertical-align: middle; }
.rot-controls { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.rot-btn { font-size: 13px; font-weight: 600; background: var(--card); border: 1px solid var(--border); padding: 7px 13px; border-radius: 8px; color: var(--text); box-shadow: var(--shadow); }
.rot-btn:hover { background: var(--primary-light); color: var(--primary-dark); }
.duty-section { margin-bottom: 24px; }
.duty-cat {
  font-size: 16px; font-weight: 800; color: var(--primary-dark);
  background: var(--primary-light); padding: 9px 14px; border-radius: 9px; margin-bottom: 10px;
}
.duty-table { width: 100%; border-collapse: collapse; min-width: 520px; }
.duty-table th, .duty-table td {
  border: 1px solid var(--border); padding: 11px 12px; font-size: 14px; vertical-align: top; text-align: left;
}
.duty-table th { background: #f1f3f7; font-weight: 700; text-align: center; }
.duty-table th.duty-day, .duty-table th.duty-person { width: 90px; }
.duty-table td.duty-day, .duty-table td.duty-person { text-align: center; white-space: nowrap; font-weight: 700; vertical-align: middle; }
.duty-table td.duty-day { background: #f3f6fc; color: var(--primary-dark); }
.duty-table td.duty-task { line-height: 1.6; }
.duty-table td.duty-detail { color: var(--text-soft); line-height: 1.6; }
.duty-table .cell-actions { white-space: nowrap; text-align: center; vertical-align: middle; }

/* ===== 표 ===== */
.table-wrap { overflow-x: auto; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.grid-table { width: 100%; border-collapse: collapse; min-width: 480px; }
.grid-table th, .grid-table td {
  border: 1px solid var(--border);
  padding: 12px 10px;
  text-align: center;
  font-size: 14px;
  vertical-align: middle;
}
.grid-table th { background: var(--primary-light); color: var(--primary-dark); font-weight: 700; }
.grid-table td.row-head { background: #f9fafb; font-weight: 700; }
.grid-table tr:nth-child(even) td:not(.row-head) { background: #fcfcfd; }
.cell-editable { cursor: text; }
.admin-mode .cell-editable:hover { background: var(--primary-light) !important; outline: 2px solid var(--primary); }
.cell-actions { white-space: nowrap; }

/* ===== 모달 ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 18px;
}
.modal {
  background: var(--card);
  border-radius: var(--radius);
  padding: 22px;
  width: 100%; max-width: 420px;
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
  max-height: 90vh; overflow-y: auto;
}
.modal h3 { font-size: 18px; margin-bottom: 16px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; color: var(--text-soft); }
.field input, .field textarea, .field select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
}
.field textarea { resize: vertical; min-height: 70px; }
.login-hint { font-size: 13px; color: var(--text-soft); background: var(--bg); padding: 10px 12px; border-radius: 8px; margin-bottom: 6px; }
/* 일정 자세히 보기(읽기 전용) */
.day-holiday { color: #dc2626; font-weight: 700; font-size: 14px; margin-bottom: 12px; }
.day-ev { padding: 12px 14px; background: var(--bg); border-radius: 10px; margin-bottom: 8px; border-left: 4px solid var(--primary); }
.day-ev-title { font-weight: 700; font-size: 15px; word-break: break-all; }
.day-ev-desc { font-size: 13px; color: var(--text-soft); margin-top: 4px; white-space: pre-wrap; word-break: break-all; }
.day-ev-period { font-size: 13px; font-weight: 700; color: var(--primary-dark); margin-top: 3px; }
/* 색상 선택 */
.color-pick { display: flex; gap: 9px; flex-wrap: wrap; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: none; padding: 0; cursor: pointer; }
.swatch.sel { outline: 3px solid #1f2937; outline-offset: 2px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }
.btn-primary { background: var(--primary); color: #fff; padding: 10px 18px; border-radius: 10px; font-weight: 700; font-size: 15px; }
.btn-ghost { background: var(--bg); color: var(--text); padding: 10px 18px; border-radius: 10px; font-weight: 500; font-size: 15px; }
.btn-danger { background: var(--danger); color: #fff; padding: 10px 18px; border-radius: 10px; font-weight: 700; font-size: 15px; margin-top: 2px; }
.btn-danger:hover { background: #dc2626; }

/* ===== 푸터 ===== */
.app-footer {
  background: #1b2440;
  color: #aab3c8;
  margin-top: 36px;
  padding: 24px 0;
  flex-shrink: 0;
}
.footer-addr { font-size: 13px; color: #8b95ad; }
.footer-inner {
  max-width: 1200px; margin: 0 auto; padding: 0 28px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.footer-brand strong { display: block; color: #fff; font-size: 15px; font-weight: 800; margin-bottom: 4px; }
.footer-brand span { display: block; font-size: 13px; color: #8b95ad; }
.footer-contact { display: flex; gap: 18px; font-size: 13px; }

/* ===== 토스트 ===== */
.toast {
  position: fixed; bottom: 70px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff;
  padding: 12px 20px; border-radius: 999px;
  font-size: 14px; font-weight: 500;
  z-index: 200; box-shadow: 0 6px 20px rgba(0,0,0,.25);
  animation: toastIn .3s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ===== 반응형 ===== */
@media (max-width: 760px) {
  .top-bar-inner { padding: 7px 14px; }
  .header-inner { flex-wrap: wrap; padding: 10px 14px; gap: 8px; }
  .brand { flex: 1 1 auto; }
  .brand-logo-img { height: 34px; }
  .header-spacer { display: none; }
  .tabs {
    order: 3;
    flex: 1 1 100%;
    justify-content: flex-start;
    gap: 2px;
    overflow-x: auto;
    border-top: 1px solid var(--border);
    padding-top: 6px;
  }
  .tab { font-size: 15px; padding: 8px 14px; }
  .tab.active::after { margin-top: 4px; }
  .container { padding: 14px; }

  /* 배너 · 푸터 모바일 */
  .hero { flex-direction: column; align-items: flex-start; padding: 24px 20px; gap: 18px; }
  .hero-title { font-size: 22px; }
  .hero-today { align-self: stretch; }
  .footer-inner { flex-direction: column; align-items: flex-start; gap: 8px; }

  /* 달력 모바일 */
  .cal-cell { min-height: 62px; padding: 3px; gap: 2px; }
  .cal-date { font-size: 12px; min-width: 18px; height: 18px; }
  .cal-dow { font-size: 11px; padding: 7px 0; }
  .cal-ev { font-size: 9px; padding: 1px 3px; border-radius: 3px; }
  .cal-holiday { font-size: 8px; }
  .cal-title { font-size: 16px; min-width: 100px; }
}
