
/* Lato from /assets/fonts */
@font-face {
  font-family: "Lato";
  src: url("/assets/fonts/Lato-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Lato";
  src: url("/assets/fonts/Lato-Italic.ttf") format("truetype");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Lato";
  src: url("/assets/fonts/Lato-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Lato";
  src: url("/assets/fonts/Lato-BoldItalic.ttf") format("truetype");
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Lato";
  src: url("/assets/fonts/Lato-Light.ttf") format("truetype");
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}

/* Brand palette */
:root {
  --brand--dark: #030405;
  --brand--white: #f9fcff;
  --grey--6: #030405;
  --grey--5: #11181f;
  --grey--4: #202c38;
  --grey--3: #3d546b;
  --grey--2: #aac3dc;
  --grey--1: #d5e0eb;
  --brand--red: #d62231;
  --brand--orange: #f50;
  --brand--purple: #57217c;
  --accent-focus: rgba(214, 34, 49, 0.35);
  --app-input-focus: var(--grey--2);
  --app-input-focus-ring: rgba(170, 195, 220, 0.25);
}

/* Dark mode: brand--dark background, brand--white text, grey scale for UI */
[data-theme="dark"],
:root:not([data-theme="light"]) {
  --app-bg: var(--brand--dark);
  --app-bg-image: url("/assets/lines-shearwater.svg");
  --app-text: var(--brand--white);
  --app-panel-bg: var(--grey--5);
  --app-panel-border: var(--grey--4);
  --app-header-bg: var(--grey--5);
  --app-header-border: var(--grey--4);
  --app-input-bg: var(--brand--dark);
  --app-input-border: var(--grey--4);
  --app-input-text: var(--brand--white);
  --app-label: var(--grey--2);
  --app-muted: var(--grey--3);
  --app-pill-bg: var(--grey--5);
  --app-pill-border: var(--grey--3);
  --app-pill-text: var(--grey--2);
  --app-embed-bg: var(--brand--dark);
  --app-embed-border: var(--grey--4);
  /* Legacy aliases used elsewhere in this file */
  --black: var(--brand--dark);
  --white: var(--brand--white);
  --gray-900: var(--grey--5);
  --gray-800: var(--grey--5);
  --gray-700: var(--grey--4);
  --gray-600: var(--grey--4);
  --gray-500: var(--grey--3);
  --gray-400: var(--grey--3);
  --gray-300: var(--grey--2);
  --gray-200: var(--grey--2);
  --accent: var(--brand--red);
}

/* Light mode: gradient baked into SVG, solid fallback color here */
[data-theme="light"] {
  --app-bg: #eef4fa;
  --app-bg-image: url("/assets/lines-shearwater-light.svg");
  --app-input-focus: var(--grey--3);
  --app-input-focus-ring: rgba(61, 84, 107, 0.2);
  --app-text: var(--grey--6);
  --app-panel-bg: var(--brand--white);
  --app-panel-border: var(--grey--1);
  --app-header-bg: var(--brand--white);
  --app-header-border: var(--grey--1);
  --app-input-bg: var(--brand--white);
  --app-input-border: var(--grey--1);
  --app-input-text: var(--grey--6);
  --app-label: var(--grey--3);
  --app-muted: var(--grey--3);
  --app-pill-bg: var(--grey--1);
  --app-pill-border: var(--grey--2);
  --app-pill-text: var(--grey--3);
  --app-embed-bg: var(--grey--1);
  --app-embed-border: var(--grey--1);
  /* Legacy aliases */
  --black: var(--brand--dark);
  --white: var(--brand--white);
  --gray-900: var(--grey--5);
  --gray-800: var(--grey--4);
  --gray-700: var(--grey--3);
  --gray-600: var(--grey--3);
  --gray-500: var(--grey--3);
  --gray-400: var(--grey--3);
  --gray-300: var(--grey--2);
  --gray-200: var(--grey--1);
  --accent: var(--brand--red);
}

* {
  box-sizing: border-box;
}
.hidden {
  display: none !important;
}
body {
  margin: 0;
  font-family: "Lato", Arial, sans-serif;
  background: var(--app-bg) var(--app-bg-image) no-repeat center;
  background-size: cover;
  background-attachment: fixed;
  color: var(--app-text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--app-header-border);
  border-left: 3px solid var(--gray-500);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--app-header-bg);
  position: sticky;
  top: 0;
  z-index: 10;
}
@media (min-width: 640px) {
  header {
    padding: 1.4rem 2rem;
  }
}
header h1 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.logo-block {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 1rem 0.4rem 0.75rem;
  background: var(--black);
  border: 1px solid var(--gray-200);
  border-radius: 0.5rem;
}
[data-theme="light"] .logo-block {
  border-color: var(--gray-300);
}
.logo-block .brand-logo {
  height: 28px;
  width: auto;
  display: block;
  flex-shrink: 0;
}
.logo-wordmark {
  font-family: "Lato", Arial, sans-serif;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.08em;
  color: var(--white);
  text-transform: uppercase;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.brand-tagline {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
  text-align: right;
}
@media (max-width: 520px) {
  .brand-tagline {
    width: 100%;
    align-items: flex-start;
    text-align: left;
  }
}
.brand-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  background: var(--app-pill-bg);
  color: var(--app-pill-text);
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid var(--app-pill-border);
}
.brand-tagline-support {
  font-family: "Lato", Arial, sans-serif;
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--app-muted);
  letter-spacing: 0.01em;
}
.brand-pill-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 999px;
  background: var(--accent);
}
main {
  display: flex;
  flex: 1;
  width: 100%;
  overflow: hidden;
  min-height: 0;
}

/* Login container — centers the login panel */
.login-container {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem 2rem;
  width: 100%;
}
@media (min-width: 640px) {
  .login-container {
    padding: 2.5rem 1.5rem 3rem;
  }
}
.panel {
  background: var(--app-panel-bg);
  border-radius: 1rem;
  padding: 1.5rem 1.25rem 1.75rem;
  border: 1px solid var(--app-panel-border);
  border-left: 3px solid var(--gray-500);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.15);
  max-width: 440px;
  width: 100%;
  margin: 0 auto;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
[data-theme="dark"] .panel,
:root:not([data-theme="light"]) .panel {
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.6);
}
@media (min-width: 640px) {
  .panel {
    padding: 1.75rem 2rem 1.9rem;
    max-width: 560px;
  }
}
.panel h2 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
  line-height: 1.35;
  letter-spacing: 0.02em;
  color: var(--app-text);
  font-weight: 600;
}
.panel p {
  margin: 0 0 1.5rem;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--app-muted);
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  margin-bottom: 0;
  color: var(--app-label);
}
input {
  width: 100%;
  min-height: 2.75rem;
  border-radius: 0.5rem;
  border: 1px solid var(--app-input-border);
  background: var(--app-input-bg);
  color: var(--app-input-text);
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  line-height: 1.5;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
input::placeholder {
  color: var(--gray-500);
}
input:hover {
  border-color: var(--gray-600);
}
input:focus {
  border-color: var(--app-input-focus);
  box-shadow: 0 0 0 2px var(--app-input-focus-ring);
  background: var(--app-input-bg);
}
input:focus-visible {
  outline: 2px solid var(--app-input-focus);
  outline-offset: 2px;
}
/* Error state: reserve red for validation only */
input:invalid:not(:placeholder-shown).touched,
.field.error input {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-focus);
}
.field {
  margin-bottom: 1.25rem;
}
.field:last-of-type {
  margin-bottom: 1.5rem;
}
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  padding: 0.6rem 1.25rem;
  background: var(--gray-700);
  color: var(--white);
  border: 1px solid var(--gray-500);
  border-radius: 999px;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: none;
  margin-top: 0;
  width: 100%;
  transition: background 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
}
button:hover:not(:disabled) {
  background: var(--gray-600);
  border-color: var(--gray-400);
}
button:focus-visible {
  outline: 2px solid var(--white);
  outline-offset: 2px;
}
button:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}
/* Primary CTA: login button – dark blue-gray to stand out from card */
#login-btn {
  background: #2c3844;
  border-color: #2c3844;
  color: var(--brand--white);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  transition: background 0.2s ease, border-color 0.2s ease, opacity 0.2s ease, box-shadow 0.2s ease;
}
#login-btn:hover:not(:disabled) {
  background: #36424f;
  border-color: #36424f;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
#login-btn:focus-visible {
  outline: 2px solid var(--brand--white);
  outline-offset: 2px;
}
.helper {
  font-size: 0.75rem;
  color: var(--gray-500);
  margin-top: 0.25rem;
  line-height: 1.4;
}
.status {
  font-size: 0.875rem;
  margin-top: 0.75rem;
  min-height: 1.25rem;
  line-height: 1.4;
  padding: 0.25rem 0;
}
.status.error {
  color: var(--accent);
  font-weight: 500;
}
.status.ok {
  color: var(--app-muted);
}
.embed-wrapper {
  border-radius: 0.75rem;
  overflow: hidden;
  background: var(--app-embed-bg);
  border: 1px solid var(--app-embed-border);
  border-top: 2px solid var(--gray-500);
  position: relative;
  min-height: 65vh;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  animation: embedFadeIn 0.3s ease;
}
@keyframes embedFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.embed-wrapper.hidden {
  display: none;
}
.embed-wrapper iframe {
  border: none;
  width: 100%;
  height: 100%;
  min-height: 65vh;
  background: var(--app-embed-bg);
}
.embed-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  color: var(--app-muted);
  font-size: 0.9rem;
  pointer-events: none;
  padding: 1rem;
}
.embed-placeholder span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 999px;
  border: 1px solid var(--gray-700);
  font-size: 1.25rem;
}
.embed-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  background: var(--app-panel-bg);
  color: var(--app-label);
  font-size: 0.9rem;
  z-index: 2;
}
.embed-loading.hidden {
  display: none;
}
.embed-loading-spinner {
  width: 2rem;
  height: 2rem;
  border: 2px solid var(--gray-600);
  border-top-color: var(--gray-400);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.header-actions.hidden {
  display: none;
}
.logout-btn {
  padding: 0.4rem 0.9rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--app-label);
  background: transparent;
  border: 1px solid var(--app-input-border);
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.logout-btn:hover {
  background: var(--app-pill-bg);
  border-color: var(--app-pill-border);
  color: var(--app-text);
}
/* Theme switch – pill track with sliding thumb, DARK | track | LIGHT */
.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  user-select: none;
}
.theme-switch:focus-visible {
  outline: 2px solid var(--white);
  outline-offset: 2px;
  border-radius: 4px;
}
.theme-switch-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-400);
  flex-shrink: 0;
}
.theme-switch-icon svg {
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
[data-theme="light"] .theme-switch-icon {
  color: var(--gray-500);
}
.theme-switch-track {
  position: relative;
  width: 3.25rem;
  height: 1.5rem;
  border-radius: 999px;
  background: var(--gray-700);
  flex-shrink: 0;
}
[data-theme="light"] .theme-switch-track {
  background: var(--gray-300);
}
.theme-switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(1.5rem - 4px);
  height: calc(1.5rem - 4px);
  border-radius: 999px;
  background: #e0e0e0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease;
}
.theme-switch--light .theme-switch-thumb {
  transform: translateX(calc(3.25rem - 100% - 4px));
  background: #000;
}

/* ── Header user pill ── */
.header-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.75rem 0.25rem 0.25rem;
  background: var(--app-pill-bg);
  border: 1px solid var(--app-pill-border);
  border-radius: 999px;
}
/* .header-avatar replaced by .avatar-circle--sm */
.header-user-name {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--app-pill-text);
  white-space: nowrap;
}

/* ── Logout button width fix ── */
.logout-btn {
  width: auto;
}

/* ── App Shell ── */
.app-shell {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ── Sidebar ── */
.sidebar {
  width: 230px;
  min-width: 230px;
  flex-shrink: 0;
  border-right: 1px solid var(--app-panel-border);
  background: var(--app-panel-bg);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 0.875rem 0;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0 0.625rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.65rem 0.875rem;
  min-height: unset;
  background: transparent;
  border: none;
  border-radius: 0.5rem;
  color: var(--app-label);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  justify-content: flex-start;
  transition: background 0.15s ease, color 0.15s ease;
  font-family: inherit;
  letter-spacing: 0;
  box-shadow: none;
}
.nav-item:hover:not(:disabled) {
  background: var(--app-panel-border);
  color: var(--app-text);
  border-color: transparent;
  box-shadow: none;
}
.nav-item.active {
  background: var(--gray-700);
  color: var(--app-text);
  border-color: transparent;
}
[data-theme="light"] .nav-item.active {
  background: var(--gray-200);
}
.nav-item:focus-visible {
  outline: 2px solid var(--white);
  outline-offset: -2px;
}

.nav-item-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 1.125rem;
  height: 1.125rem;
}
.nav-item-icon svg {
  width: 100%;
  height: 100%;
}

/* ── App content area ── */
.app-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

/* ── View panels ── */
.view-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  min-height: 0;
}

/* Analytics view — iframe fills entirely, no padding */
#view-analytics {
  overflow: hidden;
}

.iframe-container {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--app-embed-bg);
  min-height: 0;
}
.iframe-container iframe {
  flex: 1;
  border: none;
  width: 100%;
  min-height: 0;
  background: var(--app-embed-bg);
}

/* ── View header ── */
.view-header {
  padding: 1.75rem 2rem 1.25rem;
  border-bottom: 1px solid var(--app-panel-border);
  flex-shrink: 0;
}
.view-header h2 {
  margin: 0 0 0.3rem;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--app-text);
  letter-spacing: 0.01em;
}
.view-header p {
  margin: 0;
  font-size: 0.875rem;
  color: var(--app-muted);
}

/* ── Customers view ── */
.customers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 1rem;
  padding: 1.75rem 2rem;
}

.customer-card {
  background: var(--app-panel-bg);
  border: 1px solid var(--app-panel-border);
  border-radius: 0.75rem;
  padding: 1.5rem 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.875rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  cursor: default;
}
.customer-card:hover {
  border-color: var(--gray-500);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}
[data-theme="dark"] .customer-card:hover,
:root:not([data-theme="light"]) .customer-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}
.customer-card-icon {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 0.5rem;
  background: var(--app-embed-bg);
  border: 1px solid var(--app-panel-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--app-muted);
  flex-shrink: 0;
}
.customer-card-icon svg {
  width: 1.25rem;
  height: 1.25rem;
}
.customer-card-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--app-text);
  text-align: center;
  line-height: 1.35;
}

/* ── Profile view ── */
.profile-layout {
  display: flex;
  gap: 2.5rem;
  padding: 1.75rem 2rem;
  align-items: flex-start;
}
@media (max-width: 720px) {
  .profile-layout {
    flex-direction: column;
    align-items: center;
  }
}

.avatar-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.875rem;
  flex-shrink: 0;
  width: 160px;
}
.avatar-wrapper {
  flex-shrink: 0;
}

/* ── Initials / photo avatar circle ── */
.avatar-circle {
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  letter-spacing: 0.04em;
  flex-shrink: 0;
  background-size: cover;
  background-position: center;
  overflow: hidden;
  color: #f9fcff;
  user-select: none;
  font-family: "Lato", Arial, sans-serif;
}
.avatar-circle--sm {
  width: 28px;
  height: 28px;
  font-size: 0.6rem;
}
.avatar-circle--lg {
  width: 112px;
  height: 112px;
  font-size: 2rem;
  border: 3px solid var(--app-panel-border);
}
.avatar-upload-label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 1rem;
  background: var(--app-panel-bg);
  border: 1px solid var(--app-panel-border);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--app-label);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}
.avatar-upload-label:hover {
  background: var(--app-pill-bg);
  border-color: var(--gray-500);
  color: var(--app-text);
}
.avatar-upload-label svg {
  width: 0.875rem;
  height: 0.875rem;
}
.avatar-hint {
  font-size: 0.75rem;
  color: var(--app-muted);
  text-align: center;
  margin: 0;
  line-height: 1.4;
}

.profile-fields {
  flex: 1;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-width: 0;
}

.profile-section {
  background: var(--app-panel-bg);
  border: 1px solid var(--app-panel-border);
  border-radius: 0.75rem;
  padding: 1.5rem;
}
.profile-section h3 {
  margin: 0 0 1.25rem;
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--app-text);
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--app-panel-border);
}
.profile-section .field:last-of-type {
  margin-bottom: 0;
}

.input-readonly {
  background: var(--app-embed-bg) !important;
  cursor: default;
  color: var(--app-muted) !important;
}
.input-readonly:focus {
  border-color: var(--app-input-border);
  box-shadow: none;
}

.save-btn {
  width: auto;
  min-height: unset;
  padding: 0.55rem 1.5rem;
  font-size: 0.875rem;
  margin-top: 0.5rem;
  border-radius: 999px;
}

    