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

:root {
  --bg: #eef1f6;
  --surface: #fff;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --today-ring: #1d4ed8;
  --today-bg: #dbeafe;
  --conflict: #fecaca;
  --conflict-border: #ef4444;
  --drop-highlight: #bfdbfe;
  --shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.app-layout {
  display: flex;
  gap: 0;
  min-height: 100vh;
  max-width: 1320px;
  margin: 0 auto;
}

.calendars-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1rem 0.75rem;
  box-shadow: var(--shadow);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  padding: 0 0.25rem;
}

.sidebar-header h2 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.btn-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--primary);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.btn-icon:hover { background: var(--today-bg); }

.calendar-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.calendar-list-item { margin: 0; }

.calendar-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  padding: 0.35rem 0.4rem;
  border-radius: 8px;
  font-size: 0.875rem;
}

.calendar-toggle:hover { background: var(--bg); }

.calendar-color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.calendar-row {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.calendar-row .calendar-toggle { flex: 1; min-width: 0; }

.btn-share-calendar {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
  font-size: 0.9rem;
}

.btn-share-calendar:hover {
  background: var(--bg);
  color: var(--primary);
}

.calendar-list-item.shared .calendar-name {
  font-style: italic;
}

.calendar-badge {
  font-size: 0.65rem;
  margin-left: 0.35rem;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  background: var(--bg);
  color: var(--text-muted);
  font-style: normal;
}

.event-card.readonly {
  cursor: default;
  opacity: 0.92;
}

.share-modal {
  border: none;
  border-radius: 12px;
  padding: 0;
  max-width: 420px;
  width: calc(100% - 2rem);
  box-shadow: 0 8px 32px rgba(15, 23, 42, 0.2);
}

.share-modal::backdrop { background: rgba(15, 23, 42, 0.4); }

.share-modal-inner { padding: 1.25rem; }

.share-invite-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.share-members-heading {
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0.5rem 0;
}

.share-members-list {
  list-style: none;
  max-height: 200px;
  overflow-y: auto;
}

.share-member-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

.share-member-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.share-member-info span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.share-member-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.share-role-select {
  font-size: 0.75rem;
  padding: 0.2rem 0.35rem;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.role-tag {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
}

.btn-remove-member {
  border: none;
  background: var(--danger-bg);
  color: var(--danger);
  width: 24px;
  height: 24px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

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

.app {
  flex: 1;
  min-width: 0;
  padding: 1.25rem 1rem 2rem;
}

@media (max-width: 768px) {
  .app-layout { flex-direction: column; }
  .calendars-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .calendar-list {
    flex-direction: row;
    flex-wrap: wrap;
  }
}
.app-header { text-align: center; margin-bottom: 1.25rem; }
.app-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  gap: 1rem;
}
.app-header h1 { font-size: 1.5rem; font-weight: 700; }
.user-greeting { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.15rem; }
.btn-logout { flex-shrink: 0; }

.calendar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.calendar-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap;
}
.month-title { font-size: 1.3rem; font-weight: 700; flex: 1; text-align: center; min-width: 160px; }

.btn-nav, .btn-primary, .btn-secondary, .btn-danger {
  border-radius: 8px; font-size: 0.875rem; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; padding: 0.5rem 1rem; transition: 0.15s;
}
.btn-nav { color: var(--primary); background: transparent; border-color: var(--border); }
.btn-nav:hover:not(:disabled) { background: var(--today-bg); }
.btn-nav:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: transparent; border-color: var(--border); color: var(--text); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border-color: #fecaca; }

.weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px;
  margin-bottom: 4px; text-align: center; font-size: 0.72rem;
  font-weight: 700; color: var(--text-muted); text-transform: uppercase;
}

.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }

.day-cell {
  min-height: 108px; border: 1px solid var(--border); border-radius: 10px;
  padding: 0.3rem; display: flex; flex-direction: column;
  background: var(--surface); transition: background 0.15s, box-shadow 0.15s;
  overflow: hidden;
}
.day-cell:hover { background: #f8fafc; }
.day-cell.other-month { background: #f1f5f9; }
.day-cell.other-month .day-number { color: #94a3b8; }
.day-cell.today {
  background: var(--today-bg);
  box-shadow: inset 0 0 0 3px var(--today-ring);
}
.day-cell.today .day-number { color: var(--today-ring); font-weight: 800; }
.day-cell.drop-target { background: var(--drop-highlight); box-shadow: inset 0 0 0 2px var(--primary); }

.day-number { font-size: 0.82rem; font-weight: 700; margin-bottom: 0.2rem; flex-shrink: 0; }
.day-events { flex: 1; display: flex; flex-direction: column; gap: 2px; min-height: 0; overflow: hidden; }

.event-card {
  font-size: 0.64rem; line-height: 1.2; padding: 3px 5px; border-radius: 5px;
  border-left: 3px solid rgba(0,0,0,0.15); cursor: grab;
  transition: transform 0.12s, box-shadow 0.12s;
  position: relative;
}
.event-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.15);
  z-index: 2;
}
.event-card:active { cursor: grabbing; }
.event-card.conflict {
  background: var(--conflict) !important;
  border-left-color: var(--conflict-border);
  box-shadow: inset 0 0 0 1px var(--conflict-border);
}
.event-card.dragging { opacity: 0.45; }

.event-card-title { font-weight: 700; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-card-time { color: var(--text-muted); font-size: 0.58rem; }

.event-card[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute; left: 0; bottom: calc(100% + 4px);
  min-width: 140px; max-width: 220px;
  padding: 6px 8px; background: #1e293b; color: #f8fafc;
  font-size: 0.68rem; font-weight: 400; line-height: 1.35;
  border-radius: 6px; white-space: normal; z-index: 20;
  pointer-events: none; box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.more-events {
  font-size: 0.64rem; font-weight: 700; color: var(--primary);
  padding: 2px 4px; cursor: pointer;
}
.more-events:hover { text-decoration: underline; }

.calendar-status { margin-top: 0.85rem; font-size: 0.85rem; color: var(--text-muted); text-align: center; min-height: 1.2rem; }
.calendar-status.error { color: var(--danger); }
.calendar-status.loading { color: var(--primary); }

/* Painéis laterais */
.side-panel { position: fixed; inset: 0; z-index: 90; pointer-events: none; }
.side-panel.open { pointer-events: auto; }
.side-panel-backdrop {
  position: absolute; inset: 0; background: rgba(15,23,42,0.45);
  opacity: 0; transition: opacity 0.2s;
}
.side-panel.open .side-panel-backdrop { opacity: 1; }
.side-panel-content {
  position: absolute; top: 0; right: 0; width: min(380px, 100%); height: 100%;
  background: var(--surface); box-shadow: -6px 0 24px rgba(15,23,42,0.12);
  transform: translateX(100%); transition: transform 0.25s;
  padding: 1.25rem; display: flex; flex-direction: column;
}
.side-panel.open .side-panel-content { transform: translateX(0); }
.side-panel-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1rem; padding-bottom: 0.75rem; border-bottom: 1px solid var(--border); }
.side-panel-header h3 { font-size: 1.1rem; }
.btn-close { width: 2rem; height: 2rem; border: none; background: transparent; font-size: 1.4rem; color: var(--text-muted); cursor: pointer; border-radius: 6px; }
.btn-close:hover { background: var(--bg); color: var(--text); }

.day-panel-list { list-style: none; overflow-y: auto; flex: 1; }
.day-panel-list li {
  padding: 0.75rem; border: 1px solid var(--border); border-radius: 8px;
  margin-bottom: 0.5rem; cursor: pointer; border-left-width: 4px;
}
.day-panel-list li:hover { background: #f8fafc; }
.day-panel-empty { color: var(--text-muted); font-size: 0.9rem; }

/* Modal */
.event-modal {
  border: none; border-radius: 14px; padding: 0;
  max-width: 480px; width: calc(100% - 2rem);
  box-shadow: 0 20px 50px rgba(15,23,42,0.2);
}
.event-modal::backdrop { background: rgba(15,23,42,0.5); }
.event-form { padding: 1.25rem; }
.event-form-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.field { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.85rem; }
.field span { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); }
.field input, .field textarea {
  border: 1px solid var(--border); border-radius: 8px; padding: 0.5rem 0.65rem;
  font: inherit;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.edit-scope { border: 1px solid var(--border); border-radius: 8px; padding: 0.75rem; margin-bottom: 0.85rem; }
.edit-scope legend { font-size: 0.8rem; font-weight: 600; padding: 0 0.25rem; }
.radio-label { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; margin-top: 0.35rem; }
.hidden { display: none !important; }
.modal-error { color: var(--danger); font-size: 0.85rem; min-height: 1.2rem; margin-bottom: 0.5rem; }
.event-form-footer { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.footer-right { display: flex; gap: 0.5rem; }

/* Header: busca e notificações */
.header-left { min-width: 0; }
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.search-wrap { position: relative; flex: 1; min-width: 160px; max-width: 280px; }
.global-search {
  width: 100%;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.global-search:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.search-results {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  max-height: 280px;
  overflow-y: auto;
  z-index: 50;
  padding: 0.5rem;
}
.search-results.open { display: block; }
.search-section-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0.5rem 0 0.25rem;
}
.search-result-item {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 0.4rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
}
.search-result-item:hover { background: var(--bg); }
.search-loading, .search-empty, .search-error { font-size: 0.85rem; padding: 0.5rem; }
.search-user { font-size: 0.8rem; color: var(--text-muted); padding: 0.25rem 0.5rem; }

.btn-notifications {
  position: relative;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 0.4rem 0.55rem;
  cursor: pointer;
  font-size: 1.1rem;
  transition: transform 0.15s;
}
.btn-notifications:hover { transform: scale(1.05); }
.notifications-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--danger);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}
.notifications-badge.hidden { display: none; }

/* Painel notificações */
.notifications-panel {
  position: fixed;
  inset: 0;
  z-index: 200;
  pointer-events: none;
}
.notifications-panel.open { pointer-events: auto; }
.notifications-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  opacity: 0;
  transition: opacity 0.2s;
}
.notifications-panel.open .notifications-backdrop { opacity: 1; }
.notifications-content {
  position: absolute;
  top: 0;
  right: 0;
  width: min(360px, 100%);
  height: 100%;
  background: var(--surface);
  box-shadow: -4px 0 24px rgba(15, 23, 42, 0.12);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
}
.notifications-panel.open .notifications-content { transform: translateX(0); }
.notifications-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}
.notifications-header h3 { flex: 1; font-size: 1rem; }
.btn-text {
  border: none;
  background: none;
  color: var(--primary);
  font-size: 0.75rem;
  cursor: pointer;
  font-weight: 600;
}
.notifications-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding: 0.5rem;
}
.notification-item {
  padding: 0.75rem;
  border-radius: 8px;
  margin-bottom: 0.35rem;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}
.notification-item.unread {
  background: var(--today-bg);
  border-color: #93c5fd;
}
.notification-item:hover { background: var(--bg); }
.notification-type {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--primary);
}
.notification-item p { font-size: 0.875rem; margin: 0.25rem 0; }
.notification-item time { font-size: 0.7rem; color: var(--text-muted); }

/* Skeleton loading */
.calendar-grid.is-loading .day-cell:not(.skeleton-cell) {
  opacity: 0.55;
  pointer-events: none;
}
.calendar-grid.is-loading .skeleton-cell {
  min-height: 108px;
  background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.2s ease-in-out infinite;
  border-radius: 10px;
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Sidebar footer + developer */
.sidebar-footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.btn-sidebar-link {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.5rem;
  text-align: left;
  border-radius: 8px;
}
.btn-sidebar-link:hover { background: var(--bg); }
.calendars-sidebar { display: flex; flex-direction: column; }

.developer-modal, .share-modal { max-width: 480px; }
.developer-inner, .share-modal-inner { padding: 1.25rem; }
.developer-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  line-height: 1.5;
}
.developer-hint code {
  background: var(--bg);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.75rem;
}
.api-key-new {
  font-size: 0.8rem;
  margin: 0.5rem 0;
  word-break: break-all;
}
.api-key-new code {
  display: block;
  margin-top: 0.35rem;
  padding: 0.5rem;
  background: var(--bg);
  border-radius: 6px;
  font-size: 0.75rem;
}
.api-keys-list { list-style: none; }
.api-key-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}
.checkbox-public {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  margin-bottom: 1rem;
  cursor: pointer;
}

/* Animações leves */
.side-panel.open .side-panel-content,
.event-card {
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.event-card:hover:not(.readonly) { transform: translateY(-1px); }
.day-cell { transition: background-color 0.15s, border-color 0.15s; }

/* Billing & planos */
.plan-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: var(--accent-soft, #e0e7ff);
  color: var(--accent, #3730a3);
}
.btn-upgrade { font-size: 0.85rem; padding: 0.35rem 0.75rem; }
.upgrade-modal { max-width: 520px; border: none; border-radius: 12px; padding: 0; }
.upgrade-plan-list { list-style: none; display: flex; flex-direction: column; gap: 1rem; padding: 0 1rem 1rem; }
.upgrade-plan-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
}
.upgrade-plan-card h4 { margin: 0 0 0.5rem; }
.upgrade-plan-card .badge { font-size: 0.7rem; color: var(--accent); }
.hidden { display: none !important; }

/* Admin */
.admin-app { max-width: 1100px; margin: 0 auto; padding: 1rem; }
.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}
.stat-card {
  background: var(--surface, #fff);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  text-align: center;
}
.stat-value { display: block; font-size: 1.5rem; font-weight: 700; }
.stat-label { font-size: 0.75rem; color: var(--muted); }
.admin-section { margin-bottom: 2rem; }
.admin-table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.admin-table th, .admin-table td { padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border); text-align: left; }
.admin-table th { font-weight: 600; background: var(--bg); }
.btn-sm { font-size: 0.8rem; padding: 0.25rem 0.5rem; }

/* Smart suggestions & productivity */
.smart-panel {
  margin-top: 1.5rem;
  padding: 1rem;
  background: var(--surface, #fff);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.smart-panel h3 { margin: 0 0 0.75rem; font-size: 1rem; }
.smart-suggestions-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.assistant-quick-form { display: flex; gap: 0.35rem; margin-bottom: 0.5rem; }
.assistant-quick-form input { flex: 1; font-size: 0.8rem; padding: 0.4rem 0.5rem; border: 1px solid var(--border); border-radius: 6px; }
.assistant-hint { font-size: 0.75rem; color: var(--text-muted); margin: 0.25rem 0 0.5rem; min-height: 1em; }
.assistant-link { font-size: 0.8rem; color: var(--primary); text-decoration: none; display: inline-block; margin-top: 0.5rem; }
.ai-prefs-panel { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); background: var(--surface); font-size: 0.875rem; }
.ai-summary-actions { display: flex; gap: 0.5rem; padding: 0.5rem 1rem; flex-wrap: wrap; }
.smart-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  background: var(--bg);
  font-size: 0.875rem;
}
.smart-overload, .smart-conflict, .smart-reschedule { border-left: 3px solid var(--accent); }
.presence-indicator { font-size: 0.75rem; color: var(--accent); }
.productivity-page { max-width: 900px; margin: 0 auto; padding: 1rem; }
.productivity-grid { margin-top: 1rem; }
.prod-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.prod-card { border: 1px solid var(--border); border-radius: 10px; padding: 1rem; text-align: center; }
.prod-value { font-size: 1.75rem; font-weight: 700; margin: 0; }
.prod-week { display: flex; gap: 0.5rem; align-items: flex-end; height: 120px; margin-bottom: 1rem; }
.prod-bar { flex: 1; text-align: center; font-size: 0.7rem; }
.prod-bar-fill { background: var(--accent); border-radius: 4px 4px 0 0; min-height: 4px; }
.prod-insights { padding-left: 1.25rem; color: var(--muted); }

/* AI assistant */
.ai-page { max-width: 720px; margin: 0 auto; padding: 1rem; }
.ai-chat-log {
  min-height: 240px;
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  margin: 1rem 0;
  background: var(--bg);
}
.ai-msg { margin: 0.5rem 0; font-size: 0.9rem; }
.ai-msg.user { color: var(--accent); }
.ai-form { display: flex; gap: 0.5rem; }
.ai-form input { flex: 1; }
.ai-agents, .ai-integrations { margin-top: 2rem; }

.planet-panel, .autonomous-grid article {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 1rem;
  background: var(--bg);
}
.autonomous-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  padding: 1rem;
}
.autonomous-actions { padding: 0 1rem 1rem; display: flex; flex-wrap: wrap; gap: 0.5rem; }

.cognitive-layout,
.cognitive-page {
  min-height: 100vh;
  overflow-y: auto;
}

.cognitive-priority-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}
.priority-card {
  flex: 1 1 140px;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 0.8rem;
}
.priority-card strong { display: block; }
.cognitive-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; padding: 1rem; }
.planet-panel.ux-hidden { display: none; }
.planet-panel.ux-highlight { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
body[data-ux-mode="focus-first"] .cognitive-grid { grid-template-columns: 1fr; }

.eco-health-bar { padding: 0.5rem 1rem; background: linear-gradient(90deg, var(--accent), transparent); color: #fff; font-size: 0.9rem; }
body[data-eco-mode="adapting"] .eco-health-bar { background: linear-gradient(90deg, #c90, transparent); }

.mesh-civ-bar {
  padding: 0.6rem 1rem;
  background: linear-gradient(135deg, #1a3a5c, var(--accent));
  color: #fff;
  font-size: 0.9rem;
}
body[data-mesh-state="alive"] .mesh-civ-bar { box-shadow: 0 0 12px rgba(100, 180, 255, 0.4); }

.planetary-bar {
  padding: 0.6rem 1rem;
  background: linear-gradient(90deg, #1e3a5f, #4a148c, var(--accent));
  color: #fff;
  font-size: 0.9rem;
}

/* Onboarding e feedback (launch) */
.onboarding-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.onboarding-card {
  background: var(--surface);
  border-radius: 14px;
  max-width: 420px;
  width: 100%;
  padding: 1.5rem;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.2);
}
.onboarding-card h2 { font-size: 1.2rem; margin-bottom: 0.5rem; }
.onboarding-progress { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 1rem; }
.onboarding-steps { margin: 0 0 1.25rem 1.25rem; font-size: 0.9rem; }
.onboarding-steps li.done { color: var(--primary); text-decoration: line-through; }
.onboarding-actions { display: flex; flex-direction: column; gap: 0.5rem; }
.btn-text { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 0.875rem; padding: 0.35rem; }
.btn-text:hover { color: var(--primary); }
.feedback-dialog { border: none; border-radius: 14px; padding: 0; max-width: 440px; width: calc(100% - 2rem); }
.feedback-dialog::backdrop { background: rgba(15, 23, 42, 0.45); }
.feedback-form { padding: 1.25rem; }
.feedback-form header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.nps-field.hidden { display: none; }
.calendar-empty-hint {
  grid-column: 1 / -1;
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

@media (max-width: 768px) {
  .day-cell { min-height: 76px; }
  .field-row { grid-template-columns: 1fr; }
  .prod-cards { grid-template-columns: 1fr; }
}
