:root {
  --font-display: "Outfit", sans-serif;
  --font-body: "Source Sans 3", sans-serif;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, 0.1);
  --sidebar-w: 260px;
  --topbar-h: 64px;
  --transition: 180ms ease;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

h1, h2, h3, .page-title, .stat-card__value, .auth-brand h1 {
  font-family: var(--font-display);
  letter-spacing: -0.02em;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

.app-body {
  display: flex;
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
}

.app-shell {
  flex: 1;
  min-width: 0;
  min-height: 0;
  height: 100%;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.app-main {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 1.25rem 1.5rem 1.5rem;
  position: relative;
  animation: fadeUp 0.35s ease both;
}

.nav-progress {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 30;
  margin: -1.25rem -1.5rem 1rem;
  overflow: hidden;
  background: transparent;
}

.nav-progress.is-active {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}

.nav-progress.is-active::after {
  content: "";
  display: block;
  height: 100%;
  width: 40%;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: navSlide 0.9s ease-in-out infinite;
}

@keyframes navSlide {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}

.page-swap {
  animation: pageIn 0.28s ease both;
}

@keyframes pageIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

body.is-navigating {
  cursor: progress;
}

body.is-navigating .sidebar__link {
  pointer-events: none;
}

@keyframes fadeUp {
  from { opacity: 0; }
  to { opacity: 1; }
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.page-title {
  margin: 0;
  font-size: clamp(1.6rem, 2vw, 2rem);
  font-weight: 750;
}

.plan-visibility-field {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--bg) 60%, var(--surface));
  max-width: 100%;
}

.plan-visibility-field__check {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.plan-visibility-field__help {
  display: block;
  font-size: 0.875rem;
  line-height: 1.45;
  margin: 0;
  padding-left: 1.65rem;
}

.demo-plan-notice {
  margin-bottom: 1rem;
}

.page-sub {
  margin: 0.25rem 0 0;
  color: var(--muted);
}

.page-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.2rem;
  margin-bottom: 1rem;
}

.panel--narrow { max-width: 640px; }

.section-title {
  margin: 0 0 0.85rem;
  font-size: 1.05rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.65rem 1.1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--transition), background var(--transition), border-color var(--transition), color var(--transition);
  text-decoration: none !important;
  white-space: nowrap;
}

.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn--primary {
  background: var(--accent);
  color: #fff;
}
.btn--primary:hover { background: var(--accent-strong); }

.btn--secondary {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-color: transparent;
}

.btn--ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn--danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn--danger:hover:not(:disabled) {
  filter: brightness(0.96);
}

.btn--muted {
  background: color-mix(in srgb, var(--border) 55%, var(--surface));
  color: var(--muted);
  border-color: var(--border);
  cursor: not-allowed;
}

.btn--muted:disabled {
  opacity: 0.85;
}

.btn--purple {
  background: rgba(124, 58, 237, 0.14);
  color: #7c3aed;
  border-color: transparent;
}

.btn--purple:hover {
  background: rgba(124, 58, 237, 0.22);
}

.btn--sm { padding: 0.4rem 0.8rem; font-size: 0.9rem; }
.btn--block { width: 100%; }

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
}

.field span {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
}

.field em { font-style: normal; font-weight: 400; opacity: 0.8; }

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.85rem;
  font: inherit;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.form-stack { display: flex; flex-direction: column; }
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.inline-form {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  flex-wrap: wrap;
  width: 100%;
}

.inline-form--add {
  flex: 1 1 280px;
  min-width: 0;
}

.flag-switch {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 0.35rem;
  margin: 0;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
  position: relative;
  box-sizing: border-box;
}

.flag-switch__caption {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
  line-height: 1.2;
}

.flag-switch__input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}

.flag-switch__track {
  position: relative;
  display: block;
  width: 72px;
  height: 44px;
  border-radius: 999px;
  background: var(--border);
  border: 1px solid var(--border);
  transition: background 0.2s ease, border-color 0.2s ease;
  box-sizing: border-box;
}

.flag-switch__knob {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.22);
  transition: transform 0.2s ease;
}

.flag-switch__input:checked + .flag-switch__track {
  background: var(--accent);
  border-color: var(--accent-strong, var(--accent));
}

.flag-switch__input:checked + .flag-switch__track .flag-switch__knob {
  transform: translateX(28px);
}

.flag-switch__input:focus-visible + .flag-switch__track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.flag-switch:hover .flag-switch__track {
  border-color: var(--accent);
}

.visibility-badge {
  margin-left: 0.35rem;
  vertical-align: middle;
  font-size: 0.7rem;
  font-weight: 700;
}

.inline-form > #deleteSelectedBtn {
  height: 44px;
  min-height: 44px;
  padding-top: 0;
  padding-bottom: 0;
  flex-shrink: 0;
  align-self: end;
}

.filters-bar {
  display: grid;
  grid-template-columns: minmax(200px, 1.6fr) repeat(5, minmax(110px, 0.85fr)) auto;
  align-items: end;
  gap: 0.75rem;
  width: 100%;
}

.inline-form .field,
.filters-bar .field {
  margin-bottom: 0;
}

.inline-form .field input,
.inline-form .field select,
.filters-bar .field input,
.filters-bar .field select {
  height: 44px;
  min-height: 44px;
  box-sizing: border-box;
  line-height: 1.2;
  padding: 0 0.85rem;
}

.inline-form > .btn,
.filters-bar > .btn {
  height: 44px;
  min-height: 44px;
  padding-top: 0;
  padding-bottom: 0;
  flex-shrink: 0;
  align-self: end;
}

.filters-bar .field--grow {
  min-width: 0;
}

.field--grow { flex: 1; min-width: 180px; margin-bottom: 0; }

.alert {
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
  font-weight: 500;
}

.alert--success {
  background: var(--ok-soft);
  color: var(--ok);
}

.alert--warn {
  background: color-mix(in srgb, #f59e0b 14%, var(--surface));
  border: 1px solid color-mix(in srgb, #f59e0b 35%, var(--border));
  color: var(--text);
}

.alert--error {
  background: var(--danger-soft);
  color: var(--danger);
}

.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 0.85rem 0.65rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.data-table th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 700;
}

.empty-cell {
  text-align: center !important;
  color: var(--muted);
  padding: 2rem !important;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 700;
}

.badge--ok { background: var(--ok-soft); color: var(--ok); }
.badge--bad { background: var(--danger-soft); color: var(--danger); }
.badge--warn { background: var(--warn-soft); color: var(--warn); }
.badge--muted { background: var(--accent-soft); color: var(--accent-strong); }

.muted { color: var(--muted); font-size: 0.9rem; }
.inline { display: inline; }

/* Flex no <td> quebra bordas/linhas da tabela — usar wrapper interno */
.actions-cell {
  white-space: nowrap;
  vertical-align: middle;
}

.actions-cell__inner {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  align-items: center;
}

.actions-cell__inner--row {
  flex-wrap: nowrap;
  justify-content: flex-end;
  gap: 0.4rem;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
  margin: 1rem 0 0.65rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}

.toolbar__left,
.toolbar__right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.check-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.92rem;
  line-height: 1;
  white-space: nowrap;
  margin: 0;
  cursor: pointer;
}

.check-inline input {
  width: 16px;
  height: 16px;
  margin: 0;
  flex-shrink: 0;
}

.toolbar__count {
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
  line-height: 1;
}

@media (max-width: 1200px) {
  .filters-bar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .filters-bar .field--grow {
    grid-column: 1 / -1;
  }

  .filters-bar > .btn {
    justify-self: start;
  }
}

@media (max-width: 700px) {
  .filters-bar {
    grid-template-columns: 1fr 1fr;
  }

  .inline-form {
    flex-direction: column;
    align-items: stretch;
  }

  .inline-form > .btn,
  .filters-bar > .btn {
    width: 100%;
  }
}

.dialog {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0;
  background: var(--surface);
  color: var(--text);
  max-width: 420px;
  width: calc(100% - 2rem);
  box-shadow: 0 24px 48px rgba(8, 16, 28, 0.2);
}

.dialog > form,
.dialog > .form-stack {
  padding: 1.25rem 1.35rem 1.35rem;
}

.dialog--lg { max-width: 560px; }

.dialog::backdrop { background: rgba(8, 12, 18, 0.5); backdrop-filter: blur(2px); }

.dialog__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.dialog__head h3 { margin: 0 0 0.2rem; font-size: 1.15rem; }
.dialog__head .muted { margin: 0; }

.dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.15rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}

.organize-section {
  padding: 0.85rem 0;
  border-top: 1px solid var(--border);
}

.organize-section:first-of-type { border-top: 0; padding-top: 0.25rem; }

.organize-section h4 {
  margin: 0 0 0.65rem;
  font-size: 0.95rem;
  font-weight: 700;
}

.organize-section h4 small {
  font-weight: 500;
  color: var(--muted);
  font-size: 0.78rem;
}

.history-box {
  margin-top: 0.5rem;
  max-height: 140px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  background: color-mix(in srgb, var(--surface) 88%, var(--border));
}

.history-list {
  margin: 0;
  padding-left: 1rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.history-list li { margin: 0.25rem 0; }

.group-private-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.35rem;
  align-items: center;
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.group-note {
  font-size: 0.78rem;
  color: var(--muted);
}

.error-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  margin-left: 0.25rem;
  border: 0;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-weight: 800;
  font-size: 0.75rem;
  cursor: pointer;
  vertical-align: middle;
}
.error-chip:hover { filter: brightness(0.92); }

.error-pre {
  margin: 0;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--danger) 30%, var(--border));
  background: var(--danger-soft);
  color: var(--danger);
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.85rem;
  line-height: 1.45;
  max-height: 220px;
  overflow: auto;
}

.organize-hero {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}

.organize-hero__img {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--accent-soft);
}

.organize-hero__img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.organize-hero__img.is-empty { display: none; }

.status-cell {
  white-space: nowrap;
}

.import-filename { display: block; margin-bottom: 0.2rem; word-break: break-word; }

/* Estilos de importação movidos para css/components/import.css */

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}

.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle--floating {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 20;
}

.error-page {
  min-height: 50vh;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 0.5rem;
}

.error-page h1 {
  font-size: 4rem;
  margin: 0;
  color: var(--accent);
}

@media (max-width: 900px) {
  .app-shell { margin-left: 0; }
  .app-main { padding: 1rem; }
  .nav-progress { margin: -1rem -1rem 1rem; }
  .form-grid { grid-template-columns: 1fr; }
}
