* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Pretendard", "Malgun Gothic", -apple-system, BlinkMacSystemFont, sans-serif;
  background: #f4f4f2;
  color: #222;
}
.app { display: flex; flex-direction: column; height: 100vh; }
body:not(.authed) .app { display: none; }

.auth-gate {
  position: fixed;
  inset: 0;
  background: #1f2430;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
body.authed .auth-gate { display: none; }
.auth-box {
  background: #fff;
  border-radius: 12px;
  padding: 28px 32px;
  width: 260px;
  text-align: center;
}
.auth-box h2 { margin: 0 0 16px; font-size: 16px; }
.auth-box input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d8d7d1;
  border-radius: 6px;
  font-size: 14px;
  margin-bottom: 10px;
  text-align: center;
}
.auth-box .btn-primary { width: 100%; }
.auth-error { color: #c0392b; font-size: 12px; min-height: 16px; margin: 10px 0 0; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: #1f2430;
  color: #fff;
  flex-shrink: 0;
}
.topbar h1 { font-size: 18px; font-weight: 600; margin: 0; }
.topbar-right { display: flex; gap: 8px; align-items: center; }
.topbar-right input {
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid #444a5a;
  background: #2b3242;
  color: #fff;
  font-size: 13px;
  width: 180px;
}
.topbar-right input::placeholder { color: #9aa0ad; }

.btn-primary {
  background: #3d7dfc;
  color: #fff;
  border: none;
  padding: 9px 14px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 500;
}
.btn-primary:hover { background: #2f6ce0; }

.body { display: flex; flex: 1; min-height: 0; }

.sidebar {
  width: 200px;
  background: #fff;
  border-right: 1px solid #e3e2dd;
  overflow-y: auto;
  flex-shrink: 0;
  padding: 8px;
}
.sidebar button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  color: #444;
  margin-bottom: 2px;
}
.sidebar button:hover { background: #f0f0ee; }
.sidebar button.active { background: #3d7dfc; color: #fff; font-weight: 500; }
.sidebar .divider { height: 1px; background: #e8e7e2; margin: 8px 4px; }

.content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
}

h2.tab-title { margin: 0 0 4px; font-size: 20px; }
p.tab-desc { margin: 0 0 20px; color: #666; font-size: 13px; }

.panel {
  background: #fff;
  border: 1px solid #e3e2dd;
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 18px;
}
.panel h3 { margin: 0 0 12px; font-size: 14px; color: #444; }

.settings-row { display: flex; flex-wrap: wrap; gap: 16px; }
.settings-row label {
  font-size: 12px;
  color: #666;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.settings-row input, .settings-row select {
  padding: 6px 8px;
  border: 1px solid #d8d7d1;
  border-radius: 6px;
  font-size: 13px;
  width: 110px;
}
.settings-row .checkbox-field { flex-direction: row; align-items: center; gap: 6px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 10px; border-bottom: 1px solid #edece7; text-align: left; }
th { color: #777; font-weight: 500; font-size: 12px; }
tbody tr:hover { background: #fafaf8; }
td input[type="text"], td input[type="number"] {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #d8d7d1;
  border-radius: 6px;
  font-size: 13px;
}
td input[type="checkbox"] { width: 16px; height: 16px; }
td select {
  padding: 6px 8px;
  border: 1px solid #d8d7d1;
  border-radius: 6px;
  font-size: 13px;
}
.num-col { text-align: right; }
.muted { color: #999; font-size: 12px; }

.row-actions { display: flex; gap: 8px; margin-top: 12px; }
.btn-sm {
  background: #fff;
  border: 1px solid #d8d7d1;
  padding: 7px 12px;
  border-radius: 6px;
  font-size: 12.5px;
  cursor: pointer;
  color: #333;
}
.btn-sm:hover { background: #f4f4f2; }
.btn-danger { color: #c0392b; }
.btn-sm:disabled { opacity: 0.35; cursor: default; }

.reorder-cell { display: flex; flex-direction: column; gap: 2px; white-space: nowrap; }
.reorder-cell .btn-sm { padding: 2px 6px; font-size: 11px; line-height: 1.2; }

.totals {
  display: flex;
  gap: 24px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #edece7;
}
.totals .metric-label { font-size: 12px; color: #888; margin-bottom: 4px; }
.totals .metric-value { font-size: 22px; font-weight: 600; }
.totals .metric-sub { font-size: 12px; color: #999; margin-top: 2px; }
.totals .highlight-metric .metric-label { color: #2f6ce0; font-weight: 500; }
.totals .highlight-metric .metric-value { color: #2f6ce0; font-size: 26px; }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #999;
  font-size: 13px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.summary-card {
  background: #fff;
  border: 1px solid #e3e2dd;
  border-radius: 10px;
  padding: 14px 16px;
}
.summary-card .label { font-size: 12px; color: #888; margin-bottom: 6px; }
.summary-card .value { font-size: 20px; font-weight: 600; }
.summary-card .sub { font-size: 11px; color: #aaa; margin-top: 4px; }
