:root {
  /* Identidade Masotti Investimentos */
  --primary: #1B66A4;          /* azul — cor primária da marca */
  --primary-dark: #155082;     /* azul escuro p/ hover */
  --primary-light: #E8F1F8;    /* azul bem claro p/ fundos de ícones e avisos */
  --secondary: #F4F4F4;        /* cinza claro — cor secundária da marca */
  --accent: #155082;           /* azul escuro de apoio (camada de aplicativos) */
  --accent-light: #E8F1F8;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e2e6ea;
  --bg: #F4F4F4;               /* fundo da página = cinza secundário da marca */
  --card: #ffffff;
  --ok: #1B66A4;
  --warn: #B45309;
  --danger: #C0392B;           /* vermelho funcional p/ erros e ações destrutivas */
  --danger-light: #FBEAEA;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(27, 102, 164, .10), 0 8px 24px rgba(27, 102, 164, .07);
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Aptos", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: 60px;
  background: var(--primary); color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand-logo { height: 34px; width: auto; display: block; }
.brand-text { font-weight: 700; letter-spacing: .2px; padding-left: 12px; border-left: 1px solid rgba(255,255,255,.35); }
.topnav { display: flex; align-items: center; gap: 18px; }
.topnav a { color: rgba(255,255,255,.92); font-weight: 500; }
.topnav a:hover { color: #fff; }
.user-chip {
  background: rgba(255,255,255,.16); padding: 5px 12px; border-radius: 999px;
  font-size: 14px;
}
.logout { font-weight: 600; }

/* ---------- Layout ---------- */
.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 24px 64px;
  flex: 1 0 auto;
  width: 100%;
}
.page-head { margin-bottom: 24px; }
.page-head h1 { margin: 0 0 4px; font-size: 26px; }
.muted { color: var(--muted); }
.back-link { display: inline-block; margin-bottom: 8px; font-size: 14px; }
.footer {
  text-align: center;
  color: var(--muted);
  padding: 24px;
  font-size: 13px;
  flex-shrink: 0;
}

/* ---------- Department grid ---------- */
.dept-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.dept-tile {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 16px; text-align: center; color: var(--ink);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.dept-tile:hover {
  text-decoration: none; transform: translateY(-3px);
  box-shadow: var(--shadow); border-color: var(--primary);
}
.dept-icon {
  font-size: 34px; line-height: 1;
  width: 64px; height: 64px; display: grid; place-items: center;
  background: var(--primary-light); border-radius: 16px;
}
.dept-icon.inline { width: 40px; height: 40px; font-size: 22px; display: inline-grid; vertical-align: middle; }
.dept-name { font-weight: 600; }
.dept-count { font-size: 12px; color: var(--muted); }

/* ---------- App list ---------- */
.app-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.app-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--card);
  border: 1px solid rgba(27, 102, 164, 0.08);
  border-radius: var(--radius);
  padding: 18px 20px;
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(27, 102, 164, 0.02);
  transition: border-color 0.2s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.2s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.app-card:hover {
  text-decoration: none;
  border-color: var(--primary);
  box-shadow: 0 12px 24px -4px rgba(27, 102, 164, 0.12),
              0 4px 12px -2px rgba(27, 102, 164, 0.06);
  transform: translateY(-2px);
}
.app-icon {
  font-size: 24px;
  width: 48px;
  height: 48px;
  flex: none;
  display: grid;
  place-items: center;
  background: var(--primary-light);
  border-radius: 12px;
  transition: transform 0.2s ease;
}
.app-card:hover .app-icon {
  transform: scale(1.05);
}
.app-body { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.app-name { font-weight: 600; font-size: 15.5px; color: var(--ink); }
.app-desc { font-size: 13px; color: var(--muted); margin-top: 2px; }
.app-arrow {
  color: var(--primary);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary-light);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1),
              background 0.2s ease,
              color 0.2s ease;
}
.app-card:hover .app-arrow {
  transform: translateX(4px);
  background: var(--primary);
  color: #ffffff;
}

/* ---------- Auth ---------- */
.auth-wrap { min-height: 80vh; display: grid; place-items: center; }
.auth-card {
  width: 100%; max-width: 380px; background: var(--card);
  border: 1px solid var(--line); border-radius: 20px; padding: 36px 32px;
  box-shadow: var(--shadow); text-align: center;
}
.auth-logo { margin-bottom: 18px; display: flex; justify-content: center; }
.auth-logo-img { height: 46px; width: auto; }
.auth-card h1 { margin: 0 0 4px; font-size: 22px; }
.auth-sub { color: var(--muted); margin: 0 0 24px; font-size: 14px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.auth-form label { font-size: 13px; font-weight: 600; color: var(--ink); display: flex; flex-direction: column; gap: 6px; }
.auth-foot { margin-top: 20px; font-size: 14px; color: var(--muted); }

input[type=text], input[type=email], input[type=password], select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; font-size: 15px; background: #fff; color: var(--ink);
}
input:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block; border: 1px solid transparent; border-radius: 10px;
  padding: 10px 16px; font-size: 14px; font-weight: 600; cursor: pointer;
  background: #fff; color: var(--ink); transition: background .12s ease, opacity .12s ease;
}
.btn:hover { text-decoration: none; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--primary); }
.btn-ghost:hover { background: var(--primary-light); }
.btn-danger { background: #fff; border-color: #f0cfca; color: var(--danger); }
.btn-danger:hover { background: var(--danger-light); }

/* ---------- Flash ---------- */
.flash-area { margin-bottom: 20px; display: flex; flex-direction: column; gap: 10px; }
.flash { padding: 12px 16px; border-radius: 10px; font-size: 14px; border: 1px solid; }
.flash-success { background: var(--primary-light); border-color: #bfe0d6; color: var(--primary-dark); }
.flash-error { background: var(--danger-light); border-color: #f0c4bf; color: var(--danger); }
.flash-warning { background: #fff7e6; border-color: #f3e1b3; color: #8a6300; }

/* ---------- Admin ---------- */
.admin-tabs { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.tab {
  padding: 8px 14px; border-radius: 999px; font-size: 14px; font-weight: 600;
  color: var(--muted); background: #fff; border: 1px solid var(--line);
}
.tab:hover { text-decoration: none; color: var(--primary); }
.tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.stat-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); margin-bottom: 28px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; text-align: center; }
.stat-num { display: block; font-size: 30px; font-weight: 800; color: var(--primary); }
.stat-num.accent { color: var(--accent); }
.stat-label { font-size: 13px; color: var(--muted); }

.section-title { font-size: 17px; margin: 26px 0 12px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; }
.panel .section-title { margin-top: 0; }

.inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.inline-form input, .inline-form select { width: auto; flex: 1; min-width: 140px; }
.inline-form .icon-input { flex: none; width: 64px; text-align: center; }

.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table th { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.data-table input, .data-table select { padding: 6px 8px; font-size: 14px; }
.data-table .icon-input { width: 56px; text-align: center; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.row-actions form { margin: 0; display: inline; }

.app-card-list { display: flex; flex-direction: column; gap: 14px; }
/* No admin o card empilha verticalmente (cabeçalho, Editar, log) — sobrescreve
   o display:flex herdado do .app-card dos cards da área pública. */
.app-card-list .app-card { display: block; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; background: #fff; }
.app-card-form { display: flex; flex-direction: column; gap: 12px; }
.app-card-fields { display: grid; gap: 12px; grid-template-columns: 64px 1.4fr 1fr; }
.app-card-fields .field-wide { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.field input, .field select { width: 100%; box-sizing: border-box; }
.field-icon .icon-input { text-align: center; }
.app-card-footer { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-top: 10px; border-top: 1px solid var(--line); }
.app-card-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.app-card-log { margin-top: 8px; }
.app-card-log .deploy-log { max-width: none; }

/* Cabeçalho compacto do card: ícone + nome/URL + status + ações numa linha */
.app-card-head { display: flex; align-items: center; gap: 12px; }
.app-card-emoji { font-size: 22px; line-height: 1; flex: none; }
.app-card-title { display: flex; flex-direction: column; min-width: 0; margin-right: auto; }
.app-card-title a { font-weight: 600; }
.app-card-url { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-card .deploy-badge { margin-bottom: 0; flex: none; }
.app-card-edit { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 10px; }
.app-card-edit-footer { margin-top: 10px; }
/* "Editar" e "log" com a mesma fonte e altura */
.app-card-edit > summary,
.app-card-log > summary { cursor: pointer; font-size: 12px; line-height: 1.5; width: fit-content; }

@media (max-width: 700px) {
  .app-card-fields { grid-template-columns: 64px 1fr; }
  .app-card-actions { margin-left: 0; }
}

.tag { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #eef1ef; color: var(--muted); }
.tag-admin { background: var(--accent-light); color: var(--accent); }
.tag-ok { background: var(--primary-light); color: var(--primary-dark); }
.tag-pending { background: #fff3d6; color: #8a6300; }
.tag-off { background: #f0eeee; color: #8a8a8a; }
.tag-you { background: var(--primary); color: #fff; }

.deploy-badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; margin-bottom: 4px; }
.deploy-success { background: var(--primary-light); color: var(--primary-dark); }
.deploy-error { background: var(--danger-light); color: var(--danger); }
.deploy-queued, .deploy-building { background: #fff3d6; color: #8a6300; }
.deploy-log { max-width: 360px; max-height: 160px; overflow: auto; font-size: 11px; background: #1d1d1d; color: #d8d8d8; padding: 8px; border-radius: 6px; white-space: pre-wrap; }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty h1 { font-size: 48px; margin: 0 0 8px; color: var(--primary); }

/* ---------- Access management ---------- */
.access-dep-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.access-dep-head .section-title { margin: 0; }
.check-all { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; cursor: pointer; }
.access-apps { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); margin-top: 12px; }
.access-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  cursor: pointer; background: #fff;
}
.access-item:hover { border-color: var(--primary); background: var(--primary-light); }
.access-item input { width: 16px; height: 16px; flex: none; accent-color: var(--primary); }
.access-icon { font-size: 18px; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }

@media (max-width: 600px) {
  .topbar { padding: 0 14px; }
  .brand-text { display: none; }
  .container { padding: 20px 14px 48px; }
}

/* ===== Landing de Departamentos (painel com barra lateral) ===== */
.pdash {
  display: grid;
  grid-template-columns: 240px 1fr;
  column-gap: 24px;
  row-gap: 16px;
  align-items: start;
}
.pdash-aside-header {
  grid-column: 1;
  grid-row: 1;
}
.pside {
  grid-column: 1;
  grid-row: 2;
}
.pdash-main-header {
  grid-column: 2;
  grid-row: 1;
}
.pmain {
  grid-column: 2;
  grid-row: 2;
}
.pgreet { font-size: 20px; font-weight: 600; }
.pdate { font-size: 13px; color: var(--muted); margin: 2px 0 0; }
.pstats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pstat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 13px; }
.pstat-n { font-size: 22px; font-weight: 600; line-height: 1; }
.pstat-l { font-size: 10.5px; letter-spacing: .5px; text-transform: uppercase; color: var(--muted); margin-top: 5px; }
.pstat-s { font-size: 11.5px; margin-top: 5px; color: var(--muted); }
.pstat-s.up { color: #3B6D11; }
.pnav-h { font-size: 10.5px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted); margin: 18px 0 8px; }
.pnav { display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; padding: 8px 10px; border-radius: 9px; font-size: 14px; color: var(--ink); background: transparent; border: 1px solid transparent; cursor: pointer; text-decoration: none; }
.pnav:hover { border-color: var(--line); background: var(--card); text-decoration: none; }
.pnav.on { border-color: var(--line); background: var(--card); font-weight: 600; }
.pnav-c { margin-left: auto; font-size: 12px; color: var(--muted); font-weight: 400; }
.pmain-h { margin: 0; font-size: 21px; }
.pmain-sub { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }
.pmain-count { font-size: 11px; letter-spacing: .8px; text-transform: uppercase; color: var(--muted); margin: 16px 0 12px; }
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 12px; }
.pcard { position: relative; display: flex; flex-direction: column; min-height: 132px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 15px; text-decoration: none; color: var(--ink); transition: border-color .12s ease, box-shadow .12s ease; }
.pcard:hover { border-color: var(--primary); box-shadow: var(--shadow); text-decoration: none; }
.pcard-chip { width: 40px; height: 40px; border-radius: 11px; display: flex; align-items: center; justify-content: center; font-size: 20px; background: #fff; }
.pcard-dot { position: absolute; top: 18px; right: 16px; width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.pcard-nm { display: block; font-weight: 600; font-size: 15px; margin-top: 12px; }
.pcard-sub { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.pcard-ul { display: block; height: 3px; border-radius: 2px; margin: 12px 0 10px; margin-top: auto; background: var(--line); }
.pcard-cnt { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.pcard.vazio .pcard-chip { border: 1px solid var(--line); color: #b3b1a8; }
.pcard.vazio .pcard-nm { color: var(--muted); }
.pcard.vazio .pcard-cnt { color: var(--muted); font-weight: 400; }
@media (max-width: 820px) {
  .pdash {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }
  .pdash-aside-header,
  .pdash-main-header,
  .pside,
  .pmain {
    grid-column: auto;
    grid-row: auto;
  }
  .pside { width: 100%; }
}
