/* =========================================================================
   Tekmax Middleware — Sistema de diseño
   Panel de control para la sincronización SAGE 50 <-> WooCommerce B2B
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  /* Color */
  --bg: #F6F7F5;
  --surface: #FFFFFF;
  --surface-raised: #FFFFFF;
  --border: #E2E5E1;
  --border-strong: #CBD0C9;

  --ink: #1B2027;
  --ink-soft: #5B6470;
  --ink-faint: #8A9199;

  --accent: #BAE37A;
  --accent-ink: #3F6B1D;
  --accent-soft: #EEF7DF;

  --success: #2E7D5B;
  --success-soft: #E1EFE8;
  --warning: #B4841F;
  --warning-soft: #F5EBD6;
  --error: #C1442E;
  --error-soft: #F6E2DE;
  --neutral-soft: #ECEEEA;

  /* Type */
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'IBM Plex Sans', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;

  /* Layout */
  --sidebar-w: 248px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(27, 32, 39, 0.06);
  --shadow-md: 0 4px 16px rgba(27, 32, 39, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--ink);
  margin: 0;
  letter-spacing: -0.01em;
}

code, .mono { font-family: var(--font-mono); }

a { color: inherit; text-decoration: none; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* =========================================================================
   Login
   ========================================================================= */

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  background:
    radial-gradient(circle at 15% 20%, rgba(181, 101, 29, 0.07), transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(46, 125, 91, 0.06), transparent 45%),
    var(--bg);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 40px 36px 32px;
}

.login-mark {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}

.login-mark .dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent);
}

.login-mark span {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.login-card h1 {
  font-size: 22px;
  margin-bottom: 4px;
}

.login-card p.lead {
  color: var(--ink-soft);
  font-size: 13.5px;
  margin: 0 0 28px;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 14px;
  background: #FCFCFB;
  color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .1s ease, background .15s ease, border-color .15s ease;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  width: 100%;
  margin-top: 6px;
}
.btn-primary:hover { background: var(--accent-ink); color: #fff; }

.btn-ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--ink);
}
.btn-ghost:hover { border-color: var(--ink-soft); }

.login-hint {
  margin-top: 20px;
  padding: 12px 14px;
  background: var(--neutral-soft);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--ink-soft);
}
.login-hint code { color: var(--accent-ink); }

.alert {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  background: var(--error-soft);
  color: var(--error);
  border: 1px solid rgba(193, 68, 46, 0.25);
}

/* =========================================================================
   App shell
   ========================================================================= */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 22px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}

.brand .dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-family: var(--font-display); font-size: 14.5px; }
.brand-text span { font-size: 11px; color: var(--ink-faint); font-family: var(--font-mono); }

.nav-group { margin-bottom: 18px; }

.nav-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  padding: 0 10px;
  margin-bottom: 6px;
  font-weight: 500;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--ink-soft);
  margin-bottom: 2px;
  cursor: pointer;
}

.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.8; }

.nav-item:hover { background: var(--neutral-soft); color: var(--ink); }

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 500;
}
.nav-item.active svg { opacity: 1; }

.sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--ink-soft);
}

.sidebar-footer a { color: var(--ink-faint); }
.sidebar-footer a:hover { color: var(--error); }

/* Main */

.main {
  padding: 28px 36px 60px;
  max-width: 1440px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}

.page-head h1 { font-size: 24px; margin-bottom: 4px; }
.page-head p { color: var(--ink-soft); font-size: 13.5px; margin: 0; max-width: 560px; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-ink);
  margin-bottom: 6px;
  display: block;
}

/* =========================================================================
   Cards / KPIs
   ========================================================================= */

.grid-kpi {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 28px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 18px;
  box-shadow: var(--shadow-sm);
}

.kpi-label {
  font-size: 12px;
  color: var(--ink-soft);
  margin-bottom: 8px;
}

.kpi-value {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  margin-bottom: 6px;
}

.kpi-sub {
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
}

.tag::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.tag-success { background: var(--success-soft); color: var(--success); }
.tag-warning { background: var(--warning-soft); color: var(--warning); }
.tag-error   { background: var(--error-soft);   color: var(--error); }
.tag-neutral { background: var(--neutral-soft); color: var(--ink-soft); }

/* =========================================================================
   Pipeline diagram (elemento de firma)
   ========================================================================= */

.pipeline-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  margin-bottom: 28px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.pipeline-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 22px;
}

.pipeline-head h2 { font-size: 16px; }
.pipeline-head .mono { font-size: 11.5px; color: var(--ink-faint); }

.pipeline {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  align-items: center;
  gap: 6px;
}

.pnode {
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  background: #FCFCFB;
  position: relative;
}

.pnode .pdot {
  width: 8px; height: 8px;
  border-radius: 50%;
  margin: 0 auto 10px;
  background: var(--ink-faint);
}
.pnode.pending .pdot { background: var(--warning); }
.pnode.ok .pdot { background: var(--success); }
.pnode.err .pdot { background: var(--error); }

.pnode strong { display: block; font-family: var(--font-display); font-size: 14px; margin-bottom: 3px; }
.pnode span { font-size: 11px; color: var(--ink-faint); font-family: var(--font-mono); }

.pline {
  position: relative;
  height: 2px;
  background: repeating-linear-gradient(90deg, var(--border-strong) 0 6px, transparent 6px 11px);
  min-width: 36px;
}

.pline .flow-dot {
  position: absolute;
  top: -3px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0;
  animation: flow 3.2s ease-in-out infinite;
}
.pline .flow-dot.d2 { animation-delay: 1.6s; background: var(--success); }

@keyframes flow {
  0%   { left: 0%;  opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { left: calc(100% - 8px); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .pline .flow-dot { animation: none; opacity: 0.6; left: 46%; }
}

.pipeline-note {
  margin-top: 18px;
  font-size: 12.5px;
  color: var(--ink-soft);
  background: var(--warning-soft);
  border: 1px solid rgba(180, 132, 31, 0.25);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
}
.pipeline-note strong { color: var(--warning); }

/* =========================================================================
   Tables
   ========================================================================= */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.panel-head h2 { font-size: 15px; }

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

thead th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-faint);
  font-weight: 500;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 13px 20px;
  border-bottom: 1px solid var(--border);
  color: var(--ink);
  white-space: nowrap;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #FBFBFA; }

.cell-mono { font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-soft); }
.cell-muted { color: var(--ink-faint); }

/* =========================================================================
   Config / connection form
   ========================================================================= */

.form-section {
  padding: 22px 24px;
  border-bottom: 1px solid var(--border);
}
.form-section:last-child { border-bottom: none; }

.form-section h3 { font-size: 14.5px; margin-bottom: 3px; }
.form-section p.hint { font-size: 12.5px; color: var(--ink-soft); margin: 0 0 16px; }

.form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.form-row .field input, .form-row .field select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 13px;
  background: #FCFCFB;
  color: var(--ink);
}

.form-row .field input::placeholder { color: var(--ink-faint); font-style: italic; }

.badge-pending {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--warning);
  background: var(--warning-soft);
  padding: 3px 9px;
  border-radius: 999px;
}

/* Empty state */
.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--ink-soft);
}
.empty-state h3 { font-size: 15px; color: var(--ink); margin-bottom: 6px; }
.empty-state p { font-size: 13px; max-width: 380px; margin: 0 auto; }

/* Responsive */
@media (max-width: 980px) {
  .grid-kpi { grid-template-columns: repeat(2, 1fr); }
  .pipeline { grid-template-columns: 1fr; }
  .pline { width: 2px; height: 28px; margin: 0 auto; }
}

@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 20px; }
  .grid-kpi { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}
