:root { --gap: 12px; --radius: 10px; }
* { box-sizing: border-box; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "TH Sarabun New", sans-serif;
  margin: 0; padding: 20px;
  background: #0f172a; color: #e2e8f0;
}
h1,h2 { margin: 0 0 8px; }
.wrap { display: grid; gap: var(--gap); width: 100%; }
.card {
  background: #111827; border: 1px solid #1f2937;
  border-radius: var(--radius); padding: 16px;
}
.grid { display: grid; gap: 10px; }
.grid.cols-6 { grid-template-columns: repeat(auto-fit, minmax(120px,1fr)); }
label.small { font-size: 12px; opacity: .9; }
input[type="number"] {
  width: 100%; padding: 8px 10px; border-radius: 8px;
  border: 1px solid #374151; background: #0b1220; color: #e5e7eb;
}
input[type="checkbox"] { transform: scale(1.2); }
button {
  all: unset; cursor: pointer; padding: 4px 8px;
  border-radius: 8px; background: #223049; color: #e5e7eb;
}
button.danger { background:#492230; color:#ffd7d7; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px; border-bottom: 1px dashed #253043; text-align: right; }
th { background: #0b1220; position: sticky; top: 0; z-index: 2; }
td:first-child, th:first-child { text-align: left; }
.muted { color: #93a0b5; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; background: #0b5; color: #062; font-weight: 600; font-size: 12px; }
.badge.blue { background:#0a84ff; color:#001a33; }
.row-owned td { opacity: .55; }
.totals { font-weight: 700; }
.pill {
  background: #0b1220; border: 1px solid #243044;
  padding: 8px 12px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 8px;
}
.flex { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.note { font-size: 12px; color: #9aa8bf; }
.table-wrapper { max-height: 60vh; overflow:auto; border:1px solid #1f2937; border-radius: 8px; }
.sticky-footer {
  position: sticky; bottom: 0; background: #0b1220;
  border: 1px solid #1f2937; border-radius: var(--radius);
  padding: 12px;
}

/* Profile system styles */
select {
  padding: 4px 8px; border-radius: 6px;
  background: #0b1220; color: #e5e7eb;
  border: 1px solid #374151;
  cursor: pointer;
}
select:focus {
  outline: none;
  border-color: #0a84ff;
}
input[type="text"] {
  padding: 4px 8px; border-radius: 6px;
  background: #0b1220; color: #e5e7eb;
  border: 1px solid #374151;
}
input[type="text"]:focus {
  outline: none;
  border-color: #0a84ff;
}

/* Loading Modal Styles */
.loading-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(10px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  animation: fadeIn 0.3s ease-out;
}

.loading-content {
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.loading-spinner {
  width: 60px;
  height: 60px;
  border: 4px solid #1f2937;
  border-top: 4px solid #0a84ff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 20px;
}

.loading-content h2 {
  color: #e2e8f0;
  margin: 0 0 30px;
  font-size: 18px;
}

.loading-steps {
  text-align: left;
  margin: 20px 0;
}

.loading-step {
  padding: 8px 0;
  color: #64748b;
  font-size: 14px;
  opacity: 0.5;
  transition: all 0.3s ease;
}

.loading-step.active {
  color: #0a84ff;
  opacity: 1;
  transform: translateX(10px);
}

.loading-step.completed {
  color: #10b981;
  opacity: 1;
}

.loading-progress {
  margin-top: 20px;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: #1f2937;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #0a84ff, #3b82f6);
  width: 0%;
  transition: width 0.5s ease;
  border-radius: 3px;
}

.progress-text {
  color: #9ca3af;
  font-size: 12px;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-modal.fade-out {
  animation: fadeOut 0.5s ease-out forwards;
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* กล่องสรุปใหม่ */
.summary-box {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid #243044;
  border-radius: 10px;
  background: #0b1220;
  line-height: 1.8;
}
.summary-box strong { color: #0af; }
