/* ── Buttons ──────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.13s, border-color 0.13s, box-shadow 0.13s, transform 0.08s;
  white-space: nowrap;
  text-decoration: none;
  letter-spacing: 0.01em;
}

.btn:active { transform: scale(0.975); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: 0 2px 8px rgba(0,133,255,0.25);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.btn-danger {
  background: transparent;
  color: var(--red);
  border-color: rgba(217,48,37,0.25);
}
.btn-danger:hover {
  background: var(--red-dim);
  border-color: var(--red);
}

.btn-sm {
  padding: 5px 12px;
  font-size: 12.5px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius);
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-icon-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.btn-icon-danger:hover {
  background: var(--red-dim);
  color: var(--red);
}

/* ── Badges ───────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 4px;
  font-size: 11.5px;
  font-weight: 600;
  font-family: var(--font-body);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.badge-green  { background: var(--green-dim);   color: #007A4D; }
.badge-blue   { background: var(--accent-dim);  color: #0055A5; }
.badge-red    { background: var(--red-dim);     color: var(--red); }
.badge-gold   { background: var(--yellow-bg);   color: var(--yellow); }
.badge-muted  { background: #F1F3F6;            color: var(--text-secondary); }
.badge-purple { background: var(--purple-dim);  color: var(--purple); }
.badge-outline {
  border: 1px solid var(--border);
  color: var(--text-secondary);
  background: transparent;
}

/* ── Cards ────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title {
  font-family: var(--font-head);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--text-primary);
}

/* ── Tables ───────────────────────────────────────────────────────── */
.table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table thead th {
  padding: 11px 16px;
  text-align: left;
  font-size: 11px;
  font-family: var(--font-body);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-light);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--bg-page);
}

.data-table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-size: 13.5px;
  color: var(--text-primary);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.table-row {
  cursor: pointer;
  transition: background 0.1s;
}
.table-row:hover { background: var(--bg-hover); }

.row-vip {
  border-left: 3px solid var(--yellow);
}
.row-vip td:first-child {
  padding-left: 13px;
}

/* Cell helpers */
.cell-with-avatar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cell-stack { display: flex; flex-direction: column; gap: 1px; }
.cell-primary { font-size: 13.5px; color: var(--text-primary); font-weight: 500; }
.cell-secondary { font-size: 12px; color: var(--text-secondary); }

.row-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: flex-end;
  opacity: 0;
  transition: opacity 0.12s;
}
.table-row:hover .row-actions { opacity: 1; }

/* ── Avatars ──────────────────────────────────────────────────────── */
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-head);
  font-size: 12.5px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.avatar-sm {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-head);
  font-size: 9.5px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.avatar-lg {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-head);
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

/* ── Toolbar / Search ─────────────────────────────────────────────── */
.section-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.search-wrap {
  position: relative;
  flex: 1;
  max-width: 340px;
}

.search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 13.5px;
  transition: border-color 0.13s, box-shadow 0.13s;
  box-shadow: var(--shadow-card);
}
.search-input::placeholder { color: var(--text-light); }
.search-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(0,133,255,0.12);
}

.record-count {
  font-family: var(--font-body);
  font-size: 12.5px;
  color: var(--text-light);
  white-space: nowrap;
  margin-left: auto;
}

/* ── Forms ────────────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-row { display: flex; flex-direction: column; gap: 14px; }
.form-row-2 { flex-direction: row; }
.form-row-2 > .form-group { flex: 1; }
.form-row-3 { flex-direction: row; }
.form-row-3 > .form-group { flex: 1; }

.form-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.01em;
}

.required { color: var(--red); margin-left: 1px; }

.form-input,
.form-select,
.form-textarea {
  padding: 8px 11px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 13.5px;
  transition: border-color 0.13s, box-shadow 0.13s;
  width: 100%;
}

.form-input::placeholder,
.form-textarea::placeholder { color: var(--text-light); }

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(0,133,255,0.10);
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
  cursor: pointer;
}

.form-select option {
  background: var(--bg-card);
  color: var(--text-primary);
}

.form-textarea { resize: vertical; min-height: 72px; }
.input-error { border-color: var(--red) !important; box-shadow: 0 0 0 3px rgba(217,48,37,0.10) !important; }

/* ── Modal ────────────────────────────────────────────────────────── */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28,31,46,0.55);
  backdrop-filter: blur(3px);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

#modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 540px;
  max-width: 100%;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-modal);
  animation: modal-in 0.18s cubic-bezier(0.34, 1.36, 0.64, 1);
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.95) translateY(6px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}

#modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#modal-title {
  font-family: var(--font-head);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--text-primary);
}

#modal-body {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.modal-content {
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  background: var(--bg-page);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  flex-shrink: 0;
}

/* ── Detail Panel ─────────────────────────────────────────────────── */
#panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28,31,46,0.3);
  z-index: 199;
}

#detail-panel {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: 420px;
  max-width: 90vw;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  z-index: 200;
  display: flex;
  flex-direction: column;
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: -4px 0 24px rgba(0,0,0,0.10);
}

.panel-closed { transform: translateX(100%); }
.panel-open   { transform: translateX(0); }

#panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-page);
}

#panel-title {
  font-family: var(--font-head);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--text-primary);
}

#panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* Panel content */
.panel-client-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.panel-client-name {
  font-family: var(--font-head);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.panel-client-boat {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 7px;
}

.panel-section {
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.panel-section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.panel-section-title {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-light);
  margin-bottom: 10px;
}

.panel-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 5px 0;
  gap: 12px;
}

.panel-label {
  font-size: 12.5px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.panel-value {
  font-size: 13px;
  color: var(--text-primary);
  text-align: right;
  font-weight: 500;
}

.panel-notes {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  padding: 10px 12px;
  background: var(--bg-hover);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.job-history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}
.job-history-item:last-child { border-bottom: none; }

.jh-left { flex: 1; min-width: 0; }
.jh-service { font-size: 13px; color: var(--text-primary); font-weight: 500; }
.jh-date { font-size: 11.5px; color: var(--text-secondary); font-family: var(--font-mono); margin-top: 2px; }

.jh-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.jh-price {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--green-text, #007A4D);
  font-weight: 600;
}

.panel-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

/* ── Loyalty Points ───────────────────────────────────────────────── */
.loyalty-section {
  background: linear-gradient(135deg, rgba(245,158,11,0.08) 0%, rgba(245,158,11,0.03) 100%);
  border-radius: var(--radius);
  border: 1px solid rgba(245,158,11,0.25) !important;
  padding: 14px !important;
  margin-bottom: 18px;
}

.loyalty-balance {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 8px 0 4px;
}

.loyalty-stars {
  font-size: 22px;
  color: #f59e0b;
  line-height: 1;
}

.loyalty-pts-num {
  font-family: var(--font-head);
  font-size: 32px;
  font-weight: 800;
  color: #f59e0b;
  line-height: 1;
}

.loyalty-pts-label {
  font-size: 14px;
  font-weight: 600;
  color: #E08D00;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.loyalty-hint {
  font-size: 11px;
  color: var(--text-light);
  margin-bottom: 10px;
}

.loyalty-redeem-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}

.loyalty-redeem-select {
  flex: 1;
  font-size: 13px !important;
  padding: 6px 10px !important;
}

.loyalty-progress-wrap {
  height: 6px;
  background: var(--bg-hover);
  border-radius: 99px;
  overflow: hidden;
  margin: 10px 0 6px;
}

.loyalty-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
  border-radius: 99px;
  transition: width 0.4s ease;
  min-width: 4px;
}

.loyalty-progress-label {
  font-size: 11px;
  color: var(--text-light);
}

/* ── Toast ────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  opacity: 0;
  transform: translateY(8px) scale(0.97);
  transition: opacity 0.18s, transform 0.18s;
  pointer-events: auto;
  max-width: 300px;
  box-shadow: var(--shadow-raised);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.toast-show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.toast-success .toast-icon { color: var(--green); }
.toast-error   .toast-icon { color: var(--red); }
.toast-info    .toast-icon { color: var(--accent); }

.toast-icon {
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ── Empty States ─────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 56px 24px;
  text-align: center;
}

.empty-icon {
  font-size: 36px;
  margin-bottom: 14px;
  opacity: 0.25;
}

.empty-title {
  font-family: var(--font-head);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.empty-subtitle {
  font-size: 13.5px;
  color: var(--text-secondary);
  max-width: 260px;
  line-height: 1.5;
}

.empty-state-sm {
  padding: 14px 0;
  font-size: 12.5px;
  color: var(--text-secondary);
  text-align: center;
}

/* ── Stat Cards ───────────────────────────────────────────────────── */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-card);
  transition: box-shadow 0.15s, border-color 0.15s;
}
.stat-card:hover {
  box-shadow: var(--shadow-raised);
  border-color: var(--border-hover);
}

.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-value {
  font-family: var(--font-head);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.stat-label {
  font-size: 11.5px;
  color: var(--text-secondary);
  margin-top: 2px;
  font-weight: 500;
}

/* ── Chart Container ──────────────────────────────────────────────── */
.chart-container {
  width: 100%;
  min-height: 190px;
}

/* ── Mobile responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Modal slides up from bottom on mobile */
  #modal-overlay {
    align-items: flex-end;
    padding: 0;
  }
  #modal-box {
    width: 100%;
    max-width: 100%;
    max-height: 92vh;
    border-radius: 20px 20px 0 0;
    animation: modal-in-mobile 0.22s cubic-bezier(0.32, 0.72, 0, 1);
  }
  @keyframes modal-in-mobile {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }

  /* Form rows stack on mobile */
  .form-row-2 { flex-direction: column; gap: 12px; }

  /* Panel full width */
  #detail-panel { width: 100% !important; }

  /* Reduce card padding */
  .card { padding: 14px; }

  /* Row action buttons bigger tap targets */
  .btn-sm { padding: 7px 14px; font-size: 13px; }
  .btn-icon-danger { width: 32px; height: 32px; }

  /* Table cells tighter */
  .data-table th, .data-table td { padding: 10px 12px; font-size: 12.5px; }
}
