@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap');

:root {
  --ayf-pink: #E01E9A;
  --ayf-purple: #6A34C9;
  --ayf-blue: #2F6FED;
  --ayf-navy: #1F3864;
  --ayf-lavender: #F3F0FC;
  --ayf-border: #E4DCF6;
  --ayf-gradient: linear-gradient(120deg, var(--ayf-pink) 0%, var(--ayf-purple) 55%, var(--ayf-blue) 100%);

  --bg: #F7F7FB;
  --surface: #FFFFFF;
  --surface-2: #FBFAFE;
  --text: #1A1A2E;
  --text-muted: #6B6B80;
  --text-soft: #9494A8;
  --border: #E7E5F0;
  --danger: #D64545;
  --success: #1E9E6B;
  --warning: #C98A11;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(31, 22, 60, 0.06);
  --shadow-md: 0 8px 24px rgba(31, 22, 60, 0.08);
  --shadow-lg: 0 20px 48px rgba(31, 22, 60, 0.14);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }

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

/* ---------- App shell ---------- */
.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #150D2E;
  background-image: radial-gradient(circle at 0% 0%, rgba(224, 30, 154, 0.35), transparent 45%),
    radial-gradient(circle at 100% 100%, rgba(47, 111, 237, 0.35), transparent 50%);
  color: #EFEBFC;
  padding: 28px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 24px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar .brand img { width: 34px; height: 34px; object-fit: contain; }
.sidebar .brand .name { font-weight: 800; font-size: 15px; letter-spacing: 0.02em; color: #fff; }
.sidebar .brand .sub { font-size: 10.5px; color: #B7ACE0; letter-spacing: 0.04em; text-transform: uppercase; }

.sidebar .group-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #8E7FBE;
  margin: 18px 10px 8px;
  font-weight: 700;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: #D6CFEF;
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 2px;
  transition: background 0.15s, color 0.15s;
}

.sidebar nav a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar nav a.active { background: var(--ayf-gradient); color: #fff; box-shadow: var(--shadow-sm); }
.sidebar nav a .ic { display: flex; align-items: center; opacity: 0.95; flex-shrink: 0; }
.sidebar nav a .ic svg { width: 18px; height: 18px; }

.sidebar .spacer { flex: 1; }

.sidebar .user-box {
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 14px;
  margin-top: 8px;
  font-size: 12.5px;
  color: #B7ACE0;
}
.sidebar .user-box .u-name { color: #fff; font-weight: 700; font-size: 13.5px; margin-bottom: 2px; }
.sidebar .user-box button {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: rgba(255,255,255,0.08);
  border: none;
  color: #EFEBFC;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  width: 100%;
}
.sidebar .user-box button:hover { background: rgba(255,255,255,0.16); }
.sidebar .user-box button .ic svg { width: 14px; height: 14px; }

.main {
  padding: 32px 40px 60px;
  max-width: 1200px;
  min-width: 0;
}

/* ---------- Mobile topbar (hidden on desktop) ---------- */
.mobile-topbar {
  display: none;
  align-items: center;
  gap: 12px;
  background: #150D2E;
  color: #fff;
  padding: 14px 18px;
  position: sticky;
  top: 0;
  z-index: 60;
}
.mobile-topbar .menu-btn {
  background: rgba(255,255,255,0.08);
  border: none;
  color: #fff;
  width: 36px; height: 36px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.mobile-topbar .menu-btn svg { width: 18px; height: 18px; }
.mobile-topbar .menu-btn:hover { background: rgba(255,255,255,0.16); }
.mobile-topbar img { width: 26px; height: 26px; object-fit: contain; }
.mobile-topbar .name { font-weight: 800; font-size: 14.5px; }

.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(10, 6, 24, 0.55);
  z-index: 69;
}

/* Barra de navegação inferior: acesso rápido aos módulos principais em ecrãs estreitos,
   complementando o painel lateral (aberto pelo botão "Mais" ou pelo menu da barra do topo). */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #150D2E;
  border-top: 1px solid rgba(255,255,255,0.08);
  z-index: 65;
  padding: 6px 2px calc(6px + env(safe-area-inset-bottom, 0px));
}
.bottom-nav a, .bottom-nav button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex: 1;
  padding: 6px 2px;
  margin: 0 2px;
  border-radius: 10px;
  color: #9E92C4;
  font-size: 10px;
  font-weight: 700;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.15s, background 0.15s;
}
.bottom-nav svg { width: 20px; height: 20px; }
.bottom-nav a:hover, .bottom-nav button:hover { color: #fff; background: rgba(255,255,255,0.06); }
.bottom-nav a.active { color: #fff; }
.bottom-nav a.active .ic { background: var(--ayf-gradient); border-radius: 8px; }
.bottom-nav a.active .ic svg { padding: 3px; box-sizing: border-box; }
.bottom-nav .bn-label { white-space: nowrap; }

.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 12px;
}

.topbar h1 { font-size: 24px; }
.breadcrumb { font-size: 12.5px; color: var(--text-soft); margin-bottom: 6px; }
.breadcrumb a:hover { color: var(--ayf-purple); }

/* ---------- Cards & components ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.card-pad { padding: 22px 24px; }

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 18px;
}

.module-card {
  position: relative;
  border-radius: var(--radius-lg);
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  overflow: hidden;
}
.module-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--ayf-border); }
.module-card .ic-badge {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: var(--ayf-gradient);
  color: #fff;
  margin-bottom: 16px;
}
.module-card .ic-badge svg { width: 22px; height: 22px; }
.page-icon svg { width: 22px; height: 22px; vertical-align: -5px; margin-right: 2px; }
.page-icon { color: var(--ayf-purple); }
.module-card h3 { font-size: 16px; margin-bottom: 6px; }
.module-card p { font-size: 13px; color: var(--text-muted); margin: 0 0 14px; min-height: 34px; }
.module-card .count { font-size: 12px; color: var(--ayf-purple); font-weight: 700; }

.stat-row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.stat-box {
  flex: 1; min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
}
.stat-box .label { font-size: 12px; color: var(--text-soft); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-box .value { font-size: 26px; font-weight: 800; margin-top: 4px; color: var(--ayf-navy); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 700;
  border: 1px solid transparent;
  cursor: pointer;
  transition: filter 0.15s, background 0.15s, border-color 0.15s;
}
.btn-primary { background: var(--ayf-gradient); color: #fff; box-shadow: 0 6px 16px rgba(106, 52, 201, 0.28); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-secondary { background: var(--surface); color: var(--ayf-navy); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--ayf-purple); color: var(--ayf-purple); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--ayf-purple); }
.btn-danger { background: #FDEDED; color: var(--danger); }
.btn-danger:hover { background: #FADBDB; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 8px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Forms ---------- */
label { display: block; font-size: 12.5px; font-weight: 700; color: var(--ayf-navy); margin-bottom: 6px; }
.field { margin-bottom: 16px; }
.field .hint { font-size: 11.5px; color: var(--text-soft); margin-top: 4px; }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=date], input[type=tel],
textarea, select {
  width: 100%;
  padding: 10px 13px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { resize: vertical; min-height: 70px; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--ayf-purple);
  box-shadow: 0 0 0 3px rgba(106, 52, 201, 0.12);
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .field.full { grid-column: 1 / -1; }

/* ---------- Table ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 14px; font-size: 13px; border-bottom: 1px solid var(--border); }
th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-soft); font-weight: 700; }
tbody tr:hover { background: var(--ayf-lavender); }
tbody tr:last-child td { border-bottom: none; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700;
}
.badge-ok { background: #E6F7EF; color: var(--success); }
.badge-pending { background: #FCF3DE; color: var(--warning); }
.badge-off { background: #F1EFF6; color: var(--text-soft); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(20, 12, 40, 0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 24px;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 640px;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  padding: 28px 30px;
}
.modal-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; }
.modal-header h2 { font-size: 18px; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-soft); line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

.empty-state {
  text-align: center;
  padding: 44px 20px;
  color: var(--text-soft);
}
.empty-state .ic { font-size: 34px; margin-bottom: 10px; display: flex; justify-content: center; opacity: 0.55; }
.empty-state .ic svg { width: 34px; height: 34px; }

.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--ayf-navy); color: #fff;
  padding: 13px 20px; border-radius: 12px;
  font-size: 13.5px; font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  animation: toast-in 0.2s ease-out;
}
.toast.error { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.checklist-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border);
}
.checklist-item:last-child { border-bottom: none; }
.checklist-item input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--ayf-purple); }
.checklist-item.done .desc { text-decoration: line-through; color: var(--text-soft); }
.checklist-item .desc { flex: 1; font-size: 13.5px; }

.section-title { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ayf-purple); margin: 26px 0 12px; }
.section-title:first-child { margin-top: 0; }

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .mobile-topbar { display: flex; }
  .sidebar-backdrop.open { display: block; }

  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 260px;
    z-index: 70;
    transform: translateX(-100%);
    transition: transform 0.2s ease-out;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }

  .bottom-nav { display: flex; }

  .main { padding: 20px 20px calc(20px + 64px); }
  .form-grid { grid-template-columns: 1fr; }
}
