/* =========================================================
   pb-companies — design tokens & global styles
   Adapted from Sidebar_Companies.html color system
   ========================================================= */

:root {
  --c-text:        #0f172a;
  --c-muted:       #475569;
  --c-subtle:      #94a3b8;
  --c-bg:          #f8fafc;
  --c-surface:     #ffffff;
  --c-brand:       #6366f1;
  --c-brand-dark:  #4338ca;
  --c-brand-light: #e0e7ff;
  --c-danger:      #dc2626;
  --c-danger-bg:   #fef2f2;
  --c-warn:        #d97706;
  --c-warn-bg:     #fffbeb;
  --c-ok:          #059669;
  --c-ok-bg:       #ecfdf5;
  --c-info:        #2563eb;
  --c-info-bg:     #eff6ff;
  --c-border:      #e2e8f0;
  --c-border-focus:#a5b4fc;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;

  --shadow-card: 0 1px 3px rgba(15,23,42,.08), 0 4px 16px rgba(15,23,42,.04);
  --shadow-modal: 0 20px 60px rgba(15,23,42,.18);

  --font: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

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

body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--c-text);
  background: var(--c-bg);
  min-height: 100vh;
  line-height: 1.5;
}

/* ── Layout ── */
.app-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 32px;
  height: 56px;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
}

.topbar-logo {
  font-size: 15px;
  font-weight: 700;
  color: var(--c-brand);
  letter-spacing: -.3px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-family: var(--font);
}
.topbar-logo:hover { text-decoration: underline; }

.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-dot { color: var(--c-border); }

.topbar-tool-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--c-text);
}

.topbar-right { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* ── Datacenter toggle ── */
.dc-toggle {
  display: flex;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  overflow: hidden;
}

.dc-btn {
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 600;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--c-muted);
  font-family: var(--font);
  transition: background .15s, color .15s;
  letter-spacing: .03em;
}
.dc-btn:hover { background: var(--c-border); color: var(--c-text); }
.dc-btn.active { background: var(--c-brand-light); color: var(--c-brand); }

.main-content {
  display: grid;
  grid-template-columns: 280px 1fr;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
  padding: 32px 24px;
  gap: 24px;
  align-items: start;
}

/* ── Sidebar nav ── */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--c-muted);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: background .15s, color .15s;
}

.nav-item:hover { background: var(--c-border); color: var(--c-text); }
.nav-item.active { background: var(--c-brand-light); color: var(--c-brand); }
.nav-item .icon { font-size: 16px; flex-shrink: 0; }

.nav-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--c-subtle);
  padding: 16px 14px 4px;
}

/* ── Panel / Card ── */
.panel {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
}

.panel-header {
  padding: 20px 24px 0;
}

.panel-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--c-text);
}

.panel-subtitle {
  font-size: 13px;
  color: var(--c-muted);
  margin-top: 4px;
}

.panel-body { padding: 20px 24px 24px; }

.panel-divider {
  border: none;
  border-top: 1px solid var(--c-border);
  margin: 0;
}

/* ── Form elements ── */
label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--c-text);
  margin-bottom: 6px;
}

.label-hint {
  font-weight: 400;
  color: var(--c-muted);
  margin-left: 6px;
}

input[type="text"],
input[type="password"],
input[type="date"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  font-family: var(--font);
  font-size: 14px;
  color: var(--c-text);
  background: var(--c-surface);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--c-border-focus);
  box-shadow: 0 0 0 3px rgba(99,102,241,.12);
}

.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }

.input-row { display: flex; gap: 8px; }
.input-row input, .input-row select { flex: 1; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--r-sm);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background .15s, opacity .15s, transform .1s;
  white-space: nowrap;
}

.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary  { background: var(--c-brand); color: #fff; }
.btn-primary:hover:not(:disabled)  { background: var(--c-brand-dark); }

.btn-secondary {
  background: var(--c-surface);
  color: var(--c-text);
  border: 1px solid var(--c-border);
}
.btn-secondary:hover:not(:disabled) { background: var(--c-bg); }

.btn-danger   { background: var(--c-danger); color: #fff; }
.btn-danger:hover:not(:disabled)   { background: #b91c1c; }

.btn-ghost {
  background: none;
  color: var(--c-muted);
  padding: 6px 10px;
}
.btn-ghost:hover:not(:disabled) { background: var(--c-border); color: var(--c-text); }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-full { width: 100%; justify-content: center; }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
}
.badge-ok     { background: var(--c-ok-bg);     color: var(--c-ok); }
.badge-warn   { background: var(--c-warn-bg);   color: var(--c-warn); }
.badge-danger { background: var(--c-danger-bg); color: var(--c-danger); }
.badge-info   { background: var(--c-info-bg);   color: var(--c-info); }
.badge-muted  { background: var(--c-border);    color: var(--c-muted); }

/* ── Alert banners ── */
.alert {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--r-sm);
  font-size: 13px;
  line-height: 1.5;
  margin-top: 12px;
}
.alert-icon { flex-shrink: 0; font-size: 15px; margin-top: 1px; }
.alert-ok     { background: var(--c-ok-bg);     color: var(--c-ok);     border: 1px solid #a7f3d0; }
.alert-warn   { background: var(--c-warn-bg);   color: var(--c-warn);   border: 1px solid #fcd34d; }
.alert-danger { background: var(--c-danger-bg); color: var(--c-danger); border: 1px solid #fca5a5; }
.alert-info   { background: var(--c-info-bg);   color: var(--c-info);   border: 1px solid #93c5fd; }

/* ── Progress bar ── */
.progress-wrap {
  background: var(--c-border);
  border-radius: 99px;
  height: 6px;
  overflow: hidden;
  margin-top: 10px;
}

.progress-bar {
  height: 100%;
  background: var(--c-brand);
  border-radius: 99px;
  transition: width .3s ease;
}

/* ── Filter block ── */
.filter-block {
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  background: var(--c-surface);
}
.filter-block-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--c-text);
  margin: 0 0 8px;
}
.filter-radios { display: flex; flex-direction: column; gap: 6px; }
.radio-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 400;
  color: var(--c-text);
  margin-bottom: 0;
  cursor: pointer;
}
.radio-label input[type="radio"] { margin: 0; cursor: pointer; }
.filter-sub { }
.filter-dynamic-row { display: flex; gap: 8px; align-items: center; }
.filter-dynamic-row input, .filter-dynamic-row select { width: auto; }

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--c-muted);
  margin-top: 6px;
}

/* ── File drop zone ── */
.dropzone {
  border: 2px dashed var(--c-border);
  border-radius: var(--r-md);
  padding: 32px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.dropzone:hover, .dropzone.drag-over {
  border-color: var(--c-brand);
  background: var(--c-brand-light);
}
.dropzone-icon { font-size: 32px; display: block; margin-bottom: 10px; }
.dropzone-label { font-weight: 600; color: var(--c-text); }
.dropzone-hint  { font-size: 12px; color: var(--c-muted); margin-top: 4px; }

/* ── Field mapping table ── */
.mapping-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.mapping-table th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--c-muted);
  padding: 8px 12px;
  background: var(--c-bg);
  border-bottom: 1px solid var(--c-border);
  text-align: left;
}

.mapping-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--c-border);
  vertical-align: middle;
}

.mapping-table tr:last-child td { border-bottom: none; }
.mapping-table select { font-size: 13px; padding: 6px 8px; }

.col-tag {
  font-family: ui-monospace, monospace;
  font-size: 12px;
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: 4px;
  padding: 2px 6px;
  color: var(--c-text);
}

/* ── Results table ── */
.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.results-table th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--c-muted);
  padding: 8px 12px;
  background: var(--c-bg);
  border-bottom: 1px solid var(--c-border);
  text-align: left;
}
.results-table td { padding: 8px 12px; border-bottom: 1px solid var(--c-border); }
.results-table tr:last-child td { border-bottom: none; }

/* ── Home screen ── */
.home-shell {
  display: flex;
  justify-content: center;
  padding: 48px 24px;
}

.home-content {
  width: 100%;
  max-width: 800px;
}

.home-title {
  font-size: 24px;
  font-weight: 800;
  color: var(--c-text);
  letter-spacing: -.5px;
}

.home-subtitle {
  font-size: 14px;
  color: var(--c-muted);
  margin-top: 6px;
  margin-bottom: 32px;
}

/* ── Tool cards ── */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.tool-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: 24px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .1s;
  box-shadow: var(--shadow-card);
}

.tool-card:hover {
  border-color: var(--c-brand);
  box-shadow: 0 4px 20px rgba(99,102,241,.15);
  transform: translateY(-2px);
}

.tool-card-soon {
  opacity: .5;
  cursor: not-allowed;
}

.tool-card-soon:hover {
  border-color: var(--c-border);
  box-shadow: var(--shadow-card);
  transform: none;
}

.tool-card-icon { font-size: 28px; margin-bottom: 12px; }

.tool-card-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--c-text);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tool-card-desc {
  font-size: 13px;
  color: var(--c-muted);
  line-height: 1.5;
}

/* ── Token input page ── */
.auth-shell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--c-bg);
}

.auth-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 440px;
  padding: 40px;
}

.auth-logo {
  font-size: 22px;
  font-weight: 800;
  color: var(--c-brand);
  margin-bottom: 8px;
  letter-spacing: -.5px;
}

.auth-tagline {
  font-size: 13px;
  color: var(--c-muted);
  margin-bottom: 28px;
}

/* ── Utilities ── */
.hidden   { display: none !important; }
.mt-4     { margin-top: 4px; }
.mt-8     { margin-top: 8px; }
.mt-12    { margin-top: 12px; }
.mt-16    { margin-top: 16px; }
.mt-20    { margin-top: 20px; }
.mb-16    { margin-bottom: 16px; }
.gap-8    { gap: 8px; }
.flex     { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-sm  { font-size: 13px; }
.text-muted { color: var(--c-muted); }
.text-danger { color: var(--c-danger); }
.text-ok    { color: var(--c-ok); }
.font-mono { font-family: ui-monospace, monospace; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Checkbox ── */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--c-muted);
}
.checkbox-row input[type="checkbox"] { width: auto; accent-color: var(--c-brand); cursor: pointer; }

/* ── Scrollable result list ── */
.result-scroll {
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
}

/* ── Live import log ── */
.live-log {
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  overflow: hidden;
}

.live-log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--c-bg);
  border-bottom: 1px solid var(--c-border);
  font-size: 12px;
  font-weight: 600;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.live-log-counts { font-weight: 400; color: var(--c-subtle); }

.live-log-scroll {
  max-height: 240px;
  overflow-y: auto;
  background: #0f172a;
  padding: 8px 0;
  scroll-behavior: smooth;
}

.log-entry {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 3px 14px;
  font-family: ui-monospace, "Cascadia Code", "Fira Code", monospace;
  font-size: 12px;
  line-height: 1.6;
}

.log-entry .log-ts {
  flex-shrink: 0;
  color: #475569;
  font-size: 11px;
}

.log-entry .log-msg { flex: 1; }
.log-entry .log-detail { color: #475569; font-size: 11px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.log-entry.success .log-msg { color: #34d399; }
.log-entry.error   .log-msg { color: #f87171; }
.log-entry.warn    .log-msg { color: #fbbf24; }
.log-entry.info    .log-msg { color: #93c5fd; }
