/* 스터디카페 관리 웹 — 스터디마스터 앱(1.14) 화면에 맞춘 스타일.
   앱 기준 색: 주색 #659CFF, 배경 #fafafc, 사용중 rgb(154,119,97), 사용불가 rgb(255,218,68), 선택 상자 #dedee0
   앱과 같이 밝은 화면 하나만 쓴다 (기기 어두운 모드에서도 같은 색) */
:root {
  --main: #659cff; --main-dark: #4f86ea; --main-soft: #e8f0ff;
  --bg: #fafafc; --paper: #ffffff; --fg: #000000; --text: #464646; --muted: #8a8a8e; --line: #e2e2e6; --frame: #000000;
  --inuse: rgb(154, 119, 97); --inuse-soft: #efe6e0; --broken: rgb(255, 218, 68); --broken-soft: #fff6d6;
  --picker: #dedee0; --btn: #e1e1e3; --bad: #d83a2f;
  --shadow: 0 4px 18px rgba(80, 90, 120, .18);
  --font: "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", Roboto, system-ui, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font: 15px/1.45 var(--font); -webkit-text-size-adjust: 100%; min-height: 100vh; }
body.home-bg { background: var(--bg) url(img/main_background.png) center top / cover no-repeat fixed; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--main); outline-offset: 2px; }

/* 상단 바 (앱 NavigationPage: #659CFF, 흰 글자) */
.bar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 6px;
  min-height: 56px; padding: env(safe-area-inset-top, 0px) max(8px, env(safe-area-inset-right, 0px)) 0 max(8px, env(safe-area-inset-left, 0px));
  background: var(--main); color: #fff;
}
.bar h1 { flex: 1; margin: 0; font-size: 20px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 6px; }
.bar h1 img { width: 25px; height: 25px; object-fit: contain; }
.bar h1 b { font-weight: 700; }
.bar button { background: none; border: 0; color: inherit; min-width: 44px; height: 44px; font-size: 16px; cursor: pointer; border-radius: 6px; }
.bar .bar-back { font-size: 24px; }
.bar button:active { background: rgba(255, 255, 255, .18); }

.view {
  max-width: 820px; margin: 0 auto;
  padding: 10px max(10px, env(safe-area-inset-right, 0px)) calc(40px + env(safe-area-inset-bottom, 0px)) max(10px, env(safe-area-inset-left, 0px));
  display: flex; flex-direction: column; gap: 10px;
}

/* 공통 */
.card { background: var(--paper); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 12px 14px; margin: 0 -10px; }
.sec { color: var(--main); font-size: 18px; margin: 6px 4px 0; font-weight: 500; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; padding: 0 16px;
  border-radius: 3px; border: 0; background: var(--btn); color: var(--fg); cursor: pointer; font-weight: 500;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .2); text-transform: none;
}
.btn.primary { background: var(--main); color: #fff; font-weight: 700; }
.btn.danger { color: var(--bad); }
.btn.block { width: 100%; }
.btn:disabled { color: #a8a8aa; box-shadow: none; cursor: default; }
.btn:not(:disabled):active { filter: brightness(.94); }
.btns { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
input[type=text], input[type=tel], input[type=password], input[type=number], input[type=date], input[type=time], input[type=search], select, textarea {
  width: 100%; min-height: 44px; padding: 8px 10px; border: 0; border-bottom: 1px solid #9a9a9e; border-radius: 0; background: var(--paper); color: var(--fg);
}
input:focus, select:focus, textarea:focus { outline: none; border-bottom: 2px solid var(--main); }
textarea { min-height: 70px; resize: vertical; border: 1px solid var(--line); }
select { background: var(--picker); border: 0; border-radius: 0; }
label.field { display: flex; flex-direction: column; gap: 2px; font-size: 14px; color: var(--text); }
label.field > input, label.field > select, label.field > textarea { font-size: 16px; }
.check { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; cursor: pointer; color: var(--fg); }
.check input { width: 20px; height: 20px; accent-color: var(--main); }
/* 앱의 스위치 행 */
.switch-row { display: flex; align-items: center; justify-content: space-between; min-height: 48px; border-bottom: 1px solid var(--line); }
.switch-row:last-child { border-bottom: 0; }
.switch-row input { appearance: none; -webkit-appearance: none; width: 40px; height: 20px; border-radius: 10px; background: #b9b9bd; position: relative; cursor: pointer; margin: 0; }
.switch-row input::after { content: ""; position: absolute; top: -3px; left: -2px; width: 26px; height: 26px; border-radius: 50%; background: #f1f1f1; box-shadow: 0 1px 3px rgba(0, 0, 0, .4); transition: left .15s; }
.switch-row input:checked { background: #a9c6ff; }
.switch-row input:checked::after { left: 16px; background: var(--main); }
/* 앱 라디오(분/시간/일) 대신 쓰는 단추 묶음 */
.seg { display: inline-flex; border: 1px solid var(--main); border-radius: 4px; overflow: hidden; background: var(--paper); }
.seg button { border: 0; background: none; padding: 0 12px; min-height: 36px; cursor: pointer; color: var(--main); }
.seg button + button { border-left: 1px solid var(--main); }
.seg button[aria-pressed=true] { background: var(--main); color: #fff; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.pill.inuse { background: var(--inuse); color: #fff; }
.pill.broken { background: var(--broken); color: #000; }
.pill.free { background: var(--picker); color: #000; }
.pill.bad { background: var(--bad); color: #fff; }
.pill.blue { background: var(--main); color: #fff; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 16px; }
.kv dt { color: var(--text); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.empty { text-align: center; padding: 28px 8px; color: var(--muted); }
.loading { text-align: center; padding: 28px; color: var(--muted); }

/* 로그인 (앱 LoginPage: 로고 150, 흰 입력칸, 파란 로그인 단추) */
.login { max-width: 400px; margin: 4vh auto 0; width: 100%; display: flex; flex-direction: column; gap: 12px; padding: 0 10px; }
.login .logo { height: 150px; object-fit: contain; }
.login input[type=text], .login input[type=password] { font-size: 16px; }
.login .note { text-align: center; color: var(--main); font-size: 14px; }

/* 홈 (앱 MainPage) */
.hello { text-align: center; color: var(--text); padding: 22px 0 18px; }
.hello div { font-size: 15px; }
.hello b { display: block; font-size: 17px; margin-top: 4px; }
.status { position: relative; width: 100%; max-width: 520px; margin: 0 auto; aspect-ratio: 1000 / 230; }
.status img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 6px 14px rgba(90, 120, 190, .12)); }
.status button { position: absolute; top: 33%; height: 50%; width: 50%; border: 0; background: none; color: #414141; font-size: 22px; cursor: pointer; font-variant-numeric: tabular-nums; }
.status button b { font-weight: 700; }
.status .l { left: 2%; }
.status .r { left: 48%; }
.img-menu { display: grid; grid-template-columns: 1fr 1fr; gap: 0 4px; max-width: 520px; margin: 6px auto 0; width: 100%; }
.img-menu button { border: 0; background: none; padding: 0; cursor: pointer; height: 120px; display: flex; align-items: center; justify-content: center; }
.img-menu button img { max-width: 100%; max-height: 120px; object-fit: contain; }
.img-menu button:active img { transform: scale(1.05); }

/* 좌석·사물함 판 (앱 Board: 흰 테두리 상자, 상태색 안쪽 칸, 2열) */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; padding: 4px 8px; }
@media (min-width: 640px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile { border: 1px solid var(--frame); border-radius: 5px; background: var(--paper); padding: 5px; cursor: pointer; min-height: 104px; display: flex; min-width: 0; }
.tile .in { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: #000; font-size: 15px; line-height: 1.35; min-width: 0; padding: 2px; }
.tile .in span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile.s1 .in { background: var(--inuse); color: #fff; }
.tile.s2 .in { background: var(--broken); }
.tile.hit { box-shadow: 0 0 0 3px var(--main); }
.tile.dim { opacity: .35; }
.legend { display: flex; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--text); padding: 0 8px; }
.board-top { background: var(--paper); margin: -10px -10px 0; padding: 10px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.cat-row { display: flex; align-items: center; justify-content: center; gap: 12px; }
.cat-row label { color: #000; }
.cat-row select { width: auto; min-width: 140px; font-size: 18px; text-align: center; }

/* 검색 (앱: 회색 선택 상자 + 흰 입력칸) */
.search { display: flex; gap: 0; align-items: stretch; }
.search select { width: auto; flex: none; padding: 0 10px; min-height: 44px; }
.search input { flex: 1; min-width: 0; }

/* 배치도 */
.map-wrap { overflow: auto; border: 1px solid var(--line); background: var(--paper); max-height: 72vh; touch-action: pan-x pan-y; margin: 0 -10px; }
.map { position: relative; }
.map img.bgimg { position: absolute; left: 0; top: 0; width: 100%; height: 100%; object-fit: fill; pointer-events: none; }
.map .spot {
  position: absolute; border: 1px solid rgba(0, 0, 0, .39); background: #fff; color: #000; padding: 1px;
  font-size: 11px; line-height: 1.15; overflow: hidden; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
}
.map .spot.s1 { background: var(--inuse); color: #fff; }
.map .spot.s2 { background: var(--broken); }
.map .spot.dim { opacity: .35; }

/* 회원 목록 (앱 ListView: 흰 바탕, 왼쪽 상태색 막대) */
.list { display: flex; flex-direction: column; background: var(--paper); margin: 0 -10px; border-top: 1px solid var(--line); }
.list button.item { display: flex; gap: 10px; align-items: stretch; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: none; padding: 6px 12px 6px 0; cursor: pointer; width: 100%; color: #000; }
.list .item .bar-c { width: 8px; flex: none; background: var(--paper); }
.list .item.inuse .bar-c { background: var(--inuse); }
.list .item .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.list .item .t1 { font-size: 17px; }
.list .item .t2 { font-size: 15px; font-variant-numeric: tabular-nums; }
.list .item .side { text-align: right; font-size: 15px; display: flex; flex-direction: column; justify-content: center; }
.counts-line { font-size: 17px; color: #000; padding: 0 4px; }

/* 룸 예약표 (앱: 시간 | 룸 격자, 칸에 예약 번호) */
.room-grid { overflow: auto; max-height: 72vh; border: 1px solid rgba(0, 0, 0, .39); background: #fff; }
.room-grid table { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; font-size: 14px; }
.room-grid th, .room-grid td { border-right: 1px solid rgba(0, 0, 0, .39); border-bottom: 1px solid rgba(0, 0, 0, .39); padding: 0; height: 50px; }
.room-grid thead th { position: sticky; top: 0; background: #fff; z-index: 2; padding: 6px 10px; min-width: 100px; font-weight: 500; color: #000; }
.room-grid th.tm { position: sticky; left: 0; background: #fff; z-index: 1; padding: 0 8px; font-weight: 400; white-space: nowrap; font-variant-numeric: tabular-nums; color: #000; }
.room-grid thead th.tm { z-index: 3; }
.room-grid td button { width: 100%; height: 100%; border: 0; background: none; cursor: pointer; padding: 2px 6px; font-size: 13px; text-align: center; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: #000; }
.room-grid td.bk button { background: var(--main-soft); color: #1d4fb5; font-weight: 500; }
.room-grid td.broken button { background: var(--broken); }
.room-grid tr.past th.tm { color: var(--muted); }

/* 기록 (앱 LogMainPage: 탭 글자, 선택 시 파란 바탕) */
.tabs { display: flex; gap: 0; overflow-x: auto; background: #fff; margin: -10px -10px 0; border-bottom: 1px solid var(--line); }
.tabs button { flex: none; border: 0; background: none; padding: 12px 14px; cursor: pointer; white-space: nowrap; color: #000; }
.tabs button[aria-pressed=true] { background: var(--main); color: #fff; }
.tbl { overflow-x: auto; border: 1px solid rgba(0, 0, 0, .39); background: #fff; margin: 0 -10px; }
.tbl table { border-collapse: collapse; width: 100%; font-size: 14px; }
.tbl th, .tbl td { padding: 8px 10px; border: 1px solid rgba(0, 0, 0, .2); text-align: center; white-space: nowrap; font-variant-numeric: tabular-nums; color: #000; }
.tbl th { background: #f0f0f2; font-weight: 500; position: sticky; top: 0; }
.tbl tr.cancel td { color: var(--bad); }

/* 시트·대화상자 (앱 상세 화면 대신 아래에서 올라오는 창) */
.dim-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--bg); width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; border-radius: 12px 12px 0 0; box-shadow: var(--shadow);
  padding: 0 max(10px, env(safe-area-inset-right, 0px)) calc(18px + env(safe-area-inset-bottom, 0px)) max(10px, env(safe-area-inset-left, 0px));
  display: flex; flex-direction: column; gap: 10px;
}
.sheet .sh { position: sticky; top: 0; background: var(--main); color: #fff; display: flex; align-items: center; gap: 8px; padding: 0 6px 0 14px; min-height: 52px; z-index: 1; margin: 0 -10px; }
.sheet .sh h3 { flex: 1; margin: 0; font-size: 18px; font-weight: 500; }
.sheet .sh button { border: 0; background: none; font-size: 20px; width: 44px; height: 44px; cursor: pointer; color: #fff; }
.sheet .card { margin: 0 -10px; }
.sheet.full { max-width: 820px; height: 92vh; }
@media (min-width: 700px) {
  .dim-bg { align-items: center; }
  .sheet { border-radius: 10px; max-height: 88vh; }
  .sheet .sh { border-radius: 10px 10px 0 0; }
  .sheet.full { height: 88vh; }
}
.dialog { background: #fff; border-radius: 4px; max-width: 340px; width: calc(100% - 48px); margin: auto; padding: 22px 22px 10px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 18px; align-self: center; }
.dialog p { margin: 0; white-space: pre-line; font-size: 16px; color: #000; }
.dialog .btns { display: flex; justify-content: flex-end; gap: 4px; }
.dialog .btn { background: none; box-shadow: none; color: var(--main); font-weight: 700; min-height: 40px; padding: 0 12px; }
.toast { position: fixed; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: #323232; color: #fff; padding: 10px 18px; border-radius: 20px; z-index: 60; box-shadow: var(--shadow); max-width: calc(100% - 32px); white-space: pre-line; }
.choice { display: flex; flex-direction: column; background: #fff; margin: 0 -10px; }
.choice button { text-align: left; min-height: 56px; padding: 8px 18px; border: 0; border-bottom: 1px solid var(--line); background: none; cursor: pointer; color: #000; }
.choice button b { display: block; font-weight: 500; font-size: 16px; }
.choice button span { font-size: 14px; color: var(--text); }
.ticket { border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.ticket h4 { margin: 0; font-size: 16px; font-weight: 500; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.ticket h4 span { font-weight: 400; color: var(--text); font-size: 15px; font-variant-numeric: tabular-nums; }
.add { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; }
.add .btn { min-width: 80px; }
.vt { display: grid; grid-template-columns: 1fr auto 1fr; gap: 6px; align-items: center; }
