* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", Roboto, sans-serif;
  background: #f5f6f8;
  color: #1f2430;
}
.muted { color: #6b7280; font-size: 0.9em; }

/* Auth */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.auth-card {
  background: white; padding: 32px; border-radius: 12px; width: 360px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}
.auth-card h1 { font-size: 1.3em; margin: 0 0 4px; }
.auth-card form { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.auth-card label { display: flex; flex-direction: column; gap: 4px; font-size: 0.9em; }

input[type="text"], input[type="email"], input[type="password"], input[type="date"],
input[type="number"], select {
  padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 0.95em;
}

.tabs { display: flex; gap: 4px; margin: 12px 0; border-bottom: 1px solid #e5e7eb; }
.tab {
  border: none; background: none; padding: 8px 14px; cursor: pointer; color: #6b7280;
  border-bottom: 2px solid transparent; font-size: 0.95em;
}
.tab.active { color: #2563eb; border-bottom-color: #2563eb; font-weight: 600; }

.btn {
  padding: 8px 14px; border-radius: 6px; border: 1px solid #d1d5db; background: white;
  cursor: pointer; font-size: 0.9em;
}
.btn.primary { background: #2563eb; border-color: #2563eb; color: white; }
.btn.danger { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
.btn.small { padding: 4px 10px; font-size: 0.85em; }
.btn.full { width: 100%; }
.btn-row { display: flex; gap: 8px; margin: 12px 0; }

.alert { padding: 10px 12px; border-radius: 6px; margin: 10px 0; font-size: 0.9em; }
.alert.error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.alert.info { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }

/* Layout */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; background: #111827; color: #e5e7eb; display: flex; flex-direction: column;
  padding: 16px 0; flex-shrink: 0;
}
.sidebar .brand { font-weight: 700; font-size: 1.2em; padding: 0 16px 16px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-link { color: #cbd5e1; text-decoration: none; padding: 10px 16px; font-size: 0.92em; display: block; }
.nav-link.active, .nav-link:hover { background: #1f2937; color: white; }
.nav-group { display: flex; flex-direction: column; }
.nav-group-title {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  background: none; border: none; color: #cbd5e1; padding: 10px 16px; font-size: 0.92em;
  cursor: pointer; font-family: inherit; text-align: left;
}
.nav-group-title:hover { background: #1f2937; color: white; }
.nav-group-arrow { font-size: 0.75em; opacity: 0.7; }
.nav-group-children { display: flex; flex-direction: column; }
.nav-group-children .nav-link { padding-left: 32px; font-size: 0.88em; }
.sidebar-footer { padding: 16px; border-top: 1px solid #1f2937; }
.sidebar-footer .who { font-size: 0.85em; margin-bottom: 8px; }
.sidebar-footer .btn { width: 100%; }

.content { flex: 1; padding: 24px 32px; overflow-x: auto; }
.screen h2 { margin-top: 0; }
.screen-header-row { display: flex; align-items: center; justify-content: space-between; }
.screen-header-row h2 { margin: 0; }

.card { background: white; border-radius: 8px; padding: 16px; margin: 12px 0; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }

.data-table { width: 100%; border-collapse: collapse; background: white; border-radius: 8px; overflow: hidden; margin: 12px 0; }
.data-table th, .data-table td { padding: 8px 10px; border-bottom: 1px solid #eef0f2; text-align: left; font-size: 0.9em; }
.data-table th { background: #f9fafb; font-weight: 600; }
.data-table.small th, .data-table.small td { padding: 6px 8px; font-size: 0.85em; }

.inline-form { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.checkbox-inline { display: flex; align-items: center; gap: 6px; font-size: 0.9em; }

.stat-grid { display: flex; gap: 16px; margin: 16px 0; }
.stat-card { background: white; border-radius: 8px; padding: 20px; flex: 1; text-align: center; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.stat-num { font-size: 2em; font-weight: 700; color: #2563eb; }
.stat-label { color: #6b7280; font-size: 0.9em; margin-top: 4px; }

.block-card { border: 1px solid #e5e7eb; }
.block-card.excluded { opacity: 0.5; }
.block-card.needs-review { border: 2px solid #fca5a5; background: #fff7f7; }
.data-table tr.needs-review-row { background: #fff7f7; }
.data-table tr.needs-review-row:hover { background: #fdeaea; }
.hint-error { color: #b91c1c; font-size: 0.78em; margin-top: 3px; max-width: 180px; }

/* Follow-ups */
.data-table tr.postpone-row td { background: #f9fafb; padding-top: 10px; padding-bottom: 10px; }
.btn-link {
  background: none; border: none; padding: 0; margin: 0; color: #2563eb;
  text-decoration: underline; cursor: pointer; font-size: inherit; font-family: inherit;
}

/* Customers/Orders detail modal */
.clickable-row { cursor: pointer; }
.clickable-row:hover { background: #f3f4f6; }
.clickable-row.expanded { background: #eff6ff; }

/* Pending Commission expandable detail row */
tr.detail-row td { background: #f9fafb; padding: 0; }
.detail-panel { padding: 16px 18px; border-left: 3px solid #2563eb; }
.detail-panel h4 { margin: 14px 0 6px; }
.detail-panel h4:first-child { margin-top: 0; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 6px; font-size: 0.92em; }
.field-label { display: block; font-size: 0.8em; color: #6b7280; margin-bottom: 4px; }
.modal-overlay {
  position: fixed; inset: 0; background: rgba(17, 24, 39, 0.5);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto; z-index: 1000;
}
.modal-card {
  background: white; border-radius: 10px; padding: 24px; width: 100%; max-width: 780px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.2);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-head h3 { margin: 0; }
.modal-card h4 { margin: 18px 0 6px; }
.note-item { padding: 8px 0; border-bottom: 1px solid #f0f0f0; }
.note-meta { font-size: 0.8em; color: #6b7280; }
.note-text { white-space: pre-wrap; }
#note-input { padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 6px; font-family: inherit; font-size: 0.9em; resize: vertical; }
.block-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.badge { padding: 3px 8px; border-radius: 999px; font-size: 0.8em; }
.badge.warn { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.badge.ok { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.badge.error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.badge.neutral { background: #f3f4f6; color: #4b5563; border: 1px solid #e5e7eb; }
.badge.chargeback { background: #f5f3ff; color: #6d28d9; border: 1px solid #ddd6fe; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 10px 0; }
.grid4 label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85em; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 10px 0; }
.grid3 label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85em; }
