/* ============================================================
   InterCompany Sync — Design System v2
   Modern SaaS UI: dark sidebar, indigo primary, slate tokens
   ============================================================ */

/* ── Import Inter font ────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ── Design tokens ────────────────────────────────────────── */
:root {
  --ic-primary:          #4f46e5;
  --ic-primary-hover:    #4338ca;
  --ic-primary-light:    #ede9fe;
  --ic-primary-ring:     rgba(79,70,229,0.18);

  --ic-success:          #10b981;
  --ic-success-bg:       #d1fae5;
  --ic-success-text:     #065f46;

  --ic-warning:          #f59e0b;
  --ic-warning-bg:       #fef3c7;
  --ic-warning-text:     #92400e;

  --ic-danger:           #ef4444;
  --ic-danger-bg:        #fee2e2;
  --ic-danger-text:      #991b1b;

  --ic-info:             #3b82f6;
  --ic-info-bg:          #dbeafe;
  --ic-info-text:        #1e40af;

  --ic-sidebar-w:        248px;
  --ic-sidebar-bg:       #0f172a;
  --ic-sidebar-border:   rgba(255,255,255,0.07);
  --ic-sidebar-link:     #94a3b8;
  --ic-sidebar-hover-bg: rgba(255,255,255,0.06);
  --ic-sidebar-active-bg:rgba(79,70,229,0.22);
  --ic-sidebar-link-hover:#e2e8f0;
  --ic-sidebar-link-active:#ffffff;

  --ic-bg:               #f8fafc;
  --ic-surface:          #ffffff;
  --ic-border:           #e2e8f0;
  --ic-border-dark:      #cbd5e1;
  --ic-text:             #0f172a;
  --ic-muted:            #64748b;

  --ic-radius-sm:        0.375rem;
  --ic-radius:           0.5rem;
  --ic-radius-lg:        0.75rem;

  --ic-shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
  --ic-shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --ic-shadow:    0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
  --ic-shadow-md: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);

  --ic-topbar-h:  56px;
}

/* ── Base reset ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--ic-bg);
  color: var(--ic-text);
  margin: 0;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  font-size: 0.9375rem;
}

/* ── App Shell ────────────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  min-width: 0;
  margin-left: var(--ic-sidebar-w);
  padding: 1.75rem 2rem;
  display: flex;
  flex-direction: column;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--ic-sidebar-w);
  height: 100vh;
  background: var(--ic-sidebar-bg);
  border-right: 1px solid var(--ic-sidebar-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 1030;
  transition: transform 0.25s cubic-bezier(.4,0,.2,1);
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

/* Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 1.1rem 1rem 1rem;
  border-bottom: 1px solid var(--ic-sidebar-border);
  text-decoration: none;
  color: #fff;
  font-size: 0.925rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  white-space: nowrap;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.sidebar-brand:hover { color: #fff; opacity: 0.9; }

.sidebar-brand-icon {
  width: 34px;
  height: 34px;
  background: var(--ic-primary);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  box-shadow: 0 0 0 4px rgba(79,70,229,0.25);
}

.sidebar-brand-name { line-height: 1.2; }
.sidebar-brand-name span { display: block; font-size: 0.65rem; font-weight: 500; color: #64748b; letter-spacing: 0; }

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 0.5rem 0 0.75rem;
}

.sidebar-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #334155;
  padding: 1rem 1rem 0.3rem;
  display: block;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.46rem 1rem;
  color: var(--ic-sidebar-link);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 450;
  border-radius: 0;
  transition: color 0.12s, background 0.12s;
  position: relative;
  white-space: nowrap;
  margin: 0 0.35rem;
  border-radius: 6px;
}
.sidebar-link:hover {
  color: var(--ic-sidebar-link-hover);
  background: var(--ic-sidebar-hover-bg);
}
.sidebar-link.active {
  color: var(--ic-sidebar-link-active);
  background: var(--ic-sidebar-active-bg);
  font-weight: 600;
}
.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: -0.35rem;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--ic-primary);
  border-radius: 0 2px 2px 0;
}
.sidebar-link i {
  font-size: 0.95rem;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  opacity: 0.75;
}
.sidebar-link.active i { opacity: 1; }
.sidebar-link:hover i { opacity: 0.9; }

/* Footer */
.sidebar-footer {
  border-top: 1px solid var(--ic-sidebar-border);
  padding: 0.6rem 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.sidebar-user-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.65rem;
}
.sidebar-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ic-primary), #7c3aed);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.sidebar-user-email {
  font-size: 0.78rem;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}

/* sidebar form buttons */
.sidebar-footer .sidebar-btn-form { margin: 0; }
.sidebar-footer .sidebar-btn-form button {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.46rem 0.65rem;
  color: var(--ic-sidebar-link);
  background: none;
  border: none;
  font-size: 0.875rem;
  font-weight: 450;
  border-radius: 6px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: color 0.12s, background 0.12s;
}
.sidebar-footer .sidebar-btn-form button:hover {
  color: var(--ic-sidebar-link-hover);
  background: var(--ic-sidebar-hover-bg);
}
.sidebar-footer .sidebar-btn-form button i {
  font-size: 0.95rem;
  width: 18px;
  text-align: center;
  opacity: 0.75;
}

/* ── Mobile topbar ────────────────────────────────────────── */
.topbar {
  display: none;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1rem;
  height: var(--ic-topbar-h);
  background: var(--ic-sidebar-bg);
  position: sticky;
  top: 0;
  z-index: 1020;
  border-bottom: 1px solid var(--ic-sidebar-border);
}
.topbar-toggle {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 0.35rem;
  font-size: 1.25rem;
  line-height: 1;
  display: flex;
  align-items: center;
}
.topbar-brand {
  color: #fff;
  font-size: 0.925rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
  flex: 1;
}
.topbar-brand:hover { color: #fff; }

/* Sidebar overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 1029;
  backdrop-filter: blur(2px);
}

/* ── Page header ──────────────────────────────────────────── */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.85rem;
  margin-bottom: 1.5rem;
}
.page-header-left { min-width: 0; }
.page-header-title {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--ic-text);
  margin: 0;
  line-height: 1.25;
  letter-spacing: -0.02em;
}
.page-header-sub {
  margin: 0.2rem 0 0;
  color: var(--ic-muted);
  font-size: 0.85rem;
  line-height: 1.5;
}
.page-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  flex-shrink: 0;
}

/* Breadcrumb inside header */
.page-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.78rem;
  color: var(--ic-muted);
  margin-bottom: 0.3rem;
}
.page-breadcrumb a { color: var(--ic-muted); text-decoration: none; }
.page-breadcrumb a:hover { color: var(--ic-primary); }
.page-breadcrumb i { font-size: 0.65rem; }

/* ── Stat cards (dashboard) ───────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--ic-surface);
  border: 1px solid var(--ic-border);
  border-radius: var(--ic-radius);
  padding: 1.2rem 1.25rem;
  box-shadow: var(--ic-shadow-sm);
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}
.stat-card-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.sci-indigo  { background: #ede9fe; color: #4f46e5; }
.sci-blue    { background: #dbeafe; color: #2563eb; }
.sci-emerald { background: #d1fae5; color: #059669; }
.sci-amber   { background: #fef3c7; color: #d97706; }
.sci-rose    { background: #fce7f3; color: #db2777; }
.stat-card-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--ic-text);
  line-height: 1;
  margin-bottom: 0.2rem;
}
.stat-card-label {
  font-size: 0.8rem;
  color: var(--ic-muted);
  font-weight: 500;
}

/* ── Quick action cards ───────────────────────────────────── */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.quick-action-card {
  background: var(--ic-surface);
  border: 1px solid var(--ic-border);
  border-radius: var(--ic-radius);
  padding: 1.2rem 1.25rem;
  box-shadow: var(--ic-shadow-sm);
  text-decoration: none;
  color: var(--ic-text);
  display: block;
  transition: box-shadow 0.15s, border-color 0.15s, transform 0.15s;
}
.quick-action-card:hover {
  box-shadow: var(--ic-shadow);
  border-color: #a5b4fc;
  transform: translateY(-2px);
  color: var(--ic-text);
}
.quick-action-card-icon {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  background: var(--ic-primary-light);
  color: var(--ic-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  margin-bottom: 0.8rem;
}
.quick-action-card-title {
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: 0.2rem;
}
.quick-action-card-desc {
  font-size: 0.8rem;
  color: var(--ic-muted);
  line-height: 1.45;
}
.quick-action-card-arrow {
  font-size: 0.75rem;
  color: var(--ic-primary);
  margin-top: 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

/* ── IC Card ──────────────────────────────────────────────── */
.ic-card {
  background: var(--ic-surface);
  border: 1px solid var(--ic-border);
  border-radius: var(--ic-radius);
  box-shadow: var(--ic-shadow-sm);
}
.ic-card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--ic-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.ic-card-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ic-text);
  margin: 0;
}
.ic-card-body { padding: 1.25rem; }

/* ── Table wrapper ────────────────────────────────────────── */
.ic-table-wrap {
  background: var(--ic-surface);
  border: 1px solid var(--ic-border);
  border-radius: var(--ic-radius);
  box-shadow: var(--ic-shadow-sm);
  overflow: hidden;
}
.ic-table-wrap .table { margin-bottom: 0; }
.ic-table-wrap .table > :not(caption) > * > * {
  padding: 0.65rem 0.9rem;
}
.ic-table-wrap thead th {
  background: #f8fafc;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ic-muted);
  border-bottom: 1px solid var(--ic-border);
  white-space: nowrap;
}
.ic-table-wrap tbody tr { transition: background 0.1s; }
.ic-table-wrap tbody tr:hover { background: #f8fafc; }
.ic-table-wrap tbody td { border-color: #f1f5f9; vertical-align: middle; }

/* ── Badges ───────────────────────────────────────────────── */
.ic-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.22em 0.6em;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 5px;
  white-space: nowrap;
  line-height: 1.4;
}
.ic-badge-indigo  { background: #ede9fe; color: #4338ca; }
.ic-badge-blue    { background: #dbeafe; color: #1d4ed8; }
.ic-badge-emerald { background: #d1fae5; color: #065f46; }
.ic-badge-amber   { background: #fef3c7; color: #92400e; }
.ic-badge-rose    { background: #fce7f3; color: #9d174d; }
.ic-badge-slate   { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
.ic-badge-success { background: #d1fae5; color: #065f46; }
.ic-badge-danger  { background: #fee2e2; color: #991b1b; }
.ic-badge-warning { background: #fef3c7; color: #92400e; }
.ic-badge-secondary { background: #f1f5f9; color: #475569; }
.ic-badge-info    { background: #dbeafe; color: #1e40af; }
.ic-badge-purple  { background: #f3e8ff; color: #6d28d9; }
.ic-badge-outline { background: transparent; border: 1px solid currentColor; }

/* run status badges */
.run-badge-queued  { background: #f1f5f9; color: #475569; }
.run-badge-running { background: #dbeafe; color: #1d4ed8; }
.run-badge-success { background: #d1fae5; color: #065f46; }
.run-badge-partial { background: #fef3c7; color: #92400e; }
.run-badge-failed  { background: #fee2e2; color: #991b1b; }
.run-badge-stopped { background: #fce7f3; color: #9d174d; }
.run-badge-nochanges { background: #f1f5f9; color: #475569; }

/* ── Sync Control pill tabs ───────────────────────────────── */
.ic-pill-tabs {
  display: flex;
  gap: 0.25rem;
  background: #f1f5f9;
  border-radius: 8px;
  padding: 0.25rem;
  width: fit-content;
  margin-bottom: 1.25rem;
}
.ic-pill-tab {
  padding: 0.45rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ic-muted);
  border: none;
  background: none;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, box-shadow 0.15s;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.ic-pill-tab:hover { color: var(--ic-text); background: rgba(255,255,255,0.6); }
.ic-pill-tab.active {
  color: var(--ic-text);
  background: white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  font-weight: 600;
}

/* ── Button overrides / helpers ───────────────────────────── */
.btn-primary {
  background: var(--ic-primary);
  border-color: var(--ic-primary);
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--ic-primary-hover);
  border-color: var(--ic-primary-hover);
}
.btn-primary:focus { box-shadow: 0 0 0 3px var(--ic-primary-ring); }

.btn-outline-primary {
  color: var(--ic-primary);
  border-color: var(--ic-primary);
}
.btn-outline-primary:hover {
  background: var(--ic-primary);
  border-color: var(--ic-primary);
}

/* ── Auth layout ──────────────────────────────────────────── */
.auth-shell {
  display: flex;
  min-height: 100vh;
}
.auth-brand-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 3rem 2.5rem;
  background: linear-gradient(155deg, #1e1b4b 0%, #312e81 45%, #4338ca 100%);
  color: #fff;
  width: 440px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.auth-brand-panel::before {
  content: '';
  position: absolute;
  top: -80px;
  right: -80px;
  width: 300px;
  height: 300px;
  background: rgba(79,70,229,0.3);
  border-radius: 50%;
  filter: blur(60px);
}
.auth-brand-panel::after {
  content: '';
  position: absolute;
  bottom: -60px;
  left: -60px;
  width: 250px;
  height: 250px;
  background: rgba(109,40,217,0.25);
  border-radius: 50%;
  filter: blur(50px);
}
.auth-brand-content { position: relative; z-index: 1; }
.auth-brand-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 3rem;
  text-decoration: none;
}
.auth-brand-logo-icon {
  width: 46px;
  height: 46px;
  background: rgba(255,255,255,0.15);
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,0.2);
}
.auth-brand-logo-text {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
}
.auth-brand-heading {
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 0.75rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
}
.auth-brand-sub {
  font-size: 0.925rem;
  color: rgba(255,255,255,0.65);
  line-height: 1.65;
  max-width: 320px;
}
.auth-brand-features {
  margin-top: 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}
.auth-brand-feature {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.875rem;
  color: rgba(255,255,255,0.8);
}
.auth-brand-feature i { color: #a5b4fc; width: 16px; text-align: center; font-size: 0.9rem; }

.auth-form-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 3rem 2rem;
  background: #fff;
  overflow-y: auto;
}
.auth-form-inner {
  width: 100%;
  max-width: 390px;
}
.auth-form-header { margin-bottom: 1.75rem; }
.auth-form-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ic-text);
  margin-bottom: 0.3rem;
  letter-spacing: -0.02em;
}
.auth-form-sub {
  font-size: 0.875rem;
  color: var(--ic-muted);
}

/* ── Info bar (below stat cards on dashboard) ─────────────── */
.info-strip {
  background: var(--ic-primary-light);
  border: 1px solid #c7d2fe;
  border-radius: var(--ic-radius);
  padding: 0.85rem 1.1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  font-size: 0.85rem;
  color: #3730a3;
  margin-bottom: 1.25rem;
}
.info-strip i { margin-top: 1px; flex-shrink: 0; }

/* Workflow form section dividers */
.wf-section-divider {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--ic-border);
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
}
.wf-section-title {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.wf-section-hint {
  font-size: 0.78rem;
  color: var(--ic-muted);
  margin-left: 0.25rem;
}

/* ── Utility helpers ──────────────────────────────────────── */
.fw-450 { font-weight: 450; }
.text-ic { color: var(--ic-primary); }
.divider { border-top: 1px solid var(--ic-border); margin: 1.25rem 0; }

/* Password show/hide button */
.password-toggle-wrap { position: relative; }
.password-toggle-btn {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 0.25rem;
  font-size: 0.95rem;
  line-height: 1;
  display: flex;
  align-items: center;
}
.password-toggle-btn:hover { color: var(--ic-muted); }
.password-toggle-wrap .form-control { padding-right: 2.5rem; }

/* ── Responsive breakpoints ───────────────────────────────── */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.is-open {
    transform: translateX(0);
    box-shadow: var(--ic-shadow-md);
  }
  .sidebar-overlay.is-open { display: block; }
  .main-content {
    margin-left: 0;
    padding: 1rem 1rem 1.5rem;
  }
  .topbar { display: flex; }
  .auth-brand-panel { display: none; }
  .auth-form-panel { padding: 2.5rem 1.25rem; }
  .page-header-title { font-size: 1.25rem; }
}

@media (max-width: 575.98px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .quick-actions { grid-template-columns: 1fr; }
  .main-content { padding: 0.75rem 0.75rem 1rem; }
  .ic-pill-tabs { flex-wrap: wrap; }
}
