:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --purple: #7c3aed;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea {
  font-family: inherit;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #374151; }

.hidden { display: none !important; }
.text-muted { color: var(--muted); font-size: 13px; }
.text-right { text-align: right; }
.fw-bold { font-weight: 700; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; align-items: center; gap: 8px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.flex-wrap { flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }

@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.15s;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline { background: #fff; color: var(--text); border-color: var(--border); }
.btn-outline:hover:not(:disabled) { background: #f9fafb; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-lg { padding: 13px 18px; font-size: 15px; width: 100%; }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.badge-PENDING_REVIEW { background: #fef3c7; color: #92400e; }
.badge-OPEN { background: #dbeafe; color: #1e40af; }
.badge-ASSIGNED { background: #ede9fe; color: #5b21b6; }
.badge-COMPLETED { background: #d1fae5; color: #065f46; }
.badge-SETTLED { background: #e5e7eb; color: #374151; }
.badge-CANCELLED { background: #fee2e2; color: #991b1b; }
.badge-HEJHOME { background: #f3e8ff; color: #6b21a8; }
.badge-DIRECT { background: #ccfbf1; color: #0f766e; }
.badge-ACTIVE { background: #d1fae5; color: #065f46; }
.badge-PENDING { background: #fef3c7; color: #92400e; }
.badge-SUSPENDED { background: #fee2e2; color: #991b1b; }

/* Auth / Consumer Mobile Shell */
.mobile-shell {
  max-width: 500px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 16px 14px 86px;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 18px;
  position: sticky;
  top: 0;
  z-index: 20;
}

/* Admin Layout */
.admin-shell {
  display: flex;
  min-height: 100vh;
}
.admin-sidebar {
  width: 230px;
  background: #111827;
  color: #f9fafb;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}
.admin-sidebar h2 {
  font-size: 16px;
  margin: 0 0 14px 8px;
  color: #fff;
}
.nav-item {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: #d1d5db;
  font-size: 14px;
  font-weight: 500;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; font-weight: 700; }
.admin-main {
  flex: 1;
  padding: 22px;
  min-width: 0;
}

@media (max-width: 900px) {
  .admin-shell { flex-direction: column; }
  .admin-sidebar {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding: 12px;
  }
  .admin-sidebar h2 { margin: 0 12px 0 0; }
  .nav-item { width: auto; padding: 7px 10px; font-size: 13px; }
  .admin-main { padding: 14px; }
}

/* Tables */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
th, td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
th {
  background: #f9fafb;
  font-weight: 700;
  color: #4b5563;
  white-space: nowrap;
}
tr.clickable:hover { background: #f8fafc; cursor: pointer; }

/* Bottom Tab Bar for Installer */
.bottom-tabs {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 500px;
  background: #fff;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  z-index: 30;
}
.bottom-tab {
  padding: 12px 6px;
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.bottom-tab.active {
  color: var(--primary);
  border-top: 2px solid var(--primary);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}
.modal {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 22px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 12.5px;
  cursor: pointer;
}
.chip.selected {
  background: #dbeafe;
  border-color: var(--primary);
  color: #1e40af;
  font-weight: 700;
}

.thumb-grid { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.thumb {
  width: 78px;
  height: 78px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.sig-canvas {
  width: 100%;
  height: 170px;
  border: 1.5px dashed #9ca3af;
  border-radius: 10px;
  background: #fafafa;
  touch-action: none;
}

.stat-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}
.stat-card .stat-label { font-size: 12.5px; color: var(--muted); }
.stat-card .stat-val { font-size: 22px; font-weight: 800; margin-top: 4px; }

.toast {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: #111827;
  color: #fff;
  padding: 11px 18px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }
