:root {
  --bg: #f3f6fb;
  --panel: #ffffff;
  --panel-alt: #f8faff;
  --sidebar: #0f172a;
  --sidebar-soft: #1e293b;
  --primary: #3b82f6;
  --primary-soft: rgba(59, 130, 246, 0.12);
  --accent: #14b8a6;
  --warning: #f59e0b;
  --danger: #ef4444;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --shadow: 0 20px 40px rgba(15, 23, 42, 0.08);
}

body.dark-mode {
  --bg: #0f172a;
  --panel: #111827;
  --panel-alt: #0b1220;
  --sidebar: #020817;
  --sidebar-soft: #111827;
  --primary: #60a5fa;
  --primary-soft: rgba(96, 165, 250, 0.14);
  --accent: #2dd4bf;
  --warning: #fbbf24;
  --danger: #f87171;
  --text: #e5eefb;
  --muted: #9aa9c5;
  --line: rgba(148, 163, 184, 0.2);
  --shadow: 0 20px 40px rgba(2, 6, 23, 0.4);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  font-family: "Inter", sans-serif;
  background: var(--bg);
  color: var(--text);
}

body {
  min-height: 100vh;
  padding: 0;
}

button, a {
  font: inherit;
}

.app-shell {
  max-width: none;
  min-height: 100vh;
  margin: 0;
  display: grid;
  grid-template-columns: 280px 1fr;
  background: rgba(255, 255, 255, 0.5);
  border: none;
  border-radius: 0;
  box-shadow: none;
  overflow: hidden;
}

.sidebar {
  background: linear-gradient(180deg, var(--sidebar) 0%, #0b1220 100%);
  color: white;
  padding: 26px 22px;
  display: flex;
  flex-direction: column;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 8px 20px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #60a5fa, #2563eb);
  font-weight: 800;
}

.brand-logo-image,
.login-logo-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: inherit;
  transition: transform 0.2s ease;
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.62);
}

.brand-block h1 {
  margin: 0;
  font-size: 1.4rem;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-top: 24px;
}

.nav-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-label {
  margin: 0 10px 6px;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(148, 163, 184, 0.8);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 12px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: rgba(255, 255, 255, 0.8);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: 0.2s ease;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(148, 163, 184, 0.12);
  color: white;
}

.icon {
  width: 18px;
  font-size: 0.95rem;
  display: inline-grid;
  place-items: center;
}

.sidebar-card {
  margin-top: auto;
  padding: 18px 16px;
  border-radius: 18px;
  background: rgba(148, 163, 184, 0.1);
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.sidebar-card .card-kicker {
  margin: 0 0 12px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar-card h3 {
  margin: 0;
  font-size: 2rem;
}

.progress-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 14px 0 12px;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.75);
}

.progress-row strong {
  color: #86efac;
}

.progress-bar {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.1);
}

.progress-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #60a5fa, #34d399);
}

.main-panel {
  background: #f8fafc;
  padding: 24px 26px 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.topbar h2 {
  margin: 0;
  font-size: clamp(1.8rem, 2vw, 2.5rem);
}

.topbar-actions {
  display: flex;
  gap: 10px;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin: 0 0 20px;
}

.select-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
  color: var(--muted);
  font-size: 0.82rem;
}

.select-wrap select {
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  outline: none;
}

button.primary-button,
button.ghost-button,
.segmented-control button {
  border: none;
  border-radius: 12px;
  padding: 11px 16px;
  cursor: pointer;
  transition: 0.2s ease;
}

.primary-button {
  background: linear-gradient(135deg, var(--primary), #2563eb);
  color: white;
  font-weight: 600;
  box-shadow: 0 10px 18px rgba(37, 99, 235, 0.2);
}

.ghost-button {
  background: white;
  color: var(--text);
  border: 1px solid var(--line);
}

.kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--panel);
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 20px;
  padding: 20px 18px;
  min-height: 122px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.04);
}

.kpi-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.kpi-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.kpi-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
}

.kpi-card strong {
  font-size: clamp(1.55rem, 2vw, 2.2rem);
  letter-spacing: -0.04em;
}

.kpi-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
}

.kpi-meta .delta {
  display: inline-flex;
  align-items: center;
  padding: 6px 8px;
  border-radius: 999px;
  font-weight: 600;
}

.delta.positive {
  background: rgba(16, 185, 129, 0.1);
  color: #059669;
}

.delta.neutral {
  background: rgba(59, 130, 246, 0.1);
  color: #2563eb;
}

.delta.warning {
  background: rgba(245, 158, 11, 0.1);
  color: #b45309;
}

.content-grid,
.bottom-grid,
.customer-grid,
.inventory-grid {
  display: grid;
  gap: 18px;
}

.customer-grid,
.inventory-grid,
.forecast-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.customer-card,
.inventory-card,
.forecast-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 150px;
  justify-content: center;
}

.customer-card {
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.customer-card:hover,
.customer-card:focus-visible {
  border-color: var(--primary);
  outline: none;
  transform: translateY(-2px);
}

.customer-card strong,
.inventory-card strong,
.forecast-card strong {
  font-size: 1.2rem;
}

.customer-card span,
.inventory-card span,
.muted-copy,
.forecast-card p,
.forecast-card em {
  color: var(--muted);
}

.customer-card em,
.inventory-card em,
.forecast-card em {
  color: var(--primary);
  font-style: normal;
  font-weight: 600;
}

.customer-card-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: auto;
}

.customer-card-actions .ghost-button {
  padding: 8px 10px;
  color: var(--danger);
}

.integration-panel {
  margin-top: 24px;
}

.integration-toggle {
  align-self: end;
  justify-content: center;
  min-height: 44px;
  flex-direction: row;
  align-items: center;
}

.integration-status {
  min-height: 20px;
  margin: 0;
  color: var(--accent);
  font-size: 0.82rem;
}

.integration-status.error {
  color: var(--danger);
}

.form-panel {
  margin-bottom: 22px;
}

.entry-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--muted);
  font-size: 0.85rem;
}

.field-help {
  color: var(--muted);
  font-size: 0.75rem;
}

.field input,
.field select,
.field textarea {
  background: var(--panel-alt);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text);
  font: inherit;
}

.field textarea {
  resize: vertical;
  min-height: 100px;
}

.empty-state {
  margin: 24px 0 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.profile-grid {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 20px;
  align-items: center;
}

.profile-image-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 180px;
}

.profile-preview,
.profile-placeholder {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  background: linear-gradient(135deg, var(--primary-soft), var(--panel-alt));
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  color: var(--muted);
}

.profile-placeholder {
  font-size: 0.8rem;
}

.profile-form-grid {
  width: 100%;
}

.team-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.team-member-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-alt);
}

.team-member-row strong {
  display: block;
  margin-bottom: 4px;
}

.team-member-row span {
  color: var(--muted);
  font-size: 0.8rem;
}

.team-member-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.team-badge {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(20, 184, 166, 0.12);
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 700;
}

.stage-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stage-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-alt);
}

.full-width {
  grid-column: 1 / -1;
}

.compact-grid {
  grid-template-columns: 1fr auto;
  align-items: end;
}

.search-button-wrap {
  display: flex;
  align-items: end;
}

.customer-search-panel {
  margin-bottom: 18px;
}

.customer-search-results {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.customer-search-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-alt);
}

.customer-search-item strong {
  display: block;
  margin-bottom: 4px;
}

.customer-search-item span {
  color: var(--muted);
  font-size: 0.8rem;
}

.selected-customer-summary {
  margin: 14px 0 18px;
  padding: 16px 18px;
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: 14px;
  background: rgba(59, 130, 246, 0.06);
}

.selected-customer-summary strong {
  display: block;
  margin: 6px 0 4px;
  font-size: 1.1rem;
}

.selected-customer-summary p {
  margin: 0;
  color: var(--muted);
}

.hidden {
  display: none !important;
}

.form-actions {
  display: flex;
  justify-content: flex-start;
}

.forecast-card {
  padding: 20px;
}

.forecast-month {
  display: inline-block;
  width: fit-content;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.12);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 700;
}

.forecast-card p {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

.commission-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}

.commission-row:last-child {
  border-bottom: none;
}

.commission-row strong {
  display: block;
  margin-bottom: 4px;
}

.commission-row span {
  color: var(--muted);
  font-size: 0.85rem;
}

.commission-meta {
  text-align: right;
}

.commission-meta strong {
  display: block;
  margin-top: 4px;
}

.tab-view {
  display: block;
}

.tab-view.hidden {
  display: none;
}

.tab-header {
  margin-bottom: 18px;
}

.tab-header-actions,
.customer-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.customer-list-header {
  margin: 6px 0 14px;
}

.customer-list-header h3 {
  margin: 0;
}

.tab-header h2 {
  margin: 0;
  font-size: clamp(1.8rem, 2vw, 2.3rem);
}

.content-grid {
  grid-template-columns: 1.5fr 0.9fr;
  margin-bottom: 18px;
}

.bottom-grid {
  grid-template-columns: 1.35fr 0.9fr;
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 22px;
  padding: 20px 20px 18px;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.04);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.panel-header h3 {
  margin: 0;
  font-size: 1.3rem;
}

.panel-header a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.segmented-control {
  display: inline-flex;
  gap: 6px;
  background: var(--panel-alt);
  padding: 5px;
  border-radius: 12px;
}

.segmented-control button {
  background: transparent;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 10px;
}

.segmented-control button.active {
  background: white;
  color: var(--text);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

.chart-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.chart-summary .label {
  display: block;
  color: var(--muted);
  margin-bottom: 4px;
  font-size: 0.85rem;
}

.chart-summary strong {
  font-size: 2rem;
}

.positive {
  color: #059669;
  font-weight: 700;
  background: rgba(16, 185, 129, 0.08);
  border-radius: 999px;
  padding: 8px 10px;
}

.chart-bars {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  height: 210px;
  padding-top: 14px;
}

.bar-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: end;
  align-items: center;
  gap: 10px;
  height: 100%;
}

.bar {
  width: 100%;
  max-width: 42px;
  border-radius: 14px 14px 8px 8px;
  background: linear-gradient(180deg, #a5d8ff 0%, var(--primary) 100%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.4);
  position: relative;
}

.bar:nth-child(2n) {
  background: linear-gradient(180deg, #99f6e4 0%, var(--accent) 100%);
}

.bar-column .month {
  color: var(--muted);
  font-size: 0.78rem;
}

.pipeline-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pipeline-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.pipeline-item:last-child {
  border-bottom: none;
}

.company {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.company strong {
  font-size: 0.98rem;
}

.company span,
.pipeline-item .amount {
  color: var(--muted);
  font-size: 0.8rem;
}

.pipeline-item .amount {
  font-weight: 700;
  color: var(--text);
}

.pipeline-item .tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 8px;
  width: fit-content;
  padding: 6px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}

.tag.prospect {
  background: rgba(59, 130, 246, 0.1);
  color: #2563eb;
}

.tag.growth {
  background: rgba(16, 185, 129, 0.1);
  color: #059669;
}

.tag.watch {
  background: rgba(245, 158, 11, 0.1);
  color: #b45309;
}

.opportunity-status {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  margin-top: 4px;
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
}

.opportunity-status.open {
  background: rgba(59, 130, 246, 0.1);
  color: #2563eb;
}

.opportunity-status.abandon {
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
}

.opportunity-status.won {
  background: rgba(16, 185, 129, 0.1);
  color: #059669;
}

.orders-table table {
  width: 100%;
  border-collapse: collapse;
}

.orders-table th,
.orders-table td {
  text-align: left;
  padding: 14px 10px;
  border-bottom: 1px solid var(--line);
}

.orders-table th {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.orders-table td {
  font-size: 0.92rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 90px;
  padding: 7px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}

.status-pill.shipped {
  background: rgba(16, 185, 129, 0.1);
  color: #059669;
}

.status-pill.review {
  background: rgba(59, 130, 246, 0.1);
  color: #2563eb;
}

.status-pill.pending {
  background: rgba(245, 158, 11, 0.08);
  color: #b45309;
}

.activity-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.activity-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.activity-item:last-child {
  border-bottom: none;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: white;
}

.activity-item strong {
  display: block;
  margin-bottom: 4px;
  font-size: 0.92rem;
}

.activity-item p {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.activity-item time {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.73rem;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at top, rgba(59, 130, 246, 0.16), transparent 35%), var(--bg);
}

.login-card {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.login-logo {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), #2563eb);
  color: white;
  display: grid;
  place-items: center;
  font-weight: 800;
}

.login-brand h1 {
  margin: 0;
  font-size: 1.5rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
}

.form-field label {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
}

.form-field input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel-alt);
  color: var(--text);
  border-radius: 12px;
  height: 46px;
  padding: 0 14px;
  font: inherit;
}

.form-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  font-size: 0.8rem;
  color: var(--muted);
}

.form-row a {
  color: var(--primary);
  text-decoration: none;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.checkbox input {
  accent-color: var(--primary);
}

.login-button {
  width: 100%;
  border: none;
  height: 46px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), #2563eb);
  color: white;
  font-weight: 700;
  cursor: pointer;
}

.login-subtext {
  margin-top: 18px;
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
}

.login-subtext a {
  color: var(--primary);
  text-decoration: none;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    padding-bottom: 18px;
  }

  .content-grid,
  .bottom-grid,
  .kpis {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 700px) {
  body {
    padding: 0;
  }

  .main-panel {
    padding: 18px 16px 22px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .toolbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .kpis,
  .content-grid,
  .bottom-grid {
    grid-template-columns: 1fr;
  }

  .orders-table {
    overflow-x: auto;
  }
}
