:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --ink: #1b2430;
  --muted: #5a6574;
  --line: #e1e6ed;
  --brand: #1f3a5f;
  --brand-ink: #ffffff;
  --accent: #2563d0;
  --due: #b45f0a;
  --overdue: #c42f2f;
  --inspection: #1f7d4b;
  --manual: #2563d0;
  --plan: #0e7490;
  --cond: #c42f2f;
  --late: #2b2f36;
  --note: #6d43bf;
  --today: #fff6e0;
  --sel: #e8f0fd;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c; --surface: #1b2129; --ink: #e6ebf1; --muted: #93a0b0; --line: #2b333e;
    --brand: #16283f; --today: #2d2717; --sel: #1d2c44; color-scheme: dark;
    --accent: #7aa7ff; --manual: #7aa7ff; --overdue: #ff8080; --due: #f2a654;
    --inspection: #5cc993; --note: #b896f2; --plan: #4fc3d9; --cond: #ff8080; --late: #d5dbe3;
  }
  .btn.primary, .ev-kind, .note-badge { color: #0d1420 !important; }
}
.dot.plan { background: var(--plan); }
.chip.plan { color: var(--plan); }
.event.plan .ev-kind { background: var(--plan); }
.findings {
  margin-top: 8px; padding: 8px 10px; border-radius: 8px; font-size: 13px;
  background: color-mix(in srgb, var(--overdue) 7%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--overdue) 30%, var(--line));
}
.f-head { font-weight: 600; color: var(--overdue); }
.f-head b { font-weight: 700; }
.f-sub { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.findings ul { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 6px; }
.findings li { display: flex; gap: 6px; align-items: flex-start; }
.f-type { flex: none; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 4px; color: #fff; background: var(--overdue); }
.f-type.advice { background: var(--due); }
.f-text { display: grid; gap: 2px; }
.f-op, .f-art { color: var(--muted); font-size: 12px; }
.f-std { white-space: pre-wrap; color: var(--muted); font-size: 12px; margin-top: 4px; }
.findings summary { cursor: pointer; color: var(--accent); font-size: 12px; }
@media (prefers-color-scheme: dark) { .f-type { color: #0d1420; } }
.center-box {border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: grid; gap: 10px; margin: 0; }
.center-box legend { font-weight: 700; padding: 0 6px; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Pretendard", "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.45;
}
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 20px; background: var(--brand); color: var(--brand-ink);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 17px; margin: 0; font-weight: 700; letter-spacing: -0.01em; }
.top-actions { display: flex; gap: 6px; }
.topbar .btn.ghost { color: var(--brand-ink); border-color: rgba(255,255,255,.3); }
.topbar .btn.ghost:hover { background: rgba(255,255,255,.12); }

/* buttons */
.btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 8px;
  padding: 7px 12px; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.danger { color: var(--overdue); }
.icon-btn {
  border: 0; background: transparent; cursor: pointer; font-size: 22px; line-height: 1;
  width: 34px; height: 34px; border-radius: 8px;
}
.icon-btn:hover { background: var(--line); }

/* layout */
.layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px;
  padding: 16px 20px 40px; max-width: 1400px; margin: 0 auto;
}
@media (max-width: 960px) { .layout { grid-template-columns: 1fr; padding: 12px 12px 40px; } }

.cal-wrap, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.cal-wrap { padding: 14px; }
.cal-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.cal-head h2 { margin: 0 4px; font-size: 26px; min-width: 120px; text-align: center; font-variant-numeric: tabular-nums; }
.legend { margin-left: auto; display: flex; gap: 12px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 4px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.due { background: var(--due); } .dot.cond { background: var(--cond); } .dot.overdue { background: var(--late); } .dot.inspection { background: var(--inspection); }
.dot.manual { background: var(--manual); } .dot.note { background: var(--note); }

.weekdays, .grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.weekdays div { text-align: center; font-size: 12px; color: var(--muted); padding: 4px 0; font-weight: 600; }
.sun { color: var(--overdue) !important; } .sat { color: var(--accent) !important; }
.grid { gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }

.day {
  background: var(--surface); min-height: 104px; padding: 4px 5px; cursor: pointer;
  display: flex; flex-direction: column; gap: 2px; border: 0; text-align: left; position: relative;
}
.day:hover { background: var(--sel); }
.day.other { background: var(--bg); }
.day.other .num span:first-child { color: var(--muted) !important; font-weight: 500; }
.day.today { background: var(--today); }
.day.selected { outline: 2px solid var(--accent); outline-offset: -2px; z-index: 1; }
.day .num { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; display: flex; justify-content: space-between; align-items: center; }
.day.sun .num span:first-child { color: var(--overdue); }
.day.sat .num span:first-child { color: var(--accent); }
.note-badge { font-size: 10px; background: var(--note); color: #fff; border-radius: 9px; padding: 0 6px; font-weight: 600; }
.chip {
  font-size: 11.5px; border-radius: 4px; padding: 1px 5px; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; background: color-mix(in srgb, currentColor 12%, transparent);
}
.chip::before { content: "●"; font-size: 8px; margin-right: 3px; vertical-align: 1px; }
.chip.due { color: var(--due); } .chip.cond { color: var(--cond); } .chip.overdue { color: var(--late); font-weight: 700; }
.chip.inspection { color: var(--inspection); } .chip.manual { color: var(--manual); }
.chip.done { text-decoration: line-through; opacity: .6; }
.chip span { color: var(--ink); }
.more { font-size: 11px; color: var(--muted); padding-left: 4px; }

@media (max-width: 640px) {
  .day { min-height: 62px; padding: 3px; }
  .chip { font-size: 0; padding: 0; height: 6px; background: currentColor; border-radius: 3px; }
  .chip::before { display: none; }
  .chip span { display: none; }
  .legend { margin-left: 0; width: 100%; }
  .brand h1 { font-size: 15px; }
  #btnSync { display: none; }
  .topbar { padding: 8px 12px; }
  .top-actions .btn { font-size: 13px; padding: 6px 8px; }
}

/* upcoming */
.upcoming { margin-top: 18px; }
.upcoming h3 { font-size: 15px; margin: 0 0 8px; }
.upcoming h3 small { color: var(--muted); font-weight: 400; font-size: 12px; }
.upcoming ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.upcoming li {
  display: flex; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 8px; cursor: pointer;
}
.upcoming li:hover { border-color: var(--accent); }
.dday { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 56px; color: var(--due); }
.dday.over { color: var(--late); }
.upcoming .when { color: var(--muted); font-size: 13px; margin-left: auto; font-variant-numeric: tabular-nums; }
.empty { color: var(--muted); font-size: 13px; padding: 8px 2px; }

/* panel */
.panel { padding: 16px; align-self: start; position: sticky; top: 66px; max-height: calc(100vh - 84px); overflow: auto; }
@media (max-width: 960px) { .panel { position: static; max-height: none; } }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 12px; }
.panel-date { font-size: 22px; font-weight: 700; }
.panel-sub { color: var(--muted); font-size: 13px; }

.add-event { display: grid; gap: 8px; padding: 10px; background: var(--bg); border-radius: 8px; margin-bottom: 12px; }
input, select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--surface);
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); border-color: var(--accent); }
textarea { resize: vertical; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.event {
  border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; margin-bottom: 10px;
}
.event.overdue { border-color: color-mix(in srgb, var(--late) 55%, var(--line)); }
.event.done .ev-title { text-decoration: line-through; color: var(--muted); }
.ev-top { display: flex; gap: 8px; align-items: flex-start; }
.ev-title { font-weight: 600; flex: 1; }
.ev-kind { font-size: 11px; padding: 1px 7px; border-radius: 10px; color: #fff; background: var(--manual); white-space: nowrap; }
.event.due .ev-kind { background: var(--due); } .event.cond .ev-kind { background: var(--cond); } .event.overdue .ev-kind { background: var(--late); }
.event.inspection .ev-kind { background: var(--inspection); }
.ev-detail { color: var(--muted); font-size: 13px; margin-top: 3px; }
.ev-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.ev-actions { display: flex; gap: 10px; margin-top: 6px; font-size: 13px; align-items: center; }
.ev-actions label { display: inline-flex; gap: 4px; align-items: center; cursor: pointer; }
.ev-actions input { width: auto; }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-size: 13px; }
.link.danger { color: var(--overdue); }
details.raw { font-size: 12px; margin-top: 6px; }
details.raw pre { white-space: pre-wrap; word-break: break-all; background: var(--bg); padding: 8px; border-radius: 6px; max-height: 200px; overflow: auto; }

.notes { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 6px; }
.notes li { background: var(--bg); border-radius: 8px; padding: 8px 10px; font-size: 14px; }
.notes .txt { white-space: pre-wrap; word-break: break-word; }
.notes .meta { font-size: 11px; color: var(--muted); margin-top: 4px; display: flex; gap: 10px; }
.note-form { display: grid; gap: 6px; }
.note-form .btn { justify-self: end; }
.day-notes { border-top: 1px dashed var(--line); padding-top: 12px; margin-top: 4px; }
.day-notes h3 { margin: 0; font-size: 14px; }

/* dialogs */
dialog {
  border: 0; border-radius: 14px; padding: 18px; width: min(760px, calc(100vw - 24px));
  background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(15, 22, 33, .45); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.dlg-head h3 { margin: 0; }
.add-elevator { display: grid; grid-template-columns: 1.2fr 1fr auto; gap: 8px; }
@media (max-width: 640px) { .add-elevator { grid-template-columns: 1fr; } }
.hint { font-size: 12px; color: var(--muted); margin: 6px 0 12px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
td.err { color: var(--overdue); font-size: 12px; }
td .sub { color: var(--muted); font-size: 12px; }
.settings { display: grid; gap: 14px; }
.settings label { display: grid; gap: 4px; font-weight: 600; font-size: 14px; }
.settings small { font-weight: 400; color: var(--muted); font-size: 12px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.demo-row span { margin-right: auto; font-size: 14px; color: var(--muted); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: #1b2430; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .2s; max-width: calc(100vw - 32px); z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--overdue); }

/* 월간 정리 */
.summary-dlg { width: min(1180px, calc(100vw - 24px)); max-height: calc(100vh - 32px); }
.summary-dlg .dlg-head h3 { margin: 0 4px; font-size: 18px; }
.report h2 { margin: 0; font-size: 24px; }
.report h3 { font-size: 16px; margin: 22px 0 8px; }
.report h4 { font-size: 13px; margin: 0 0 6px; color: var(--muted); }
.report .sub { color: var(--muted); font-size: 12px; }
.report-head { margin-bottom: 14px; }
.tiles { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 900px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tile { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.t-num { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.t-name { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tile.pass .t-num { color: var(--inspection); }
.tile.cond .t-num, .tile.wait .t-num { color: var(--due); }
.tile.fail .t-num, .tile.warn .t-num { color: var(--overdue); }
.breakdowns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
@media (max-width: 760px) { .breakdowns { grid-template-columns: 1fr; } }
.bd { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.bd li { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.bd b { font-variant-numeric: tabular-nums; }
.sum-table { font-size: 13px; }
.sum-table td.num { color: var(--muted); font-variant-numeric: tabular-nums; }
.sum-table .nowrap, .dues .nowrap { white-space: nowrap; }
.sum-table .findcell { min-width: 220px; }
.sum-table .findcell ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.sum-table .notecell { min-width: 140px; white-space: pre-wrap; font-size: 12px; }
.sum-table .notecell div + div { border-top: 1px dashed var(--line); margin-top: 3px; padding-top: 3px; }
.ft { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 0 5px; border-radius: 3px; margin-right: 4px; color: #fff; background: var(--overdue); }
.ft.advice { background: var(--due); }
.prev { font-size: 11.5px; color: var(--due); margin-top: 3px; }
.res { font-weight: 700; font-size: 12.5px; }
.res.pass { color: var(--inspection); } .res.cond { color: var(--due); } .res.fail, .res.missing { color: var(--overdue); }
.res.wait { color: var(--plan); }
.dues { margin: 0; padding-left: 18px; font-size: 13px; display: grid; gap: 4px; }
@media (prefers-color-scheme: dark) { .ft { color: #0d1420; } }

@media print {
  body.print-summary > *:not(#dlgSummary) { display: none !important; }
  body.print-summary { background: #fff; }
  body.print-summary #dlgSummary {
    position: static; display: block; width: auto; max-height: none; overflow: visible;
    box-shadow: none; padding: 0; margin: 0; color: #000; background: #fff;
  }
  body.print-summary #dlgSummary::backdrop { display: none; }
  .no-print { display: none !important; }
  .table-wrap { overflow: visible; }
  .sum-table tr { break-inside: avoid; }
  .tile { padding: 6px 8px; } .t-num { font-size: 20px; }
  @page { size: A4 landscape; margin: 10mm; }
}
.sum-table th:nth-child(3), .sum-table td:nth-child(3) { min-width: 150px; }
.sum-table th:nth-child(5), .sum-table td:nth-child(5) { min-width: 180px; }
.sum-table th:last-child, .sum-table td:last-child { width: 16%; }

/* 확인창 */
.confirm-dlg { width: min(420px, calc(100vw - 32px)); }
.confirm-dlg p { margin: 0 0 16px; white-space: pre-line; line-height: 1.55; }
.confirm-actions { justify-content: flex-end; }
.btn.danger-fill { background: var(--overdue); border-color: var(--overdue); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.danger-fill { color: #0d1420; } }
.excluded h4 { margin: 16px 0 6px; font-size: 13px; }
.excluded h4 small { color: var(--muted); font-weight: 400; }
.excluded ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 13px; }
.excluded li { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; border-bottom: 1px dashed var(--line); }

/* 휴대폰 화면 */
@media (max-width: 640px) {
  .hide-sm { display: none; }
  .topbar .brand h1 { display: none; }
  .topbar { gap: 8px; }
  .top-actions { flex: 1; justify-content: flex-end; }
  .cal-head h2 { font-size: 22px; min-width: 0; }
  .upcoming li { gap: 8px; padding: 8px; }
  .upcoming li > span:nth-child(2) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .upcoming .when { white-space: nowrap; font-size: 12px; }
  .dday { min-width: 46px; }
  .panel { padding: 12px; }
  dialog { padding: 14px; }
  .summary-dlg { max-height: calc(100vh - 16px); }
  .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .tile { padding: 8px; } .t-num { font-size: 22px; }
}
@media (max-width: 960px) { .layout { grid-template-columns: minmax(0, 1fr); } }
.cal-wrap, .panel, .event, .upcoming li { min-width: 0; }
.ev-meta, .ev-detail, .ev-title { overflow-wrap: anywhere; }
.phone-box { display: grid; gap: 4px; }
.phone-url { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--accent); user-select: all; }
.phone-box small { color: var(--muted); font-size: 12px; }
.backup-box { display: grid; gap: 8px; }
.backup-box .row { justify-content: space-between; }
.backup-box small, .backup-box .sub { color: var(--muted); font-size: 12px; }
.backup-box label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; }
.bk-dir { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.bk-path { font-size: 13px; font-weight: 600; word-break: break-all; }

/* 변동사항 */
.bell { position: relative; }
.badge { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--overdue); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.refresh-row { justify-content: space-between; margin-bottom: 10px; }
.refresh-row .sub { font-size: 12px; color: var(--muted); flex: 1; min-width: 200px; }
.chg-group h4 { margin: 14px 0 6px; font-size: 13px; }
.chg-group h4 small { color: var(--muted); font-weight: 400; }
.chg-group ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.chg-group li { display: flex; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; font-size: 13.5px; }
.chg-group li:hover { border-color: var(--accent); }
.chg-group li.unseen { background: color-mix(in srgb, var(--accent) 8%, var(--surface)); border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.chg-group li .sub { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.chg-ic { flex: none; width: 20px; text-align: center; }
.check-row { display: flex !important; align-items: center; gap: 8px; font-weight: 600; }
.check-row.hidden { display: none !important; }
.check-row input { width: auto; }
@media (prefers-color-scheme: dark) { .badge { color: #0d1420; } }

/* 로그인 사용자 */
body:not(.is-manager) .admin-only { display: none !important; }
body:not(.is-admin) .super-only, body:not(.is-admin) .super-only-opt { display: none !important; }
.user-btn { max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
.account-row { justify-content: space-between; margin-bottom: 12px; }
.account-row .sub, .phone-mini .sub { color: var(--muted); font-size: 13px; }
.pw-form { gap: 8px; margin-bottom: 14px; }
.phone-mini { display: grid; gap: 4px; font-size: 13px; }
#userAdmin h4 { margin: 0 0 8px; }
#userAdmin h4 small { color: var(--muted); font-weight: 400; }
.user-table select { width: auto; padding: 4px 6px; }
.user-table .nowrap { white-space: nowrap; }
.add-user { display: grid; grid-template-columns: 1fr 1fr 1fr auto auto; gap: 8px; margin-top: 10px; }
@media (max-width: 760px) { .add-user { grid-template-columns: 1fr 1fr; } }
.notes .meta b { color: var(--ink); font-weight: 600; }

/* 부서 */
.dept-chip { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 10px;
  background: rgba(255,255,255,.16); color: var(--brand-ink); white-space: nowrap; }
body.is-admin .dept-chip { display: none; }
.dept-switch { width: auto; max-width: 140px; padding: 5px 8px; background: rgba(255,255,255,.12);
  color: var(--brand-ink); border-color: rgba(255,255,255,.3); }
.dept-switch option { color: #1b2430; }
.dept-list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 4px; }
.dept-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0;
  border-bottom: 1px dashed var(--line); font-size: 13.5px; }
.dept-list .sub { color: var(--muted); font-size: 12px; }
#deptAdmin h4 { margin: 0 0 8px; }
#deptAdmin h4 small { color: var(--muted); font-weight: 400; }
.add-user { grid-template-columns: 1fr 1fr 1fr auto auto auto; }
@media (max-width: 760px) { .add-user { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) { .dept-chip { display: none; } .dept-switch { max-width: 90px; } }

.admin-dlg { width: min(1100px, calc(100vw - 24px)); }
.admin-dlg h4 { margin: 4px 0 8px; }
.user-table th, .user-table td { white-space: nowrap; }
@media (max-width: 700px) {
  .user-table thead { display: none; }
  .user-table, .user-table tbody, .user-table tr, .user-table td { display: block; }
  .user-table tr { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
  .user-table td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
  .user-table td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: 12px; }
  .user-table td.u-name { font-weight: 700; font-size: 15px; }
  .user-table td.u-actions-cell { display: block; padding-top: 8px; margin-top: 4px; border-top: 1px dashed var(--line); }
  .user-table .u-actions { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
  .user-table .u-act { padding: 8px 6px; }
}

.fetch-dlg { width: min(440px, calc(100vw - 24px)); }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
#btnAdmin { position: relative; }
.pending-box { border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line)); background: color-mix(in srgb, var(--accent) 6%, var(--surface));
  border-radius: 10px; padding: 12px; margin-bottom: 12px; }
.pending-box h4 { margin: 0 0 4px; }
.badge-inline { font-size: 12px; color: var(--accent); }
.pending-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; }
.pending-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 0; border-top: 1px solid var(--line); }
.pending-list .p-note { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.pending-list .p-act { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pending-list select { width: auto; padding: 4px 6px; }
#confirmMsg { white-space: pre-line; line-height: 1.55; }

/* 사용자 관리: 줄마다 작업 버튼 (위험도 순서대로 색) */
.u-actions { display: flex; gap: 6px; justify-content: flex-start; }
.u-act { white-space: nowrap; font-weight: 600; }
.u-act:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.u-pause { color: var(--due); border-color: color-mix(in srgb, var(--due) 45%, var(--line)); }
.u-pause:hover { border-color: var(--due); background: color-mix(in srgb, var(--due) 8%, transparent); }
.u-resume { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.u-resume:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.u-delete { color: var(--overdue); border-color: color-mix(in srgb, var(--overdue) 45%, var(--line)); }
.u-delete:hover { border-color: var(--overdue); background: color-mix(in srgb, var(--overdue) 8%, transparent); }
@media (min-width: 701px) {
  .user-table th, .user-table td { padding: 6px 6px; }
  .user-table td[data-label="최근 로그인"] { font-size: 12px; }
}

/* 부서 목록: 사용자 목록과 같은 작업 버튼 */
.dept-list li { padding: 8px 0; }
.dept-list li > input { min-width: 0; }
.d-actions { flex: none; }
@media (max-width: 700px) {
  .dept-list li { flex-wrap: wrap; }
  .dept-list li > span:first-child, .dept-list li > input { flex: 1 1 100%; }
  .dept-list .d-actions { flex: 1 1 100%; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
  .dept-list .d-actions .u-act { padding: 8px 6px; }
}

/* 가입 요청: 수락/거절도 같은 작업 버튼 */
@media (max-width: 700px) {
  .pending-list .p-who, .pending-list .p-act { flex: 1 1 100%; }
  .pending-list .p-act select { flex: 1 1 0; }
  .pending-list .p-btns { flex: 1 1 100%; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
  .pending-list .p-btns .u-act { padding: 8px 6px; }
}

/* 휴대폰·좁은 화면: 위쪽 막대를 두 줄로 (1줄: 로고·부서·이름 / 2줄: 작업 버튼이 화면 너비를 나눠 가짐)
   → 페이지가 화면보다 넓어져서 브라우저가 축소해 보이는 문제 방지 */
@media (max-width: 1024px) {
  .topbar { flex-wrap: wrap; row-gap: 0; padding: 8px 12px; }
  .topbar .brand { margin-right: auto; min-width: 0; }
  .top-actions { display: contents; }
  .topbar #deptSwitch { order: 1; }
  .topbar #btnAccount { order: 2; }
  .topbar::after { content: ""; order: 3; flex-basis: 100%; height: 8px; }
  .top-actions > .btn:not(#btnAccount) {
    order: 4; flex: 1 1 0; min-width: 0; justify-content: center; text-align: center;
    padding: 7px 4px; white-space: nowrap; overflow: visible;
  }
  .topbar .user-btn { max-width: 42vw; }
}

/* 넓은 화면에서도 버튼이 많으면 넘치지 않고 줄바꿈 */
.topbar { flex-wrap: wrap; }
.top-actions { flex-wrap: wrap; justify-content: flex-end; min-width: 0; }
.brand h1 { white-space: nowrap; }

/* 안드로이드·삼성 인터넷이 글자를 제멋대로 키우지 않게 */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

/* 다가오는 검사: 평소엔 접어 두고 눌러서 펼침 */
.up-toggle { width: 100%; display: flex; align-items: center; gap: 10px; text-align: left; cursor: pointer;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 11px 14px; font: inherit; }
.up-toggle:hover { border-color: var(--accent); }
.up-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.up-title { font-size: 15px; font-weight: 700; white-space: nowrap; }
.up-count { color: var(--accent); font-weight: 700; margin-left: 4px; }
.up-next { flex: 1; min-width: 0; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-chev { color: var(--muted); transition: transform .15s ease; }
.up-toggle[aria-expanded="true"] .up-chev { transform: rotate(180deg); }
.up-body { margin-top: 8px; }
.up-hint { display: block; color: var(--muted); font-size: 12px; margin: 0 0 6px 2px; }
@media (prefers-reduced-motion: reduce) { .up-chev { transition: none; } }

/* 제목 순서(h1→h2→h3)를 맞추느라 바꾼 태그가 기존 모양을 유지하도록 */
.up-heading { margin: 0; font-size: inherit; font-weight: inherit; }
h2.panel-date { margin: 0; }

/* 변동사항 알림 */
.push-box { display: grid; gap: 6px; padding: 12px; margin: 4px 0 12px; border: 1px solid var(--line); border-radius: 10px; }
.push-box small { color: var(--muted); }
.push-box .push-state { color: var(--ink); font-weight: 600; }
.push-nudge { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; margin-bottom: 10px; border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 8%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line)); }
