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

:root {
  --md-bg:      #ebe8f5;
  --md-surface: #ffffff;
  --md-text:    #1a1a2e;
  --md-accent:  #7c6ff7;
  --md-pink:    #e879a0;
  --md-teal:    #2bc4b4;
  --md-muted:   #888888;
  --md-subtle:  #aaaaaa;
  --md-border:  #f0f0f5;
  --md-hover:   #f4f2fc;
  --md-shadow:  0 1px 3px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.04);
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--md-bg);
  min-height: 100vh;
  color: var(--md-text);
}

/* ── NAVBAR ── */
.navbar {
  background: var(--md-surface);
  display: flex;
  align-items: center;
  padding: 0 28px;
  height: 64px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 0 rgba(0,0,0,0.06);
}

.navbar-logo {
  width: 38px;
  height: 38px;
  background: var(--md-accent);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.navbar-logo svg {
  width: 20px;
  height: 20px;
}

.navbar-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--md-text);
  letter-spacing: -0.3px;
  flex: 1;
}

.navbar-meta {
  font-size: 12px;
  color: var(--md-muted);
}

/* ── MAIN CONTENT ── */
.main {
  padding: 32px;
  max-width: 1400px;
  margin: 0 auto;
}

/* ── PAGE HEADER ── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  opacity: 0;
  animation: fadeIn 0.4s ease 0.05s forwards;
}

.page-title {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.page-subtitle {
  font-size: 13px;
  color: var(--md-muted);
  margin-top: 4px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-badge {
  background: var(--md-accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  padding: 3px 10px;
  align-self: center;
}

.btn-add {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  background: var(--md-text);
  color: #fff;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.2s ease;
  white-space: nowrap;
}

.btn-add svg {
  width: 14px;
  height: 14px;
}

.btn-add:hover {
  background: #2d2d4e;
}

/* ── SECTION ── */
.section {
  margin-bottom: 32px;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--md-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.section-count {
  background: var(--md-border);
  color: var(--md-subtle);
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  padding: 1px 8px;
}

/* ── GRID ── */
.systems-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

/* ── SYSTEM CARD ── */
.system-card {
  background: var(--md-surface);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--md-shadow);
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  opacity: 0;
  animation: fadeUp 0.5s cubic-bezier(0.22,1,0.36,1) forwards;
  position: relative;
  overflow: hidden;
}

.system-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--card-color, var(--md-accent));
  opacity: 0;
  transition: opacity 0.2s ease;
}

.system-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08), 0 12px 32px rgba(0,0,0,0.08);
}

.system-card:hover::before {
  opacity: 1;
}

.card-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--card-color, var(--md-accent)) 12%, transparent);
  flex-shrink: 0;
}

.card-icon svg {
  width: 20px;
  height: 20px;
  color: var(--card-color, var(--md-accent));
}

.card-body {
  flex: 1;
}

.card-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--md-text);
  margin-bottom: 4px;
}

.card-desc {
  font-size: 12px;
  color: var(--md-muted);
  line-height: 1.5;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-link-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--card-color, var(--md-accent));
}

.card-arrow {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--card-color, var(--md-accent)) 10%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.system-card:hover .card-arrow {
  background: var(--card-color, var(--md-accent));
}

.card-arrow svg {
  width: 14px;
  height: 14px;
  color: var(--card-color, var(--md-accent));
  transition: color 0.2s ease;
}

.system-card:hover .card-arrow svg {
  color: #fff;
}

/* ── COMING SOON CARD ── */
.system-card--soon {
  cursor: default;
  opacity: 0.6;
}

.system-card--soon:hover {
  transform: none;
  box-shadow: var(--md-shadow);
}

.system-card--soon::before {
  display: none;
}

.card-soon-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--md-subtle);
  background: var(--md-border);
  border-radius: 999px;
  padding: 2px 8px;
}

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center;
  padding: 64px 32px;
  color: var(--md-subtle);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state p {
  font-size: 14px;
}

.link-btn {
  background: none;
  border: none;
  color: var(--md-accent);
  font-size: 14px;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

/* ── CARD EDIT BUTTON ── */
.card-edit-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: none;
  background: var(--md-border);
  color: var(--md-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
  z-index: 2;
}

.card-edit-btn svg {
  width: 13px;
  height: 13px;
}

.system-card:hover .card-edit-btn {
  opacity: 1;
}

.card-edit-btn:hover {
  background: var(--md-accent);
  color: #fff;
}

/* ── DRAWER ── */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 26, 46, 0.4);
  backdrop-filter: blur(2px);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.drawer-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 420px;
  max-width: 100vw;
  background: var(--md-surface);
  z-index: 201;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: -8px 0 32px rgba(0,0,0,0.12);
}

.drawer.open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--md-border);
  flex-shrink: 0;
}

.drawer-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--md-text);
}

.drawer-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: var(--md-border);
  color: var(--md-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}

.drawer-close:hover { background: #e0ddf5; }
.drawer-close svg { width: 14px; height: 14px; }

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.drawer-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--md-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
}

/* ── FORM ELEMENTS ── */
.form-group {
  margin-bottom: 18px;
}

.form-row {
  display: flex;
  gap: 16px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--md-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.required { color: var(--md-pink); }

.form-input, .form-select {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--md-border);
  border-radius: 10px;
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  color: var(--md-text);
  background: #fff;
  outline: none;
  transition: border-color 0.15s ease;
}

.form-input:focus, .form-select:focus {
  border-color: var(--md-accent);
}

.form-input::placeholder { color: var(--md-subtle); }

/* Color swatches */
.color-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2.5px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
  outline: none;
}

.color-swatch:hover { transform: scale(1.15); }

.color-swatch.active {
  border-color: var(--md-text);
  transform: scale(1.15);
}

/* Icon grid */
.icon-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
}

.icon-option {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  border: 1.5px solid var(--md-border);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--md-muted);
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  padding: 6px;
}

.icon-option svg { width: 100%; height: 100%; }

.icon-option:hover {
  border-color: var(--md-accent);
  color: var(--md-accent);
  background: var(--md-hover);
}

.icon-option.active {
  border-color: var(--md-accent);
  background: var(--md-accent);
  color: #fff;
}

/* Toggle */
.toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  margin-top: 6px;
}

.toggle-label input { display: none; }

.toggle-track {
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: var(--md-border);
  position: relative;
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.toggle-label input:checked + .toggle-track { background: var(--md-accent); }

.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: left 0.2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-label input:checked + .toggle-track .toggle-thumb { left: 21px; }

.toggle-text { font-size: 13px; color: var(--md-text); }

/* Footer buttons */
.btn-save {
  flex: 1;
  padding: 10px 20px;
  background: var(--md-text);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  font-family: 'Inter', sans-serif;
}

.btn-save:hover { background: #2d2d4e; }

.btn-delete {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  background: #fff2f2;
  color: #e53e3e;
  border: 1.5px solid #fecaca;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  font-family: 'Inter', sans-serif;
  white-space: nowrap;
}

.btn-delete svg { width: 14px; height: 14px; }
.btn-delete:hover { background: #fee2e2; }

/* ── ANIMATIONS ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* stagger via nth-child para hasta 20 cards */
.systems-grid .system-card:nth-child(1)  { animation-delay: 0.06s; }
.systems-grid .system-card:nth-child(2)  { animation-delay: 0.12s; }
.systems-grid .system-card:nth-child(3)  { animation-delay: 0.18s; }
.systems-grid .system-card:nth-child(4)  { animation-delay: 0.24s; }
.systems-grid .system-card:nth-child(5)  { animation-delay: 0.30s; }
.systems-grid .system-card:nth-child(6)  { animation-delay: 0.36s; }
.systems-grid .system-card:nth-child(7)  { animation-delay: 0.42s; }
.systems-grid .system-card:nth-child(8)  { animation-delay: 0.48s; }
.systems-grid .system-card:nth-child(9)  { animation-delay: 0.54s; }
.systems-grid .system-card:nth-child(10) { animation-delay: 0.60s; }
.systems-grid .system-card:nth-child(11) { animation-delay: 0.66s; }
.systems-grid .system-card:nth-child(12) { animation-delay: 0.72s; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .main { padding: 20px 16px; }
  .navbar { padding: 0 16px; }
  .page-title { font-size: 24px; }
  .systems-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .systems-grid { grid-template-columns: 1fr; }
}
