/* ============================================================
   ServiceTrade Pipeline — stylesheet
   ============================================================ */

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

:root {
  --navy:    #0f172a;
  --navy-2:  #1e293b;
  --navy-3:  #334155;
  --blue:    #3b82f6;
  --blue-dk: #2563eb;
  --green:   #22c55e;
  --red:     #ef4444;
  --amber:   #f59e0b;
  --slate:   #64748b;
  --slate-lt:#94a3b8;
  --bg:      #f8fafc;
  --white:   #ffffff;
  --border:  #e2e8f0;
  --radius:  8px;
  --shadow:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  background: var(--bg);
  color: var(--navy);
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  font-family: "SF Mono", "Fira Code", Consolas, monospace;
  font-size: 0.85em;
  background: #f1f5f9;
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--navy-2);
}

/* ---- Navbar ---- */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--navy);
  padding: 0 24px;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 0 rgba(255,255,255,.05);
}

.navbar-brand {
  color: var(--white);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -.2px;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.navbar-brand:hover { text-decoration: none; opacity: .9; }
.brand-icon { font-size: 18px; }

.navbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.navbar-user {
  color: var(--slate-lt);
  font-size: 13px;
}

/* ---- Page wrapper ---- */
.billing-banner {
  background: #7f1d1d;
  color: #fecaca;
  text-align: center;
  padding: 10px 24px;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}
.billing-banner-link {
  color: #fff;
  font-weight: 600;
  text-decoration: underline;
  white-space: nowrap;
}
.billing-banner-link:hover { opacity: 0.85; }

.page-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius);
  border: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, opacity .15s, transform .1s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--blue);
  color: var(--white);
}
.btn-primary:hover { background: var(--blue-dk); text-decoration: none; color: var(--white); }

.btn-ghost {
  background: transparent;
  color: var(--slate-lt);
  border: 1px solid var(--navy-3);
}
.btn-ghost:hover { background: var(--navy-3); color: var(--white); text-decoration: none; }

.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-full { width: 100%; }

/* ---- Alerts ---- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 13.5px;
  line-height: 1.5;
}
.alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
}

/* ---- Auth pages ---- */
.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 56px);
  padding: 32px 16px;
}

.auth-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  padding: 40px 36px;
  width: 100%;
  max-width: 440px;
}

.auth-header { margin-bottom: 28px; }
.auth-header h1 { font-size: 22px; font-weight: 700; color: var(--navy); }
.auth-subtitle { color: var(--slate); margin-top: 6px; font-size: 13.5px; }

.auth-form { display: flex; flex-direction: column; gap: 16px; }

.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-weight: 500; font-size: 13px; color: var(--navy-2); }
.form-group input {
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--navy);
  background: var(--white);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.form-group input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.form-group input::placeholder { color: var(--slate-lt); }
.form-hint { font-size: 12px; color: var(--slate-lt); }

.form-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0;
  color: var(--slate);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.form-divider::before, .form-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-footer {
  text-align: center;
  margin-top: 20px;
  color: var(--slate);
  font-size: 13px;
}

/* ---- Dashboard ---- */
.dashboard-wrapper { max-width: 100%; }

.dashboard-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}
.dashboard-title { font-size: 22px; font-weight: 700; }
.dashboard-subtitle { color: var(--slate); margin-top: 4px; font-size: 13px; }

/* ---- Summary cards ---- */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.summary-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow);
}
.summary-value { font-size: 28px; font-weight: 700; line-height: 1; }
.summary-label { font-size: 12px; color: var(--slate); margin-top: 4px; text-transform: uppercase; letter-spacing: .04em; }

.summary-card--success .summary-value { color: var(--green); }
.summary-card--running .summary-value { color: var(--blue); }
.summary-card--error   .summary-value { color: var(--red); }
.summary-card--pending .summary-value { color: var(--slate); }

/* ---- Table ---- */
.table-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.pipeline-table {
  width: 100%;
  border-collapse: collapse;
}
.pipeline-table th {
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--slate);
  text-align: left;
}
.pipeline-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.pipeline-table tr:last-child td { border-bottom: none; }
.pipeline-table tr:hover td { background: #f8fafc; }

.endpoint-name { font-size: 13px; }

.text-muted  { color: var(--slate); }
.text-sm     { font-size: 12px; }
.text-right  { text-align: right; }
.text-center { text-align: center; }

.error-cell { max-width: 220px; }
.error-text {
  color: var(--red);
  font-size: 12px;
  cursor: help;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  max-width: 100%;
}

/* ---- Status badges ---- */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: lowercase;
}
.badge--success { background: #dcfce7; color: #15803d; }
.badge--running { background: #dbeafe; color: #1d4ed8; }
.badge--error   { background: #fee2e2; color: #dc2626; }
.badge--pending { background: #f1f5f9; color: var(--slate); }

.footer-note {
  margin-top: 16px;
  font-size: 12px;
  color: var(--slate-lt);
  text-align: center;
}

/* ---- Toast notifications ---- */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 18px;
  border-radius: var(--radius);
  background: var(--navy-2);
  color: var(--white);
  font-size: 13.5px;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .25s, transform .25s;
  z-index: 9999;
  max-width: 320px;
}
.toast--visible { opacity: 1; transform: translateY(0); }
.toast--success { background: #166534; }
.toast--error   { background: #991b1b; }
.toast--info    { background: var(--navy-2); }

/* ---- Responsive ---- */
@media (max-width: 640px) {
  .auth-card { padding: 28px 20px; }
  .dashboard-header { flex-direction: column; }
  .pipeline-table th:nth-child(6),
  .pipeline-table td:nth-child(6) { display: none; }
}

/* ============================================================
   Extended styles for all 15 features
   ============================================================ */

/* ---- Navbar extended ---- */
.navbar-left  { display: flex; align-items: center; }
.navbar-center {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  justify-content: center;
}
.brand-name { font-size: 14px; }

.nav-link {
  color: var(--slate-lt);
  font-size: 12.5px;
  font-weight: 500;
  padding: 6px 9px;
  border-radius: 5px;
  text-decoration: none;
  transition: color .15s, background .15s;
  white-space: nowrap;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}
.nav-link:hover, .nav-link--active {
  color: var(--white);
  background: var(--navy-3);
  text-decoration: none;
}

/* ---- Nav dropdown ---- */
.nav-dropdown { position: relative; }
.nav-dropdown-btn { display: flex; align-items: center; gap: 4px; }
.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 200px;
  background: var(--navy-2);
  border: 1px solid var(--navy-3);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  z-index: 200;
  padding: 6px;
}
.nav-dropdown-menu--open { display: block; }
.nav-dropdown-item {
  display: block;
  color: var(--slate-lt);
  font-size: 12.5px;
  padding: 7px 10px;
  border-radius: 5px;
  text-decoration: none;
  transition: background .12s, color .12s;
}
.nav-dropdown-item:hover { background: var(--navy-3); color: var(--white); text-decoration: none; }
.nav-dropdown-divider { border-top: 1px solid var(--navy-3); margin: 4px 0; }

/* ---- Location selector ---- */
.loc-form { display: flex; align-items: center; }
.loc-select {
  background: var(--navy-2);
  border: 1px solid var(--navy-3);
  color: var(--slate-lt);
  border-radius: 5px;
  padding: 4px 8px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}
.loc-select:focus { outline: none; border-color: var(--blue); }

/* ---- Page header ---- */
.page-header {
  margin-bottom: 24px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header h1 { font-size: 22px; font-weight: 700; margin: 0; }
.page-subtitle { color: var(--slate); font-size: 13px; margin: 4px 0 0; }

/* ---- Stat grid ---- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.stat-label { font-size: 11.5px; color: var(--slate); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
.stat-value { font-size: 26px; font-weight: 700; line-height: 1; }
.stat-card--green .stat-value { color: var(--green); }
.stat-card--red   .stat-value { color: var(--red); }
.stat-card--amber .stat-value { color: var(--amber); }
.stat-card--blue  .stat-value { color: var(--blue); }

/* ---- Chart ---- */
.chart-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
@media (max-width: 768px) { .chart-row { grid-template-columns: 1fr; } }
.chart-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  box-shadow: var(--shadow);
}
.chart-title { font-size: 14px; font-weight: 600; margin-bottom: 14px; }

/* ---- Alert badge (maintenance alerts page) ---- */
.alert-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.alert-badge--critical { background: #fee2e2; color: #dc2626; }
.alert-badge--warning  { background: #fef3c7; color: #92400e; }
.alert-badge--info     { background: #dbeafe; color: #1d4ed8; }

/* ---- Settings sections ---- */
.settings-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}
.settings-card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}
.settings-card-header h2 { font-size: 15px; font-weight: 600; margin: 0; }
.settings-card-header p  { margin: 4px 0 0; font-size: 12.5px; color: var(--slate); }
.settings-card-body { padding: 20px; }

/* ---- Form helpers ---- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.form-full { grid-column: 1 / -1; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--navy-2); }
.field input, .field select, .field textarea {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13.5px;
  color: var(--navy);
  background: var(--white);
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
.field-hint { font-size: 11.5px; color: var(--slate-lt); }

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
}
.toggle-label { font-size: 13.5px; font-weight: 500; }
.toggle-desc { font-size: 12px; color: var(--slate); }

/* ---- Alert banners ---- */
.alert-success {
  background: #dcfce7;
  border: 1px solid #86efac;
  color: #166534;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13.5px;
  margin-bottom: 16px;
}
.alert-info {
  background: #dbeafe;
  border: 1px solid #93c5fd;
  color: #1e40af;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13.5px;
  margin-bottom: 16px;
}
.alert-warning {
  background: #fef3c7;
  border: 1px solid #fcd34d;
  color: #92400e;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13.5px;
  margin-bottom: 16px;
}

/* ---- Onboarding checklist ---- */
.onboarding-widget {
  background: linear-gradient(135deg, #eff6ff 0%, #f0fdf4 100%);
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 24px;
}
.onboarding-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.onboarding-title { font-size: 15px; font-weight: 600; color: var(--navy-2); }
.onboarding-progress { font-size: 12px; color: var(--slate); }
.onboarding-steps { display: flex; flex-direction: column; gap: 8px; }
.onboarding-step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
}
.onboarding-step a { color: var(--navy-2); text-decoration: none; }
.onboarding-step a:hover { color: var(--blue); text-decoration: underline; }
.onboarding-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  flex-shrink: 0;
}
.onboarding-icon--done { background: var(--green); color: var(--white); }
.onboarding-icon--todo { background: var(--border); color: var(--slate); }
.onboarding-bar {
  background: var(--border);
  border-radius: 999px;
  height: 6px;
  margin-top: 14px;
  overflow: hidden;
}
.onboarding-bar-fill {
  height: 100%;
  background: var(--green);
  border-radius: 999px;
  transition: width .4s ease;
}

/* ---- KPI builder ---- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  box-shadow: var(--shadow);
  position: relative;
}
.kpi-name  { font-size: 12px; color: var(--slate); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .03em; }
.kpi-value { font-size: 28px; font-weight: 700; color: var(--navy); }
.kpi-agg   { font-size: 11px; color: var(--slate-lt); margin-top: 4px; }
.kpi-delete {
  position: absolute;
  top: 8px; right: 8px;
  background: none;
  border: none;
  color: var(--slate-lt);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
}
.kpi-delete:hover { background: #fee2e2; color: var(--red); }

/* ---- Portal (public) ---- */
.portal-wrapper { max-width: 860px; margin: 0 auto; padding: 32px 20px; }
.portal-header { margin-bottom: 28px; }
.portal-company { font-size: 22px; font-weight: 700; }
.portal-meta   { color: var(--slate); font-size: 13px; margin-top: 4px; }
.portal-section-title { font-size: 15px; font-weight: 600; margin: 24px 0 12px; }

/* ---- Exports page ---- */
.export-table-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid #f1f5f9;
}
.export-table-row:last-child { border-bottom: none; }
.export-table-name { font-size: 13.5px; font-weight: 500; }
.export-actions { display: flex; gap: 6px; }

/* ---- Code block ---- */
.code-block {
  background: var(--navy-2);
  color: #93c5fd;
  padding: 14px 18px;
  border-radius: 8px;
  font-family: "SF Mono", "Fira Code", Consolas, monospace;
  font-size: 12px;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ---- Profitability ---- */
.profit-positive { color: var(--green); font-weight: 600; }
.profit-negative { color: var(--red);   font-weight: 600; }

/* ---- Skeleton / lazy-load states ---- */
.skeleton-text {
  background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s infinite;
  border-radius: 4px;
  color: transparent !important;
  min-width: 80px;
  display: inline-block;
}
.chart-skeleton {
  background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s infinite;
  border-radius: 8px;
  height: 180px;
  width: 100%;
}
@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.loading-spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid #e2e8f0;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
