/* 샘랩 근태 — 모바일 우선. 기준 폭 360 / 820 / 884 / 1180 / 1440 */
:root {
  --bg: #f2f4f6;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --text: #191f28;
  --text-2: #4e5968;
  --text-3: #6b7684;
  --line: #e5e8eb;
  --primary: #3182f6;
  --primary-press: #1b64da;
  --primary-soft: #e8f3ff;
  --danger: #d92d20;
  --danger-soft: #fdecea;
  --success: #0b7a44;
  --success-soft: #e6f6ee;
  --warn: #9a5b00;
  --warn-soft: #fff4e0;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 2px 8px rgba(0, 0, 0, .04);
  --tabbar-h: 64px;
  --header-h: 56px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  font-size: 16px; line-height: 1.55; word-break: keep-all; overflow-wrap: anywhere;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid rgba(49, 130, 246, .45); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── 앱 골격 ── */
.app-header {
  position: sticky; top: 0; z-index: 30; height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: 14px; }
.header-user { display: flex; align-items: center; gap: 10px; font-size: 15px; color: var(--text-2); min-width: 0; }
.header-user .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.header-user a.name { color: var(--text-2); text-decoration: none; display: inline-flex; align-items: center; min-height: 44px; }
.header-user a.name:hover { color: var(--text); text-decoration: underline; }
.link-btn { background: none; border: 0; padding: 8px 4px; color: var(--text-2); cursor: pointer; font-size: 15px; }
.link-btn:hover { color: var(--text); text-decoration: underline; }

.layout { display: block; }
.side-nav { display: none; }
.main { padding: 16px 16px calc(var(--tabbar-h) + 24px); max-width: 1120px; margin: 0 auto; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; height: var(--tabbar-h);
  display: flex; background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--text-3); font-size: 13px; font-weight: 600;
}
.tabbar a:hover { text-decoration: none; }
.tabbar a[aria-current="page"] { color: var(--primary); }
.tabbar svg, .side-nav svg { width: 24px; height: 24px; }

@media (min-width: 1024px) {
  .layout { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: calc(100vh - var(--header-h)); }
  .side-nav {
    display: block; position: sticky; top: var(--header-h); align-self: start; height: calc(100vh - var(--header-h));
    background: var(--surface); border-right: 1px solid var(--line); padding: 16px 12px;
  }
  .side-nav a {
    display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius-sm);
    color: var(--text-2); font-weight: 600; font-size: 16px;
  }
  .side-nav a:hover { background: var(--surface-2); text-decoration: none; }
  .side-nav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary-press); font-weight: 700; }
  .tabbar { display: none; }
  .main { padding: 28px 32px 48px; width: 100%; }
}

/* ── 공통 요소 ── */
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 12px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--text-2); }
.small { font-size: 15px; }
.meta { font-size: 14px; color: var(--text-3); }
.num { font-variant-numeric: tabular-nums; }

.card { background: var(--surface); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 0; }
.card-title { font-size: 18px; font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.card-title .spacer + * { font-weight: 500; }
.section-title { font-size: 20px; font-weight: 700; margin: 8px 0 4px; }

.grid-2 { display: grid; gap: 16px; grid-template-columns: 1fr; }
.grid-3 { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 760px) {
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 0 18px; border-radius: 12px; border: 1px solid transparent;
  font-weight: 700; font-size: 16px; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .12s, transform .06s;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-press); }
.btn-secondary { background: #e8ebed; color: var(--text); }
.btn-secondary:hover { background: #dde1e4; }
.btn-ghost { background: transparent; color: var(--text-2); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: #fadad6; }
.btn-sm { min-height: 40px; padding: 0 14px; font-size: 15px; border-radius: 10px; }
.btn-block { width: 100%; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 6px;
  font-size: 14px; font-weight: 700; line-height: 1.6; background: #eef0f2; color: var(--text-2); white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--success-soft); color: var(--success); }
.badge.info { background: var(--primary-soft); color: var(--primary-press); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--danger-soft); color: var(--danger); }

.flash { padding: 14px 16px; border-radius: 12px; font-weight: 600; margin-bottom: 16px; }
.flash.success { background: var(--success-soft); color: var(--success); }
.flash.error { background: var(--danger-soft); color: var(--danger); }
.flash.info { background: var(--primary-soft); color: var(--primary-press); }

/* 목록 */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 14px 0; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }
.list > li:first-child { border-top: 0; padding-top: 4px; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 600; }
.empty { padding: 24px 8px; text-align: center; color: var(--text-2); }
.empty .btn { margin-top: 12px; }

/* 폼 */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field > .label { font-size: 15px; font-weight: 600; color: var(--text-2); }
.input, select.input, textarea.input {
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 12px; border: 1px solid #d1d6db;
  background: var(--surface); font-size: 16px;
}
textarea.input { min-height: 96px; resize: vertical; }
.input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px rgba(49, 130, 246, .2); }
.help { font-size: 14px; color: var(--text-3); }
.form-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .form-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--primary); }

/* 토글 스위치 */
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; cursor: pointer; }
.switch input { appearance: none; -webkit-appearance: none; width: 48px; height: 28px; border-radius: 14px; background: #c9cfd5; position: relative; cursor: pointer; flex-shrink: 0; transition: background .15s; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked { background: var(--primary); }
.switch input:checked::after { transform: translateX(20px); }

/* 세그먼트 */
.segmented { display: flex; background: #eef0f2; border-radius: 12px; padding: 4px; gap: 4px; }
.segmented label { flex: 1; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: flex; align-items: center; justify-content: center; min-height: 40px; border-radius: 9px; font-weight: 600; color: var(--text-2); cursor: pointer; }
.segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.segmented input:focus-visible + span { outline: 3px solid rgba(49, 130, 246, .45); }

/* 표 */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius-sm); }
table.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th, .table td { padding: 12px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th { font-weight: 700; color: var(--text-2); background: var(--surface-2); position: sticky; top: 0; }
.table td.wrap { white-space: normal; min-width: 160px; }
.table tr.selected td { background: var(--primary-soft); }

/* ── 홈 ── */
.clock-card { text-align: center; padding: 28px 20px; }
.clock-date { font-size: 16px; color: var(--text-2); font-weight: 600; }
.clock-time { font-size: 44px; font-weight: 800; letter-spacing: -1px; margin: 4px 0 12px; }
.judge { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; background: var(--surface-2); font-weight: 600; font-size: 15px; color: var(--text-2); }
.judge .dot { width: 8px; height: 8px; border-radius: 50%; background: #adb5bd; }
.judge.ok .dot { background: var(--success); }
.judge.warn .dot { background: #e8a33b; }
.big-btn { width: 100%; min-height: 72px; font-size: 22px; border-radius: 18px; margin-top: 20px; }
.punch-times { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 20px; }
.punch-times > div { background: var(--surface-2); border-radius: 12px; padding: 12px; }
.punch-times .label { font-size: 14px; color: var(--text-3); font-weight: 600; }
.punch-times .value { font-size: 22px; font-weight: 800; }
.stat .label { font-size: 15px; color: var(--text-2); font-weight: 600; }
.stat .value { font-size: 26px; font-weight: 800; margin-top: 2px; }
.stat .value small { font-size: 16px; font-weight: 600; color: var(--text-2); }
.progress { height: 10px; background: #eef0f2; border-radius: 6px; overflow: hidden; margin-top: 10px; }
.progress > div { height: 100%; background: var(--primary); border-radius: 6px; }
.progress.warn > div { background: #e8a33b; }
.progress.over > div { background: var(--danger); }
.home-grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .home-grid { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); align-items: start; } }

/* 시트(모달) */
dialog.sheet { border: 0; padding: 0; border-radius: 20px; width: min(480px, calc(100vw - 32px)); max-height: calc(100vh - 64px); box-shadow: 0 10px 40px rgba(0,0,0,.2); }
dialog.sheet::backdrop { background: rgba(0, 0, 0, .4); }
.sheet-body { padding: 24px 20px 20px; display: flex; flex-direction: column; gap: 14px; }
.sheet-title { font-size: 20px; font-weight: 800; }
.sheet-actions { display: flex; gap: 8px; }
.sheet-actions .btn { flex: 1; }
@media (max-width: 600px) {
  dialog.sheet { margin: auto 0 0; width: 100vw; max-width: 100vw; border-radius: 20px 20px 0 0; }
}

details.disclosure > summary { cursor: pointer; font-weight: 700; list-style: none; display: flex; align-items: center; gap: 8px; min-height: 44px; }
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary::after { content: ''; margin-left: auto; width: 9px; height: 9px; border-right: 2px solid var(--text-3); border-bottom: 2px solid var(--text-3); transform: rotate(45deg) translate(-2px, -2px); transition: transform .15s; }
details.disclosure[open] > summary::after { transform: rotate(-135deg) translate(-2px, -2px); }

/* 휴가 계산 미리보기 */
.date-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }
.date-grid .input { min-width: 0; padding-left: 8px; padding-right: 4px; font-size: 15px; }
.calc { background: var(--primary-soft); border-radius: 12px; padding: 14px 16px; font-weight: 600; color: var(--primary-press); }
.calc.bad { background: var(--danger-soft); color: var(--danger); }

/* 팀 */
.team-counts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 640px) { .team-counts { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.team-counts > div, .team-counts > a > div { background: var(--surface-2); border-radius: 12px; padding: 12px; height: 100%; }
.team-counts > a { color: inherit; text-decoration: none; }
.team-counts > a:hover > div { background: var(--primary-soft); }
.team-counts .value { font-size: 24px; font-weight: 800; }
.cal { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 720px; font-size: 14px; }
.cal th, .cal td { border-bottom: 1px solid var(--line); padding: 8px; vertical-align: top; text-align: left; }
.cal th { background: var(--surface-2); font-weight: 700; color: var(--text-2); }
.cal th.off, .cal td.off { background: #fafbfc; color: var(--text-3); }
.cal td.name { font-weight: 700; white-space: nowrap; position: sticky; left: 0; background: var(--surface); z-index: 1; }
.cal th.name { position: sticky; left: 0; z-index: 2; }
.chip { display: block; padding: 2px 6px; border-radius: 6px; font-size: 13px; font-weight: 600; margin-bottom: 2px; white-space: nowrap; }
.chip.work { background: var(--success-soft); color: var(--success); }
.chip.leave { background: var(--primary-soft); color: var(--primary-press); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }

/* 관리자 */
.subnav { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 16px; scrollbar-width: thin; }
.subnav a { flex-shrink: 0; padding: 10px 14px; border-radius: 10px; font-weight: 600; color: var(--text-2); background: var(--surface); border: 1px solid var(--line); font-size: 15px; }
.subnav a:hover { text-decoration: none; background: var(--surface-2); }
.subnav a[aria-current="page"] { background: var(--text); color: #fff; border-color: var(--text); }
.md { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .md { grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); align-items: start; } }
.md-list { max-height: 70vh; overflow-y: auto; }
.md-list a { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 10px; color: var(--text); }
.md-list a:hover { background: var(--surface-2); text-decoration: none; }
.md-list a[aria-current="true"] { background: var(--primary-soft); font-weight: 700; }
.filters { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; }
@media (min-width: 900px) { .filters { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.warn-box { background: var(--warn-soft); color: var(--warn); border-radius: 12px; padding: 12px 14px; font-weight: 600; font-size: 15px; }
code.ip { font-size: 15px; background: var(--surface-2); padding: 2px 6px; border-radius: 6px; }

/* 로그인 */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: 20px; padding: 32px 24px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 16px; }
.login-card h1 { font-size: 24px; font-weight: 800; }
.btn-slack { background: #4a154b; color: #fff; min-height: 52px; }
.btn-slack:hover { background: #3b113c; }
.dev-box { border-top: 1px dashed var(--line); padding-top: 16px; }

/* 그리드 자식이 표·긴 입력 때문에 넓어져 가로 스크롤이 생기지 않게 */
.md > *, .grid-2 > *, .home-grid > *, .layout > * { min-width: 0; }
.list > li > form { min-width: 0; }
.row > .input { min-width: 0; }
@media (max-width: 420px) { .filters { grid-template-columns: 1fr; } }
