/* ============================================================
   COMPONENTS — Liquid Glass UI Kit
   ============================================================ */

/* ---- Global Reset ---- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  height: 100%;
}

body {
  font-family: var(--font-system);
  font-size: 14px;
  color: var(--text-primary);
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01", "ss02", "cv11", "kern";
  background-color: var(--bg-color);
  transition: background-color 0.4s ease;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ---- Global Scrollbars ---- */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
}

/* ============================================================
   BUTTONS — shadcn/ui
   h-10 (40px) default · rounded-md (6px) · transition-colors only
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  user-select: none;
  text-decoration: none;
  border: 1px solid var(--glass-border-outer);
  background: var(--bg-color);
  color: var(--text-primary);
  height: 40px;
  padding: 0 16px;
  outline: none;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s, opacity 0.15s, box-shadow 0.15s;
}

.btn:hover {
  background: var(--row-hover);
}

.btn:active {
  opacity: 0.85;
}

.btn:focus-visible {
  box-shadow: 0 0 0 3px var(--ring);
}

.btn:disabled,
.btn[disabled],
.btn.loading {
  pointer-events: none;
  opacity: 0.5;
}

.btn.loading::after {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  flex-shrink: 0;
}

/* Primary — bg-primary text-primary-foreground hover:bg-primary/90 */
.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
  border-color: transparent;
}

.btn-primary:hover {
  background: var(--accent-hover);
  color: var(--on-accent);
}

/* Secondary — bg-secondary text-secondary-foreground hover:bg-secondary/80 */
.btn-secondary {
  background: var(--fill-secondary);
  color: var(--text-primary);
  border-color: transparent;
}

.btn-secondary:hover {
  background: var(--fill-primary);
}

/* Ghost — hover:bg-accent hover:text-accent-foreground */
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-primary);
}

.btn-ghost:hover {
  background: var(--row-hover);
  color: var(--text-primary);
}

/* Destructive — bg-destructive text-white hover:bg-destructive/90 */
.btn-danger {
  background: var(--color-red);
  color: #fff;
  border-color: transparent;
}

.btn-danger:hover {
  opacity: 0.9;
}

/* Success */
.btn-success {
  background: var(--color-green);
  color: #fff;
  border-color: transparent;
}

.btn-success:hover {
  opacity: 0.9;
}

/* Link */
.btn-link {
  background: transparent;
  border-color: transparent;
  color: var(--text-primary);
  height: auto;
  padding: 0;
  text-underline-offset: 4px;
}

.btn-link:hover {
  background: transparent;
  text-decoration: underline;
}

/* ---- Sizes ---- */
/* sm: h-9 px-3 */
.btn-sm {
  height: 36px;
  padding: 0 12px;
  font-size: 13px;
}

/* lg: h-11 px-8 */
.btn-lg {
  height: 44px;
  padding: 0 32px;
  font-size: 15px;
}

/* icon: h-10 w-10 */
.btn-icon {
  height: 40px;
  width: 40px;
  padding: 0;
}

/* icon-sm: h-8 w-8 */
.btn-icon-sm {
  height: 32px;
  width: 32px;
  padding: 0;
  font-size: 13px;
}

.btn-full {
  width: 100%;
}

/* ============================================================
   INPUTS & FORMS — shadcn/ui
   h-10 (40px) · rounded-md (6px) · ring-2 ring-ring ring-offset-2 on focus
   ============================================================ */
.input {
  height: 40px;
  width: 100%;
  border-radius: 6px;
  border: 1px solid var(--glass-border-outer);
  background: transparent;
  color: var(--text-primary);
  padding: 0 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input::placeholder {
  color: var(--text-tertiary);
}

.input:focus-visible,
.input:focus {
  border-color: var(--text-primary);
  box-shadow: 0 0 0 3px var(--ring);
}

.input:read-only {
  opacity: 0.6;
  cursor: default;
}

textarea.input {
  height: auto;
  resize: vertical;
  min-height: 80px;
  padding: 10px 12px;
}

/* Hide native number spinners */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
}

/* ---- Select used directly with .input class (no wrapper) ---- */
select.input {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238E8E93' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-color: var(--control-bg);
  cursor: pointer;
  color-scheme: light;
}

select.input option {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

/* Dark theme: solid bg so native popup doesn't look transparent, lighter arrow */
[data-theme="dark"] select.input {
  color-scheme: dark;
  background-color: var(--bg-elevated);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23ebebf5' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}

[data-theme="dark"] select.input option {
  background: var(--bg-color);
  color: var(--text-primary);
}

[data-theme="dark"] select.input option:checked {
  background: var(--accent);
  color: var(--on-accent);
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrapper .input-icon {
  position: absolute;
  left: 10px;
  color: var(--text-secondary);
  pointer-events: none;
  display: flex;
}

.input-wrapper .input {
  padding-left: 34px;
}

.input-wrapper .input-icon-right {
  position: absolute;
  right: 10px;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1;
}

.form-error {
  font-size: 12px;
  color: var(--color-red);
  margin-top: 2px;
}

.form-hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Custom Select */
.select-wrapper {
  position: relative;
  display: inline-block;
  width: 100%;
}

.select-wrapper select {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: 1px solid var(--glass-border-outer);
  color: var(--text-primary);
  border-radius: 6px;
  height: 40px;
  padding: 0 36px 0 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  width: 100%;
  cursor: pointer;
  color-scheme: light;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.select-wrapper select option {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.select-wrapper select:hover {
  background-color: var(--control-bg-hover);
}

.select-wrapper select:focus {
  border-color: var(--text-primary);
  box-shadow: 0 0 0 3px var(--ring);
}

/* Dark mode */
[data-theme="dark"] .select-wrapper select {
  color-scheme: dark;
  background-color: var(--bg-elevated);
  border-color: var(--control-border);
  color: var(--text-primary);
}

[data-theme="dark"] .select-wrapper select option {
  background: var(--bg-color);
  color: var(--text-primary);
}

[data-theme="dark"] .select-wrapper select option:checked {
  background: var(--accent);
  color: var(--on-accent);
}

[data-theme="dark"] .select-wrapper select:hover {
  background-color: var(--control-bg-hover);
}

.select-wrapper::after {
  content: '';
  position: absolute;
  right: 12px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 1px solid var(--text-secondary);
  border-bottom: 1px solid var(--text-secondary);
  transform: translateY(-65%) rotate(45deg);
  pointer-events: none;
  transition: border-color 0.18s;
}

.select-wrapper:hover::after,
.select-wrapper:focus-within::after {
  border-color: var(--accent);
}

/* ---- Custom Select (div-based, fully themed) ---- */
.cs-wrap {
  position: relative;
  width: 100%;
}

.cs-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  text-align: left;
  background: transparent;
  border: 1px solid var(--glass-border-outer);
  border-radius: 6px;
  height: 40px;
  padding: 0 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-primary);
  width: 100%;
  outline: none;
  transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s;
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
}

.cs-trigger:hover {
  background: var(--row-hover);
}

.cs-wrap.open .cs-trigger {
  border-color: var(--text-primary);
  box-shadow: 0 0 0 3px var(--ring);
}

.cs-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cs-label.placeholder {
  color: var(--text-secondary);
}

.cs-chevron {
  flex-shrink: 0;
  color: var(--text-secondary);
  transition: transform 0.18s ease;
}

.cs-wrap.open .cs-chevron {
  transform: rotate(180deg);
}

/* Dropdown is portaled to document.body at runtime — visibility toggled by .cs-open class */
.cs-dropdown {
  position: fixed;
  /* JS sets top/left/width */
  background: var(--bg-elevated);
  border: 1px solid var(--glass-border-outer);
  border-radius: 8px;
  border: 1px solid var(--glass-border-outer);
  padding: 4px;
  z-index: var(--z-popup);
  max-height: 220px;
  overflow-y: auto;
  opacity: 0;
  pointer-events: none;
  min-width: 120px;
}

.cs-dropdown.cs-open {
  opacity: 1;
  pointer-events: auto;
}

.cs-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.12s;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.cs-option:hover {
  background: var(--row-hover);
}

.cs-option.selected {
  background: var(--accent-ring);
  color: var(--accent);
}

.cs-option.selected::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  flex-shrink: 0;
}

/* ---- Checkbox list (multi-select, e.g. module selection) ---- */
.cb-list {
  border: 1px solid var(--control-border);
  border-radius: 10px;
  overflow: hidden;
  max-height: 210px;
  overflow-y: auto;
  background: var(--control-bg);
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
}

.cb-list::-webkit-scrollbar {
  width: 3px;
}

.cb-list::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 3px;
}

.cb-list-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--glass-border-inner);
  cursor: pointer;
  transition: background 0.1s;
  user-select: none;
}

.cb-list-row:last-child {
  border-bottom: none;
}

.cb-list-row:hover:not(.disabled) {
  background: var(--row-hover);
}

.cb-list-row.disabled {
  opacity: 0.7;
  cursor: default;
}

.cb-list-row input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.cb-list-row.disabled input[type="checkbox"] {
  cursor: default;
}

.cb-list-label {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Toggle Switch — shadcn: h-6 w-11 (24×44px), checked = bg-primary */
.switch {
  position: relative;
  display: inline-flex;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.switch-track {
  position: absolute;
  inset: 0;
  background: var(--glass-border-outer);
  border-radius: 12px;
  transition: background 0.15s;
  cursor: pointer;
}

.switch-track::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  left: 2px;
  top: 2px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.15s ease;
}

.switch input:checked + .switch-track {
  background: var(--accent);
}

.switch input:checked + .switch-track::before {
  transform: translateX(20px);
}

.switch input:focus-visible + .switch-track {
  box-shadow: 0 0 0 3px var(--ring);
}

/* Checkbox */
.checkbox-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}

.checkbox-wrapper input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 1px solid var(--control-border);
  background: var(--control-bg);
  border-radius: 4px;
  position: relative;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
  flex-shrink: 0;
}

.checkbox-wrapper input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.checkbox-wrapper input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1.5px;
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.checkbox-wrapper input[type="checkbox"]:focus-visible {
  box-shadow: 0 0 0 3px var(--ring);
}

/* Range Slider */
.range-input {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--fill-tertiary);
  border-radius: 2px;
  outline: none;
}

.range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: var(--bg-elevated);
  border-radius: 50%;
  border: 1px solid var(--glass-border-outer);
  cursor: pointer;
}


/* Progress Bar */
.progress {
  width: 100%;
  height: 6px;
  background: var(--fill-tertiary);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.55s var(--ease-smooth);
}

.progress-bar.success {
  background: var(--color-green);
}

.progress-bar.warning {
  background: var(--color-yellow);
}

/* ============================================================
   CARDS — shadcn/ui: rounded-lg (8px) border bg-card
   ============================================================ */
.card {
  background: var(--glass-bg-card);
  border: 1px solid var(--glass-border-outer);
  border-radius: 8px;
  padding: 24px;
}

.card-hover {
  transition: background 0.1s ease;
}

.card-hover:hover {
  background: var(--control-bg-hover);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--glass-border-inner);
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  line-height: 1.3;
}

/* Metric Card */
.metric-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.metric-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.metric-value {
  font-size: 28px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.metric-delta {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-green);
}

.metric-delta.negative {
  color: var(--color-red);
}

/* ============================================================
   LIST ITEM — Base class para qualquer "linha em lista"
   Use em conjunto com modificadores:
     .list-item-interactive  → cursor pointer + hover lift
     .list-item-draggable    → cursor grab + hover só bg
   ============================================================ */
.list-item {
  display: flex;
  align-items: center;
  gap: var(--list-item-gap);
  padding: var(--list-item-padding);
  border-radius: var(--list-item-radius);
  border: 1px solid var(--glass-border-inner);
  background: var(--glass-bg-card);
}

.list-item-interactive {
  cursor: pointer;
  transition: background 0.1s ease;
}

.list-item-interactive:hover {
  background: var(--control-bg-hover);
}

.list-item-interactive:active {
  background: var(--fill-secondary);
}

.list-item-draggable {
  cursor: grab;
}

.list-item-draggable:hover {
  background: var(--control-bg);
}

.list-item-draggable:active {
  cursor: grabbing;
}

/* ============================================================
   BADGES / TAGS — shadcn/ui
   rounded-full · px-2.5 py-0.5 · text-xs font-semibold
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  border: 1px solid transparent;
  /* default = secondary variant */
  background: var(--fill-secondary);
  color: var(--text-primary);
}

/* shadcn "default" variant = primary */
.badge-primary {
  background: var(--accent);
  color: var(--on-accent);
}

/* shadcn "outline" variant */
.badge-outline {
  background: transparent;
  border-color: var(--glass-border-outer);
  color: var(--text-primary);
}

/* semantic variants — keep colored for readability */
.badge-success {
  background: var(--badge-success-bg);
  color: var(--color-green);
}

.badge-warning {
  background: var(--badge-warning-bg);
  color: var(--color-yellow);
}

.badge-error {
  background: var(--badge-error-bg);
  color: var(--color-red);
}

.badge-info {
  background: var(--badge-info-bg);
  color: var(--text-primary);
}

.badge-promo {
  background: var(--badge-promo-bg);
  color: var(--color-purple);
}

.badge-neutral {
  background: var(--row-hover);
  color: var(--text-secondary);
}

/* ============================================================
   SEGMENTED CONTROL — shadcn Tabs List
   bg-muted · active = bg-background text-foreground
   ============================================================ */
.segmented {
  display: inline-flex;
  background: var(--fill-secondary);
  border-radius: 6px;
  padding: 2px;
  gap: 0;
}

.segmented button {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  font-weight: 500;
  transition: color 0.15s, background-color 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.segmented button:hover {
  color: var(--text-primary);
}

.segmented button.active {
  background: var(--bg-color);
  color: var(--text-primary);
}

/* ============================================================
   TABLE
   ============================================================ */
.table-wrapper {
  overflow-x: auto;
  border-radius: 8px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table thead tr {
  background: var(--row-hover);
}

.table th {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--glass-border-inner);
  white-space: nowrap;
}

.table th:first-child {
  border-radius: 8px 0 0 0;
}

.table th:last-child {
  border-radius: 0 8px 0 0;
}

.table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--glass-border-inner);
  color: var(--text-primary);
  vertical-align: middle;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover td {
  background: var(--row-hover);
}

.table .mono {
  font-variant-numeric: tabular-nums;
  font-family: "SF Mono", Menlo, monospace;
}

.table .positive {
  color: var(--color-green);
  font-weight: 500;
}

.table .negative {
  color: var(--color-red);
  font-weight: 500;
}

/* ============================================================
   AVATAR
   ============================================================ */
.avatar {
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--glass-border-inner);
  background: var(--control-bg);
  flex-shrink: 0;
}

.avatar-initials {
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.avatar-sm,
.avatar-initials.avatar-sm {
  width: 28px;
  height: 28px;
  font-size: 11px;
}

.avatar-md,
.avatar-initials.avatar-md {
  width: 36px;
  height: 36px;
  font-size: 13px;
}

.avatar-lg,
.avatar-initials.avatar-lg {
  width: 48px;
  height: 48px;
  font-size: 16px;
}

.avatar-xl,
.avatar-initials.avatar-xl {
  width: 72px;
  height: 72px;
  font-size: 24px;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: modalOverlayIn 0.15s ease;
}
.modal-overlay.closing { animation: modalOverlayOut 0.15s ease forwards; }

/* O .modal é o CONTAINER: header e footer ficam fixos; só o body rola. */
.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--glass-border-outer);
  border-radius: 12px;
  box-shadow: 0 10px 40px -12px rgba(0, 0, 0, 0.30);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;            /* o container não rola — quem rola é o .modal-body */
  animation: modalIn 0.18s var(--ease-smooth, ease);
}
.modal.closing { animation: modalOut 0.15s ease forwards; }

/* Header fixo (título + botão fechar) */
.modal-header {
  flex-shrink: 0;
  padding: 18px 20px 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--divider);
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.015em;
  line-height: 1.3;
}

.modal-close {
  background: transparent;
  border: none;
  border-radius: 6px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: background-color 0.15s, color 0.15s;
}

.modal-close:hover {
  background: var(--row-hover);
  color: var(--text-primary);
}

/* Corpo rolável — a única parte que scrolla */
.modal-body {
  flex: 1 1 auto;
  min-height: 0;               /* permite encolher dentro do flex p/ habilitar o scroll */
  overflow-y: auto;
  padding: 24px;
}

/* Footer fixo (cancelar / criar / salvar) */
.modal-footer {
  flex-shrink: 0;
  padding: 16px 24px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  border-top: 1px solid var(--divider);
}

/* Wide modal */
.modal-lg {
  max-width: 760px;
}

.modal-xl {
  max-width: 1000px;
}

/* ---- Animações do modal ---- */
@keyframes modalOverlayIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalOverlayOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes modalIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}
@keyframes modalOut {
  from { opacity: 1; transform: none; }
  to   { opacity: 0; transform: translateY(8px) scale(0.98); }
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: var(--z-toast);
  pointer-events: none;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--glass-border-outer);
  border-radius: 8px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 280px;
  max-width: 400px;
  pointer-events: auto;
  font-size: 13px;
  font-weight: 500;
}

.toast-icon {
  flex-shrink: 0;
}

.toast-text {
  flex: 1;
  color: var(--text-primary);
}

.toast-close {
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
}

.toast-close:hover {
  color: var(--text-primary);
}

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

.toast.error .toast-icon {
  color: var(--color-red);
}

.toast.warning .toast-icon {
  color: var(--color-yellow);
}

.toast.info .toast-icon {
  color: var(--accent);
}

/* ============================================================
   DROPDOWN MENU
   ============================================================ */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 180px;
  background: var(--bg-elevated);
  border: 1px solid var(--glass-border-outer);
  border-radius: 6px;
  padding: 4px;
  z-index: var(--z-dropdown);
  opacity: 0;
  pointer-events: none;
}

.dropdown.open .dropdown-menu {
  opacity: 1;
  pointer-events: auto;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 400;
  color: var(--text-primary);
  cursor: pointer;
  transition: background-color 0.15s;
  white-space: nowrap;
}

.dropdown-item:hover {
  background: var(--row-hover);
}

.dropdown-item.danger {
  color: var(--color-red);
}

.dropdown-divider {
  height: 1px;
  background: var(--glass-border-inner);
  margin: 4px 0;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 24px;
  gap: 12px;
  color: var(--text-secondary);
}

.empty-state svg {
  opacity: 0.4;
}

.empty-state h3 {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
}

.empty-state p {
  font-size: 13px;
  max-width: 320px;
  line-height: 1.5;
}

/* ============================================================
   LOADING SPINNER
   ============================================================ */
.spinner {
  width: 24px;
  height: 24px;
  border: 2.5px solid var(--glass-border-inner);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner-sm {
  width: 16px;
  height: 16px;
  border-width: 1px;
}

.spinner-lg {
  width: 36px;
  height: 36px;
  border-width: 1px;
}

.loading-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  flex-direction: column;
  gap: 16px;
  background: inherit;
}

/* ============================================================
   SCROLLBAR (Mac native style)
   ============================================================ */
::-webkit-scrollbar {
  width: 14px;
  height: 14px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background-color: var(--scrollbar-thumb);
  border-radius: 10px;
  border: 1px solid transparent;
  background-clip: padding-box;
  transition: background-color 0.2s;
}

::-webkit-scrollbar-thumb:hover {
  background-color: var(--scrollbar-thumb-hover);
}

::-webkit-scrollbar-corner {
  background: transparent;
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */
.flex {
  display: flex;
}

.flex-col {
  display: flex;
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.items-start {
  align-items: flex-start;
}

.justify-between {
  justify-content: space-between;
}

.justify-center {
  justify-content: center;
}

.justify-end {
  justify-content: flex-end;
}

.gap-4 {
  gap: 4px;
}

.gap-6 {
  gap: 6px;
}

.gap-8 {
  gap: 8px;
}

.gap-10 {
  gap: 10px;
}

.gap-12 {
  gap: 12px;
}

.gap-16 {
  gap: 16px;
}

.gap-20 {
  gap: 20px;
}

.gap-24 {
  gap: 24px;
}

.flex-1 {
  flex: 1;
}

.shrink-0 {
  flex-shrink: 0;
}

.w-full {
  width: 100%;
}

.h-full {
  height: 100%;
}

.overflow-hidden {
  overflow: hidden;
}

.overflow-auto {
  overflow: auto;
}

.text-sm {
  font-size: 12px;
  color: var(--text-secondary);
}

.text-xs {
  font-size: 11px;
  color: var(--text-secondary);
}

.font-600 {
  font-weight: 500;
}

.font-700 {
  font-weight: 600;
}

.text-muted {
  color: var(--text-secondary);
}

.text-accent {
  color: var(--accent);
}

.text-green {
  color: var(--color-green);
}

.text-red {
  color: var(--color-red);
}

.mono {
  font-variant-numeric: tabular-nums;
  font-family: "SF Mono", Menlo, monospace;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.divider {
  height: 1px;
  background: var(--glass-border-inner);
}

.divider-v {
  width: 1px;
  background: var(--glass-border-inner);
  align-self: stretch;
}

.hidden {
  display: none !important;
}

.rounded-full {
  border-radius: 9999px;
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }

  100% {
    background-position: 200% 0;
  }
}

/* Skeleton loading */
.skeleton {
  background: linear-gradient(90deg,
      var(--glass-border-inner) 25%,
      var(--glass-bg-card) 50%,
      var(--glass-border-inner) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
}

/* Spinner */
.spinner {
  border: 2px solid var(--glass-border-outer);
  border-top-color: var(--accent);
  background: none;
  -webkit-mask: none;
  mask: none;
  animation: spin 0.7s linear infinite;
}
.spinner-sm { border-width: 1.5px; }
.spinner-lg { border-width: 2.5px; }

/* Table rows */
.table tbody tr {
  transition: background 0.1s ease;
}

/* Switch track */
.switch-track::before {
  transition: transform 0.15s ease;
}

/* Segmented */
.segmented button {
  transition: color 0.1s ease, background 0.1s ease;
}

/* Interactive items */
.module-list-item,
.access-user-card,
.snippet-item {
  transition: background 0.1s ease;
}
.module-list-item:hover,
.access-user-card:hover,
.snippet-item:hover {
  background: var(--control-bg-hover);
}

/* Modal close */
.modal-close {
  transition: background 0.1s ease, color 0.1s ease;
}