:root {
  --bg: #f4f1e8;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-strong: rgba(255, 255, 255, 0.92);
  --surface-dark: #153127;
  --text: #16231f;
  --muted: #587065;
  --line: rgba(21, 49, 39, 0.12);
  --accent: #007f5f;
  --accent-soft: #dff3ea;
  --accent-strong: #025f47;
  --warn: #d97706;
  --danger: #b42318;
  --shadow: 0 20px 45px rgba(26, 40, 36, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Bahnschrift", "Aptos", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(0, 127, 95, 0.18), transparent 26%),
    radial-gradient(circle at bottom right, rgba(234, 179, 8, 0.15), transparent 24%),
    linear-gradient(180deg, #f9f5ec 0%, #efe7d5 100%);
}

button,
input,
select,
textarea {
  font: inherit;
}

.hidden {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
}

.login-card {
  width: min(1080px, 100%);
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 24px;
  align-items: stretch;
}

.brand-block {
  background: linear-gradient(135deg, rgba(2, 95, 71, 0.94), rgba(15, 58, 52, 0.88));
  color: #fff;
  padding: 40px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.brand-logo {
  display: block;
  height: auto;
}

.brand-logo-login {
  width: min(360px, 72%);
  margin-bottom: 28px;
  filter: brightness(0) invert(1);
}

.brand-block h1 {
  font-size: clamp(2.5rem, 3vw, 4rem);
  line-height: 1;
  margin: 12px 0 16px;
  max-width: 10ch;
}

.lead {
  max-width: 42ch;
  color: rgba(255, 255, 255, 0.82);
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  font-size: 0.76rem;
  letter-spacing: 0;
  font-weight: 800;
  opacity: 0.72;
}

.panel,
.auth-panel {
  background: var(--surface);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.auth-panel,
.panel {
  padding: 24px;
}

.panel-head h2,
.panel-head h3,
.panel-header-row h2 {
  margin: 0;
}

.panel-head p,
.panel-header-row p {
  margin: 6px 0 0;
  color: var(--muted);
}

label {
  display: grid;
  gap: 8px;
}

label span {
  font-size: 0.92rem;
  font-weight: 600;
}

.field-hint {
  color: var(--muted);
  font-size: 0.84rem;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.94);
  padding: 12px 14px;
  color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(0, 127, 95, 0.18);
  border-color: var(--accent);
}

.primary-btn,
.secondary-btn,
.tab-btn {
  border: none;
  border-radius: 6px;
  padding: 12px 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.primary-btn {
  background: var(--accent);
  color: #fff;
}

.primary-btn:hover,
.secondary-btn:hover,
.tab-btn:hover {
  transform: translateY(-1px);
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.88);
  color: var(--text);
  border: 1px solid var(--line);
}

.tab-btn {
  background: transparent;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 14px 12px;
}

.tab-btn.active {
  color: var(--accent-strong);
  border-color: var(--accent-strong);
}

.error-text {
  min-height: 20px;
  margin: 6px 0 0;
  color: var(--danger);
  font-size: 0.92rem;
}

.demo-credentials {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.demo-credentials h3 {
  margin: 0 0 12px;
  font-size: 1rem;
}

.credential-grid {
  display: grid;
  gap: 12px;
}

.credential-grid div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 6px;
  background: rgba(0, 127, 95, 0.06);
}

.main-screen {
  padding: 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand-logo-topbar {
  width: 124px;
  max-width: 22vw;
}

.topbar h1 {
  margin: 8px 0 0;
  font-size: clamp(1.8rem, 2vw, 2.8rem);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-chip,
.date-chip {
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.user-chip span {
  font-weight: 800;
}

.user-chip small,
.date-chip {
  color: var(--muted);
}

.tabbar {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  margin-bottom: 20px;
  background: rgba(255, 255, 255, 0.52);
  border-radius: var(--radius);
  padding: 4px 12px;
  border: 1px solid rgba(255, 255, 255, 0.45);
}

.content {
  display: grid;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.panel-header-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}

.dashboard-hero {
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  gap: 18px;
  margin-bottom: 18px;
}

.hero-copy,
.hero-side {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.82), rgba(248, 252, 250, 0.62));
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.hero-copy h2 {
  margin: 10px 0 12px;
  font-size: clamp(2rem, 2.4vw, 3.2rem);
  line-height: 1;
  max-width: 14ch;
}

.hero-summary {
  margin: 0;
  max-width: 58ch;
  color: var(--muted);
  font-size: 1rem;
}

.hero-side {
  display: grid;
  gap: 14px;
  align-content: start;
}

.hero-health-card {
  padding: 18px;
  border-radius: 6px;
  background: linear-gradient(135deg, rgba(2, 95, 71, 0.96), rgba(11, 70, 62, 0.9));
  color: #fff;
}

.hero-health-card strong {
  display: block;
  font-size: 0.95rem;
  margin-bottom: 10px;
}

.hero-health-value {
  font-size: clamp(1.8rem, 2vw, 2.6rem);
  font-weight: 800;
  line-height: 1;
}

.hero-health-note {
  margin-top: 10px;
  color: rgba(255, 255, 255, 0.76);
  font-size: 0.92rem;
}

.metrics-grid,
.report-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.metric-card,
.report-card {
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}

.metric-label,
.report-card h3 {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.metric-value,
.report-value {
  margin-top: 10px;
  font-size: clamp(1.6rem, 2vw, 2.4rem);
  font-weight: 800;
}

.metric-note {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.metric-trend {
  margin-top: 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(2, 95, 71, 0.08);
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 700;
}

.two-column {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.dashboard-layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
  gap: 20px;
  align-items: start;
}

.dashboard-main-stack,
.dashboard-side-rail {
  display: grid;
  gap: 20px;
  align-content: start;
}

.dashboard-top-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr);
  gap: 20px;
  align-items: start;
  margin-bottom: 20px;
}

.dashboard-side-stack {
  display: grid;
  gap: 20px;
}

.stack-list,
.list-view {
  display: grid;
  gap: 12px;
}

.stack-item,
.list-card,
.user-card {
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px;
}

.stack-item header,
.list-card header,
.user-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
}

.stack-item strong,
.list-card strong,
.user-card strong {
  font-size: 0.98rem;
}

.bar-track {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: rgba(2, 95, 71, 0.08);
  overflow: hidden;
  margin-top: 10px;
}

.bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, #0fa174, #025f47);
  border-radius: inherit;
}

.sub-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.compact-meta {
  margin-top: 6px;
}

.funnel-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.pipeline-support-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.pipeline-bottom-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.funnel-stage,
.snapshot-card,
.insight-card {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 16px;
}

.funnel-stage p,
.snapshot-card p,
.insight-card p {
  margin: 0;
  color: var(--muted);
}

.funnel-stage strong,
.snapshot-card strong,
.insight-card strong {
  display: block;
  margin-top: 10px;
  font-size: 1.5rem;
  line-height: 1;
}

.funnel-stage .sub-meta,
.snapshot-card .sub-meta,
.insight-card .sub-meta {
  margin-top: 10px;
}

.funnel-visual {
  margin-top: 14px;
  height: 12px;
  border-radius: 999px;
  background: rgba(2, 95, 71, 0.08);
  overflow: hidden;
}

.funnel-visual span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #f59e0b, #0fa174);
}

.insight-list {
  display: grid;
  gap: 12px;
}

.insight-row {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.84);
}

.insight-row header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.insight-row header strong {
  font-size: 0.96rem;
}

.insight-row .sub-meta {
  justify-content: space-between;
}

.snapshot-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.visit-form,
.compact-form {
  display: grid;
  gap: 18px;
}

.form-grid,
.filters-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.filters-grid {
  margin-bottom: 16px;
}

.span-2 {
  grid-column: span 2;
}

.form-actions {
  display: flex;
  gap: 12px;
}

.gps-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
}

.toolbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.photo-capture-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.photo-preview-wrap {
  margin-top: 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  padding: 10px;
}

.photo-preview-wrap img {
  width: 100%;
  max-height: 280px;
  object-fit: contain;
  border-radius: 6px;
  display: block;
}

.form-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 6px;
  border: 1px solid rgba(2, 95, 71, 0.18);
  background: rgba(2, 95, 71, 0.08);
  color: var(--accent-strong);
}

.report-filters {
  margin: 18px 0 20px;
}

.table-wrap {
  overflow: auto;
  border-radius: 6px;
  border: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: rgba(255, 255, 255, 0.88);
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 0.92rem;
  vertical-align: top;
}

td.actions-cell {
  white-space: nowrap;
}

.gps-cell a {
  color: var(--accent-strong);
  text-decoration: none;
  font-weight: 700;
}

.gps-cell a:hover {
  text-decoration: underline;
}

.table-action {
  padding: 8px 10px;
  font-size: 0.85rem;
}

.table-action.danger {
  color: var(--danger);
  border-color: rgba(180, 35, 24, 0.2);
}

.card-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.photo-thumb-btn {
  display: grid;
  gap: 6px;
  justify-items: center;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  border-radius: 6px;
  padding: 6px;
  cursor: pointer;
  color: var(--accent-strong);
  font-weight: 700;
}

.photo-thumb-btn img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 4px;
  display: block;
}

.photo-thumb-btn span {
  font-size: 0.78rem;
}

th {
  background: rgba(2, 95, 71, 0.06);
  font-size: 0.85rem;
  text-transform: uppercase;
}

.pill {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
}

.pill.new-lead,
.pill.interested {
  background: rgba(245, 158, 11, 0.12);
  color: #9a6700;
}

.pill.converted {
  background: rgba(0, 127, 95, 0.12);
  color: var(--accent-strong);
}

.pill.follow-up-required,
.pill.repeat-visit {
  background: rgba(59, 130, 246, 0.12);
  color: #1d4ed8;
}

.pill.closed-lost {
  background: rgba(180, 35, 24, 0.12);
  color: var(--danger);
}

.pill.admin,
.pill.manager,
.pill.sales {
  background: rgba(2, 95, 71, 0.12);
  color: var(--accent-strong);
}

.pill.distributor,
.pill.spare-parts,
.pill.garage,
.pill.factory,
.pill.hardware,
.pill.others {
  background: rgba(245, 158, 11, 0.14);
  color: #8c5a00;
}

.sub-panel {
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: var(--radius);
  padding: 18px;
}

.sub-panel h3 {
  margin-top: 0;
}

.compact-sub-panel {
  padding: 16px;
  background: rgba(255, 255, 255, 0.72);
}

.compact-sub-copy {
  margin: -2px 0 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.chart-card {
  min-height: 250px;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 16px;
}

.mini-chart {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  gap: 14px;
  min-height: 190px;
  align-items: end;
}

.mini-chart-item {
  display: grid;
  gap: 8px;
  justify-items: center;
}

.mini-chart-bar-wrap {
  height: 150px;
  width: 100%;
  border-radius: 6px;
  background: rgba(2, 95, 71, 0.08);
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}

.mini-chart-bar {
  width: 100%;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, #16a34a, #0f766e);
  min-height: 8px;
}

.mini-chart-item strong {
  font-size: 0.95rem;
}

.mini-chart-item span {
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
  word-break: break-word;
}

.chart-caption {
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.88rem;
}

.photo-viewer {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
}

.photo-viewer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 18, 16, 0.72);
}

.photo-viewer-card {
  position: relative;
  width: min(960px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  background: rgba(255, 255, 255, 0.98);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  display: grid;
  gap: 14px;
}

.photo-viewer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.photo-viewer-card img {
  width: 100%;
  max-height: calc(100vh - 140px);
  object-fit: contain;
  border-radius: 6px;
  background: #f8faf9;
}

@media (max-width: 980px) {
  .login-card,
  .two-column,
  .dashboard-hero,
  .dashboard-top-grid,
  .dashboard-side-stack,
  .dashboard-layout,
  .dashboard-main-stack,
  .dashboard-side-rail,
  .snapshot-grid,
  .funnel-grid,
  .pipeline-support-grid,
  .pipeline-bottom-grid,
  .metrics-grid,
  .report-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .main-screen,
  .login-screen {
    padding: 16px;
  }

  .brand-block,
  .auth-panel,
  .panel {
    padding: 18px;
  }

  .form-grid,
  .filters-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: span 1;
  }

  .topbar,
  .panel-header-row {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-brand {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .brand-logo-login {
    width: min(300px, 78%);
  }

  .brand-logo-topbar {
    width: 112px;
    max-width: none;
  }
}
