:root {
  color-scheme: dark;
  --bg: #0b0f1a;
  --panel: #111827;
  --panel-strong: #0f172a;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.16);
  --success: #22c55e;
  --danger: #f87171;
  --border: rgba(148, 163, 184, 0.2);
  --shadow: 0 18px 40px rgba(2, 6, 23, 0.5);
  font-family: "Space Grotesk", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at top, rgba(56, 189, 248, 0.08), transparent 40%),
    radial-gradient(circle at 20% 20%, rgba(34, 197, 94, 0.12), transparent 35%),
    var(--bg);
  color: var(--text);
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.app-title {
  margin: 0;
  font-size: 28px;
}

.app-subtitle {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 14px;
}

.app-badge {
  background: var(--panel-strong);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 0.6px;
  border: 1px solid var(--border);
}

.tabs {
  margin-top: 24px;
  display: flex;
  gap: 12px;
}

.sync-bar {
  margin-top: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  display: grid;
  gap: 12px;
  box-shadow: var(--shadow);
}

.sync-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.sync-fields label {
  min-width: 220px;
}

.sync-note {
  color: var(--muted);
  font-size: 12px;
}

.sync-status {
  font-size: 12px;
  color: var(--muted);
}

.sync-status.is-error {
  color: #fca5a5;
}

.tab {
  border: 1px solid var(--border);
  background: var(--panel-strong);
  padding: 10px 18px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
  transition: all 0.2s ease;
}

.tab.is-active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.25);
}

.panel {
  display: none;
  margin-top: 24px;
}

.panel.is-active {
  display: block;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.card {
  padding: 18px;
  background: var(--panel);
  border-radius: 18px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(148, 163, 184, 0.35);
  animation: fadeUp 0.6s ease both;
}

.card p {
  margin: 0 0 8px;
  color: var(--muted);
}

.card h2 {
  margin: 0;
}

.card.is-highlight {
  border-color: rgba(56, 189, 248, 0.4);
  background: linear-gradient(140deg, rgba(56, 189, 248, 0.18), rgba(15, 23, 42, 0.7));
}

.form-section,
.list-section {
  margin-top: 24px;
  padding: 20px;
  background: var(--panel);
  border-radius: 18px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  animation: fadeUp 0.6s ease both;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

label {
  display: flex;
  flex-direction: column;
  font-size: 13px;
  color: var(--muted);
  gap: 8px;
}

input,
select {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  font-size: 14px;
  background: var(--panel-strong);
  color: var(--text);
}

.full {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
}

#promemoria-cancel {
  display: none;
}

button {
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  max-width: 100%;
}

button.primary,
button.ghost {
  white-space: normal;
}

button.primary {
  margin-top: 16px;
  background: var(--accent);
  color: #04121e;
  box-shadow: 0 10px 24px rgba(56, 189, 248, 0.3);
}

button.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

button:hover {
  transform: translateY(-1px);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.section-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.list {
  display: grid;
  gap: 12px;
}

.item {
  padding: 14px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  display: grid;
  gap: 8px;
  background: rgba(15, 23, 42, 0.85);
}

.item.is-open {
  border-color: #ef4444;
  background: rgba(127, 29, 29, 0.35);
}

.item.is-good {
  border-color: #22c55e;
  background: rgba(20, 83, 45, 0.35);
}

.item.is-warning {
  border-color: #f59e0b;
  background: rgba(120, 53, 15, 0.35);
}

.item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.item-title {
  font-weight: 600;
  word-break: break-word;
}

.item-meta {
  color: var(--muted);
  font-size: 13px;
}

.badge {
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(148, 163, 184, 0.35);
  color: #e2e8f0;
}

.badge.success {
  background: #22c55e;
  color: #052e16;
}

.badge.danger {
  background: #ef4444;
  color: #2a0a0a;
}

.badge.warning {
  background: #f59e0b;
  color: #2a1a05;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 600px) {
  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .tabs {
    flex-direction: column;
  }

  .cards {
    grid-template-columns: 1fr;
  }

  .grid {
    grid-template-columns: 1fr;
  }
}
