/* CT Chemicals — mobile-first styles */

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: #1a1a1a;
  background: #f5f5f5;
}

.page-wrap  { max-width: 680px; margin: 0 auto; padding: 16px; }
.card       { background: #fff; border-radius: 8px; padding: 20px; margin-bottom: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.1); }

h1 { font-size: 1.4rem; margin-bottom: 4px; }
h2 { font-size: 1.1rem; margin-bottom: 12px; color: #333; }
h3 { font-size: 1rem;   margin-bottom: 8px;  color: #444; }

.subtitle { color: #666; font-size: 0.9rem; margin-bottom: 16px; }

/* ── Alerts ────────────────────────────────────────────── */
.alert          { padding: 12px 16px; border-radius: 6px; margin-bottom: 16px; font-size: 0.9rem; }
.alert-error    { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success  { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-info     { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }

/* ── Forms ─────────────────────────────────────────────── */
.form-group    { margin-bottom: 16px; }
label          { display: block; font-weight: 600; margin-bottom: 4px; font-size: 0.9rem; }
input[type=text],
input[type=number],
input[type=password],
input[type=file],
select,
textarea {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 1rem;
  background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #D61E8C;
  box-shadow: 0 0 0 3px rgba(214,30,140,.15);
}

.radio-group         { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 4px; }
.radio-group label   { font-weight: normal; display: flex; align-items: center; gap: 6px; cursor: pointer; }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: 12px 24px;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}
.btn-primary   { background: #D61E8C; color: #fff; }
.btn-primary:hover { background: #b5187a; }
.btn-full      { width: 100%; display: block; }
.btn-sm        { padding: 6px 14px; font-size: 0.85rem; }

/* ── CT Chemicals order form logo ──────────────────────── */
.form-logo { display: block; max-width: 300px; height: auto; margin: 0 auto 4px; }
.form-logo-round { display: block; width: 90px; height: 90px; margin: 20px auto 8px; border-radius: 50%; }
.success-brand { text-align: center; margin-top: 8px; }
.success-brand p { color: #6b7280; font-size: 0.8rem; margin-top: 4px; }

/* ── Full pricelist toggle ──────────────────────────────── */
.toggle-card { padding: 0; }
.btn-toggle-pricelist {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: none;
  border: none;
  font-size: 1rem;
  font-weight: 600;
  color: #29B6F6;
  cursor: pointer;
  border-radius: 8px;
  text-align: left;
}
.btn-toggle-pricelist:hover { background: #f0faff; }
.toggle-icon { font-size: 0.75rem; color: #6b7280; }
.sku-label   { color: #6b7280; }

/* ── Product table (order form) ─────────────────────────── */
.product-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.product-table th { text-align: left; padding: 8px 6px; border-bottom: 2px solid #e5e7eb; color: #6b7280; font-size: 0.8rem; text-transform: uppercase; }
.product-table td { padding: 10px 6px; border-bottom: 1px solid #f3f4f6; vertical-align: middle; }
.product-table tr:last-child td { border-bottom: none; }
.qty-input     { width: 64px; text-align: center; padding: 6px 4px; }

/* ── Running total bar ──────────────────────────────────── */
#total-bar {
  position: sticky;
  bottom: 0;
  background: #1A3A6B;
  color: #fff;
  padding: 14px 20px;
  border-radius: 8px 8px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1rem;
}
#total-bar .discount-note { font-size: 0.8rem; color: #86d8f7; }

/* ── Dashboard ──────────────────────────────────────────── */
.snapshot-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 4px; }
.stat-box      { background: #f9fafb; border-radius: 6px; padding: 14px; text-align: center; }
.stat-box .val { font-size: 1.6rem; font-weight: 700; color: #1A3A6B; }
.stat-box .lbl { font-size: 0.75rem; color: #6b7280; margin-top: 2px; text-transform: uppercase; }

.outstanding-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.outstanding-table th { text-align: left; padding: 8px 6px; color: #6b7280; font-size: 0.75rem; text-transform: uppercase; border-bottom: 2px solid #e5e7eb; }
.outstanding-table td { padding: 10px 6px; border-bottom: 1px solid #f3f4f6; }

.badge-green  { display: inline-block; background: #dcfce7; color: #166534; padding: 2px 8px; border-radius: 12px; font-size: 0.75rem; }
.badge-amber  { display: inline-block; background: #fef9c3; color: #92400e; padding: 2px 8px; border-radius: 12px; font-size: 0.75rem; }
.badge-red    { display: inline-block; background: #fee2e2; color: #991b1b; padding: 2px 8px; border-radius: 12px; font-size: 0.75rem; }

.status-dot        { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.status-dot.green  { background: #22c55e; }
.status-dot.amber  { background: #f59e0b; }
.status-dot.red    { background: #ef4444; }

.system-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid #f3f4f6; font-size: 0.9rem; }

.error-log-entry { font-size: 0.8rem; color: #6b7280; padding: 6px 0; border-bottom: 1px solid #f3f4f6; }
.error-log-entry .comp { color: #dc2626; font-weight: 600; }

@media (min-width: 540px) {
  .snapshot-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ── Scheduler panel ────────────────────────────────────── */
.scheduler-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #f3f4f6;
  gap: 8px;
  flex-wrap: wrap;
}
.scheduler-row:last-child { border-bottom: none; }
.scheduler-job-name  { font-weight: 600; font-size: 0.9rem; min-width: 90px; }
.scheduler-job-desc  { font-size: 0.8rem; color: #6b7280; flex: 1; }
.scheduler-job-sched { font-size: 0.75rem; color: #9ca3af; font-family: monospace; }
.scheduler-actions   { display: flex; gap: 6px; }
.btn-xs {
  padding: 4px 10px;
  border: none;
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
  font-weight: 600;
}
.btn-xs.pause  { background: #fef3c7; color: #92400e; }
.btn-xs.resume { background: #dcfce7; color: #166534; }
.btn-xs.trigger { background: #dbeafe; color: #1e40af; }
.btn-xs:disabled { opacity: 0.5; cursor: not-allowed; }

/* Toggle switch */
.toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}
.toggle-label input { display: none; }
.toggle-track {
  width: 40px; height: 22px;
  background: #d1d5db;
  border-radius: 11px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}
.toggle-label input:checked + .toggle-track { background: #D61E8C; }
.toggle-thumb {
  position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: left 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.toggle-label input:checked + .toggle-track .toggle-thumb { left: 21px; }
.toggle-text { font-size: 0.85rem; color: #374151; }

/* ── Customer list ──────────────────────────────────────── */
.customer-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.customer-table th {
  text-align: left;
  padding: 8px 6px;
  color: #6b7280;
  font-size: 0.72rem;
  text-transform: uppercase;
  border-bottom: 2px solid #e5e7eb;
}
.customer-table td { padding: 9px 6px; border-bottom: 1px solid #f3f4f6; vertical-align: top; }
.customer-table tr:last-child td { border-bottom: none; }
.cust-code { font-family: monospace; color: #374151; }
.cust-test-badge { background: #fef9c3; color: #92400e; border-radius: 10px; padding: 1px 6px; font-size: 0.7rem; }

/* ── Recent orders ──────────────────────────────────────── */
.orders-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.orders-table th {
  text-align: left;
  padding: 8px 6px;
  color: #6b7280;
  font-size: 0.72rem;
  text-transform: uppercase;
  border-bottom: 2px solid #e5e7eb;
}
.orders-table td { padding: 9px 6px; border-bottom: 1px solid #f3f4f6; }
.orders-table tr:last-child td { border-bottom: none; }
.status-pending   { color: #f59e0b; font-weight: 600; }
.status-confirmed { color: #2563eb; font-weight: 600; }
.status-delivered { color: #16a34a; font-weight: 600; }
.status-cancelled { color: #9ca3af; }
