/**
 * Shared layout + Nexus* components — Second Edition brand tokens.
 * See docs/react/brand-colors.md. Public reference: https://secondedition.co
 */
:root {
  --se-green: #657f60;
  --se-green-hover: #556b52;
  --se-tan: #dac9b6;
  --se-charcoal: #2f2f2f;
  --se-silver: #fafafa;
  --se-white: #ffffff;

  --nm-bg: var(--se-white);
  --nm-surface: var(--se-silver);
  --nm-media-bg: var(--se-silver);
  --nm-border: rgba(47, 47, 47, 0.1);
  --nm-border-focus: rgba(101, 127, 96, 0.55);
  --nm-text: var(--se-charcoal);
  --nm-muted: rgba(47, 47, 47, 0.55);
  --nm-accent: var(--se-green);
  --nm-accent-hover: var(--se-green-hover);
  --nm-accent-soft: rgba(101, 127, 96, 0.18);
  --nm-danger: #b91c1c;
  --nm-success: #4a7c59;
  --nm-radius: 12px;
  --nm-radius-sm: 8px;
  --nm-shadow-sm: 0 1px 3px rgba(47, 47, 47, 0.06);
  --nm-shadow-md: 0 10px 36px rgba(47, 47, 47, 0.08);
  --nm-font: "DM Sans", system-ui, sans-serif;

  /* Login canvas + card (reference: light gray page, white bordered card) */
  --login-canvas-bg: #f9fafb;
  --login-card-border: #e5e7eb;
  --login-card-max-width: 25rem; /* ~400px */
  --login-card-min-height: 28.125rem; /* 450px */
}

html.nm-html-root {
  height: 100%;
}

body.nm-body {
  margin: 0;
  min-height: 100%;
  font-family: var(--nm-font);
  background: var(--nm-bg);
  color: var(--nm-text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#label-generator-root {
  min-height: 100%;
  position: relative;
  padding: 1rem 1.25rem 1.5rem;
  box-sizing: border-box;
}

#login-root {
  min-height: 100%;
}

/* Login (React) — gray canvas, white card, brand + fields + primary CTA */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1.25rem 2rem;
  box-sizing: border-box;
  background: var(--login-canvas-bg);
}

.login-page .nm-solo-main {
  width: 100%;
  max-width: var(--login-card-max-width);
  margin: 0;
}

.login-page .nm-panel {
  background: var(--se-white);
  border: 1px solid var(--login-card-border);
  border-radius: var(--nm-radius);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.login-page .nm-panel-body {
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  min-height: var(--login-card-min-height);
  padding: 2rem 2.25rem 2.25rem;
}

.login-page__card-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1rem;
  flex-shrink: 0;
  margin-bottom: 0;
}

.login-page__logo {
  height: 36px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  opacity: 0.92;
}

.login-page__meta {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 0.35rem;
}

.login-page__nexus {
  font-family: "Montserrat", var(--nm-font);
  font-weight: 600;
  font-size: 0.8125rem;
  letter-spacing: 0.08em;
  color: var(--nm-muted);
  line-height: 1.2;
}

.login-page__version {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--nm-muted);
  letter-spacing: 0.02em;
}

.login-page__middle {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 0.75rem 0.25rem;
}

.login-page__tagline {
  margin: 0;
  max-width: 17rem;
  text-align: center;
  font-size: 1rem;
  font-weight: 500;
  font-style: italic;
  line-height: 1.5;
  letter-spacing: 0.01em;
  color: rgba(47, 47, 47, 0.42);
}

.login-page__form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  flex-shrink: 0;
  width: 100%;
}

.login-page__fields {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login-page .nc-text-input {
  border: 1px solid var(--login-card-border);
  border-radius: var(--nm-radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.9375rem;
  background: var(--se-white);
}

.login-page .nc-text-input::placeholder {
  color: #9ca3af;
}

.login-page__error {
  margin-top: 0.25rem;
  padding: 0.75rem 0.85rem;
  border-radius: var(--nm-radius-sm);
  background: rgba(185, 28, 28, 0.08);
  border: 1px solid rgba(185, 28, 28, 0.22);
  color: var(--nm-danger);
  font-size: 0.8125rem;
  line-height: 1.45;
  white-space: pre-wrap;
  text-align: left;
}

@media (max-width: 600px) {
  #login-root {
    min-height: 100vh;
    min-height: 100dvh;
  }

  .login-page {
    min-height: 100vh;
    min-height: 100dvh;
    padding: 0;
    align-items: stretch;
  }

  .login-page .nm-solo-main {
    max-width: none;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
  }

  .login-page .nm-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    border-radius: 0;
    border: none;
    box-shadow: none;
  }

  .login-page .nm-panel-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    min-height: 0;
    padding-top: max(1.75rem, env(safe-area-inset-top, 0px));
    padding-right: max(1.25rem, env(safe-area-inset-right, 0px));
    padding-bottom: max(2rem, env(safe-area-inset-bottom, 0px));
    padding-left: max(1.25rem, env(safe-area-inset-left, 0px));
  }

  .login-page__card-head {
    flex-shrink: 0;
  }

  .login-page__middle {
    flex: 1;
    padding: 0.5rem 0.25rem;
  }

  .login-page__tagline {
    font-size: 0.9375rem;
    max-width: 16rem;
  }

  .login-page__logo {
    height: auto;
    max-height: clamp(2.25rem, 11vw, 3.25rem);
    width: auto;
    max-width: 100%;
    object-fit: contain;
  }
}

.nm-solo-main {
  max-width: 36rem;
  margin: 0 auto;
}

.nm-chrome-logo {
  position: absolute;
  top: 14px;
  left: 18px;
  height: 32px;
  width: auto;
  opacity: 0.92;
}

.nm-chrome-nexus-btn {
  position: absolute;
  top: 12px;
  right: 120px;
  padding: 0.4rem 0.7rem;
  border: none;
  border-radius: var(--nm-radius-sm);
  background: transparent;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.8125rem;
  letter-spacing: 0.06em;
  color: var(--nm-muted);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.nm-chrome-nexus-btn:hover {
  color: var(--nm-text);
  background: rgba(47, 47, 47, 0.05);
}

.nm-chrome-version {
  position: absolute;
  top: 16px;
  right: 220px;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--nm-muted);
  letter-spacing: 0.02em;
}

.nm-chrome-logout {
  position: absolute;
  top: 12px;
  right: 16px;
  padding: 0.4rem 0.75rem;
  border: none;
  border-radius: var(--nm-radius-sm);
  background: transparent;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--nm-muted);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.nm-chrome-logout:hover {
  color: var(--nm-text);
  background: rgba(47, 47, 47, 0.05);
}

.nm-chrome-main {
  max-width: 36rem;
  margin: 4.25rem auto 0;
}

.nm-panel {
  background: var(--nm-surface);
  border: 1px solid var(--nm-border);
  border-radius: var(--nm-radius);
  box-shadow: var(--nm-shadow-sm);
  overflow: hidden;
}

.nm-panel-header {
  padding: 1.125rem 1.375rem;
  border-bottom: 1px solid var(--nm-border);
  background: var(--nm-surface);
}

.nm-panel-title {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--nm-text);
}

.nm-panel-body {
  padding: 1.5rem 1.375rem;
}

/* Tan well for thumbnails / media previews (see brand-colors.md) */
.nm-media-well {
  background: var(--nm-media-bg);
  border-radius: var(--nm-radius-sm);
}

/* Loading */
.nm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(245, 243, 238, 0.78);
  backdrop-filter: blur(3px);
  align-items: center;
  justify-content: center;
}

.nm-overlay.nm-overlay-visible {
  display: flex;
}

.nm-ring {
  width: 40px;
  height: 40px;
  animation: nm-spin 0.85s linear infinite;
}

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

/* Modal — calm surface, accent bar for state (less color noise) */
.nm-modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1001;
  background: rgba(47, 47, 47, 0.4);
  backdrop-filter: blur(2px);
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.nm-modal-backdrop.nm-modal-visible {
  display: flex;
}

.nm-modal {
  max-width: 22rem;
  width: 100%;
  border-radius: var(--nm-radius);
  padding: 1.375rem 1.5rem;
  font-family: inherit;
  background: var(--nm-surface);
  box-shadow: var(--nm-shadow-md);
  border: 1px solid var(--nm-border);
  border-left-width: 4px;
  line-height: 1.5;
}

.nm-modal-error {
  border-left-color: var(--nm-danger);
}

.nm-modal-success {
  border-left-color: var(--nm-success);
}

.nm-modal-header {
  font-weight: 600;
  font-size: 0.8125rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--nm-muted);
  margin-bottom: 0.375rem;
}

.nm-modal-body {
  font-size: 0.9375rem;
  color: var(--nm-text);
  line-height: 1.55;
}

.nm-modal-actions {
  margin-top: 1.25rem;
  display: flex;
  justify-content: flex-end;
}

.nm-modal-actions button {
  padding: 0.5rem 1.125rem;
  border-radius: var(--nm-radius-sm);
  border: none;
  background: var(--se-charcoal);
  color: var(--se-white);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.nm-modal-actions button:hover {
  background: #252525;
  opacity: 0.98;
}

/* Nexus* controls */
.nc-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  text-align: center;
}

.nc-btn {
  font-family: inherit;
  cursor: pointer;
  border-radius: var(--nm-radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.25;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.nc-btn:focus-visible {
  outline: 2px solid var(--nm-border-focus);
  outline-offset: 2px;
}

.nc-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.nc-btn--primary {
  background-color: var(--nm-accent);
  color: var(--se-white);
  border: none;
  box-shadow: none;
}

.nc-btn--primary:hover:not(:disabled) {
  background-color: var(--nm-accent-hover);
}

.nc-btn--secondary {
  padding: 0.5rem 1rem;
  border: 1px solid rgba(47, 47, 47, 0.22);
  background: var(--se-white);
  color: var(--se-charcoal);
}

.nc-btn--secondary:hover:not(:disabled) {
  background: var(--se-cream);
  border-color: rgba(47, 47, 47, 0.35);
}

/* Charcoal fill — brand “black” button */
.nc-btn--dark {
  padding: 0.5rem 1rem;
  border: none;
  background: var(--se-charcoal);
  color: var(--se-white);
}

.nc-btn--dark:hover:not(:disabled) {
  background: #252525;
}

.nc-btn--hero {
  width: 100%;
  min-height: 5.5rem;
  font-size: clamp(1.0625rem, 2.8vw, 1.375rem);
  font-weight: 600;
  letter-spacing: 0.04em;
  border-radius: var(--nm-radius);
}

/* Full-width primary / dark CTA — standard app control (e.g. login) */
.nc-btn--block {
  width: 100%;
  box-sizing: border-box;
  min-height: 2.75rem;
  padding: 0.75rem 1.25rem;
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border-radius: var(--nm-radius-sm);
}

.nc-number-input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--nm-border);
  border-radius: var(--nm-radius);
  font-family: inherit;
  color: var(--nm-text);
  background: var(--nm-surface);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.nc-number-input:focus {
  outline: none;
  border-color: var(--nm-accent);
  box-shadow: 0 0 0 3px var(--nm-accent-soft);
}

.nc-number-input--hero {
  min-height: 4.25rem;
  font-size: 1.375rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  text-align: center;
}

.nc-number-input--hero::placeholder {
  color: var(--nm-muted);
  font-weight: 400;
}

.nc-text-input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--nm-border);
  border-radius: var(--nm-radius-sm);
  font-family: inherit;
  font-size: 0.9375rem;
  color: var(--nm-text);
  background: var(--nm-bg);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.nc-text-input:focus {
  outline: none;
  border-color: var(--nm-accent);
  box-shadow: 0 0 0 3px var(--nm-accent-soft);
}

.nc-text-input::placeholder {
  color: var(--nm-muted);
}

/* NexusSelect */
.nc-select {
  width: 100%;
  box-sizing: border-box;
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--nm-border);
  border-radius: var(--nm-radius-sm);
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--nm-text);
  background: var(--nm-bg);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%232f2f2f' opacity='.45'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
}

.nc-select:focus {
  outline: none;
  border-color: var(--nm-accent);
  box-shadow: 0 0 0 3px var(--nm-accent-soft);
}

/* NexusMultiSelect — trigger reuses .nc-select chrome, popover uses its own
 * list styling. Positioning is absolute relative to .nc-mselect so the
 * popover anchors to the trigger even inside overflowing scroll panes. */

.nc-mselect {
  position: relative;
  display: inline-block;
  width: 100%;
}

.nc-mselect__trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  text-align: left;
  cursor: pointer;
  background-color: var(--nm-surface);
}

.nc-mselect__trigger[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

.nc-mselect__summary {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.nc-mselect__placeholder {
  color: var(--nm-muted);
}

.nc-mselect__caret {
  font-size: 0.7rem;
  color: var(--nm-muted);
}

.nc-mselect__list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 60;
  margin: 0;
  padding: 0.25rem 0;
  list-style: none;
  max-height: 14rem;
  overflow: auto;
  background: var(--nm-surface);
  border: 1px solid var(--nm-border);
  border-radius: var(--nm-radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  outline: none;
}

.nc-mselect__option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
}

.nc-mselect__option:hover,
.nc-mselect__option--focus {
  background: var(--nm-accent-soft);
}

.nc-mselect__option--selected {
  font-weight: 600;
}

.nc-mselect__option--disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.nc-mselect__option input[type="checkbox"] {
  pointer-events: none;
}

.nc-mselect__empty {
  padding: 0.5rem 0.75rem;
  color: var(--nm-muted);
  font-style: italic;
}

/* NexusChipSelect */
.nc-chip-select {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.nc-chip-select__label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--nm-muted);
}

.nc-chip-select__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.nc-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  border: 1px solid var(--nm-border);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--nm-bg);
  color: var(--nm-text);
}

.nc-chip__remove {
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 0.875rem;
  line-height: 1;
  color: var(--nm-muted);
  padding: 0;
}

.nc-chip__remove:hover {
  color: var(--nm-danger);
}

/* NexusTabs */
.nc-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--nm-border);
  margin-bottom: 1rem;
}

.nc-tab {
  padding: 0.5rem 1rem;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--nm-muted);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.nc-tab:hover {
  color: var(--nm-text);
}

.nc-tab--active {
  color: var(--nm-accent);
  border-bottom-color: var(--nm-accent);
}

/* NexusTable */
.nc-table-wrap {
  overflow-x: auto;
}

.nc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.nc-table th,
.nc-table td {
  padding: 0.5rem 0.625rem;
  text-align: left;
  border-bottom: 1px solid var(--nm-border);
  white-space: nowrap;
}

.nc-table th {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--nm-muted);
  background: var(--nm-bg);
  position: sticky;
  top: 0;
}

.nc-table--right {
  text-align: right;
}

.nc-table__sort {
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: inherit;
}

.nc-table__sort:hover {
  color: var(--nm-accent);
}

/* KPI card */
.nc-kpi {
  padding: 0.75rem;
  border: 1px solid var(--nm-border);
  border-radius: var(--nm-radius-sm);
  background: var(--nm-bg);
}

.nc-kpi__label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--nm-muted);
  margin-bottom: 0.2rem;
}

.nc-kpi__value {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--nm-text);
  letter-spacing: -0.02em;
}

/* NexusSearchInput */
.nc-search {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--nm-border);
  border-radius: 999px;
  background: var(--nm-bg);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
  min-height: 2.25rem;
  box-sizing: border-box;
}

.nc-search:focus-within {
  border-color: var(--nm-border-focus);
  box-shadow: 0 0 0 3px var(--nm-accent-soft);
}

.nc-search__input {
  border: 0;
  outline: 0;
  background: transparent;
  flex: 1 1 auto;
  min-width: 0;
  font: inherit;
  color: inherit;
  padding: 0;
}

.nc-search__input::placeholder {
  color: var(--nm-muted);
}

.nc-search__input::-webkit-search-cancel-button {
  display: none;
}

.nc-search__icon {
  display: inline-flex;
  align-items: center;
  color: var(--nm-muted);
  font-size: 0.9rem;
}

.nc-search__clear {
  border: 0;
  background: transparent;
  color: var(--nm-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 0.25rem;
  border-radius: 999px;
}

.nc-search__clear:hover {
  color: var(--nm-text);
  background: var(--nm-accent-soft);
}

/* NexusRelativeTime */
.nc-rel-time {
  font-variant-numeric: tabular-nums;
  color: var(--nm-muted);
}

/* NexusAvatarInitials */
.nc-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: var(--se-white);
  font-weight: 600;
  letter-spacing: 0.02em;
  user-select: none;
  flex-shrink: 0;
}

