@font-face {
  font-family: 'Caveat';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('../fonts/caveat-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --brand: #0f172a;
  --brand-dark: #020617;
  --brand-dark2: #1e293b;
  --brand-darker: #020617;
  --brand-light: #334155;
  --brand-lighter: #e2e8f0;
  --brand-opacity: rgba(15, 23, 42, 0.2);
  --brand-disabled: #e2e8f0;
  /* The brand color from the opposite theme — light in light mode's inverse,
     used e.g. for the logo lines drawn on the brand-filled circle. */
  --brand-contrast: #cbd5e1;

  --danger: #f56565;
  --danger-light: #fc8181;
  --danger-lighter: #fed7d7;
  --danger-toast: #fecaca;

  --success: #48bb78;
  --success-light: #81e6d9;
  --success-lighter: #c6f6d5;
  --success-toast: #d1fae5;

  --info-toast: #dbeafe;

  --text-primary: #2d3748;
  --text-secondary: #555555;
  --text-tertiary: #777777;
  --text-contrast: #ffffff;

  --background: #f4f7fe;
  --background-input: rgba(0, 0, 0, 0);
  --background-button-supporting: rgba(0, 0, 0, 0.08);

  --border-default: #dddddd;
  --border-2: #eeeeee;
  --border-3: #aaaaaa;
  --border-4: #dfdfdf;

  --surface-1: #ffffff;
  --surface-2: #edf0f3;
  --surface-3: #f8f8f8;
  --surface-4: #f0f0f0;

  --shadow-surface-1: rgba(0, 0, 0, 0.1);
  --shadow-surface-2: rgba(0, 0, 0, 0.2);

  --ai-gradient: #e2f4ec, #fcefff, #fff7df;
}

:root.dark {
  --brand: #cbd5e1;
  --brand-dark: #e2e8f0;
  --brand-dark2: #cbd5e1;
  --brand-darker: #f1f5f9;
  --brand-light: #94a3b8;
  --brand-lighter: #334155;
  --brand-opacity: rgba(203, 213, 225, 0.2);
  --brand-disabled: #334155;
  /* Opposite theme's brand color — the light-mode brand in dark mode. */
  --brand-contrast: #0f172a;

  --danger: #fc8181;
  --danger-light: #fc8181;
  --danger-lighter: #feb2b2;
  --danger-toast: #7f1d1d;

  --success: #68d391;
  --success-light: #48bb78;
  --success-lighter: #68d391;
  --success-toast: #14532d;

  --info-toast: #1e40af;

  --text-primary: #e0e0e0;
  --text-secondary: #b0b0b0;
  --text-tertiary: #808080;
  --text-contrast: #2d3748;

  --background: #121212;
  --background-input: #333333;
  --background-button-supporting: rgba(255, 255, 255, 0.15);

  --border-default: #555555;
  --border-2: #000000;
  --border-3: #222222;
  --border-4: #3a3a3a;

  --surface-1: #1e1e1e;
  --surface-2: #2a2d31;
  --surface-3: #262626;
  --surface-4: #323232;

  --shadow-surface-1: rgba(0, 0, 0, 0.5);
  --shadow-surface-2: rgba(0, 0, 0, 1);

  --ai-gradient: #2d3a34, #3a2f3d, #3f3b2d;
}

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

.desktop {
  display: flex !important;
}

.mobile {
  display: none !important;
}

body {
  font-family: 'Inter', sans-serif;
  color: var(--text-primary);
  background-color: var(--background);
}

a {
  text-decoration: none;
}

.link {
  text-decoration: none;
  color: var(--text-tertiary);
}

.link:hover {
  text-decoration: underline;
}

button {
  display: flex;
  flex-direction: row;
  height: 48px;
  border-radius: 8px;
  font-size: 16px;
  gap: 8px;
  padding: 12px;
  border: none;
  outline: none;
  cursor: pointer;
  align-items: center;
  align-content: center;
  justify-content: center;
  color: var(--text-contrast);
  background-color: var(--brand-dark2);
}

button:hover {
  background-color: var(--brand-dark);
}

button:disabled {
  background-color: var(--brand-disabled);
  cursor: not-allowed;
}

button.danger {
  background-color: var(--danger);
}

button.danger:hover {
  background-color: var(--danger-light);
}

button.round-icon {
  width: 40px;
  height: 40px;
  padding: 8px;
  border-radius: 20px;
  color: var(--text-primary);
  background: var(--surface-2);
}

button.round-icon.small {
  width: 32px;
  height: 32px;
  padding: 6px;
  border-radius: 16px;
  color: var(--text-primary);
  background: var(--surface-2);
}

button.round-icon.success {
  background: var(--success-light);
}

button.round-icon.danger {
  background: var(--danger-light);
}

button.round-icon:hover {
  background: var(--shadow-surface-1);
}

button.round-icon-text {
  height: 40px;
  padding: 8px;
  border-radius: 20px;
  color: var(--text-primary);
  background: var(--surface-2);
}

button.round-icon-text.small {
  height: 32px;
  gap: 4px;
  padding: 6px 12px 6px 10px;
  font-size: 12px;
  border-radius: 16px;
  color: var(--text-primary);
  background: var(--surface-2);
}

button.round-icon-text.success {
  background: var(--success-light);
}

button.round-icon-text.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}

button.round-icon-text.danger:hover {
  background: var(--danger-lighter);
  color: var(--danger);
}

button.round-icon-text:hover {
  background: var(--shadow-surface-1);
}

button.icon {
  width: 40px;
  height: 40px;
  padding: 8px;
  border-radius: 50%;
  color: var(--text-primary);
  background-color: transparent;
}

button.icon:hover {
  transform: scale(1.1);
}

button.secondary {
  border-radius: 8px;
  border: 1px solid var(--brand-dark2);
  background: transparent;
  color: var(--text-primary);
}

button.secondary.small {
  height: 36px;
  padding: 8px 12px;
}

button.secondary:hover {
  background: var(--info-toast);
}

button.tertiary {
  padding: 8px 16px 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-default);
  background: transparent;
  color: var(--text-primary);
}

button.tertiary:hover {
  box-shadow: 0 0 6px var(--shadow-surface-1);
}

form {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow: hidden;
  min-height: 0;
}

.inputs-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.inputs-container::-webkit-scrollbar {
  display: none;
}

.input-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-container.ai input {
  display: none;
}

.input-container.ai {
  display: flex;
  flex-direction: row;
  align-items: center;
  padding: 8px;
  padding-left: 12px;
  border-radius: 10px;
  border: 1px solid #00000010;
  background: linear-gradient(135deg, var(--ai-gradient));
  transition: box-shadow 0.3s ease;
}

.input-container.ai:hover {
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

.input-container.ai label {
  flex: 1;
  display: flex;
  flex-direction: row;
  font-size: 16px;
  font-weight: lighter;
  align-items: center;
  gap: 10px;
}

.input-container.ai button {
  height: 36px;
  padding: 0px 12px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--text-primary);
  border: 0px;
  background-color: var(--background-button-supporting);
}

.horizontal {
  flex-direction: row;
  justify-content: space-between;
}

.horizontal.compact {
  flex-direction: row;
  justify-content: flex-start;
}

.input-container label {
  font-size: 14px;
  font-weight: 600;
  display: block;
  user-select: none;
}

.input-container input,
select {
  width: 100%;
  height: 48px;
  padding: 12px;
  border-radius: 8px;
  color: var(--text-primary);
  background-color: var(--background-input);
  border: 1px solid var(--border-default);
  font-size: 16px;
  outline: none;
}

select.secondary {
  height: 36px;
  padding: 8px 8px;
  font-size: 14px;
  background-color: var(--surface-1);
}

input.secondary {
  height: 36px;
  padding: 8px 12px;
  font-size: 14px;
  background-color: var(--surface-1);
}

.input-container input:focus,
select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px var(--brand-opacity);
}

.input-container input:disabled,
select:disabled {
  background-color: var(--surface-2);
}

.radio-group {
  height: 48px;
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 8px;
  background: var(--surface-2);
}

.radio-group.compact {
  height: 36px;
}

.radio-group input {
  display: none;
}

.radio-group label {
  font-weight: normal;
}

.radio-group.flex label {
  flex: 1;
}

.radio-group input + span {
  text-align: center;
  white-space: nowrap;
  display: inline-block;
  height: 40px;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  align-content: center;
  color: var(--text-primary);
  user-select: none;
}

.radio-group.compact input + span {
  height: 28px;
}

.radio-group input:checked + span {
  background-color: var(--surface-1);
  box-shadow: 0 0 3px var(--shadow-surface-1);
}

/** Layouts */

.multi-columns {
  display: flex;
  gap: 16px;
}

.multi-columns .column {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/** Icons */

.icon-smaller {
  width: 14px;
  height: 14px;
}

.icon-small {
  width: 16px;
  height: 16px;
}

.icon-sm {
  width: 20px;
  height: 20px;
}

.icon-medium {
  width: 24px;
  height: 24px;
}

/** Brand logo — a touch larger than a standard medium icon.
    Inline SVG so the circle/arrows track the theme via CSS vars.
    The circle is always the theme's brand color, the arrows its contrast:
    Light: dark #0f172a circle with white arrows.
    Dark:  light #cbd5e1 circle with dark #0f172a arrows. */
.brand-logo {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.brand-logo circle {
  fill: var(--brand);
}

.brand-logo path {
  stroke: #ffffff;
}

:root.dark .brand-logo path {
  stroke: var(--brand-contrast);
}

/* ============================================================
   App bar — shared chrome for the auth pages (.auth-top-bar) and
   the app / landing / record pages (.top-bar). Per-page layout
   (position, justify, gaps, nav menu) stays in the page CSS. */
.top-bar,
.auth-top-bar {
  z-index: 100;
  display: flex;
  height: 64px;
  padding: 12px 32px;
  align-items: center;
  background-color: rgba(255, 255, 255, 0.7);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
}

/* Light mode has no bottom border; in dark mode it defines the edge
   against the near-black background where the blur alone isn't enough. */
.dark .top-bar,
.dark .auth-top-bar {
  background-color: rgba(20, 20, 20, 0.7);
  border-bottom: 1px solid var(--border-4);
}

.top-bar .brand-name,
.auth-top-bar .left-actions .brand-name {
  font-family: 'Caveat', cursive;
  /* Match the h1 this wordmark used to be, minus the heading semantics. */
  font-size: 2em;
  font-weight: 500;
  padding-right: 12px;
  user-select: none;
  color: var(--brand);
}

/* ============================================================
   Auth screens — shared shell for login / signup / companies:
   a centered card floating over a tinted gradient background.
   Page-specific bits (forgot-password link, company grid, logout
   button) stay in the page stylesheets. */
body.root {
  background-color: var(--background);
  position: relative;
  overflow: hidden;
}

body.root::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  background: radial-gradient(
      circle at 15% 10%,
      rgba(49, 130, 206, 0.16),
      transparent 55%
    ),
    radial-gradient(
      circle at 85% 90%,
      rgba(72, 187, 120, 0.12),
      transparent 55%
    );
  pointer-events: none;
}

.root {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  margin: 0;
}

.auth-top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  justify-content: space-between;
}

.auth-top-bar .left-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
  text-decoration: none;
}

.auth-top-bar .right-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.auth-container {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 420px;
  gap: 24px;
  margin: 24px;
  padding: 40px 32px 32px;
  border-radius: 18px;
  box-shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.18);
  background: var(--surface-1);
}

.dark .auth-container {
  border: 1px solid var(--border-4);
}

.auth-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-header button.round-icon {
  display: none;
  flex-shrink: 0;
}

.auth-heading {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-heading h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}

.auth-heading p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin: 0;
}

.auth-container form {
  display: flex;
  flex-direction: column;
  gap: 18px;
  /* The auth form doesn't scroll, so undo the global `form` overflow:hidden —
     otherwise it clips the input focus ring on the left/right edges. */
  overflow: visible;
}

.auth-container button[type='submit'] {
  height: 52px;
  padding: 0 24px;
  font-weight: 600;
  font-size: 16px;
  border-radius: 10px;
  margin-top: 8px;
}

.auth-footer {
  text-align: center;
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0;
}

.auth-footer a {
  color: var(--brand-dark);
  font-weight: 500;
  text-decoration: none;
}

.auth-footer a:hover {
  text-decoration: underline;
}

/* Legal consent line under the auth forms — quieter than the main footer. */
.auth-footer.auth-legal {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: -8px;
}

.auth-footer.auth-legal a {
  color: var(--text-secondary);
}

.input-container#code-container {
  display: none;
}

@media (max-width: 480px) {
  .auth-container {
    padding: 32px 24px 24px;
    margin: 16px;
  }

  .auth-heading h1 {
    font-size: 1.5rem;
  }
}

/** Modals */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding: 24px;
  z-index: 200;
  display: flex;
  opacity: 0;
  visibility: hidden;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.5);
  transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
}

.modal.show {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  display: flex;
  flex-direction: column;
  position: relative;
  width: 400px;
  max-height: 90vh;
  gap: 32px;
  padding: 24px;
  border-radius: 16px;
  box-shadow: 0 0 10px var(--shadow-surface-1);
  background-color: var(--surface-1);
}

.modal-content h2 {
  margin-top: 8px;
  margin-bottom: 16px;
}

.modal-content p {
  font-weight: 200;
}

.modal-content .close {
  position: absolute;
  top: 12px;
  right: 12px;
}

/* Reusable form-modal chrome — shared by the add/edit entity & employee modals
   so they match the create-company modal (icon header, helper note, footer). */
.modal-content.form-modal {
  width: 520px;
  max-width: 92vw;
}

.modal-hero {
  display: flex;
  gap: 20px;
  align-items: center;
  padding-right: 32px; /* clear the close button */
}

.modal-hero-icon {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--brand-lighter);
  color: var(--brand-dark);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Override the base `.modal-content h2` margins (higher specificity) so the
   title sits tight against the subtitle. */
.modal-hero .modal-hero-title {
  margin: 0;
}

.modal-hero-subtitle {
  margin: 4px 0 0;
  font-size: 13px;
  font-weight: 200;
  color: var(--text-secondary);
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex: 1;
  min-height: 0;
}

.modal-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.modal-note {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  font-size: 12px;
  font-weight: 200;
  line-height: 1.4;
  color: var(--text-tertiary);
}

.modal-note .icon-small {
  flex: none;
  margin-top: 1px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--border-2);
  padding-top: 20px;
}

.modal-actions button {
  height: 44px;
  padding: 0 20px;
  font-size: 15px;
}

@media (max-width: 560px) {
  .modal-row {
    grid-template-columns: 1fr;
  }
}

/* Empty states for list views (records, entities, employees). */
.empty-state-li {
  list-style: none;
}

.empty-state {
  flex: 1 1 auto;
  min-height: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
  padding: 24px;
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Brand tint (same as the modal hero icons) so the circle stands clear of the
     page background instead of blending into it. */
  background: var(--brand-lighter);
  color: var(--brand-dark);
  margin-bottom: 4px;
}

.empty-state-icon .icon-medium {
  width: 28px;
  height: 28px;
}

.empty-state-title {
  margin: 0;
  font-size: 16px;
  color: var(--text-primary);
}

.empty-state-message {
  margin: 0;
  max-width: 320px;
  font-size: 13px;
  font-weight: 200;
  line-height: 1.5;
  color: var(--text-secondary);
}

.empty-state-action {
  margin-top: 8px;
  height: 40px;
  padding: 0 18px;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Currency no-conversion warning (forced prompt + settings) */
.country-prompt-warning {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 12px;
  border-radius: 8px;
  background-color: var(--surface-2);
  font-size: 0.85rem;
  font-weight: 200;
  line-height: 1.4;
}

.country-prompt-warning .icon-small {
  flex-shrink: 0;
  margin-top: 2px;
}

.toast {
  position: absolute;
  bottom: 24px;
  background-color: var(--brand-lighter);
  z-index: 200;
  display: flex;
  align-self: center;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 8px 8px 8px 16px;
  border-radius: 12px;
  color: var(--text-primary);
  box-shadow: 0 0 24px var(--shadow-surface-2);
  background-color: var(--info-toast);
}

.toast.success {
  background-color: var(--success-toast);
}

.toast.danger {
  background-color: var(--danger-toast);
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
}

.toast.hide {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast button {
  height: 36px;
  padding: 0px 12px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--text-primary);
  background-color: var(--background-button-supporting);
}

label {
  font-size: 16px;
  color: var(--text-primary);
  user-select: none;
}

label a {
  color: var(--brand-dark2);
}

label.sm {
  font-size: 14px;
}

label.center {
  align-self: center;
}

label.error {
  color: var(--danger);
}

label.required::after {
  content: ' *';
  color: var(--danger);
  margin-left: 2px;
}

/** Dropdown */
.dropdown {
  position: relative;
  display: inline-flex;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 10;
  display: none;
  flex-direction: column;
  min-width: 160px;
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--border-default);
  background: var(--surface-1);
  box-shadow: 0 4px 12px var(--shadow-surface-1);
}

.dropdown-menu.show {
  display: flex;
}

.dropdown-menu.up {
  top: auto;
  bottom: calc(100% + 6px);
}

.dropdown-menu .dropdown-item {
  display: flex;
  height: auto;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-primary);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.dropdown-menu .dropdown-item:hover {
  background: var(--surface-2);
}

/** Helpers */
.flex {
  flex: 1;
}

@media screen and (max-width: 480px) {
  .desktop {
    display: none !important;
  }

  .mobile {
    display: flex !important;
  }
}

/* Centered loading spinner for list views (records, entities, employees). */
.list-loading {
  flex: 1 1 auto;
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.list-loading .spinner {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid var(--surface-3);
  border-top-color: var(--brand);
  animation: list-loading-spin 0.7s linear infinite;
}

@keyframes list-loading-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Reserve each icon's box before lucide swaps the <i data-lucide> placeholder
   for an <svg>. An <i> is display:inline by default, so its .icon-* width/height
   are ignored and the icon collapses to ~0 until hydration — causing a layout
   shift ("wobble") when the bundle finishes and createIcons() runs. inline-block
   lets the size classes apply to the placeholder, so the swap is size-neutral. */
[data-lucide] {
  display: inline-block;
}
