/* ============================================================
   출근햇슈 — UI 킷 (flex 톤)
   PC: 라이트 사이드바 레이아웃 / 모바일: 다크 카드 + 하단 탭
   ============================================================ */

:root {
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;

  /* light (flex web) */
  --bg:        #F4F5F7;
  --surface:   #FFFFFF;
  --surface-2: #F7F8FA;
  --text:      #1F2328;
  --text-2:    #5B6069;
  --muted:     #8B8F98;
  --border:    #E8EAED;
  --hover:     #EEF0F3;
  --active:    #E6E8EC;

  --green:     #2FBF4A;
  --green-2:   #22B573;
  --green-bg:  #E9F8EC;
  --coral:     #F05A4F;
  --coral-bg:  #FDECEA;
  --amber:     #F5A623;
  --amber-bg:  #FFF4E0;
  --blue:      #3B82F6;
  --blue-bg:   #E8F0FE;
  --purple:    #8B5CF6;
  --purple-bg: #F1ECFE;
  --cyan:      #22C1D6;

  --r-sm: 8px; --r: 12px; --r-lg: 16px; --r-xl: 22px; --r-pill: 999px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  --sidebar-w: 240px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #121316;
    --surface:   #1E1F23;
    --surface-2: #26282D;
    --text:      #ECEDEF;
    --text-2:    #B4B7BD;
    --muted:     #8A8D93;
    --border:    #2A2C31;
    --hover:     #26282D;
    --active:    #2E3036;
    --green:     #4ADE5C;
    --green-bg:  rgba(74,222,92,.14);
    --coral-bg:  rgba(240,90,79,.16);
    --amber-bg:  rgba(245,166,35,.16);
    --blue-bg:   rgba(59,130,246,.16);
    --purple-bg: rgba(139,92,246,.16);
    --shadow: none;
  }
}
html[data-theme="light"] { color-scheme: light; }
html[data-theme="dark"]  { color-scheme: dark; }
html[data-theme="dark"] {
  --bg:#121316; --surface:#1E1F23; --surface-2:#26282D; --text:#ECEDEF; --text-2:#B4B7BD; --muted:#8A8D93;
  --border:#2A2C31; --hover:#26282D; --active:#2E3036; --green:#4ADE5C; --green-bg:rgba(74,222,92,.14);
  --coral-bg:rgba(240,90,79,.16); --amber-bg:rgba(245,166,35,.16); --blue-bg:rgba(59,130,246,.16); --purple-bg:rgba(139,92,246,.16); --shadow:none;
}
html[data-theme="light"] {
  --bg:#F4F5F7; --surface:#FFFFFF; --surface-2:#F7F8FA; --text:#1F2328; --text-2:#5B6069; --muted:#8B8F98;
  --border:#E8EAED; --hover:#EEF0F3; --active:#E6E8EC; --green:#2FBF4A; --green-bg:#E9F8EC;
  --coral-bg:#FDECEA; --amber-bg:#FFF4E0; --blue-bg:#E8F0FE; --purple-bg:#F1ECFE;
  --shadow:0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; letter-spacing: -0.01em;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
h1,h2,h3,h4 { margin: 0; font-weight: 700; letter-spacing: -0.02em; }
h1 { font-size: 28px; } h2 { font-size: 20px; } h3 { font-size: 16px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .xs { font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 16px 12px;
  background: var(--bg); border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: 4px;
}
.main { padding: 28px 36px 80px; max-width: 1200px; width: 100%; }

.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 14px; }
.brand .logo {
  width: 28px; height: 28px; border-radius: 8px; background: var(--coral); color: #fff; display: grid; place-items: center;
  font-weight: 800; font-size: 14px;
}
.brand .name { font-weight: 700; font-size: 15px; }

.status-chip {
  display: flex; align-items: center; gap: 8px; margin: 0 4px 12px; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); font-size: 14px;
}
.status-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status-chip.working .dot { background: var(--green); box-shadow: 0 0 0 3px var(--green-bg); }
.status-chip.break .dot { background: var(--amber); }

.nav a, .nav button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: var(--r-sm);
  color: var(--text-2); font-size: 14.5px; text-align: left;
}
.nav a:hover { background: var(--hover); color: var(--text); }
.nav a.active { background: var(--active); color: var(--text); font-weight: 600; }
.nav .ico { width: 18px; text-align: center; opacity: .85; }
.nav .sec { margin: 14px 10px 4px; font-size: 12px; color: var(--muted); }
.nav .badge { margin-left: auto; }
.sidebar .spacer { flex: 1; }
.me { display: flex; align-items: center; gap: 10px; padding: 10px; border-top: 1px solid var(--border); margin-top: 8px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--coral-bg); color: var(--coral); display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-head .tabs { display: flex; gap: 22px; }
.page-head .tabs a { font-size: 26px; font-weight: 800; color: var(--muted); }
.page-head .tabs a.active { color: var(--text); }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 20px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 14px; }
.card .card-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card .card-title h3 { font-size: 15px; color: var(--text-2); font-weight: 600; }
.grid { display: grid; gap: 14px; }
.grid.c2 { grid-template-columns: 1fr 1fr; } .grid.c3 { grid-template-columns: repeat(3, 1fr); } .grid.c4 { grid-template-columns: repeat(4, 1fr); }
.row { display: flex; align-items: center; gap: 10px; } .row.between { justify-content: space-between; } .row.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 8px; }

.stat .label { font-size: 13px; color: var(--muted); }
.stat .value { font-size: 26px; font-weight: 800; letter-spacing: -0.03em; margin-top: 2px; }
.stat .value small { font-size: 14px; color: var(--muted); font-weight: 500; }

.list { display: flex; flex-direction: column; }
.list .item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.list .item:last-child { border-bottom: 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: var(--r);
  font-weight: 600; font-size: 14.5px; background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  transition: transform .06s, background .15s;
}
.btn:hover { background: var(--hover); } .btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: linear-gradient(90deg, var(--green), var(--green-2)); color: #fff; border: 0; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { background: var(--coral-bg); color: var(--coral); border: 0; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.lg { padding: 14px 22px; font-size: 16px; border-radius: var(--r-lg); }
.btn.pill { border-radius: var(--r-pill); }
.btn.block { width: 100%; }

/* 모바일 flex 스타일 큰 알약 (지금 퇴근 / 오전 9:00) */
.punch-pill {
  display: inline-flex; flex-direction: column; align-items: center; padding: 10px 26px; border-radius: var(--r-pill);
  background: var(--green); color: #0B2A10; font-weight: 800; line-height: 1.15; border: 0; min-width: 150px;
}
.punch-pill small { font-size: 12px; font-weight: 600; opacity: .8; }
.punch-pill b { font-size: 20px; }
.punch-pill.out { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: var(--r-pill); font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--text-2); }
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.coral { background: var(--coral-bg); color: var(--coral); }
.badge.amber { background: var(--amber-bg); color: var(--amber); }
.badge.blue  { background: var(--blue-bg);  color: var(--blue); }
.badge.purple{ background: var(--purple-bg);color: var(--purple); }
.badge.count { background: var(--coral); color: #fff; min-width: 20px; justify-content: center; padding: 0 6px; height: 20px; }

/* 고용상태 */
.emp-regular   { background: var(--blue-bg);   color: var(--blue); }
.emp-probation { background: var(--amber-bg);  color: var(--amber); }
.emp-intern    { background: var(--green-bg);  color: var(--green); }
.emp-resigned  { background: var(--surface-2); color: var(--muted); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--text-2); font-weight: 600; }
.field .help { font-size: 12px; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; padding: 10px 12px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text); outline: none;
}
.input:focus { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-bg); }
.input.sm { padding: 6px 8px; font-size: 13px; }
.switch { position: relative; width: 40px; height: 22px; border-radius: 999px; background: var(--border); transition: .15s; flex: none; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: .15s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch.on { background: var(--green); } .switch.on::after { left: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }

/* ---------- Table ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12.5px; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table td .input { max-width: 120px; }
.table tr.click { cursor: pointer; } .table tr.click:hover td { background: var(--hover); }
.table td .badge + .badge { margin-left: 4px; }

/* ---------- Progress ---------- */
.progress { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--border); }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--green), var(--cyan)); border-radius: 999px; transition: width .4s; }

/* ---------- Toast / Modal ---------- */
.toast-wrap { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { padding: 12px 16px; border-radius: var(--r); background: var(--text); color: var(--bg); font-size: 14px; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,.2); animation: up .2s ease-out; }
.toast.error { background: var(--coral); color: #fff; }
.toast.cs { background: var(--amber); color: #2b1d00; }
@keyframes up { from { opacity: 0; transform: translateY(8px);} to { opacity: 1; transform: none;} }

.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; z-index: 90; padding: 20px; }
.modal { background: var(--surface); border-radius: var(--r-xl); padding: 24px; width: min(520px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; border: 1px solid var(--border); }
.modal h3 { margin-bottom: 8px; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login { width: min(400px, 100%); }
.login .brand { justify-content: center; padding-bottom: 20px; }
.login .brand .name { font-size: 22px; }

/* ---------- Empty ---------- */
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.empty .ico { font-size: 28px; margin-bottom: 6px; opacity: .6; }

/* ---------- 주간 / 월간 (P1) ---------- */
.holi { color: var(--coral); } .sat { color: var(--blue); }
.sdot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.sdot.green { background: var(--green); } .sdot.amber { background: var(--amber); } .sdot.coral { background: var(--coral); } .sdot.blue { background: var(--blue); }
.week-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; }
.day-cell {
  display: flex; flex-direction: column; gap: 6px; min-height: 132px; padding: 14px 12px; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow);
}
.day-cell:hover { background: var(--hover); }
.day-cell.off { background: var(--surface-2); box-shadow: none; }
.day-cell.today, .cal-cell.today { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-bg); }
.dc-head { display: flex; flex-direction: column; gap: 2px; }
.dc-badges, .cal-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: auto; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal .dow { text-align: center; font-size: 12px; color: var(--muted); padding: 2px 0 4px; }
.cal .dow:nth-child(6) { color: var(--blue); } .cal .dow:nth-child(7) { color: var(--coral); }
.cal-cell {
  display: flex; flex-direction: column; gap: 3px; min-height: 96px; padding: 8px; text-align: left; min-width: 0;
  background: var(--surface-2); border: 1px solid transparent; border-radius: var(--r);
}
.cal-cell:hover { background: var(--hover); }
.cal-cell.blank { background: transparent; pointer-events: none; }
.cal-cell .num { font-size: 13px; font-weight: 700; }
.cal-cell.sat .num { color: var(--blue); } .cal-cell.sun .num, .cal-cell.holiday .num { color: var(--coral); }
.cal-cell .hname { font-size: 11px; color: var(--coral); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-cell .hrs { font-size: 14px; font-weight: 700; }

/* 큰 액션 카드 (근무 신청 등) */
.list .item.appr { align-items: flex-start; }
@media (max-width: 860px) { .list .item.appr { flex-direction: column; align-items: stretch; } .list .item.appr > .row { justify-content: flex-end; } }
.action-card { display: flex; align-items: center; gap: 14px; text-align: left; width: 100%; }
.action-card:hover { background: var(--hover); }
.action-card .ico { font-size: 26px; width: 44px; height: 44px; border-radius: var(--r); background: var(--surface-2); display: grid; place-items: center; flex: none; }
.card + .grid, .grid + .card { margin-top: 14px; }

/* ---------- Mobile ---------- */
.tabbar { display: none; }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 18px 16px 110px; }
  .page-head .tabs a { font-size: 22px; }
  .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: 1fr 1fr; }
  .grid.c2:has(.action-card) { grid-template-columns: 1fr; }
  .card { border-radius: var(--r-xl); }
  .tabbar {
    display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    background: var(--bg); border-top: 1px solid var(--border); padding: 8px 0 max(10px, env(safe-area-inset-bottom));
  }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11.5px; color: var(--muted); }
  .tabbar a.active { color: var(--text); font-weight: 600; }
  .tabbar .ico { font-size: 20px; }
  .punch-bar {
    position: fixed; left: 12px; right: 12px; bottom: 76px; z-index: 49; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r-xl); padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; box-shadow: 0 -4px 24px rgba(0,0,0,.25);
  }
  .m-hide { display: none !important; }
  .week-grid { grid-template-columns: 1fr; gap: 8px; }
  .day-cell { min-height: 0; display: grid; grid-template-columns: 76px 1fr auto; grid-template-areas: "head time dur" "head badges dur"; align-items: center; padding: 12px 14px; }
  .dc-head { grid-area: head; } .dc-time { grid-area: time; } .dc-dur { grid-area: dur; } .dc-badges { grid-area: badges; margin-top: 0; }
  .cal { gap: 3px; }
  .cal-cell { min-height: 60px; padding: 6px 4px; align-items: center; text-align: center; }
  .cal-cell .row { flex-direction: column; gap: 3px; }
  .cal-cell .hname, .cal-cell .cal-badges { display: none; }
  .cal-cell .hrs { font-size: 11px; }
  .page-head { flex-wrap: wrap; align-items: center; }
}
@media (min-width: 861px) { .d-hide { display: none !important; } }
