:root {
  --bg: #f6f4f0;
  --surface: #ffffff;
  --ink: #1d1b19;
  --muted: #7b756d;
  --line: #e4dfd7;
  --accent: #1d1b19;
  --accent-ink: #ffffff;
  --danger: #b3261e;
  --danger-bg: #fdeceb;
  --warn-bg: #fff6dc;
  --ok: #2e7d4f;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 6px 20px rgba(0, 0, 0, .05);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", "Malgun Gothic", sans-serif;
}
a { color: inherit; }
h1, h2, h3, p { margin: 0; }

/* ── 버튼 ─────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: #cfc8bd; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--danger); border-color: #ecc4c0; }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.small { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn.big { min-height: 50px; width: 100%; font-size: 16px; }
.btn.ghost { border-color: transparent; background: transparent; }

/* ── 상단 바 ───────────────────────────── */
#topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: rgba(246, 244, 240, .92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; letter-spacing: .14em; text-decoration: none; }
.page-title { color: var(--muted); font-weight: 600; white-space: nowrap; }
.spacer { flex: 1; }
.who { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 32vw; }
.who small { margin-left: 6px; padding: 2px 7px; border-radius: 99px; background: var(--line); font-size: 11px; }
#sync { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; white-space: nowrap; }
#sync i { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
#sync[data-state="saving"] i { background: #d99a00; }
#sync[data-state="offline"] i { background: var(--danger); }
@media (max-width: 720px) {
  #sync .sync-text { display: none; }
  #sync[data-state="offline"] .sync-text { display: inline; }
  .page-title { display: none; }
}

/* ── 로그인/안내 화면 ───────────────────── */
#gate { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
#topbar:not([hidden]) ~ #gate { min-height: calc(100dvh - 70px); }
.gate-card {
  width: 100%; max-width: 380px; padding: 32px 24px;
  background: var(--surface); border-radius: 20px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 14px; text-align: center;
}
.logo { font-size: 28px; font-weight: 800; letter-spacing: .2em; }
.gate-sub { color: var(--muted); margin-top: -10px; }
.gate-hint { color: var(--muted); font-size: 13px; }
.notice { padding: 12px 14px; border-radius: 10px; font-size: 14px; text-align: left; overflow-wrap: anywhere; }
.notice.warn { background: var(--warn-bg); }
.notice.error { background: var(--danger-bg); color: var(--danger); }

/* ── 본문 ─────────────────────────────── */
#main { max-width: 1200px; margin: 0 auto; padding: 16px 16px 80px; }

/* 첫 화면(업무 도구 목록) */
.tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-top: 16px; }
.tool {
  display: block; padding: 22px; border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow); text-decoration: none;
}
.tool h2 { font-size: 17px; }
.tool p { color: var(--muted); font-size: 13px; margin-top: 4px; }
.tool .path { display: inline-block; margin-top: 12px; font-size: 12px; color: var(--muted); }
.section-title { font-size: 13px; color: var(--muted); font-weight: 700; margin-top: 8px; }

/* ── 입력 ─────────────────────────────── */
input, select, textarea {
  width: 100%; min-height: 42px; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: 16px; /* 아이폰에서 입력 시 화면이 확대되지 않도록 16px */
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid #8a8378; outline-offset: 1px; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
label.field > span b { color: var(--danger); }

/* ── 알림 ─────────────────────────────── */
#toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 100;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: calc(100vw - 32px); padding: 11px 18px; border-radius: 99px;
  background: #1d1b19; color: #fff; font-size: 14px; font-weight: 600;
  transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: var(--danger); border-radius: 14px; }

/* ── 창(dialog) 공통 ───────────────────── */
dialog {
  border: 0; padding: 0; color: var(--ink);
  background: var(--surface); border-radius: 18px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
}
dialog::backdrop { background: rgba(29, 27, 25, .45); }

/* ── 표(직원 관리) ─────────────────────── */
.panel { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-top: 16px; }
.panel h2 { font-size: 16px; margin-bottom: 12px; }
.row-list { display: flex; flex-direction: column; }
.row-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.row-item:first-child { border-top: 0; }
.row-item .grow { flex: 1; min-width: 0; }
.row-item .grow b { display: block; }
.row-item .grow span { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 700; background: var(--line); white-space: nowrap; }
.form-row { display: grid; grid-template-columns: 1.4fr 1fr auto; gap: 10px; align-items: end; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }

/* 직원별 사용 도구 체크 */
.tool-checks { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-top: 8px; }
.tool-checks-label { color: var(--muted); font-size: 13px; font-weight: 700; }
.tool-checks .check { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 600; color: var(--ink); cursor: pointer; }
.tool-checks .check input { width: 18px; height: 18px; min-height: 0; padding: 0; }
.row-item.member { align-items: flex-start; }
