:root {
  --brand: #4f46e5;
  --brand-2: #6366f1;
  --brand-soft: #eef0ff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e8ecf3;
  --bg: #f4f6fb;
  --card: #ffffff;
  --ok: #12a150;
  --bad: #e5484d;
  --warn: #e08600;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 10px 30px rgba(15, 23, 42, .05);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Pretendard", "Malgun Gothic", "맑은 고딕", "Segoe UI", sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
input, select, button { font-family: inherit; }

/* ---------------- 레이아웃 ---------------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 236px; flex: 0 0 236px;
  background: var(--card);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.side-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 22px 20px 18px;
}
.side-logo .mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; font-weight: 800; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 14px rgba(79, 70, 229, .32);
}
.side-logo .word { font-size: 17px; font-weight: 800; letter-spacing: -.2px; }

.side-nav { padding: 6px 12px; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  color: #475569; font-weight: 700; font-size: 13.5px;
  transition: background .12s, color .12s;
}
.nav-item .ico {
  width: 22px; height: 22px; border-radius: 7px; flex: 0 0 22px;
  background: #eef2f8; color: #64748b;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800;
}
.nav-item:hover { background: #f4f6fb; color: var(--ink); }
.nav-item.active { background: var(--brand-soft); color: var(--brand); }
.nav-item.active .ico { background: var(--brand); color: #fff; }

.side-foot { margin-top: auto; padding: 16px 20px 20px; border-top: 1px solid var(--line); }
.role-chip {
  display: inline-block; background: var(--brand-soft); color: var(--brand);
  border-radius: 20px; padding: 3px 12px; font-size: 11.5px; font-weight: 800;
}
.side-user { margin-top: 8px; color: var(--muted); font-size: 12.5px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 66px; padding: 0 28px; background: var(--card);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 5;
}
.tb-left { display: flex; align-items: center; gap: 12px; }
.tb-store { font-size: 16px; font-weight: 800; }
.tb-right { display: flex; align-items: center; gap: 12px; }
.who { color: #5b6572; font-size: 13px; }
.chip {
  background: var(--brand-soft); color: var(--brand);
  border-radius: 20px; padding: 4px 13px; font-size: 12px; font-weight: 800;
}
.inline { display: inline; }

select {
  font-size: 12.5px; font-weight: 700; color: var(--brand);
  background: var(--brand-soft); border: 1px solid #d9dbfb;
  border-radius: 9px; padding: 7px 10px; cursor: pointer;
}

.content { padding: 26px 28px 40px; max-width: 1180px; width: 100%; }

.page-head { margin-bottom: 18px; }
.page-head h2 { font-size: 22px; font-weight: 800; letter-spacing: -.3px; }
.page-head p { margin-top: 5px; color: var(--muted); font-size: 13px; }

/* ---------------- 카드 ---------------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--shadow);
}
.card.pad { padding: 16px 18px; }
.card.wide { width: 440px; padding: 28px 26px; }
.muted { color: var(--muted); font-size: 13px; margin: 4px 0 14px; }

.group-label {
  margin: 22px 0 10px; font-size: 12.5px; font-weight: 800;
  color: #94a3b8; letter-spacing: .04em;
}

/* ---------------- 툴바 ---------------- */
.toolbar { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.tool-label { color: #475569; font-weight: 800; font-size: 13px; margin-right: 2px; }
.tilde { color: #98a2b3; }
.sep { width: 1px; height: 22px; background: var(--line); margin: 0 6px; }
.spacer { flex: 1; }
input[type=date] {
  font-size: 13.5px; color: var(--ink); background: #fff;
  border: 1px solid #dbe1ea; border-radius: 9px; padding: 8px 12px; outline: none;
}
input[type=date]:focus { border-color: var(--brand); }

/* ---------------- 타일(다운로드 항목) ---------------- */
.tile-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.tile {
  text-align: left; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 15px 16px; display: flex; flex-direction: column; gap: 5px;
  transition: transform .1s, box-shadow .14s, border-color .14s;
}
.tile:hover {
  border-color: #c7cbf7; box-shadow: 0 8px 22px rgba(79, 70, 229, .12);
  transform: translateY(-1px);
}
.tile:disabled { opacity: .55; cursor: default; transform: none; box-shadow: none; }
.tile-name { font-size: 14.5px; font-weight: 800; }
.tile-desc { font-size: 12px; color: var(--muted); }

/* ---------------- 요약 통계 ---------------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 16px 0; }
.card.stat { padding: 15px 18px; }
.card.stat .k { color: var(--muted); font-size: 12.5px; font-weight: 700; }
.card.stat .v { font-size: 28px; font-weight: 800; margin-top: 3px; letter-spacing: -.5px; }

/* ---------------- 상태 ---------------- */
.status-card { margin-top: 18px; }
.statusbar {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 18px; margin-top: 4px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
}
.status-row { display: flex; align-items: center; gap: 10px; }
#status, #statusText { color: #475569; font-size: 13px; }
.dot {
  width: 9px; height: 9px; border-radius: 50%; flex: 0 0 9px;
  background: #cbd5e1;
}
.dot.run { background: var(--brand); animation: pulse 1.1s infinite; }
.dot.ok { background: var(--ok); }
.dot.bad { background: var(--bad); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* ---------------- 버튼 ---------------- */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; border: none; border-radius: 10px;
  font-size: 14px; font-weight: 800; padding: 10px 22px; cursor: pointer;
  box-shadow: 0 6px 16px rgba(79, 70, 229, .26);
  transition: filter .12s, transform .1s;
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { background: #c3c6e6; box-shadow: none; cursor: default; }
.btn-primary.block { width: 100%; margin-top: 8px; }
.btn-ghost {
  background: #fff; color: #475569; border: 1px solid var(--line);
  border-radius: 9px; padding: 8px 14px; font-size: 12.5px; font-weight: 700; cursor: pointer;
}
.btn-ghost:hover { color: var(--ink); border-color: #cdd6e2; }
.dl-excel {
  display: inline-flex; align-items: center; gap: 8px;
  background: #217346; color: #fff; font-size: 13px; font-weight: 800;
  text-decoration: none; border: none; border-radius: 9px;
  padding: 9px 16px; white-space: nowrap;
  box-shadow: 0 1px 3px rgba(33, 115, 70, .35);
}
.dl-excel:hover { background: #1a5b38; }
.dl-excel .xls-ico { display: block; flex: none; }

/* ---------------- 표 ---------------- */
.table-wrap { margin-top: 14px; position: relative; }
table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; overflow: hidden; box-shadow: var(--shadow);
}
th {
  background: #f7f9fc; color: #66707d; font-size: 12.5px; font-weight: 800;
  text-align: left; padding: 12px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td {
  padding: 11px 12px; border-bottom: 1px solid #e6ebf2; font-size: 13.5px;
  vertical-align: middle; white-space: nowrap;
}
tr.group-end td { border-bottom: 2px solid #c8d3e0; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafbff; }
td.c, th.c { text-align: center; }
.grade { font-weight: 800; }
td.reason { color: #5b6572; white-space: normal; word-break: break-word; }
.empty-row td {
  text-align: center; color: #a3adba; font-size: 13.5px;
  padding: 46px 12px; background: #fff;
}
.empty-row:hover td { background: #fff; }

/* ---------------- 로그인 / 설정 ---------------- */
body.center {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px;
  background:
    radial-gradient(1200px 600px at 50% -10%, #e7e9ff 0%, rgba(231,233,255,0) 60%),
    var(--bg);
}
.auth-wrap { width: 100%; display: flex; justify-content: center; }
.auth-card {
  width: 372px; background: var(--card); border: 1px solid var(--line);
  border-radius: 20px; padding: 34px 30px 28px; text-align: center;
  box-shadow: 0 20px 60px rgba(15, 23, 42, .12);
}
.auth-card.wide { width: 500px; text-align: left; }
.auth-logo {
  width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 15px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 24px rgba(79, 70, 229, .34);
}
.auth-logo .mark { color: #fff; font-size: 22px; font-weight: 800; }
.auth-card h1 { font-size: 24px; font-weight: 800; letter-spacing: -.4px; }
.auth-card .sub { margin: 5px 0 20px; color: var(--muted); font-size: 13px; }
.auth-hint { margin-top: 14px; color: #94a3b8; font-size: 12px; }

.seg {
  display: flex; background: #f1f3f9; border-radius: 11px; padding: 4px; margin-bottom: 18px;
}
.seg-btn {
  flex: 1; border: none; background: transparent; cursor: pointer;
  padding: 9px 0; border-radius: 8px; font-size: 13.5px; font-weight: 800; color: #64748b;
}
.seg-btn.on { background: #fff; color: var(--brand); box-shadow: 0 2px 8px rgba(15,23,42,.08); }

.field-label {
  display: block; text-align: left; font-size: 12.5px; font-weight: 700;
  color: #475569; margin: 12px 0 5px;
}
.auth-card input {
  width: 100%; padding: 11px 13px; font-size: 14px;
  border: 1px solid #dbe1ea; border-radius: 10px; outline: none;
}
.auth-card input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.divider {
  display: flex; align-items: center; gap: 10px; margin: 20px 0 2px;
  color: #94a3b8; font-size: 12px; font-weight: 700;
}
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.error {
  color: var(--bad); font-size: 12.5px; margin: 10px 0 0; text-align: center;
  background: #fdecec; border-radius: 9px; padding: 9px 12px; line-height: 1.45;
}

/* ---------------- 매장 선택 ---------------- */
.center-wrap { display: flex; justify-content: center; padding: 40px 20px; }
.card.wide h2 { font-size: 18px; }
.store-row {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 15px; margin-bottom: 8px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 11px;
}
.store-row:hover { background: #f7faff; border-color: #d5e1ff; }
.store-row input { accent-color: var(--brand); }
.row-end { display: flex; justify-content: flex-end; margin-top: 14px; }

@media (max-width: 720px) {
  .sidebar { display: none; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .two { grid-template-columns: 1fr; }
  .auth-card.wide { width: 100%; }
}
