/* ===================================================================
   업무 허브 - 전역 스타일 (라이트 SaaS 스타일 + 좌측 사이드바)
   섹션: 변수 / 기본 / 레이아웃 / 사이드바 / 카드 / 버튼·폼 / 배지
        / 리스트 / 테이블 / 잠금화면 / 유틸 / 반응형
   =================================================================== */

/* ---- 변수 ---------------------------------------------------------- */
:root {
  --bg: #f6f7f9;          /* 앱 배경 */
  --bg-soft: #ffffff;     /* 사이드바 */
  --panel: #ffffff;       /* 카드 */
  --panel-2: #f1f3f5;     /* 보조 채움 (secondary 버튼/칩) */
  --border: #e5e7eb;
  --text: #1f2430;
  --text-dim: #6b7280;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --ok: #16a34a;
  --warn: #d97706;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.08);
  --side-w: 244px;
  font-size: 15px;
}

/* ---- 기본 ---------------------------------------------------------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  display: flex;
  font-family: "Pretendard", "Segoe UI", "Malgun Gothic", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 0.5rem; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: 0.9rem; text-transform: none; }
svg { display: block; }

/* ---- 사이드바 ------------------------------------------------------ */
.sidebar {
  flex: 0 0 var(--side-w);
  width: var(--side-w);
  height: 100vh;
  position: sticky;
  top: 0;
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1.1rem 0.85rem;
}
.side-brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.35rem 0.6rem 1rem;
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}
.side-brand .logo { font-size: 1.35rem; }
.side-links { display: flex; flex-direction: column; gap: 0.15rem; }
.side-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.7rem;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.92rem;
  transition: background 0.12s, color 0.12s;
}
.side-link:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.side-link.active { background: var(--accent-soft); color: var(--accent); }
.side-link .ic { width: 19px; height: 19px; flex: 0 0 19px; }
.side-link .ic svg { width: 19px; height: 19px; }
.side-foot {
  border-top: 1px solid var(--border);
  padding: 0.85rem 0.7rem 0.2rem;
  font-size: 0.82rem;
  color: var(--text-dim);
}
.lock-state { display: inline-flex; align-items: center; gap: 0.45rem; }
.lock-state .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-dim); flex: 0 0 8px; }
.lock-state .dot.on { background: var(--ok); }
.lock-state .dot.locked { background: var(--warn); }
.lock-state .dot.off { background: #cbd5e1; }
.side-account { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-top: 0.6rem; }
.side-user { font-size: 0.82rem; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-logout { background: none; border: 1px solid var(--border); color: var(--text-dim); padding: 0.28rem 0.6rem; font-size: 0.78rem; font-weight: 600; }
.side-logout:hover { background: var(--panel-2); color: var(--text); }

/* ---- 레이아웃 ------------------------------------------------------ */
.container {
  flex: 1;
  min-width: 0;
  max-width: 1120px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 2.25rem 4rem;
}
.grid { display: grid; gap: 1.1rem; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-dash { grid-template-columns: 1.6fr 1fr; align-items: start; }
@media (max-width: 1000px) { .grid-2, .grid-dash { grid-template-columns: 1fr; } }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.1rem; flex-wrap: wrap; }

/* ---- 카드 ---------------------------------------------------------- */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.3rem;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 1.1rem; }
.card .section-head { margin-bottom: 0.75rem; }
.card h2 { display: flex; align-items: center; gap: 0.45rem; }
.muted { color: var(--text-dim); }
.empty { color: var(--text-dim); text-align: center; padding: 1.75rem 0; font-size: 0.92rem; }

/* ---- 버튼·폼 ------------------------------------------------------- */
button, .btn {
  font: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0.55rem 1rem;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  transition: background 0.13s, box-shadow 0.13s, border-color 0.13s;
  white-space: nowrap;
}
button:hover, .btn:hover { background: var(--accent-hover); }
button.secondary { background: #fff; color: var(--text); border-color: var(--border); }
button.secondary:hover { background: var(--panel-2); }
button.danger { background: #fff; color: var(--danger); border-color: var(--border); }
button.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
button.small { padding: 0.32rem 0.65rem; font-size: 0.82rem; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

input, textarea, select {
  font: inherit;
  width: 100%;
  padding: 0.55rem 0.7rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: border-color 0.13s, box-shadow 0.13s;
}
input::placeholder, textarea::placeholder { color: #9ca3af; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--text-dim); margin: 0.7rem 0 0.3rem; }
.form-row { margin-bottom: 0.5rem; }
.row { display: flex; gap: 0.6rem; align-items: center; }
.row > * { flex: 1; }
.row .shrink { flex: 0 0 auto; }

/* ---- 배지 ---------------------------------------------------------- */
.badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  vertical-align: middle;
  line-height: 1.6;
}
.badge.high { background: var(--danger); }
.badge.due { background: var(--warn); }
.badge.list { background: var(--panel-2); color: var(--text-dim); font-weight: 600; }

/* ---- 리스트 아이템 ------------------------------------------------- */
.item {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}
.item:last-child { border-bottom: none; }
.item .time { flex: 0 0 82px; color: var(--text-dim); font-size: 0.82rem; font-variant-numeric: tabular-nums; line-height: 1.35; }
.item .body { flex: 1; min-width: 0; }
.item .title { font-weight: 600; }
.item.important {
  border-left: 3px solid var(--danger);
  padding-left: 0.7rem;
  margin-left: -0.7rem;
  background: var(--danger-soft);
  border-radius: 0 6px 6px 0;
}
.item .sub { font-size: 0.82rem; color: var(--text-dim); margin-top: 0.1rem; }

/* ---- 테이블 -------------------------------------------------------- */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { text-align: left; padding: 0.65rem 0.7rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table th { color: var(--text-dim); font-size: 0.76rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background 0.1s; }
.data-table tbody tr:hover td { background: #fafbfc; }

/* ---- 잠금 / 로그인 화면 -------------------------------------------- */
.lock-screen { max-width: 400px; margin: 7vh auto; }
.lock-screen h1 { margin-bottom: 0.75rem; }
/* 로그인 페이지는 사이드바 없이 중앙 정렬 */
.auth-body { display: block; }
.auth-wrap { max-width: 420px; margin: 0 auto; padding: 8vh 1.25rem 2rem; }
.auth-wrap .lock-screen { margin: 0; }

/* ---- 유틸 ---------------------------------------------------------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(8px);
  background: #111827; color: #fff; padding: 0.7rem 1.2rem;
  border-radius: var(--radius-sm); box-shadow: var(--shadow-md);
  z-index: 100; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; font-size: 0.9rem;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--danger); }
.pill { font-size: 0.74rem; font-weight: 700; padding: 0.15rem 0.6rem; border-radius: 999px; border: 1px solid var(--border); }
.pill.on { background: #ecfdf5; color: var(--ok); border-color: #a7f3d0; }
.pill.off { background: var(--panel-2); color: var(--text-dim); }
.mono { font-family: "SFMono-Regular", "Consolas", monospace; font-size: 0.9em; }
.chip { display: inline-flex; align-items: center; gap: 0.4rem; background: #fff; border: 1px solid var(--border); border-radius: 999px; padding: 0.25rem 0.7rem; font-size: 0.82rem; margin: 0.15rem; }
.chip button { background: none; border: none; padding: 0; color: var(--text-dim); font-size: 0.9rem; line-height: 1; }
.chip button:hover { color: var(--danger); background: none; }
.right { text-align: right; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.gap { gap: 0.5rem; }

/* ---- 반응형: 좁은 화면에서는 상단 가로 바로 전환 -------------------- */
@media (max-width: 720px) {
  body { flex-direction: column; }
  .sidebar {
    flex-basis: auto; width: 100%; height: auto;
    flex-direction: row; align-items: center; gap: 0.5rem;
    padding: 0.6rem 0.9rem; border-right: none; border-bottom: 1px solid var(--border);
  }
  .side-top { display: flex; align-items: center; gap: 0.75rem; flex: 1; min-width: 0; overflow-x: auto; }
  .side-brand { padding: 0; }
  .side-brand .name { display: none; }
  .side-links { flex-direction: row; }
  .side-link .lbl { display: none; }
  .side-link { padding: 0.5rem; }
  .side-foot { border-top: none; padding: 0; white-space: nowrap; }
  .side-foot .lock-state span:not(.dot) { display: none; }
  .container { padding: 1.25rem 1.1rem 3rem; }
}
