:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #1c2128;
  --text-muted: #6b7280;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --green-bg: #dcfce7;
  --green-text: #166534;
  --amber-bg: #fef3c7;
  --amber-text: #92400e;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

header {
  padding: 24px 32px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.header-logo {
  height: 44px;
  width: auto;
  padding-right: 14px;
  border-right: 1px solid var(--border);
}

h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.conn-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  cursor: default;
}

.conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.conn-status.conn-checking {
  color: var(--text-muted);
  background: #f3f4f6;
}
.conn-status.conn-checking .conn-dot {
  background: #9ca3af;
  animation: conn-pulse 1s ease-in-out infinite;
}

.conn-status.conn-ok {
  color: var(--green-text);
  background: var(--green-bg);
  border-color: transparent;
}
.conn-status.conn-ok .conn-dot {
  background: #22c55e;
}

.conn-status.conn-down {
  color: #991b1b;
  background: #fee2e2;
  border-color: transparent;
}
.conn-status.conn-down .conn-dot {
  background: #ef4444;
}

@keyframes conn-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

#search {
  flex: 1 1 280px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
}

.toolbar select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--surface);
}

#refreshBtn {
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: white;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

#refreshBtn:hover {
  background: var(--accent-hover);
}

#refreshBtn:disabled {
  opacity: 0.6;
  cursor: default;
}

#exportBtn {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

#exportBtn:hover {
  background: #fafbfc;
}

.status-bar {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  gap: 16px;
}

main {
  padding: 20px 32px 40px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 13px;
}

thead th {
  text-align: left;
  padding: 10px 12px;
  background: #fafbfc;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}

thead th:hover {
  color: var(--text);
}

tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

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

tbody tr:hover {
  background: #fafbfc;
}

/* separador visual entre pickings distintos, ya que ahora cada fila es un producto:
   borde superior mas marcado + franja de color alternada por grupo de picking */
tbody tr.group-start td {
  border-top: 2px solid #aab0ba;
}

tbody tr.group-alt {
  background: #f5f7fa;
}

tbody tr.group-alt:hover {
  background: #eef1f5;
}

tbody tr.group-total td {
  font-weight: 600;
  text-align: right;
  color: var(--text-muted);
  background: #eef1f5;
  border-bottom: 2px solid #aab0ba;
}

tbody tr.group-total td:first-child {
  text-align: left;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.badge.assigned {
  background: var(--green-bg);
  color: var(--green-text);
}

.badge.partially_available,
.badge.confirmed,
.badge.waiting {
  background: var(--amber-bg);
  color: var(--amber-text);
}

.badge.draft {
  background: #e5e7eb;
  color: #374151;
}

.badge.done {
  background: #dbeafe;
  color: #1e40af;
}

.badge.cancel {
  background: #fee2e2;
  color: #991b1b;
}

.products-preview {
  color: var(--text-muted);
  font-size: 12px;
}

.skus {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
}

.error {
  background: #fee2e2;
  color: #991b1b;
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 14px;
}

.hidden {
  display: none;
}

.empty, .loading {
  padding: 40px;
  text-align: center;
  color: var(--text-muted);
}

body.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

.login-logo {
  display: block;
  width: 220px;
  max-width: 100%;
  height: auto;
  margin: 0 auto 16px;
}

.login-card h2 {
  margin: 0 0 4px;
  font-size: 18px;
}

.login-hint {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--text-muted);
}

.login-card label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 6px;
}

.login-card input {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
}

.login-card button {
  margin-top: 14px;
  padding: 10px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: white;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.login-card button:hover {
  background: var(--accent-hover);
}

.login-card button:disabled {
  opacity: 0.6;
  cursor: default;
}

.login-error {
  background: #fee2e2;
  color: #991b1b;
  padding: 8px 10px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-top: 4px;
}

.user-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
  padding: 0;
}

.link-btn:hover {
  text-decoration: underline;
}

.logout-form {
  display: inline;
  margin: 0;
}
